Patch adding Copy Paste functionality for UML class attributes and operations
Submitted by Nikos Patsiouras
Link to original bug (#741005)
Description
Created attachment 291956 UMLClassContentCopyPastePatch
I use dia frequently for keeping tabs on some of my code when designing or when I need to reevaluate things.But it's been frustrating lately that I have to manually copy ,or worse write, every attribute,every operation,every field basically that makes up the class when I have to do a lot of moving around.
So I messed with the code for UML attributes and operations(located in class_attributes_dialog.c and respectively class_operations_dialog.c) and added new buttons in the create page functions and added their respective callbacks. Not knowing what's the best way to do this and since this is a big project I settled for using a static global pointer as a helper for copying things.In the copy callback I either create a newly allocated copy or if there was mem being pointed to by the static pointer(as a result of a previous copy which wasn't pasted) I just copy the fields.In the paste callback I just point the local pointer to the memory the static pointer points to and set the static pointer to NULL to remove the reference and let dia handle things as it does in the new callback.My only predicament is where to free the static pointer in case the application is about to exit and we haven't pasted after a copy,meaning it will leak.As far as the copy goes,I use the already provided copy functions from umlattribute.c and umloperation.c.I've also tried to follow the style of code from the files I messed with so they should look ok.
All I care is for the functionality to make it into the next version since it's useful.If you can improve this,please do.
Patch 291956, "UMLClassContentCopyPastePatch":
UMLClassContentCopyPaste.patch.gz
Version: 0.97.x