Code

revert the PS rotation part of Adrian's patch for 437550, see discussion in the bug
[inkscape.git] / src / sp-defs.cpp
index 95823ee62f4442db0412ab8e3ff6d36f0af68a82..aa0cb0be7643f285f71af3c052fa78cb4596c24e 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "sp-defs.h"
 #include "xml/repr.h"
+#include "document.h"
 
 static void sp_defs_class_init(SPDefsClass *dc);
 static void sp_defs_init(SPDefs *defs);
@@ -25,7 +26,7 @@ static void sp_defs_init(SPDefs *defs);
 static void sp_defs_release(SPObject *object);
 static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags);
 static void sp_defs_modified(SPObject *object, guint flags);
-static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 
 static SPObjectClass *parent_class;
 
@@ -63,7 +64,7 @@ static void sp_defs_class_init(SPDefsClass *dc)
     sp_object_class->write = sp_defs_write;
 }
 
-static void sp_defs_init(SPDefs *defs)
+static void sp_defs_init(SPDefs */*defs*/)
 {
 
 }
@@ -83,21 +84,14 @@ static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags)
 
     flags &= SP_OBJECT_MODIFIED_CASCADE;
 
-    GSList *l = NULL;
-    for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
-        g_object_ref(G_OBJECT(child));
-        l = g_slist_prepend(l, child);
-    }
-
-    l = g_slist_reverse(l);
-
+    GSList *l = g_slist_reverse(object->childList(true));
     while (l) {
         SPObject *child = SP_OBJECT(l->data);
         l = g_slist_remove(l, child);
-        if (flags || (child->uflags & SP_OBJECT_MODIFIED_FLAG)) {
+        if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
             child->updateDisplay(ctx, flags);
         }
-        g_object_unref(G_OBJECT(child));
+        g_object_unref (G_OBJECT (child));
     }
 }
 
@@ -127,17 +121,17 @@ static void sp_defs_modified(SPObject *object, guint flags)
     }
 }
 
-static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 {
     if (flags & SP_OBJECT_WRITE_BUILD) {
 
         if (!repr) {
-            repr = sp_repr_new("svg:defs");
+            repr = xml_doc->createElement("svg:defs");
         }
 
         GSList *l = NULL;
         for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
-            Inkscape::XML::Node *crepr = child->updateRepr(NULL, flags);
+            Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
             if (crepr) l = g_slist_prepend(l, crepr);
         }
 
@@ -154,7 +148,7 @@ static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Node
     }
 
     if (((SPObjectClass *) (parent_class))->write) {
-        (* ((SPObjectClass *) (parent_class))->write)(object, repr, flags);
+        (* ((SPObjectClass *) (parent_class))->write)(object, xml_doc, repr, flags);
     }
 
     return repr;