Code

Fix handle for LPERotateCopies
[inkscape.git] / src / sp-root.cpp
index b3946cfee9bf90d3b640db5db4d71e3ca6a73f60..94b561bcce3c3433a09c443afa01e01035c1aa49 100644 (file)
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <cstring>
+#include <string>
 
 #include "svg/svg.h"
 #include "display/nr-arena-group.h"
@@ -43,7 +48,7 @@ static void sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, In
 static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child);
 static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags);
 static void sp_root_modified(SPObject *object, guint flags);
-static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 
 static NRArenaItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
 static void sp_root_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
@@ -123,7 +128,7 @@ sp_root_init(SPRoot *root)
     root->width.unset(SVGLength::PERCENT, 1.0, 1.0);
     root->height.unset(SVGLength::PERCENT, 1.0, 1.0);
 
-    /* nr_matrix_set_identity(&root->viewbox); */
+    /* root->viewbox.set_identity(); */
     root->viewBox_set = FALSE;
 
     root->c2p.set_identity();
@@ -353,9 +358,9 @@ sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML:
         (* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref);
 
     SPObject *co = object->document->getObjectByRepr(child);
-    g_assert(co != NULL);
+    g_assert (co != NULL || !strcmp("comment", child->name())); // comment repr node has no object
 
-    if (SP_IS_DEFS(co)) {
+    if (co && SP_IS_DEFS(co)) {
         SPObject *c;
         /* We search for first <defs> node - it is not beautiful, but works */
         for (c = sp_object_first_child(SP_OBJECT(group)) ; c != NULL; c = SP_OBJECT_NEXT(c) ) {
@@ -572,12 +577,12 @@ sp_root_modified(SPObject *object, guint flags)
  * Writes the object into the repr object, then calls the parent's write routine.
  */
 static Inkscape::XML::Node *
-sp_root_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+sp_root_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 {
     SPRoot *root = SP_ROOT(object);
 
     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-        repr = sp_repr_new("svg:svg");
+        repr = xml_doc->createElement("svg:svg");
     }
 
     if (flags & SP_OBJECT_WRITE_EXT) {
@@ -605,7 +610,7 @@ sp_root_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     }
 
     if (((SPObjectClass *) (parent_class))->write)
-        ((SPObjectClass *) (parent_class))->write(object, repr, flags);
+        ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);
 
     return repr;
 }