From: mental Date: Sun, 21 Jan 2007 19:03:03 +0000 (+0000) Subject: start switching sp_repr_new* over to XML::Document::create*, and rename create method... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3caca4f8381f7ae35678d16074c2414c02a0c0ff;p=inkscape.git start switching sp_repr_new* over to XML::Document::create*, and rename create methods to match DOM --- diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 7423f93a1..059d476f1 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -288,7 +288,8 @@ static Inkscape::XML::Node* Inkscape::colorprofile_write( SPObject *object, Inks ColorProfile *cprof = COLORPROFILE(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:color-profile"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:color-profile"); } if ( (flags & SP_OBJECT_WRITE_ALL) || cprof->href ) { diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 9de045837..9d15ce10a 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -868,11 +868,12 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); SPDocument *doc = sp_desktop_document(desktop); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); if ( c && !sp_curve_empty(c) ) { /* We actually have something to write */ - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); /* Set style */ sp_desktop_apply_style_tool(desktop, repr, "tools.connector", false); diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 9a13bab73..a10264811 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -98,7 +98,8 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge : wx ) >= 0 ) { - Inkscape::XML::Node *repr = sp_repr_new("sodipodi:guide"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); repr->setAttribute("orientation", (horiz) ? "horizontal" : "vertical"); double const guide_pos_dt = event_dt[ horiz ? NR::Y diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index c0acea533..cffbf52e1 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1268,7 +1268,7 @@ clonetiler_apply (GtkWidget *widget, void *) } // Create the clone - Inkscape::XML::Node *clone = sp_repr_new("svg:use"); + Inkscape::XML::Node *clone = obj_repr->document()->createElement("svg:use"); clone->setAttribute("x", "0"); clone->setAttribute("y", "0"); clone->setAttribute("inkscape:tiled-clone-of", id_href); diff --git a/src/dialogs/input.cpp b/src/dialogs/input.cpp index 8d6ff399d..21a6ea4a7 100644 --- a/src/dialogs/input.cpp +++ b/src/dialogs/input.cpp @@ -165,7 +165,7 @@ sp_input_save_to_preferences (void) repr = sp_repr_lookup_child(devices, "id", device->name); if (repr == NULL) { - repr = sp_repr_new("group"); + repr = devices->document()->createElement("group"); repr->setAttribute("id", device->name); devices->appendChild(repr); Inkscape::GC::release(repr); diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index 3402e72b5..9ad3c0586 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -1368,8 +1368,9 @@ void cmd_new_element_node(GtkObject *object, gpointer data) g_assert(selected_repr != NULL); if (name.text) { + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_document); Inkscape::XML::Node *new_repr; - new_repr = sp_repr_new(name.text); + new_repr = xml_doc->createElement(name.text); g_free(name.text); selected_repr->appendChild(new_repr); set_tree_select(new_repr); @@ -1387,7 +1388,8 @@ void cmd_new_text_node(GtkObject *object, gpointer data) { g_assert(selected_repr != NULL); - Inkscape::XML::Node *text = sp_repr_new_text(""); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_document); + Inkscape::XML::Node *text = xml_doc->createTextNode(""); selected_repr->appendChild(text); sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, diff --git a/src/document.cpp b/src/document.cpp index 8731ee71c..9fc6dc4da 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -277,7 +277,7 @@ sp_document_create(Inkscape::XML::Document *rdoc, // see if there's a template with id="base" in the preferences if (!r) { // if there's none, create an empty element - rnew = sp_repr_new("sodipodi:namedview"); + rnew = rdoc->createElement("sodipodi:namedview"); rnew->setAttribute("id", "base"); } else { // otherwise, take from preferences @@ -292,7 +292,7 @@ sp_document_create(Inkscape::XML::Document *rdoc, /* Defs */ if (!SP_ROOT(document->root)->defs) { Inkscape::XML::Node *r; - r = sp_repr_new("svg:defs"); + r = rdoc->createElement("svg:defs"); rroot->addChild(r, NULL); Inkscape::GC::release(r); g_assert(SP_ROOT(document->root)->defs); diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 38820326e..028d889d9 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -518,6 +518,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc); SPDocument *doc = sp_desktop_document(desktop); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); if ( c && !sp_curve_empty(c) ) { /* We actually have something to write */ @@ -526,7 +527,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) if (dc->white_item) { repr = SP_OBJECT_REPR(dc->white_item); } else { - repr = sp_repr_new("svg:path"); + repr = xml_doc->createElement("svg:path"); /* Set style */ sp_desktop_apply_style_tool(desktop, repr, tool_name(dc), false); } diff --git a/src/event-context.h b/src/event-context.h index ae7ec61da..7e3c125fb 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -90,6 +90,7 @@ struct SPEventContextClass : public GObjectClass { }; #define SP_EVENT_CONTEXT_DESKTOP(e) (SP_EVENT_CONTEXT(e)->desktop) +#define SP_EVENT_CONTEXT_DOCUMENT(e) ((SP_EVENT_CONTEXT_DESKTOP(e))->doc()) #define SP_EVENT_CONTEXT_STATIC 0 diff --git a/src/extension/parameter.cpp b/src/extension/parameter.cpp index 7dba1b507..7183b9778 100644 --- a/src/extension/parameter.cpp +++ b/src/extension/parameter.cpp @@ -580,7 +580,7 @@ Inkscape::XML::Node * Parameter::new_child (Inkscape::XML::Node * parent) { Inkscape::XML::Node * retval; - retval = sp_repr_new("inkscape:extension-param"); + retval = parent->document()->createElement("inkscape:extension-param"); retval->setAttribute("name", _name); parent->appendChild(retval); @@ -590,6 +590,7 @@ Parameter::new_child (Inkscape::XML::Node * parent) Inkscape::XML::Node * Parameter::document_param_node (SPDocument * doc) { + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::XML::Node * defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc)); Inkscape::XML::Node * params = NULL; @@ -606,7 +607,7 @@ Parameter::document_param_node (SPDocument * doc) } if (params == NULL) { - params = sp_repr_new("inkscape:extension-param"); + params = xml_doc->createElement("inkscape:extension-param"); params->setAttribute("extension", extension->get_id()); defs->appendChild(params); } diff --git a/src/file.cpp b/src/file.cpp index 491588f1e..521579d69 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -787,7 +787,8 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, if ((style && style->firstChild()) || items_count > 1) { // create group - Inkscape::XML::Node *newgroup = sp_repr_new("svg:g"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(in_doc); + Inkscape::XML::Node *newgroup = xml_doc->createElement("svg:g"); sp_repr_css_set (newgroup, style, "style"); for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); child != NULL; child = SP_OBJECT_NEXT(child) ) { diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 2c0a3636f..b5c6bdc69 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -33,9 +33,11 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); + // create a new filter Inkscape::XML::Node *repr; - repr = sp_repr_new("svg:filter"); + repr = xml_doc->createElement("svg:filter"); repr->setAttribute("inkscape:collect", "always"); double rx = radius * (expansionY != 0? (expansion / expansionY) : 1); @@ -56,7 +58,7 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion //create feGaussianBlur node Inkscape::XML::Node *b_repr; - b_repr = sp_repr_new("svg:feGaussianBlur"); + b_repr = xml_doc->createElement("svg:feGaussianBlur"); b_repr->setAttribute("inkscape:collect", "always"); double stdDeviation = radius; diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 0da9896e1..bd7ecaf4c 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -93,12 +93,13 @@ sp_gradient_get_private_normalized(SPDocument *document, SPGradient *vector, SPG SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); // create a new private gradient of the requested type Inkscape::XML::Node *repr; if (type == SP_GRADIENT_TYPE_LINEAR) { - repr = sp_repr_new("svg:linearGradient"); + repr = xml_doc->createElement("svg:linearGradient"); } else { - repr = sp_repr_new("svg:radialGradient"); + repr = xml_doc->createElement("svg:radialGradient"); } // privates are garbage-collectable @@ -1135,8 +1136,9 @@ SPGradient * sp_document_default_gradient_vector(SPDocument *document, guint32 color) { SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); - Inkscape::XML::Node *repr = sp_repr_new("svg:linearGradient"); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:linearGradient"); repr->setAttribute("inkscape:collect", "always"); // set here, but removed when it's edited in the gradient editor @@ -1144,7 +1146,7 @@ sp_document_default_gradient_vector(SPDocument *document, guint32 color) // (1) here, search gradients by color and return what is found without duplication // (2) in fill & stroke, show only one copy of each gradient in list - Inkscape::XML::Node *stop = sp_repr_new("svg:stop"); + Inkscape::XML::Node *stop = xml_doc->createElement("svg:stop"); gchar b[64]; sp_svg_write_color(b, 64, color); @@ -1160,7 +1162,7 @@ sp_document_default_gradient_vector(SPDocument *document, guint32 color) repr->appendChild(stop); Inkscape::GC::release(stop); - stop = sp_repr_new("svg:stop"); + stop = xml_doc->createElement("svg:stop"); { gchar *t = g_strdup_printf("stop-color:%s;stop-opacity:0;", b); diff --git a/src/interface.cpp b/src/interface.cpp index da734e671..bf9b481ee 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1105,7 +1105,7 @@ sp_ui_drag_data_received(GtkWidget *widget, Inkscape::XML::Node *repr = sp_repr_document_root(rnewdoc); gchar const *style = repr->attribute("style"); - Inkscape::XML::Node *newgroup = sp_repr_new("svg:g"); + Inkscape::XML::Node *newgroup = rnewdoc->createElement("svg:g"); newgroup->setAttribute("style", style); for (Inkscape::XML::Node *child = repr->firstChild(); child != NULL; child = child->next()) { @@ -1157,8 +1157,9 @@ sp_ui_drag_data_received(GtkWidget *widget, b64out.setColumnWidth(0); SPDocument *doc = SP_ACTIVE_DOCUMENT; + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); - Inkscape::XML::Node *newImage = sp_repr_new("svg:image"); + Inkscape::XML::Node *newImage = xml_doc->createElement("svg:image"); for ( int i = 0; i < data->length; i++ ) { b64out.put( data->data[i] ); diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp index c2178b78d..0bb0783f0 100644 --- a/src/jabber_whiteboard/inkboard-document.cpp +++ b/src/jabber_whiteboard/inkboard-document.cpp @@ -345,7 +345,7 @@ InkboardDocument::commitUndoable() } XML::Node* -InkboardDocument::createElementNode(char const* name) +InkboardDocument::createElement(char const* name) { return new XML::ElementNode(g_quark_from_string(name)); } @@ -357,7 +357,7 @@ InkboardDocument::createTextNode(char const* content) } XML::Node* -InkboardDocument::createCommentNode(char const* content) +InkboardDocument::createComment(char const* content) { return new XML::CommentNode(Util::share_string(content)); } diff --git a/src/jabber_whiteboard/inkboard-document.h b/src/jabber_whiteboard/inkboard-document.h index fba6691aa..16ee1b7ff 100644 --- a/src/jabber_whiteboard/inkboard-document.h +++ b/src/jabber_whiteboard/inkboard-document.h @@ -81,9 +81,9 @@ public: XML::Event* commitUndoable(); - XML::Node* createElementNode(char const* name); + XML::Node* createElement(char const* name); XML::Node* createTextNode(char const* content); - XML::Node* createCommentNode(char const* content); + XML::Node* createComment(char const* content); // // XML::NodeObserver methods diff --git a/src/jabber_whiteboard/session-manager.cpp b/src/jabber_whiteboard/session-manager.cpp index a5f2e2588..a04ab05f0 100644 --- a/src/jabber_whiteboard/session-manager.cpp +++ b/src/jabber_whiteboard/session-manager.cpp @@ -358,11 +358,11 @@ makeInkboardDocument(int code, gchar const* rootname, State::SessionType type, G InkboardDocument* rdoc = new InkboardDocument(g_quark_from_static_string("xml"), type, to); rdoc->setAttribute("version", "1.0"); rdoc->setAttribute("standalone", "no"); - XML::Node *comment = sp_repr_new_comment(" Created with Inkscape (http://www.inkscape.org/) "); + XML::Node *comment = rdoc->createComment(" Created with Inkscape (http://www.inkscape.org/) "); rdoc->appendChild(comment); GC::release(comment); - XML::Node* root = sp_repr_new(rootname); + XML::Node* root = rdoc->createElement(rootname); rdoc->appendChild(root); GC::release(root); diff --git a/src/marker.cpp b/src/marker.cpp index 65ed3789f..1fb758462 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -25,6 +25,7 @@ #include "xml/repr.h" #include "attributes.h" #include "marker.h" +#include "document.h" struct SPMarkerView { SPMarkerView *next; @@ -489,7 +490,8 @@ sp_marker_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) marker = SP_MARKER (object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new ("svg:marker"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:marker"); } if (marker->markerUnits_set) { diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 99d22edc7..9a8eb3e92 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -28,6 +28,7 @@ #include "text-editing.h" #include "style.h" #include "inkscape.h" +#include "desktop.h" #include "document.h" #include "message-stack.h" #include "selection.h" @@ -118,7 +119,8 @@ sp_selected_path_combine(void) g_slist_free(items); - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); // restore id repr->setAttribute("id", id); @@ -198,7 +200,7 @@ sp_selected_path_break_apart(void) for (GSList *l = list; l != NULL; l = l->next) { curve = (SPCurve *) l->data; - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Node *repr = parent->document()->createElement("svg:path"); repr->setAttribute("style", style); gchar *str = sp_svg_write_path(SP_CURVE_BPATH(curve)); @@ -321,7 +323,8 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy) if (!curve) return NULL; - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(item)->document(); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); /* Transformation */ repr->setAttribute("transform", SP_OBJECT_REPR(item)->attribute("transform")); /* Style */ diff --git a/src/prefs-utils.cpp b/src/prefs-utils.cpp index e365966bd..14a37ee4b 100644 --- a/src/prefs-utils.cpp +++ b/src/prefs-utils.cpp @@ -143,7 +143,7 @@ prefs_set_recent_file(gchar const *uri, gchar const *name) if (child) { recent->changeOrder(child, NULL); } else { - child = sp_repr_new("document"); + child = recent->document()->createElement("document"); child->setAttribute("uri", uri); recent->addChild(child, NULL); } diff --git a/src/rect-context.cpp b/src/rect-context.cpp index fd3d05a30..82eef51e7 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -439,7 +439,8 @@ static void sp_rect_drag(SPRectContext &rc, NR::Point const pt, guint state) } /* Create object */ - Inkscape::XML::Node *repr = sp_repr_new("svg:rect"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&rc)); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:rect"); /* Set style */ sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.rect", false); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 61d6b9284..fbf5d52df 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -431,6 +431,7 @@ void sp_selection_group() return; SPDocument *document = sp_desktop_document (desktop); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@ -458,7 +459,7 @@ void sp_selection_group() gint topmost = ((Inkscape::XML::Node *) g_slist_last(p)->data)->position(); Inkscape::XML::Node *topmost_parent = ((Inkscape::XML::Node *) g_slist_last(p)->data)->parent(); - Inkscape::XML::Node *group = sp_repr_new("svg:g"); + Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); while (p) { Inkscape::XML::Node *current = (Inkscape::XML::Node *) p->data; @@ -1982,6 +1983,8 @@ sp_selection_clone() Inkscape::Selection *selection = sp_desktop_selection(desktop); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + // check if something is selected if (selection->isEmpty()) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select an object to clone.")); @@ -2001,7 +2004,7 @@ sp_selection_clone() Inkscape::XML::Node *sel_repr = (Inkscape::XML::Node *) reprs->data; Inkscape::XML::Node *parent = sp_repr_parent(sel_repr); - Inkscape::XML::Node *clone = sp_repr_new("svg:use"); + Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); sp_repr_set_attr(clone, "x", "0"); sp_repr_set_attr(clone, "y", "0"); sp_repr_set_attr(clone, "xlink:href", g_strdup_printf("#%s", sel_repr->attribute("id"))); @@ -2135,6 +2138,7 @@ sp_selection_tile(bool apply) return; SPDocument *document = sp_desktop_document(desktop); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@ -2197,7 +2201,7 @@ sp_selection_tile(bool apply) prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation); if (apply) { - Inkscape::XML::Node *rect = sp_repr_new ("svg:rect"); + Inkscape::XML::Node *rect = xml_doc->createElement("svg:rect"); rect->setAttribute("style", g_strdup_printf("stroke:none;fill:url(#%s)", pat_id)); NR::Point min = bounds.min() * parent_transform.inverse(); @@ -2374,6 +2378,7 @@ sp_selection_create_bitmap_copy () return; SPDocument *document = sp_desktop_document(desktop); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@ -2505,7 +2510,7 @@ sp_selection_create_bitmap_copy () GdkPixbuf *pb = gdk_pixbuf_new_from_file (filepath, NULL); if (pb) { // Create the repr for the image - Inkscape::XML::Node * repr = sp_repr_new ("svg:image"); + Inkscape::XML::Node * repr = xml_doc->createElement("svg:image"); repr->setAttribute("xlink:href", filename); repr->setAttribute("sodipodi:absref", filepath); if (res == PX_PER_IN) { // for default 90 dpi, snap it to pixel grid diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 501b5fcfd..a1927f337 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -245,7 +245,8 @@ static Inkscape::XML::Node * sp_clippath_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:clipPath"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:clipPath"); } if (((SPObjectClass *) (parent_class))->write) @@ -387,7 +388,8 @@ sp_clippath_create (GSList *reprs, SPDocument *document, NR::Matrix const* apply { Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); - Inkscape::XML::Node *repr = sp_repr_new ("svg:clipPath"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:clipPath"); repr->setAttribute("clipPathUnits", "userSpaceOnUse"); defsrepr->appendChild(repr); diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index cf9f5a28f..5a8dce6df 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -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); @@ -125,7 +126,8 @@ static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Node if (flags & SP_OBJECT_WRITE_BUILD) { if (!repr) { - repr = sp_repr_new("svg:defs"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:defs"); } GSList *l = NULL; diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index b2b0f7b05..819aed997 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -30,6 +30,7 @@ #include "display/curve.h" #include +#include "document.h" #include "sp-ellipse.h" #include "prefs-utils.h" @@ -284,7 +285,8 @@ static Inkscape::XML::Node *sp_genericellipse_write(SPObject *object, Inkscape:: if (flags & SP_OBJECT_WRITE_EXT) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:path"); } sp_repr_set_svg_double(repr, "sodipodi:cx", ellipse->cx.computed); @@ -376,7 +378,8 @@ sp_ellipse_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) ellipse = SP_GENERICELLIPSE(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:ellipse"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:ellipse"); } sp_repr_set_svg_double(repr, "cx", ellipse->cx.computed); @@ -523,7 +526,8 @@ sp_circle_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) ellipse = SP_GENERICELLIPSE(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:circle"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:circle"); } sp_repr_set_svg_double(repr, "cx", ellipse->cx.computed); @@ -704,7 +708,8 @@ sp_arc_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) SPArc *arc = SP_ARC(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:path"); } if (flags & SP_OBJECT_WRITE_EXT) { diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp index cc0405541..8c84d6128 100644 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@ -15,6 +15,7 @@ #include "sp-flowdiv.h" #include "sp-string.h" +#include "document.h" static void sp_flowdiv_class_init (SPFlowdivClass *klass); static void sp_flowdiv_init (SPFlowdiv *group); @@ -197,7 +198,8 @@ sp_flowdiv_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) // SPFlowdiv *group = SP_FLOWDIV (object); if ( flags&SP_OBJECT_WRITE_BUILD ) { - if ( repr == NULL ) repr = sp_repr_new ("svg:flowDiv"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + if ( repr == NULL ) repr = xml_doc->createElement("svg:flowDiv"); GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; @@ -206,7 +208,7 @@ sp_flowdiv_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) } else if ( SP_IS_FLOWPARA(child) ) { c_repr = child->updateRepr(NULL, flags); } 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); } @@ -368,7 +370,8 @@ static Inkscape::XML::Node * sp_flowtspan_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) { if ( flags&SP_OBJECT_WRITE_BUILD ) { - if ( repr == NULL ) repr = sp_repr_new ("svg:flowSpan"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + if ( repr == NULL ) repr = xml_doc->createElement("svg:flowSpan"); GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; @@ -377,7 +380,7 @@ sp_flowtspan_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) } else if ( SP_IS_FLOWPARA (child) ) { c_repr = child->updateRepr(NULL, flags); } 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); } @@ -541,7 +544,8 @@ sp_flowpara_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) // SPFlowpara *group = SP_FLOWPARA (object); if ( flags&SP_OBJECT_WRITE_BUILD ) { - if ( repr == NULL ) repr = sp_repr_new ("svg:flowPara"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + if ( repr == NULL ) repr = xml_doc->createElement("svg:flowPara"); GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; @@ -550,7 +554,7 @@ sp_flowpara_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) } else if ( SP_IS_FLOWPARA (child) ) { c_repr = child->updateRepr(NULL, flags); } 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); } @@ -643,7 +647,8 @@ static Inkscape::XML::Node * sp_flowline_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) { if ( flags&SP_OBJECT_WRITE_BUILD ) { - if ( repr == NULL ) repr = sp_repr_new ("svg:flowLine"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + if ( repr == NULL ) repr = xml_doc->createElement("svg:flowLine"); } else { } @@ -719,7 +724,8 @@ static Inkscape::XML::Node * sp_flowregionbreak_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) { if ( flags&SP_OBJECT_WRITE_BUILD ) { - if ( repr == NULL ) repr = sp_repr_new ("svg:flowLine"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + if ( repr == NULL ) repr = xml_doc->createElement("svg:flowLine"); } else { } diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index ec6fd0427..b589bb64d 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -291,7 +291,8 @@ static Inkscape::XML::Node * sp_flowtext_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) { if ( flags & SP_OBJECT_WRITE_BUILD ) { - if ( repr == NULL ) repr = sp_repr_new("svg:flowRoot"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + if ( repr == NULL ) repr = xml_doc->createElement("svg:flowRoot"); GSList *l = NULL; for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node *c_repr = NULL; @@ -519,7 +520,8 @@ SPFlowtext::getAsText() SPItem *item = SP_ITEM(this); - Inkscape::XML::Node *repr = sp_repr_new("svg:text"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(this)); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:text"); repr->setAttribute("xml:space", "preserve"); repr->setAttribute("style", SP_OBJECT_REPR(this)->attribute("style")); NR::Point anchor_point = this->layout.characterAnchorPoint(this->layout.begin()); @@ -527,7 +529,7 @@ SPFlowtext::getAsText() sp_repr_set_svg_double(repr, "y", anchor_point[NR::Y]); for (Inkscape::Text::Layout::iterator it = this->layout.begin() ; it != this->layout.end() ; ) { - Inkscape::XML::Node *line_tspan = sp_repr_new("svg:tspan"); + Inkscape::XML::Node *line_tspan = xml_doc->createElement("svg:tspan"); line_tspan->setAttribute("sodipodi:role", "line"); Inkscape::Text::Layout::iterator it_line_end = it; @@ -535,7 +537,7 @@ SPFlowtext::getAsText() while (it != it_line_end) { - Inkscape::XML::Node *span_tspan = sp_repr_new("svg:tspan"); + Inkscape::XML::Node *span_tspan = xml_doc->createElement("svg:tspan"); NR::Point anchor_point = this->layout.characterAnchorPoint(it); // use kerning to simulate justification and whatnot Inkscape::Text::Layout::iterator it_span_end = it; @@ -598,7 +600,7 @@ SPFlowtext::getAsText() Glib::ustring new_string; while (span_text_start_iter != span_text_end_iter) new_string += *span_text_start_iter++; // grr. no substr() with iterators - Inkscape::XML::Node *new_text = sp_repr_new_text(new_string.c_str()); + Inkscape::XML::Node *new_text = xml_doc->createTextNode(new_string.c_str()); span_tspan->appendChild(new_text); Inkscape::GC::release(new_text); } @@ -665,18 +667,19 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, NR::Point p0, N { SPDocument *doc = sp_desktop_document (desktop); - Inkscape::XML::Node *root_repr = sp_repr_new("svg:flowRoot"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); + Inkscape::XML::Node *root_repr = xml_doc->createElement("svg:flowRoot"); root_repr->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create SPItem *ft_item = SP_ITEM(desktop->currentLayer()->appendChildRepr(root_repr)); SPObject *root_object = doc->getObjectByRepr(root_repr); g_assert(SP_IS_FLOWTEXT(root_object)); - Inkscape::XML::Node *region_repr = sp_repr_new("svg:flowRegion"); + Inkscape::XML::Node *region_repr = xml_doc->createElement("svg:flowRegion"); root_repr->appendChild(region_repr); SPObject *region_object = doc->getObjectByRepr(region_repr); g_assert(SP_IS_FLOWREGION(region_object)); - Inkscape::XML::Node *rect_repr = sp_repr_new("svg:rect"); // FIXME: use path!!! after rects are converted to use path + Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect"); // FIXME: use path!!! after rects are converted to use path region_repr->appendChild(rect_repr); SPObject *rect = doc->getObjectByRepr(rect_repr); @@ -695,12 +698,12 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, NR::Point p0, N sp_rect_position_set(SP_RECT(rect), x0, y0, w, h); SP_OBJECT(rect)->updateRepr(); - Inkscape::XML::Node *para_repr = sp_repr_new("svg:flowPara"); + Inkscape::XML::Node *para_repr = xml_doc->createElement("svg:flowPara"); root_repr->appendChild(para_repr); SPObject *para_object = doc->getObjectByRepr(para_repr); g_assert(SP_IS_FLOWPARA(para_object)); - Inkscape::XML::Node *text = sp_repr_new_text(""); + Inkscape::XML::Node *text = xml_doc->createTextNode(""); para_repr->appendChild(text); Inkscape::GC::release(root_repr); diff --git a/src/sp-gradient-test.h b/src/sp-gradient-test.h index 7906a3d48..b8645155e 100644 --- a/src/sp-gradient-test.h +++ b/src/sp-gradient-test.h @@ -74,7 +74,8 @@ public: SP_OBJECT(gr)->document = _doc; sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "matrix(0, 1, -1, 0, 0, 0)"); - Inkscape::XML::Node *repr = sp_repr_new("svg:radialGradient"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(_doc); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:radialGradient"); SP_OBJECT(gr)->updateRepr(repr, SP_OBJECT_WRITE_ALL); { gchar const *tr = repr->attribute("gradientTransform"); diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index d28f631de..71dc0e20e 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -204,7 +204,8 @@ sp_stop_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) SPStop *stop = SP_STOP(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:stop"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:stop"); } @@ -862,6 +863,7 @@ sp_gradient_repr_write_vector(SPGradient *gr) g_return_if_fail(gr != NULL); g_return_if_fail(SP_IS_GRADIENT(gr)); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(gr)); Inkscape::XML::Node *repr = SP_OBJECT_REPR(gr); /* We have to be careful, as vector may be our own, so construct repr list at first */ @@ -869,7 +871,7 @@ sp_gradient_repr_write_vector(SPGradient *gr) for (guint i = 0; i < gr->vector.stops.size(); i++) { Inkscape::CSSOStringStream os; - Inkscape::XML::Node *child = sp_repr_new("svg:stop"); + Inkscape::XML::Node *child = xml_doc->createElement("svg:stop"); sp_repr_set_css_double(child, "offset", gr->vector.stops[i].offset); /* strictly speaking, offset an SVG rather than a CSS one, but exponents make no * sense for offset proportions. */ @@ -1391,7 +1393,8 @@ sp_lineargradient_write(SPObject *object, Inkscape::XML::Node *repr, guint flags SPLinearGradient *lg = SP_LINEARGRADIENT(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:linearGradient"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:linearGradient"); } if ((flags & SP_OBJECT_WRITE_ALL) || lg->x1._set) @@ -1692,7 +1695,8 @@ sp_radialgradient_write(SPObject *object, Inkscape::XML::Node *repr, guint flags SPRadialGradient *rg = SP_RADIALGRADIENT(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:radialGradient"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:radialGradient"); } if ((flags & SP_OBJECT_WRITE_ALL) || rg->cx._set) sp_repr_set_svg_double(repr, "cx", rg->cx.computed); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 973bb9f87..06371f232 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -881,7 +881,8 @@ sp_image_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) image = SP_IMAGE (object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new ("svg:image"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:image"); } repr->setAttribute("xlink:href", image->href); diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 6ad8a4871..9c8b0ba32 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -258,7 +258,8 @@ static Inkscape::XML::Node * sp_mask_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new ("svg:mask"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:mask"); } if (((SPObjectClass *) (parent_class))->write) @@ -273,7 +274,8 @@ sp_mask_create (GSList *reprs, SPDocument *document, NR::Matrix const* applyTran { Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); - Inkscape::XML::Node *repr = sp_repr_new ("svg:mask"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:mask"); repr->setAttribute("maskUnits", "userSpaceOnUse"); defsrepr->appendChild(repr); diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 2253bf1e1..74382b768 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -262,7 +262,8 @@ sp_offset_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) SPOffset *offset = SP_OFFSET (object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new ("svg:path"); + Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(object)->document(); + repr = xml_doc->createElement("svg:path"); } if (flags & SP_OBJECT_WRITE_EXT) { diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 2e8cc2f75..3b455e505 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -31,6 +31,8 @@ #include "sp-path.h" +#include "document.h" + #define noPATH_VERBOSE static void sp_path_class_init(SPPathClass *klass); @@ -232,7 +234,8 @@ sp_path_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) SPShape *shape = (SPShape *) object; if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:path"); } if ( shape->curve != NULL ) { diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 89eeacec4..8de8ac77b 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -438,9 +438,10 @@ SPPattern * pattern_chain (SPPattern *pattern) { SPDocument *document = SP_OBJECT_DOCUMENT (pattern); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); - Inkscape::XML::Node *repr = sp_repr_new ("svg:pattern"); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); repr->setAttribute("inkscape:collect", "always"); gchar *parent_ref = g_strconcat ("#", SP_OBJECT_REPR(pattern)->attribute("id"), NULL); repr->setAttribute("xlink:href", parent_ref); @@ -494,9 +495,10 @@ sp_pattern_transform_multiply (SPPattern *pattern, NR::Matrix postmul, bool set) const gchar * pattern_tile (GSList *reprs, NR::Rect bounds, SPDocument *document, NR::Matrix transform, NR::Matrix move) { + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); - Inkscape::XML::Node *repr = sp_repr_new ("svg:pattern"); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); repr->setAttribute("patternUnits", "userSpaceOnUse"); sp_repr_set_svg_double(repr, "width", bounds.extent(NR::X)); sp_repr_set_svg_double(repr, "height", bounds.extent(NR::Y)); diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index 56cbfefde..a2b1c5972 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -21,6 +21,7 @@ #include "libnr/n-art-bpath.h" #include "svg/stringstream.h" #include "xml/repr.h" +#include "document.h" static void sp_polygon_class_init(SPPolygonClass *pc); static void sp_polygon_init(SPPolygon *polygon); @@ -120,7 +121,8 @@ static Inkscape::XML::Node *sp_polygon_write(SPObject *object, Inkscape::XML::No sp_shape_set_shape(shape); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:polygon"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:polygon"); } /* We can safely write points here, because all subclasses require it too (Lauris) */ diff --git a/src/sp-root.cpp b/src/sp-root.cpp index b3946cfee..d6e423edc 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -577,7 +577,8 @@ sp_root_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) SPRoot *root = SP_ROOT(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:svg"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:svg"); } if (flags & SP_OBJECT_WRITE_EXT) { diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index ab65ba4dd..a2449fb9a 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -23,6 +23,7 @@ #include "display/curve.h" #include #include "xml/repr.h" +#include "document.h" #include "sp-spiral.h" @@ -139,7 +140,8 @@ sp_spiral_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) SPSpiral *spiral = SP_SPIRAL (object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new ("svg:path"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:path"); } if (flags & SP_OBJECT_WRITE_EXT) { diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index ff27f3de0..4408f7ce8 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -122,7 +122,8 @@ static Inkscape::XML::Node * sp_style_elem_write(SPObject *const object, Inkscape::XML::Node *repr, guint const flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:style"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:style"); } g_return_val_if_fail(object, repr); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 3059cf22d..5c2c5412c 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -303,13 +303,14 @@ sp_text_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) SPText *text = SP_TEXT (object); if (flags & SP_OBJECT_WRITE_BUILD) { + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); if (!repr) - repr = sp_repr_new ("svg:text"); + repr = xml_doc->createElement("svg:text"); GSList *l = NULL; for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node *crepr = NULL; if (SP_IS_STRING(child)) { - crepr = sp_repr_new_text(SP_STRING(child)->string.c_str()); + crepr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } else { crepr = child->updateRepr(NULL, flags); } diff --git a/src/sp-use.cpp b/src/sp-use.cpp index ae4e9f61a..5b2ed9e23 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -241,7 +241,8 @@ sp_use_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) SPUse *use = SP_USE(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = sp_repr_new("svg:use"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:use"); } if (((SPObjectClass *) (parent_class))->write) { @@ -652,6 +653,7 @@ sp_use_unlink(SPUse *use) Inkscape::XML::Node *parent = sp_repr_parent(repr); SPDocument *document = SP_OBJECT(use)->document; + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); // Track the ultimate source of a chain of uses. SPItem *orig = sp_use_root(use); @@ -661,7 +663,7 @@ sp_use_unlink(SPUse *use) Inkscape::XML::Node *copy = NULL; if (SP_IS_SYMBOL(orig)) { // make a group, copy children - copy = sp_repr_new("svg:g"); + copy = xml_doc->createElement("svg:g"); for (Inkscape::XML::Node *child = SP_OBJECT_REPR(orig)->firstChild() ; child != NULL; child = child->next()) { Inkscape::XML::Node *newchild = child->duplicate(); copy->appendChild(newchild); diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 6ce05dbd9..2e4214f06 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -396,7 +396,8 @@ sp_spiral_drag(SPSpiralContext *sc, NR::Point p, guint state) } /* Create object */ - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(sc)); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("sodipodi:type", "spiral"); /* Set style */ diff --git a/src/star-context.cpp b/src/star-context.cpp index 2c39eafa0..03954e939 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -405,7 +405,8 @@ static void sp_star_drag(SPStarContext *sc, NR::Point p, guint state) } /* Create object */ - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(sc)); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("sodipodi:type", "star"); /* Set style */ diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 91c263584..0a655fdcb 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -20,6 +20,7 @@ #include "sp-rect.h" #include "sp-textpath.h" #include "inkscape.h" +#include "desktop.h" #include "document.h" #include "message-stack.h" #include "selection.h" @@ -92,6 +93,8 @@ text_put_on_path() SPItem *text = text_or_flowtext_in_selection(selection); SPItem *shape = shape_in_selection(selection); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + if (!text || !shape || g_slist_length((GSList *) selection->itemList()) != 2) { sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select a text and a path to put text on path.")); return; @@ -152,7 +155,7 @@ text_put_on_path() } // create textPath and put it into the text - Inkscape::XML::Node *textpath = sp_repr_new("svg:textPath"); + Inkscape::XML::Node *textpath = xml_doc->createElement("svg:textPath"); // reference the shape textpath->setAttribute("xlink:href", g_strdup_printf("#%s", SP_OBJECT_REPR(shape)->attribute("id"))); if (text_alignment == Inkscape::Text::Layout::RIGHT) @@ -279,6 +282,7 @@ text_flow_into_shape() return; SPDocument *doc = sp_desktop_document (desktop); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@ -296,14 +300,14 @@ text_flow_into_shape() SP_OBJECT_REPR(text)->setAttribute("transform", NULL); } - Inkscape::XML::Node *root_repr = sp_repr_new("svg:flowRoot"); + Inkscape::XML::Node *root_repr = xml_doc->createElement("svg:flowRoot"); root_repr->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create root_repr->setAttribute("style", SP_OBJECT_REPR(text)->attribute("style")); // fixme: transfer style attrs too SP_OBJECT_REPR(SP_OBJECT_PARENT(shape))->appendChild(root_repr); SPObject *root_object = doc->getObjectByRepr(root_repr); g_return_if_fail(SP_IS_FLOWTEXT(root_object)); - Inkscape::XML::Node *region_repr = sp_repr_new("svg:flowRegion"); + Inkscape::XML::Node *region_repr = xml_doc->createElement("svg:flowRegion"); root_repr->appendChild(region_repr); SPObject *object = doc->getObjectByRepr(region_repr); g_return_if_fail(SP_IS_FLOWREGION(object)); @@ -314,7 +318,7 @@ text_flow_into_shape() items = items->next) { SPItem *item = SP_ITEM(items->data); if (SP_IS_SHAPE(item)){ - Inkscape::XML::Node *clone = sp_repr_new("svg:use"); + Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); clone->setAttribute("x", "0"); clone->setAttribute("y", "0"); clone->setAttribute("xlink:href", g_strdup_printf("#%s", SP_OBJECT_REPR(item)->attribute("id"))); @@ -325,7 +329,7 @@ text_flow_into_shape() } if (SP_IS_TEXT(text)) { // flow from text, as string - Inkscape::XML::Node *para_repr = sp_repr_new("svg:flowPara"); + Inkscape::XML::Node *para_repr = xml_doc->createElement("svg:flowPara"); root_repr->appendChild(para_repr); object = doc->getObjectByRepr(para_repr); g_return_if_fail(SP_IS_FLOWPARA(object)); @@ -333,7 +337,7 @@ text_flow_into_shape() Inkscape::Text::Layout const *layout = te_get_layout(text); Glib::ustring text_ustring = sp_te_get_string_multiline(text, layout->begin(), layout->end()); - Inkscape::XML::Node *text_repr = sp_repr_new_text(text_ustring.c_str()); // FIXME: transfer all formatting! and convert newlines into flowParas! + Inkscape::XML::Node *text_repr = xml_doc->createTextNode(text_ustring.c_str()); // FIXME: transfer all formatting! and convert newlines into flowParas! para_repr->appendChild(text_repr); Inkscape::GC::release(para_repr); @@ -370,6 +374,7 @@ text_unflow () return; SPDocument *doc = sp_desktop_document (desktop); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@ -393,7 +398,7 @@ text_unflow () SPItem *flowtext = SP_ITEM(items->data); /* Create */ - Inkscape::XML::Node *rtext = sp_repr_new("svg:text"); + Inkscape::XML::Node *rtext = xml_doc->createElement("svg:text"); rtext->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create /* Set style */ @@ -408,12 +413,12 @@ text_unflow () } /* Create */ - Inkscape::XML::Node *rtspan = sp_repr_new("svg:tspan"); + Inkscape::XML::Node *rtspan = xml_doc->createElement("svg:tspan"); rtspan->setAttribute("sodipodi:role", "line"); // otherwise, why bother creating the tspan? rtext->addChild(rtspan, NULL); gchar *text_string = sp_te_get_string_multiline(flowtext); - Inkscape::XML::Node *text_repr = sp_repr_new_text(text_string); // FIXME: transfer all formatting!!! + Inkscape::XML::Node *text_repr = xml_doc->createTextNode(text_string); // FIXME: transfer all formatting!!! free(text_string); rtspan->appendChild(text_repr); diff --git a/src/text-context.cpp b/src/text-context.cpp index e969ffbfc..b65bcf19f 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -473,7 +473,8 @@ sp_text_context_setup_text(SPTextContext *tc) SPEventContext *ec = SP_EVENT_CONTEXT(tc); /* Create */ - Inkscape::XML::Node *rtext = sp_repr_new("svg:text"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DESKTOP(ec)->doc()); + Inkscape::XML::Node *rtext = xml_doc->createElement("svg:text"); rtext->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create /* Set style */ @@ -483,13 +484,13 @@ sp_text_context_setup_text(SPTextContext *tc) sp_repr_set_svg_double(rtext, "y", tc->pdoc[NR::Y]); /* Create */ - Inkscape::XML::Node *rtspan = sp_repr_new("svg:tspan"); + Inkscape::XML::Node *rtspan = xml_doc->createElement("svg:tspan"); rtspan->setAttribute("sodipodi:role", "line"); // otherwise, why bother creating the tspan? rtext->addChild(rtspan, NULL); Inkscape::GC::release(rtspan); /* Create TEXT */ - Inkscape::XML::Node *rstring = sp_repr_new_text(""); + Inkscape::XML::Node *rstring = xml_doc->createTextNode(""); rtspan->addChild(rstring, NULL); Inkscape::GC::release(rstring); SPItem *text_item = SP_ITEM(ec->desktop->currentLayer()->appendChildRepr(rtext)); diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index a02d410a1..925e4e195 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -517,12 +517,13 @@ void Tracer::traceThread() //#OK. Now let's start making new nodes + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); Inkscape::XML::Node *groupRepr = NULL; //# if more than 1, make a roup of s if (nrPaths > 1) { - groupRepr = sp_repr_new("svg:g"); + groupRepr = xml_doc->createElement("svg:g"); par->addChild(groupRepr, imgRepr); } @@ -533,7 +534,7 @@ void Tracer::traceThread() TracingEngineResult result = results[i]; totalNodeCount += result.getNodeCount(); - Inkscape::XML::Node *pathRepr = sp_repr_new("svg:path"); + Inkscape::XML::Node *pathRepr = xml_doc->createElement("svg:path"); pathRepr->setAttribute("style", result.getStyle().c_str()); pathRepr->setAttribute("d", result.getPathData().c_str()); diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index a96e1589d..b701adc2b 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -15,6 +15,8 @@ #include "context-menu.h" #include "../xml/repr.h" +#include "desktop.h" +#include "document.h" static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu); @@ -158,7 +160,8 @@ sp_item_create_link(GtkMenuItem *menuitem, SPItem *item) SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); - Inkscape::XML::Node *repr = sp_repr_new("svg:a"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:a"); SP_OBJECT_REPR(SP_OBJECT_PARENT(item))->addChild(repr, SP_OBJECT_REPR(item)); SPObject *object = SP_OBJECT_DOCUMENT(item)->getObjectByRepr(repr); g_return_if_fail(SP_IS_ANCHOR(object)); diff --git a/src/ui/widget/ruler.cpp b/src/ui/widget/ruler.cpp index 30a1761bd..681b1dbbc 100644 --- a/src/ui/widget/ruler.cpp +++ b/src/ui/widget/ruler.cpp @@ -147,7 +147,8 @@ Ruler::on_button_release_event(GdkEventButton *evb) _dragging = false; if ( (_horiz_f ? wy : wx ) >= 0 ) { - Inkscape::XML::Node *repr = sp_repr_new("sodipodi:guide"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(_dt->doc()); + Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); repr->setAttribute("orientation", _horiz_f ? "horizontal" : "vertical"); double const guide_pos_dt = event_dt[ _horiz_f ? NR::Y : NR::X ]; sp_repr_set_svg_double(repr, "position", guide_pos_dt); diff --git a/src/xml/document.h b/src/xml/document.h index eeb16e74f..de9164aa2 100644 --- a/src/xml/document.h +++ b/src/xml/document.h @@ -34,9 +34,9 @@ public: virtual void commit()=0; virtual Inkscape::XML::Event *commitUndoable()=0; - virtual Node *createElementNode(char const *name)=0; + virtual Node *createElement(char const *name)=0; virtual Node *createTextNode(char const *content)=0; - virtual Node *createCommentNode(char const *content)=0; + virtual Node *createComment(char const *content)=0; }; } diff --git a/src/xml/repr-action-test.cpp b/src/xml/repr-action-test.cpp index 7f5f27f2d..7ab857f46 100644 --- a/src/xml/repr-action-test.cpp +++ b/src/xml/repr-action-test.cpp @@ -16,9 +16,9 @@ int main(int argc, char *argv[]) { utest_start("XML Transactions"); - a = sp_repr_new("a"); - b = sp_repr_new("b"); - c = sp_repr_new("c"); + a = document->createElement("a"); + b = document->createElement("b"); + c = document->createElement("c"); UTEST_TEST("rollback of node addition") { sp_repr_begin_transaction(document); diff --git a/src/xml/simple-document.cpp b/src/xml/simple-document.cpp index e8c652b2d..4063abde4 100644 --- a/src/xml/simple-document.cpp +++ b/src/xml/simple-document.cpp @@ -51,7 +51,7 @@ Inkscape::XML::Event *SimpleDocument::commitUndoable() { return _log_builder.detach(); } -Node *SimpleDocument::createElementNode(char const *name) { +Node *SimpleDocument::createElement(char const *name) { return new ElementNode(g_quark_from_string(name)); } @@ -59,7 +59,7 @@ Node *SimpleDocument::createTextNode(char const *content) { return new TextNode(Util::share_string(content)); } -Node *SimpleDocument::createCommentNode(char const *content) { +Node *SimpleDocument::createComment(char const *content) { return new CommentNode(Util::share_string(content)); } diff --git a/src/xml/simple-document.h b/src/xml/simple-document.h index ca130e62b..c8ee4d9b4 100644 --- a/src/xml/simple-document.h +++ b/src/xml/simple-document.h @@ -46,9 +46,9 @@ public: void commit(); Inkscape::XML::Event *commitUndoable(); - Node *createElementNode(char const *name); + Node *createElement(char const *name); Node *createTextNode(char const *content); - Node *createCommentNode(char const *content); + Node *createComment(char const *content); void notifyChildAdded(Node &parent, Node &child, Node *prev);