Code

Filter effects dialog:
[inkscape.git] / src / sp-tspan.cpp
index 3b5780721dda18940d5f295947f3eee01b4b6dd1..c53a75d5dd1defd06866919e903fe2cca344ec2d 100644 (file)
 #include "attributes.h"
 #include "sp-use-reference.h"
 #include "sp-tspan.h"
+#include "sp-tref.h"
 #include "sp-textpath.h"
 #include "text-editing.h"
 #include "style.h"
 #include "libnr/nr-matrix-fns.h"
 #include "xml/repr.h"
+#include "document.h"
 
 
 /*#####################################################
@@ -226,9 +228,10 @@ static Inkscape::XML::Node *
 sp_tspan_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
 {
     SPTSpan *tspan = SP_TSPAN(object);
+    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
        
     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-        repr = sp_repr_new("svg:tspan");
+        repr = xml_doc->createElement("svg:tspan");
     }
        
     tspan->attributes.writeTo(repr);
@@ -237,12 +240,12 @@ sp_tspan_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
         GSList *l = NULL;
         for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
             Inkscape::XML::Node* c_repr=NULL;
-            if ( SP_IS_TSPAN(child) ) {
+            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                 c_repr = child->updateRepr(NULL, flags);
             } else if ( SP_IS_TEXTPATH(child) ) {
                 //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
             } else if ( SP_IS_STRING(child) ) {
-                c_repr = sp_repr_new_text(SP_STRING(child)->string.c_str());
+                c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
             }
             if ( c_repr ) l = g_slist_prepend(l, c_repr);
         }
@@ -253,7 +256,7 @@ sp_tspan_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
         }
     } else {
         for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
-            if ( SP_IS_TSPAN(child) ) {
+            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                 child->updateRepr(flags);
             } else if ( SP_IS_TEXTPATH(child) ) {
                 //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
@@ -390,7 +393,8 @@ sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr)
     }
        
     if ( no_content ) {
-        Inkscape::XML::Node* rch = sp_repr_new_text("");
+        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+        Inkscape::XML::Node* rch = xml_doc->createTextNode("");
         repr->addChild(rch, NULL);
     }
        
@@ -487,9 +491,10 @@ static Inkscape::XML::Node *
 sp_textpath_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
 {
     SPTextPath *textpath = SP_TEXTPATH(object);
+    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
        
     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-        repr = sp_repr_new("svg:textPath");
+        repr = xml_doc->createElement("svg:textPath");
     }
        
     textpath->attributes.writeTo(repr);
@@ -511,12 +516,12 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
         GSList *l = NULL;
         for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
             Inkscape::XML::Node* c_repr=NULL;
-            if ( SP_IS_TSPAN(child) ) {
+            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                 c_repr = child->updateRepr(NULL, flags);
             } else if ( SP_IS_TEXTPATH(child) ) {
                 //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
             } else if ( SP_IS_STRING(child) ) {
-                c_repr = sp_repr_new_text(SP_STRING(child)->string.c_str());
+                c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
             }
             if ( c_repr ) l = g_slist_prepend(l, c_repr);
         }
@@ -527,7 +532,7 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
         }
     } else {
         for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
-            if ( SP_IS_TSPAN(child) ) {
+            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                 child->updateRepr(flags);
             } else if ( SP_IS_TEXTPATH(child) ) {
                 //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
@@ -572,7 +577,7 @@ sp_textpath_to_text(SPObject *tp)
 
     for ( GSList *i = tp_reprs ; i ; i = i->next ) {
         // make a copy of each textpath child
-        Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate();
+        Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate(SP_OBJECT_REPR(text)->document());
         // remove the old repr from under textpath
         SP_OBJECT_REPR(tp)->removeChild((Inkscape::XML::Node *) i->data);
         // put its copy into under textPath