Code

Fix for Bug 238113 (preserve title/desc for various Inkscape operations)
authorjeff_schiller <jeff_schiller@users.sourceforge.net>
Sun, 24 Aug 2008 13:16:51 +0000 (13:16 +0000)
committerjeff_schiller <jeff_schiller@users.sourceforge.net>
Sun, 24 Aug 2008 13:16:51 +0000 (13:16 +0000)
src/path-chemistry.cpp
src/splivarot.cpp

index 4c459ba64dc563b2b76ea151ed3335203cf9efda..32a7968b28b76b1ed68aa91e4a654cb63596c24e 100644 (file)
@@ -339,6 +339,7 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec
          items = items->next) {
 
         SPItem *item = SP_ITEM(items->data);
+       SPDocument *document = item->document;
 
         if (SP_IS_PATH(item) && !SP_PATH(item)->original_curve) {
             continue; // already a path, and no path effect
@@ -387,6 +388,10 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec
         Inkscape::XML::Node *parent = SP_OBJECT_REPR(item)->parent();
         // remember id
         char const *id = SP_OBJECT_REPR(item)->attribute("id");
+        // remember title
+        gchar *title = item->title();
+        // remember description
+        gchar *desc = item->desc();
 
         // It's going to resurrect, so we delete without notifying listeners.
         SP_OBJECT(item)->deleteObject(false);
@@ -395,6 +400,16 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec
         repr->setAttribute("id", id);
         // add the new repr to the parent
         parent->appendChild(repr);
+        SPObject* newObj = document->getObjectByRepr(repr);
+        if (title && newObj) {
+               newObj->setTitle(title);
+               g_free(title);
+        }
+        if (desc && newObj) {
+               newObj->setDesc(desc);
+               g_free(desc);
+        }
+
         // move to the saved position
         repr->setPosition(pos > 0 ? pos : 0);
 
index 77675000f5415da6d1ff7f3ff04b7c5d46fbcbb4..0996ca53812e2a2d9aa61520c86ea2f42faed796 100644 (file)
@@ -473,7 +473,8 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
     gchar const *style = repr_source->attribute("style");
     gchar const *mask = repr_source->attribute("mask");
     gchar const *clip_path = repr_source->attribute("clip-path");
-
+    gchar *title = source->title();
+    gchar *desc = source->desc();
     // remove source paths
     selection->clear();
     for (GSList *l = il; l != NULL; l = l->next) {
@@ -582,13 +583,21 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
 
         repr->setAttribute("id", id);
         parent->appendChild(repr);
-        repr->setPosition(pos > 0 ? pos : 0);
+        if (title) {
+               sp_desktop_document(desktop)->getObjectByRepr(repr)->setTitle(title);
+        }            
+        if (desc) {
+               sp_desktop_document(desktop)->getObjectByRepr(repr)->setDesc(desc);
+        }
+               repr->setPosition(pos > 0 ? pos : 0);
 
         selection->add(repr);
         Inkscape::GC::release(repr);
     }
 
     g_free(transform);
+    if (title) g_free(title);
+    if (desc) g_free(desc);
 
     if (verb != SP_VERB_NONE) {
         sp_document_done(sp_desktop_document(desktop), verb, description);
@@ -803,7 +812,11 @@ sp_selected_path_outline(SPDesktop *desktop)
         Inkscape::XML::Node *parent = SP_OBJECT_REPR(item)->parent();
         // remember id
         char const *id = SP_OBJECT_REPR(item)->attribute("id");
-
+        // remember title
+        gchar *title = item->title();
+        // remember description
+        gchar *desc = item->desc();
+        
         if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether
 
             SPDocument * doc = sp_desktop_document(desktop);
@@ -835,10 +848,17 @@ sp_selected_path_outline(SPDesktop *desktop)
                 g_repr->setPosition(pos > 0 ? pos : 0);
 
                 g_repr->appendChild(repr);
+                // restore title, description, id, transform
                 repr->setAttribute("id", id);
                 SPItem *newitem = (SPItem *) doc->getObjectByRepr(repr);
                 sp_item_write_transform(newitem, repr, transform);
-
+                if (title) {
+                       newitem->setTitle(title);
+                }
+                if (desc) {
+                       newitem->setDesc(desc);
+                }
+                
                 SPShape *shape = SP_SHAPE(item);
 
                 Geom::PathVector const & pathv = curve->get_pathvector();
@@ -899,11 +919,18 @@ sp_selected_path_outline(SPDesktop *desktop)
                 // move to the saved position
                 repr->setPosition(pos > 0 ? pos : 0);
 
+                // restore title, description, id, transform
                 repr->setAttribute("id", id);
 
                 SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr);
                 sp_item_write_transform(newitem, repr, transform);
-
+                if (title) {
+                       newitem->setTitle(title);
+                }
+                if (desc) {
+                       newitem->setDesc(desc);
+                }
+                
                 selection->add(repr);
 
             }
@@ -915,6 +942,8 @@ sp_selected_path_outline(SPDesktop *desktop)
             SP_OBJECT(item)->deleteObject(false);
 
         }
+        if (title) g_free(title);
+        if (desc) g_free(desc);
 
         delete res;
         delete orig;
@@ -1521,7 +1550,11 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
     char const *id = SP_OBJECT_REPR(item)->attribute("id");
     // remember path effect
     char const *patheffect = SP_OBJECT_REPR(item)->attribute("inkscape:path-effect");
-
+    // remember title
+    gchar *title = item->title();
+    // remember description
+    gchar *desc = item->desc();
+    
     //If a group was selected, to not change the selection list
     if (modifySelection)
         selection->remove(item);
@@ -1576,7 +1609,17 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
 
     // restore path effect
     repr->setAttribute("inkscape:path-effect", patheffect);
-
+    
+    // restore title & description
+    if (title) {
+       newitem->setTitle(title);
+        g_free(title);
+    }
+    if (desc) {
+       newitem->setDesc(desc);
+        g_free(desc);
+    }
+    
     //If we are not in a selected group
     if (modifySelection)
         selection->add(repr);