summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d46dc71)
raw | patch | inline | side by side (parent: d46dc71)
author | mental <mental@users.sourceforge.net> | |
Tue, 20 Mar 2007 22:54:29 +0000 (22:54 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Tue, 20 Mar 2007 22:54:29 +0000 (22:54 +0000) |
52 files changed:
index 7894a89b8eba16f95abdcdbe80ca7e11eb7d334c..e1640e6afe422431284582baf98fa3bf66aaa5de 100644 (file)
return NULL;
// Create a copy repr of the marker with id="sample"
- Inkscape::XML::Node *mrepr = SP_OBJECT_REPR (marker)->duplicate();
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(sandbox);
+ Inkscape::XML::Node *mrepr = SP_OBJECT_REPR (marker)->duplicate(xml_doc);
mrepr->setAttribute("id", "sample");
// Replace the old sample in the sandbox by the new one
index 9ad3c0586b4ed1ceb708646ac83f344635b89d0c..dd5371460f7c21a552f5a3f58a1f147f709bb002 100644 (file)
--- a/src/dialogs/xml-tree.cpp
+++ b/src/dialogs/xml-tree.cpp
g_assert(selected_repr != NULL);
Inkscape::XML::Node *parent = sp_repr_parent(selected_repr);
- Inkscape::XML::Node *dup = selected_repr->duplicate();
+ Inkscape::XML::Node *dup = selected_repr->duplicate(parent->document());
parent->addChild(dup, selected_repr);
sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
diff --git a/src/document.cpp b/src/document.cpp
index c6dc66a514cd5675f5eaaf1831c561a648600f3e..e66089fedfdcb6ee5a294c64fb1bc1e36bd4b0e1 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
rnew->setAttribute("id", "base");
} else {
// otherwise, take from preferences
- rnew = r->duplicate();
+ rnew = r->duplicate(rroot->document());
}
// insert into the document
rroot->addChild(rnew, NULL);
index af70a04f0f188fcbaf73dfd5f0521f00f68a7850..96e4bd855b8fe9be8fda6de34d4e37b7b1fa681a 100644 (file)
child = child->next()) {
if (!strcmp("sodipodi:namedview", child->name()))
continue;
- oldroot->appendChild(child->duplicate());
+ oldroot->appendChild(child->duplicate(newroot->document()));
}
/** \todo Restore correct layer */
index 5d8c9a82d005c058418d7595139c3ac725e2a760..3989f9427c52ac6f0fd56bfdc85b79ad30d21747 100644 (file)
for (int i = 0; i < steps; i++) {
double offset = (width / (float)(steps - 1) * (float)i) - (width / 2.0);
- new_items[i] = (SP_OBJECT_REPR(spitem))->duplicate();
+ new_items[i] = (SP_OBJECT_REPR(spitem))->duplicate(xml_doc);
SPCSSAttr * css = sp_repr_css_attr(new_items[i], "style");
sp_repr_css_set_property(css, "opacity", opacity_string);
diff --git a/src/file.cpp b/src/file.cpp
index c5347a66e5f2eecae8b35dcdb5e9f12e6b459de3..639ba3913e5080112eeb924dc7f2a761f0d10257 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
SPObject *defs = SP_DOCUMENT_DEFS(doc);
Inkscape::IO::fixupHrefs(doc, in_doc->base, true);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
Inkscape::XML::Node *last_def = SP_OBJECT_REPR(in_defs)->lastChild();
for (SPObject *child = sp_object_first_child(defs);
child != NULL; child = SP_OBJECT_NEXT(child))
{
// FIXME: in case of id conflict, newly added thing will be re-ided and thus likely break a reference to it from imported stuff
- SP_OBJECT_REPR(in_defs)->addChild(SP_OBJECT_REPR(child)->duplicate(), last_def);
+ SP_OBJECT_REPR(in_defs)->addChild(SP_OBJECT_REPR(child)->duplicate(xml_doc), last_def);
}
guint items_count = 0;
for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (SP_IS_ITEM(child)) {
- Inkscape::XML::Node *newchild = SP_OBJECT_REPR(child)->duplicate();
+ Inkscape::XML::Node *newchild = SP_OBJECT_REPR(child)->duplicate(xml_doc);
// convert layers to groups; FIXME: add "preserve layers" mode where each layer
// from impot is copied to the same-named layer in host
// just add one item
for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (SP_IS_ITEM(child)) {
- Inkscape::XML::Node *newitem = SP_OBJECT_REPR(child)->duplicate();
+ Inkscape::XML::Node *newitem = SP_OBJECT_REPR(child)->duplicate(xml_doc);
newitem->setAttribute("inkscape:groupmode", NULL);
if (desktop) {
index 82a88faa3047d5fc18f7897a28ea9658c73a853e..0a312193dde1a063d750aee6b33322a91904005b 100644 (file)
sp_gradient_fork_vector_if_necessary (SPGradient *gr)
{
if (SP_OBJECT_HREFCOUNT(gr) > 1) {
- SPDocument *document = SP_OBJECT_DOCUMENT(gr);
+ SPDocument *doc = SP_OBJECT_DOCUMENT(gr);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
- Inkscape::XML::Node *repr = SP_OBJECT_REPR (gr)->duplicate();
- SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document))->addChild(repr, NULL);
- SPGradient *gr_new = (SPGradient *) document->getObjectByRepr(repr);
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR (gr)->duplicate(xml_doc);
+ SP_OBJECT_REPR (SP_DOCUMENT_DEFS (doc))->addChild(repr, NULL);
+ SPGradient *gr_new = (SPGradient *) doc->getObjectByRepr(repr);
gr_new = sp_gradient_ensure_vector_normalized (gr_new);
Inkscape::GC::release(repr);
return gr_new;
GSList *child_copies = NULL;
for (GSList *i = child_reprs; i != NULL; i = i->next) {
Inkscape::XML::Node *repr = (Inkscape::XML::Node *) i->data;
- child_copies = g_slist_append (child_copies, repr->duplicate());
+ Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(vector)->document();
+ child_copies = g_slist_append (child_copies, repr->duplicate(xml_doc));
}
index 42b4df5783167973a50bc26f4ec2a3904aff223b..77947394d246b6884be2870a3d946a8cb8206947 100644 (file)
--- a/src/gradient-context.cpp
+++ b/src/gradient-context.cpp
}
Inkscape::XML::Node *new_stop_repr = NULL;
- new_stop_repr = SP_OBJECT_REPR(prev_stop)->duplicate();
+ new_stop_repr = SP_OBJECT_REPR(prev_stop)->duplicate(SP_OBJECT_REPR(vector)->document());
SP_OBJECT_REPR(vector)->addChild(new_stop_repr, SP_OBJECT_REPR(prev_stop));
SPStop *newstop = (SPStop *) SP_OBJECT_DOCUMENT(vector)->getObjectByRepr(new_stop_repr);
index 0e035e83200b3d846b3d668d1964e662df79f035..575197fee3109deef8efe245edd39aef92dc4786 100644 (file)
SPObject *object = doc->getObjectById(name);
if (object && SP_IS_MARKER(object)) {
SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc);
- Inkscape::XML::Node *mark_repr = SP_OBJECT_REPR(object)->duplicate();
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_doc);
+ Inkscape::XML::Node *mark_repr = SP_OBJECT_REPR(object)->duplicate(xml_doc);
SP_OBJECT_REPR(defs)->addChild(mark_repr, NULL);
SPObject *cloned_item = current_doc->getObjectByRepr(mark_repr);
Inkscape::GC::release(mark_repr);
SPObject *object = doc->getObjectById(name);
if (object && SP_IS_PATTERN(object)) {
SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc);
- Inkscape::XML::Node *pat_repr = SP_OBJECT_REPR(object)->duplicate();
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_doc);
+ Inkscape::XML::Node *pat_repr = SP_OBJECT_REPR(object)->duplicate(xml_doc);
SP_OBJECT_REPR(defs)->addChild(pat_repr, NULL);
Inkscape::GC::release(pat_repr);
return object;
SPObject *object = doc->getObjectById(name);
if (object && SP_IS_GRADIENT(object)) {
SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc);
- Inkscape::XML::Node *pat_repr = SP_OBJECT_REPR(object)->duplicate();
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_doc);
+ Inkscape::XML::Node *pat_repr = SP_OBJECT_REPR(object)->duplicate(xml_doc);
SP_OBJECT_REPR(defs)->addChild(pat_repr, NULL);
Inkscape::GC::release(pat_repr);
return object;
diff --git a/src/interface.cpp b/src/interface.cpp
index c7608f53a6c65f3e53d21cb3e2a77ddf0054dc7a..ac896751311bc13450f2301ffa807f428e8cdfc0 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
guint event_time,
gpointer user_data)
{
+ SPDocument *doc = SP_ACTIVE_DOCUMENT;
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+
switch (info) {
#if ENABLE_MAGIC_COLORS
case APP_X_INKY_COLOR:
{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
int destX = 0;
int destY = 0;
gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY );
sp_desktop_apply_css_recursive( item, css, true );
item->updateRepr();
- SPDocument *doc = SP_ACTIVE_DOCUMENT;
sp_document_done( doc , SP_VERB_NONE,
_("Drop color"));
case APP_X_COLOR:
{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
int destX = 0;
int destY = 0;
gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY );
sp_desktop_apply_css_recursive( item, css, true );
item->updateRepr();
- SPDocument *doc = SP_ACTIVE_DOCUMENT;
sp_document_done( doc , SP_VERB_NONE,
_("Drop color"));
}
case SVG_XML_DATA: {
gchar *svgdata = (gchar *)data->data;
- SPDocument *doc = SP_ACTIVE_DOCUMENT;
-
Inkscape::XML::Document *rnewdoc = sp_repr_read_mem(svgdata, data->length, SP_SVG_NS_URI);
if (rnewdoc == NULL) {
Inkscape::XML::Node *newgroup = rnewdoc->createElement("svg:g");
newgroup->setAttribute("style", style);
+ Inkscape::XML::Document * xml_doc = sp_document_repr_doc(doc);
for (Inkscape::XML::Node *child = repr->firstChild(); child != NULL; child = child->next()) {
- Inkscape::XML::Node *newchild = child->duplicate();
+ Inkscape::XML::Node *newchild = child->duplicate(xml_doc);
newgroup->appendChild(newchild);
}
Inkscape::GC::release(rnewdoc);
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
// Add it to the current layer
// Greg's edits to add intelligent positioning of svg drops
Base64OutputStream b64out(outs);
b64out.setColumnWidth(0);
- SPDocument *doc = SP_ACTIVE_DOCUMENT;
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
Inkscape::XML::Node *newImage = xml_doc->createElement("svg:image");
}
}
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
// Add it to the current layer
desktop->currentLayer()->appendChildRepr(newImage);
index 16ee1b7ffc21ae29faf774e9f0267b3018e3add1..26d79396ed844bbb1d867727afbe977809604c79 100644 (file)
_initBindings();
}
- XML::SimpleNode* _duplicate() const
+ XML::SimpleNode* _duplicate(XML::Document* xml_doc) const
{
return new InkboardDocument(*this);
}
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 0437414a8efec0c33e890297e458128d2b5de6a1..8e6783f20d4209031cfc469399fc1a6dfc2cad78 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
g_assert(np);
Inkscape::XML::Node *old_repr = SP_OBJECT(np->path)->repr;
- Inkscape::XML::Node *new_repr = old_repr->duplicate();
+ Inkscape::XML::Node *new_repr = old_repr->duplicate(old_repr->document());
// remember the position of the item
gint pos = old_repr->position();
index 1fe70b896cdfd351e22e0f8d9ed6ac1290376f04..f8548cdc4eda0fb199276a687c923b59de6597b8 100644 (file)
#include "helper/units.h"
#include "sp-item.h"
#include "unit-constants.h"
+#include "xml/simple-document.h"
+
using NR::X;
using NR::Y;
#include "selection-chemistry.h"
/* fixme: find a better place */
+Inkscape::XML::Document *clipboard_document = NULL;
GSList *clipboard = NULL;
GSList *defs_clipboard = NULL;
SPCSSAttr *style_clipboard = NULL;
NR::Maybe<NR::Rect> size_clipboard;
-static void sp_copy_stuff_used_by_item(GSList **defs_clip, SPItem *item, const GSList *items);
+static void sp_copy_stuff_used_by_item(GSList **defs_clip, SPItem *item, const GSList *items, Inkscape::XML::Document* xml_doc);
/**
* Copies repr and its inherited css style elements, along with the accumulated transform 'full_t',
* then prepends the copy to 'clip'.
*/
-void sp_selection_copy_one (Inkscape::XML::Node *repr, NR::Matrix full_t, GSList **clip)
+void sp_selection_copy_one (Inkscape::XML::Node *repr, NR::Matrix full_t, GSList **clip, Inkscape::XML::Document* xml_doc)
{
- Inkscape::XML::Node *copy = repr->duplicate();
+ Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
// copy complete inherited style
SPCSSAttr *css = sp_repr_css_attr_inherited(repr, "style");
@@ -108,13 +111,13 @@ void sp_selection_copy_one (Inkscape::XML::Node *repr, NR::Matrix full_t, GSList
*clip = g_slist_prepend(*clip, copy);
}
-void sp_selection_copy_impl (const GSList *items, GSList **clip, GSList **defs_clip, SPCSSAttr **style_clip)
+void sp_selection_copy_impl (const GSList *items, GSList **clip, GSList **defs_clip, SPCSSAttr **style_clip, Inkscape::XML::Document* xml_doc)
{
// Copy stuff referenced by all items to defs_clip:
if (defs_clip) {
for (GSList *i = (GSList *) items; i != NULL; i = i->next) {
- sp_copy_stuff_used_by_item (defs_clip, SP_ITEM (i->data), items);
+ sp_copy_stuff_used_by_item (defs_clip, SP_ITEM (i->data), items, xml_doc);
}
*defs_clip = g_slist_reverse(*defs_clip);
}
@@ -132,7 +135,7 @@ void sp_selection_copy_impl (const GSList *items, GSList **clip, GSList **defs_c
// Copy item reprs:
for (GSList *i = (GSList *) sorted_items; i != NULL; i = i->next) {
- sp_selection_copy_one (SP_OBJECT_REPR (i->data), sp_item_i2doc_affine(SP_ITEM (i->data)), clip);
+ sp_selection_copy_one (SP_OBJECT_REPR (i->data), sp_item_i2doc_affine(SP_ITEM (i->data)), clip, xml_doc);
}
*clip = g_slist_reverse(*clip);
Inkscape::XML::Node *repr = (Inkscape::XML::Node *) gl->data;
gchar const *id = repr->attribute("id");
if (!id || !doc->getObjectById(id)) {
- Inkscape::XML::Node *copy = repr->duplicate();
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+ Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
SP_OBJECT_REPR(defs)->addChild(copy, NULL);
Inkscape::GC::release(copy);
}
}
}
-GSList *sp_selection_paste_impl (SPDocument *document, SPObject *parent, GSList **clip, GSList **defs_clip)
+GSList *sp_selection_paste_impl (SPDocument *doc, SPObject *parent, GSList **clip, GSList **defs_clip)
{
- paste_defs (defs_clip, document);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+ paste_defs (defs_clip, doc);
GSList *copied = NULL;
// add objects to document
for (GSList *l = *clip; l != NULL; l = l->next) {
Inkscape::XML::Node *repr = (Inkscape::XML::Node *) l->data;
- Inkscape::XML::Node *copy = repr->duplicate();
+ Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
// premultiply the item transform by the accumulated parent transform in the paste layer
NR::Matrix local = sp_item_i2doc_affine(SP_ITEM(parent));
if (desktop == NULL)
return;
+ Inkscape::XML::Document* xml_doc = sp_document_repr_doc(desktop->doc());
Inkscape::Selection *selection = sp_desktop_selection(desktop);
// check if something is selected
while (reprs) {
Inkscape::XML::Node *parent = ((Inkscape::XML::Node *) reprs->data)->parent();
- Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) reprs->data)->duplicate();
+ Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) reprs->data)->duplicate(xml_doc);
parent->appendChild(copy);
if (desktop == NULL)
return;
- SPDocument *document = sp_desktop_document (desktop);
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+ SPDocument *doc = sp_desktop_document (desktop);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
Inkscape::XML::Node *current = (Inkscape::XML::Node *) p->data;
if (current->parent() == topmost_parent) {
- Inkscape::XML::Node *spnew = current->duplicate();
+ Inkscape::XML::Node *spnew = current->duplicate(xml_doc);
sp_repr_unparent(current);
group->appendChild(spnew);
Inkscape::GC::release(spnew);
NR::Matrix item_t (NR::identity());
if (t_str)
sp_svg_transform_read(t_str, &item_t);
- item_t *= sp_item_i2doc_affine(SP_ITEM(document->getObjectByRepr(current->parent())));
+ item_t *= sp_item_i2doc_affine(SP_ITEM(doc->getObjectByRepr(current->parent())));
//FIXME: when moving both clone and original from a transformed group (either by
//grouping into another parent, or by cut/paste) the transform from the original's
//parent becomes embedded into original itself, and this affects its clones. Fix
//then, if this is clone, looking up its original in that array and pre-multiplying
//it by the inverse of that original's transform diff.
- sp_selection_copy_one (current, item_t, &temp_clip);
+ sp_selection_copy_one (current, item_t, &temp_clip, xml_doc);
sp_repr_unparent(current);
// paste into topmost_parent (temporarily)
- GSList *copied = sp_selection_paste_impl (document, document->getObjectByRepr(topmost_parent), &temp_clip, NULL);
+ GSList *copied = sp_selection_paste_impl (doc, doc->getObjectByRepr(topmost_parent), &temp_clip, NULL);
if (temp_clip) g_slist_free (temp_clip);
if (copied) { // if success,
// take pasted object (now in topmost_parent)
Inkscape::XML::Node *in_topmost = (Inkscape::XML::Node *) copied->data;
// make a copy
- Inkscape::XML::Node *spnew = in_topmost->duplicate();
+ Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc);
// remove pasted
sp_repr_unparent(in_topmost);
// put its copy into group
return NULL;
}
SPObject *parent = SP_OBJECT_PARENT(items->data);
- /* Strictly speaking this CAN happen, if user selects <svg> from XML editor */
+ /* Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor */
if (!SP_IS_GROUP(parent)) {
return NULL;
}
sp_selection_delete();
}
-void sp_copy_gradient (GSList **defs_clip, SPGradient *gradient)
+void sp_copy_gradient (GSList **defs_clip, SPGradient *gradient, Inkscape::XML::Document* xml_doc)
{
SPGradient *ref = gradient;
while (ref) {
// climb up the refs, copying each one in the chain
- Inkscape::XML::Node *grad_repr = SP_OBJECT_REPR(ref)->duplicate();
+ Inkscape::XML::Node *grad_repr = SP_OBJECT_REPR(ref)->duplicate(xml_doc);
*defs_clip = g_slist_prepend (*defs_clip, grad_repr);
ref = ref->ref->getObject();
}
}
-void sp_copy_pattern (GSList **defs_clip, SPPattern *pattern)
+void sp_copy_pattern (GSList **defs_clip, SPPattern *pattern, Inkscape::XML::Document* xml_doc)
{
SPPattern *ref = pattern;
while (ref) {
// climb up the refs, copying each one in the chain
- Inkscape::XML::Node *pattern_repr = SP_OBJECT_REPR(ref)->duplicate();
+ Inkscape::XML::Node *pattern_repr = SP_OBJECT_REPR(ref)->duplicate(xml_doc);
*defs_clip = g_slist_prepend (*defs_clip, pattern_repr);
// items in the pattern may also use gradients and other patterns, so we need to recurse here as well
for (SPObject *child = sp_object_first_child(SP_OBJECT(ref)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (!SP_IS_ITEM (child))
continue;
- sp_copy_stuff_used_by_item (defs_clip, (SPItem *) child, NULL);
+ sp_copy_stuff_used_by_item (defs_clip, (SPItem *) child, NULL, xml_doc);
}
ref = ref->ref->getObject();
}
}
-void sp_copy_single (GSList **defs_clip, SPObject *thing)
+void sp_copy_single (GSList **defs_clip, SPObject *thing, Inkscape::XML::Document* xml_doc)
{
- Inkscape::XML::Node *duplicate_repr = SP_OBJECT_REPR(thing)->duplicate();
+ Inkscape::XML::Node *duplicate_repr = SP_OBJECT_REPR(thing)->duplicate(xml_doc);
*defs_clip = g_slist_prepend (*defs_clip, duplicate_repr);
}
-void sp_copy_textpath_path (GSList **defs_clip, SPTextPath *tp, const GSList *items)
+void sp_copy_textpath_path (GSList **defs_clip, SPTextPath *tp, const GSList *items, Inkscape::XML::Document* xml_doc)
{
SPItem *path = sp_textpath_get_path_item (tp);
if (!path)
return;
if (items && g_slist_find ((GSList *) items, path)) // do not copy it to defs if it is already in the list of items copied
return;
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(path)->duplicate();
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(path)->duplicate(xml_doc);
*defs_clip = g_slist_prepend (*defs_clip, repr);
}
/**
* Copies things like patterns, markers, gradients, etc.
*/
-void sp_copy_stuff_used_by_item (GSList **defs_clip, SPItem *item, const GSList *items)
+void sp_copy_stuff_used_by_item (GSList **defs_clip, SPItem *item, const GSList *items, Inkscape::XML::Document* xml_doc)
{
SPStyle *style = SP_OBJECT_STYLE (item);
if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
if (SP_IS_LINEARGRADIENT (server) || SP_IS_RADIALGRADIENT (server))
- sp_copy_gradient (defs_clip, SP_GRADIENT(server));
+ sp_copy_gradient (defs_clip, SP_GRADIENT(server), xml_doc);
if (SP_IS_PATTERN (server))
- sp_copy_pattern (defs_clip, SP_PATTERN(server));
+ sp_copy_pattern (defs_clip, SP_PATTERN(server), xml_doc);
}
if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item);
if (SP_IS_LINEARGRADIENT (server) || SP_IS_RADIALGRADIENT (server))
- sp_copy_gradient (defs_clip, SP_GRADIENT(server));
+ sp_copy_gradient (defs_clip, SP_GRADIENT(server), xml_doc);
if (SP_IS_PATTERN (server))
- sp_copy_pattern (defs_clip, SP_PATTERN(server));
+ sp_copy_pattern (defs_clip, SP_PATTERN(server), xml_doc);
}
// For shapes, copy all of the shape's markers into defs_clip
@@ -923,40 +929,40 @@ void sp_copy_stuff_used_by_item (GSList **defs_clip, SPItem *item, const GSList
SPShape *shape = SP_SHAPE (item);
for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
if (shape->marker[i]) {
- sp_copy_single (defs_clip, SP_OBJECT (shape->marker[i]));
+ sp_copy_single (defs_clip, SP_OBJECT (shape->marker[i]), xml_doc);
}
}
}
if (SP_IS_TEXT_TEXTPATH (item)) {
- sp_copy_textpath_path (defs_clip, SP_TEXTPATH(sp_object_first_child(SP_OBJECT(item))), items);
+ sp_copy_textpath_path (defs_clip, SP_TEXTPATH(sp_object_first_child(SP_OBJECT(item))), items, xml_doc);
}
if (item->clip_ref->getObject()) {
- sp_copy_single (defs_clip, item->clip_ref->getObject());
+ sp_copy_single (defs_clip, item->clip_ref->getObject(), xml_doc);
}
if (item->mask_ref->getObject()) {
SPObject *mask = item->mask_ref->getObject();
- sp_copy_single (defs_clip, mask);
+ sp_copy_single (defs_clip, mask, xml_doc);
// recurse into the mask for its gradients etc.
for (SPObject *o = SP_OBJECT(mask)->children; o != NULL; o = o->next) {
if (SP_IS_ITEM(o))
- sp_copy_stuff_used_by_item (defs_clip, SP_ITEM (o), items);
+ sp_copy_stuff_used_by_item (defs_clip, SP_ITEM (o), items, xml_doc);
}
}
if (style->filter.filter) {
SPObject *filter = style->filter.filter;
if (SP_IS_FILTER(filter)) {
- sp_copy_single (defs_clip, filter);
+ sp_copy_single (defs_clip, filter, xml_doc);
}
}
// recurse
for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) {
if (SP_IS_ITEM(o))
- sp_copy_stuff_used_by_item (defs_clip, SP_ITEM (o), items);
+ sp_copy_stuff_used_by_item (defs_clip, SP_ITEM (o), items, xml_doc);
}
}
if (desktop == NULL)
return;
+ if (!clipboard_document) {
+ clipboard_document = new Inkscape::XML::SimpleDocument();
+ }
+
Inkscape::Selection *selection = sp_desktop_selection(desktop);
if (tools_isactive (desktop, TOOLS_DROPPER)) {
const GSList *items = g_slist_copy ((GSList *) selection->itemList());
// 0. Copy text to system clipboard
- // FIXME: for non-texts, put serialized XML as text to the clipboard;
+ // FIXME: for non-texts, put serialized Inkscape::XML as text to the clipboard;
//for this sp_repr_write_stream needs to be rewritten with iostream instead of FILE
Glib::ustring text;
if (tools_isactive (desktop, TOOLS_TEXT)) {
clipboard = g_slist_remove(clipboard, clipboard->data);
}
- sp_selection_copy_impl (items, &clipboard, &defs_clipboard, &style_clipboard);
+ sp_selection_copy_impl (items, &clipboard, &defs_clipboard, &style_clipboard, clipboard_document);
if (tools_isactive (desktop, TOOLS_TEXT)) { // take style from cursor/text selection, overwriting the style just set by copy_impl
SPStyle *const query = sp_style_new();
SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer());
if (next) {
GSList *temp_clip = NULL;
- sp_selection_copy_impl (items, &temp_clip, NULL, NULL); // we're in the same doc, so no need to copy defs
+ sp_selection_copy_impl (items, &temp_clip, NULL, NULL, sp_document_repr_doc(dt->doc())); // we're in the same doc, so no need to copy defs
sp_selection_delete_impl (items);
next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
GSList *copied;
SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer());
if (next) {
GSList *temp_clip = NULL;
- sp_selection_copy_impl (items, &temp_clip, NULL, NULL); // we're in the same doc, so no need to copy defs
+ sp_selection_copy_impl (items, &temp_clip, NULL, NULL, sp_document_repr_doc(dt->doc())); // we're in the same doc, so no need to copy defs
sp_selection_delete_impl (items);
next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
GSList *copied;
if (desktop == NULL)
return;
- SPDocument *document = sp_desktop_document(desktop);
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+ SPDocument *doc = sp_desktop_document(desktop);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
return;
}
- sp_document_ensure_up_to_date(document);
+ sp_document_ensure_up_to_date(doc);
NR::Maybe<NR::Rect> r = selection->bounds();
if ( !r || r->isEmpty() ) {
return;
}
// calculate the transform to be applied to objects to move them to 0,0
- NR::Point move_p = NR::Point(0, sp_document_height(document)) - (r->min() + NR::Point (0, r->extent(NR::Y)));
+ NR::Point move_p = NR::Point(0, sp_document_height(doc)) - (r->min() + NR::Point (0, r->extent(NR::Y)));
move_p[NR::Y] = -move_p[NR::Y];
NR::Matrix move = NR::Matrix (NR::translate (move_p));
// create a list of duplicates
GSList *repr_copies = NULL;
for (GSList *i = items; i != NULL; i = i->next) {
- Inkscape::XML::Node *dup = (SP_OBJECT_REPR (i->data))->duplicate();
+ Inkscape::XML::Node *dup = (SP_OBJECT_REPR (i->data))->duplicate(xml_doc);
repr_copies = g_slist_prepend (repr_copies, dup);
}
int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- const gchar *pat_id = pattern_tile (repr_copies, bounds, document,
+ const gchar *pat_id = pattern_tile (repr_copies, bounds, doc,
NR::Matrix(NR::translate(desktop->dt2doc(NR::Point(r->min()[NR::X], r->max()[NR::Y])))) * parent_transform.inverse(), parent_transform * move);
// restore compensation setting
g_slist_free (items);
- sp_document_done (document, SP_VERB_EDIT_TILE,
+ sp_document_done (doc, SP_VERB_EDIT_TILE,
_("Objects to pattern"));
}
if (desktop == NULL)
return;
- SPDocument *document = sp_desktop_document(desktop);
+ SPDocument *doc = sp_desktop_document(desktop);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
pat_transform *= item->transform;
for (SPObject *child = sp_object_first_child(SP_OBJECT(pattern)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
- Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate();
+ Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc);
SPItem *i = SP_ITEM (desktop->currentLayer()->appendChildRepr(copy));
// FIXME: relink clones to the new canvas objects
// use SPObject::setid when mental finishes it to steal ids of
// this is needed to make sure the new item has curve (simply requestDisplayUpdate does not work)
- sp_document_ensure_up_to_date (document);
+ sp_document_ensure_up_to_date (doc);
NR::Matrix transform( i->transform * pat_transform );
sp_item_write_transform(i, SP_OBJECT_REPR(i), transform);
if (desktop == NULL)
return;
- SPDocument *document = sp_desktop_document(desktop);
+ SPDocument *doc = sp_desktop_document(desktop);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
}
// /END FIXME
- sp_document_ensure_up_to_date(document);
+ sp_document_ensure_up_to_date(doc);
GSList *items = g_slist_copy((GSList *) selection->itemList());
apply_to_items = g_slist_prepend (apply_to_items, desktop->currentLayer());
for (GSList *i = items; i != NULL; i = i->next) {
- Inkscape::XML::Node *dup = (SP_OBJECT_REPR (i->data))->duplicate();
+ Inkscape::XML::Node *dup = (SP_OBJECT_REPR (i->data))->duplicate(xml_doc);
mask_items = g_slist_prepend (mask_items, dup);
if (remove_original) {
} else if (!topmost) {
// topmost item is used as a mask, which is applied to other items in a selection
GSList *i = items;
- Inkscape::XML::Node *dup = (SP_OBJECT_REPR (i->data))->duplicate();
+ Inkscape::XML::Node *dup = (SP_OBJECT_REPR (i->data))->duplicate(xml_doc);
mask_items = g_slist_prepend (mask_items, dup);
if (remove_original) {
apply_to_items = g_slist_prepend (apply_to_items, i->data);
}
- Inkscape::XML::Node *dup = (SP_OBJECT_REPR (i->data))->duplicate();
+ Inkscape::XML::Node *dup = (SP_OBJECT_REPR (i->data))->duplicate(xml_doc);
mask_items = g_slist_prepend (mask_items, dup);
if (remove_original) {
GSList *mask_items_dup = NULL;
for (GSList *mask_item = mask_items; NULL != mask_item; mask_item = mask_item->next) {
- Inkscape::XML::Node *dup = reinterpret_cast<Inkscape::XML::Node *>(mask_item->data)->duplicate();
+ Inkscape::XML::Node *dup = reinterpret_cast<Inkscape::XML::Node *>(mask_item->data)->duplicate(xml_doc);
mask_items_dup = g_slist_prepend (mask_items_dup, dup);
}
const gchar *mask_id = NULL;
if (apply_clip_path) {
- mask_id = sp_clippath_create(mask_items_dup, document, &maskTransform);
+ mask_id = sp_clippath_create(mask_items_dup, doc, &maskTransform);
} else {
- mask_id = sp_mask_create(mask_items_dup, document, &maskTransform);
+ mask_id = sp_mask_create(mask_items_dup, doc, &maskTransform);
}
g_slist_free (mask_items_dup);
g_slist_free (items_to_delete);
if (apply_clip_path)
- sp_document_done (document, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path"));
+ sp_document_done (doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path"));
else
- sp_document_done (document, SP_VERB_OBJECT_SET_MASK, _("Set mask"));
+ sp_document_done (doc, SP_VERB_OBJECT_SET_MASK, _("Set mask"));
}
void sp_selection_unset_mask(bool apply_clip_path) {
if (desktop == NULL)
return;
- SPDocument *document = sp_desktop_document(desktop);
+ SPDocument *doc = sp_desktop_document(desktop);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
// check if something is selected
}
bool remove_original = prefs_get_int_attribute ("options.maskobject", "remove", 1);
- sp_document_ensure_up_to_date(document);
+ sp_document_ensure_up_to_date(doc);
gchar const* attributeName = apply_clip_path ? "clip-path" : "mask";
std::map<SPObject*,SPItem*> referenced_objects;
SPObject *obj = (*it).first;
GSList *items_to_move = NULL;
for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
- Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate();
+ Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc);
items_to_move = g_slist_prepend (items_to_move, copy);
}
}
if (apply_clip_path)
- sp_document_done (document, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path"));
+ sp_document_done (doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path"));
else
- sp_document_done (document, SP_VERB_OBJECT_UNSET_MASK, _("Release mask"));
+ sp_document_done (doc, SP_VERB_OBJECT_UNSET_MASK, _("Release mask"));
}
void fit_canvas_to_selection(SPDesktop *desktop) {
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index b127e1657feb898983bc4dd745253e14f6d18f78..150a67c3012cddc68a1b2e7ed436f95a459d7dca 100644 (file)
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
// remember parent
Inkscape::XML::Node *parent = sp_repr_parent(original_repr);
- Inkscape::XML::Node *copy_repr = original_repr->duplicate();
+ Inkscape::XML::Node *copy_repr = original_repr->duplicate(parent->document());
// add the new repr to the parent
parent->appendChild(copy_repr);
diff --git a/src/sp-feblend.cpp b/src/sp-feblend.cpp
index c901d60735ffc58e6c01206744ef9bbbeb28ed9c..7192f3bc672110698e609c5c05b87b8cc10de563 100644 (file)
--- a/src/sp-feblend.cpp
+++ b/src/sp-feblend.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
index f224e9c3c174ffc52d62e8d676d219e195873743..3ee184a7235024fd401be09bb58bced643a1b09b 100644 (file)
--- a/src/sp-fecolormatrix.cpp
+++ b/src/sp-fecolormatrix.cpp
@@ -150,7 +150,7 @@ sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
index 6c228c3fb59e945ce4dd3a24d032d0191b20a8b1..941431f6d8ea4f83c9c539dd97bd9fcf533df090 100644 (file)
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
diff --git a/src/sp-fecomposite.cpp b/src/sp-fecomposite.cpp
index ed127e7230af8f7f1fd8c5ab856fcd2f87dbb17b..cb65cc812dd4374d1bc187ddd953a979995e15a1 100644 (file)
--- a/src/sp-fecomposite.cpp
+++ b/src/sp-fecomposite.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
index b02f75fd18422d9cc60773b757922bacd5736312..0a255b0670305232afaaca222077a3c55c66b20b 100644 (file)
@@ -150,7 +150,7 @@ sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint fla
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
index beb2d6f14880ea6b5522d83f66976a10db4f4b8c..e9720ab1648a10805dd54c3833e22b0c6a810810 100644 (file)
@@ -150,7 +150,7 @@ sp_feDiffuseLighting_write(SPObject *object, Inkscape::XML::Node *repr, guint fl
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
index d651a3ab5e51205928aa3deb4eecda0d54e003df..138ae6e0ed5452a990af4ed539e95ad9befc55a6 100644 (file)
@@ -150,7 +150,7 @@ sp_feDisplacementMap_write(SPObject *object, Inkscape::XML::Node *repr, guint fl
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
diff --git a/src/sp-feflood.cpp b/src/sp-feflood.cpp
index 843f49da51b912af9ca1f44afcb78e44cc3237d0..5f4050a2657d348db6af6c2a5bd3252189675a37 100644 (file)
--- a/src/sp-feflood.cpp
+++ b/src/sp-feflood.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
diff --git a/src/sp-feimage.cpp b/src/sp-feimage.cpp
index aeacdcef2300c9654e901be75b77ebdfc326156f..e1bbe86cf1fd014fc49430c64261fd0199bd7a15 100644 (file)
--- a/src/sp-feimage.cpp
+++ b/src/sp-feimage.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
diff --git a/src/sp-femerge.cpp b/src/sp-femerge.cpp
index 64c01432c689c44154eb647c313309b1b6a0b668..4436c7d1e8b849eee21fc50d346439cc8c2a3324 100644 (file)
--- a/src/sp-femerge.cpp
+++ b/src/sp-femerge.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
index eed1f7602ccbf6b2579743f5ea24049511f4b6ae..cdfd0bd3803b637638639ebb1ee5cc742e930915 100644 (file)
--- a/src/sp-femorphology.cpp
+++ b/src/sp-femorphology.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
diff --git a/src/sp-feoffset.cpp b/src/sp-feoffset.cpp
index b766f5224909c307e50c88c6cee7e32383bf7774..72f352a722dc3db84d13211c6309cddb44d93ca3 100644 (file)
--- a/src/sp-feoffset.cpp
+++ b/src/sp-feoffset.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
index b1ef987e12511a45a394b0cc657babb6e7db7e94..ce251b6fa1c67a828db576a7d36d570b191ff13f 100644 (file)
@@ -150,7 +150,7 @@ sp_feSpecularLighting_write(SPObject *object, Inkscape::XML::Node *repr, guint f
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
diff --git a/src/sp-fetile.cpp b/src/sp-fetile.cpp
index 7d33cd5023e7f92891bd1f2fc6dbc25aba486993..bb6893cbce66654f551e3d00f34a5f971724ad26 100644 (file)
--- a/src/sp-fetile.cpp
+++ b/src/sp-fetile.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
index 033dfd7e42f2e17653dab33f3c0f0aca18c8a78f..ab46433d12a093dfc40171db9ca8e059688d6d7c 100644 (file)
--- a/src/sp-feturbulence.cpp
+++ b/src/sp-feturbulence.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
index c0027e7c38346484a128f6001af12291ca911ee5..7be694980afdde0bcbae5def9a6aee80579bf3dc 100644 (file)
@@ -151,7 +151,8 @@ sp_filter_primitive_write(SPObject *object, Inkscape::XML::Node *repr, guint fla
// is this sane?
//repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ /// \todo FIXME: Plumb an appropriate XML::Document into this
+ repr = SP_OBJECT_REPR(object)->duplicate(NULL);
}
}
diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp
index 729e13d4aec5a453d16d64ed230744eea8c5d03b..ef5d71483ee599e5d8c1e7d2815380ff83019bdf 100644 (file)
--- a/src/sp-filter.cpp
+++ b/src/sp-filter.cpp
SPFilter *filter = SP_FILTER(object);
if (!repr) {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
if ((flags & SP_OBJECT_WRITE_ALL) || filter->filterUnits_set) {
index 63680a10bf5ad238cd9fab01de0b38e6e1c26a99..0fcc6d77916328f4a52dbc759806a4f24d8dfb1d 100644 (file)
--- a/src/sp-gaussian-blur.cpp
+++ b/src/sp-gaussian-blur.cpp
// is this sane?
// repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index f73bc26002874e08e37e9874e300d21d0e78e5d1..d4fa9536d4cf246c7ea31e970330896a3d4dc414 100644 (file)
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
child->updateRepr();
- Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate();
+ Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document());
// Merging transform
NR::Matrix ctrans;
items = g_slist_prepend (items, nrepr);
} else {
- Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate();
+ Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document());
objects = g_slist_prepend (objects, nrepr);
}
}
diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp
index 0f4b1fb1d104bffa152b5feebb04739212fbbe30..275a5be1d77e30bb7211491e9384931115cb0cdd 100644 (file)
--- a/src/sp-metadata.cpp
+++ b/src/sp-metadata.cpp
if (repr) {
repr->mergeFrom(SP_OBJECT_REPR (object), "id");
} else {
- repr = SP_OBJECT_REPR (object)->duplicate();
+ repr = SP_OBJECT_REPR (object)->duplicate(repr->document());
}
}
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 75bb35cd584f556ac88b50150fdaba65efc0f1dd..c2b8aba10da4f48e5409ef067d9ce805bab46e40 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -652,7 +652,8 @@ static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::
if (repr) {
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ /// \todo FIXME: Plumb an appropriate XML::Document into this
+ repr = SP_OBJECT_REPR(object)->duplicate(NULL);
}
}
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 5dbc4101e7bfb3a392fa4132ab1f1676175f5c41..f969fe8428b56ba4335f2137f2263c4a6a0471c8 100644 (file)
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
sp_object_private_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
{
if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
if (!( flags & SP_OBJECT_WRITE_EXT )) {
repr->setAttribute("inkscape:collect", NULL);
}
}
}
+/** Used both to create reprs in the original document, and to create
+ * reprs in another document (e.g. a temporary document used when
+ * saving as "Plain SVG"
+ */
Inkscape::XML::Node *
SPObject::updateRepr(Inkscape::XML::Node *repr, unsigned int flags) {
if (SP_OBJECT_IS_CLONED(this)) {
g_warning("Class %s does not implement ::write", G_OBJECT_TYPE_NAME(this));
if (!repr) {
if (flags & SP_OBJECT_WRITE_BUILD) {
- repr = SP_OBJECT_REPR(this)->duplicate();
+ /// \todo FIXME: Plumb an appropriate XML::Document into this
+ repr = SP_OBJECT_REPR(this)->duplicate(NULL);
}
- /// \todo fixme: else probably error (Lauris) */
+ /// \todo FIXME: else probably error (Lauris) */
} else {
repr->mergeFrom(SP_OBJECT_REPR(this), "id");
}
diff --git a/src/sp-skeleton.cpp b/src/sp-skeleton.cpp
index f45ff1fda676923bcd94d3e07e6736771af2a106..e9f69e2668066f353bc596d35dafe2e69474d62f 100644 (file)
--- a/src/sp-skeleton.cpp
+++ b/src/sp-skeleton.cpp
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate();
+ repr = SP_OBJECT_REPR(object)->duplicate(repr->document());
}
}
diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp
index 3339b2377e65ecf2d5638be2786593feffaac379..0b8f97da1318207feee59b9e78049e69097c9d07 100644 (file)
--- a/src/sp-tspan.cpp
+++ b/src/sp-tspan.cpp
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
diff --git a/src/sp-use.cpp b/src/sp-use.cpp
index 5b2ed9e239c81d23eb41de9247120753bcffb97a..8aa8d3090f6bf0aa713fb811c173add3b7cbec86 100644 (file)
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
if (SP_IS_SYMBOL(orig)) { // make a group, copy children
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();
+ Inkscape::XML::Node *newchild = child->duplicate(copy->document());
copy->appendChild(newchild);
}
} else { // just copy
- copy = SP_OBJECT_REPR(orig)->duplicate();
+ copy = SP_OBJECT_REPR(orig)->duplicate(copy->document());
}
// Add the duplicate repr just after the existing one.
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index f2a115f43c9657f3a031e83929e1d6a76ec42281..3035cb1a7ae022a5c633b425f664be203d87949f 100644 (file)
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
tr = marker_item->transform * marker->c2p * tr * transform;
if (SP_OBJECT_REPR(marker_item)) {
- Inkscape::XML::Node *m_repr = SP_OBJECT_REPR(marker_item)->duplicate();
+ Inkscape::XML::Node *m_repr = SP_OBJECT_REPR(marker_item)->duplicate(xml_doc);
g_repr->appendChild(m_repr);
SPItem *marker_item = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(m_repr);
sp_item_write_transform(marker_item, m_repr, tr);
diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp
index 79d5e3a2dc390d5a62068ea6b80c0db2beaff839..4853258596d82d74c539e119585d06b964a0f728 100644 (file)
--- a/src/text-chemistry.cpp
+++ b/src/text-chemistry.cpp
SP_OBJECT_REPR(text)->addChild(textpath, NULL);
for ( GSList *i = text_reprs ; i ; i = i->next ) {
- // make a copy of each text child
- Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate();
+ // Make a copy of each text child
+ Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate(xml_doc);
// We cannot have multiline in textpath, so remove line attrs from tspans
if (!strcmp(copy->name(), "svg:tspan")) {
copy->setAttribute("sodipodi:role", NULL);
} else { // reflow an already flowed text, preserving paras
for (SPObject *o = SP_OBJECT(text)->children; o != NULL; o = o->next) {
if (SP_IS_FLOWPARA(o)) {
- Inkscape::XML::Node *para_repr = SP_OBJECT_REPR(o)->duplicate();
+ Inkscape::XML::Node *para_repr = SP_OBJECT_REPR(o)->duplicate(xml_doc);
root_repr->appendChild(para_repr);
object = doc->getObjectByRepr(para_repr);
g_return_if_fail(SP_IS_FLOWPARA(object));
index b701adc2b3183fd9ccd1a66167c0634880a506e1..71e174fb6f83001d180094b5d27aa1f0d94f2629 100644 (file)
--- a/src/ui/context-menu.cpp
+++ b/src/ui/context-menu.cpp
g_return_if_fail(SP_IS_ANCHOR(object));
const char *id = SP_OBJECT_REPR(item)->attribute("id");
- Inkscape::XML::Node *child = SP_OBJECT_REPR(item)->duplicate();
+ Inkscape::XML::Node *child = SP_OBJECT_REPR(item)->duplicate(xml_doc);
SP_OBJECT(item)->deleteObject(false);
repr->addChild(child, NULL);
child->setAttribute("id", id);
index 68d69f3f9b5a7c96e4056e36185f6a3907b1dce0..88a04bd7a115b6de797b33c7a7fb775d92ed8709 100644 (file)
@@ -305,13 +305,14 @@ sp_gradient_selector_add_vector_clicked (GtkWidget *w, SPGradientSelector *sel)
SPDocument *doc;
SPGradient *gr;
Inkscape::XML::Node *repr;
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
doc = sp_gradient_vector_selector_get_document (SP_GRADIENT_VECTOR_SELECTOR (sel->vectors));
if (!doc) return;
gr = sp_gradient_vector_selector_get_gradient (SP_GRADIENT_VECTOR_SELECTOR (sel->vectors));
if (gr) {
- repr = SP_OBJECT_REPR (gr)->duplicate();
+ repr = SP_OBJECT_REPR (gr)->duplicate(xml_doc);
} else {
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
Inkscape::XML::Node *stop;
index 5a0b5c35e98d7747bdc41a65d10ad49f2446dfac..f1c4e3500437665d8ccc1013367ee5997119fe61 100644 (file)
}
if (i < 2) {
sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", 0.0);
- Inkscape::XML::Node *child = SP_OBJECT_REPR(stop)->duplicate();
+ Inkscape::XML::Node *child = SP_OBJECT_REPR(stop)->duplicate(SP_OBJECT_REPR(gradient)->document());
sp_repr_set_css_double(child, "offset", 1.0);
SP_OBJECT_REPR(gradient)->addChild(child, SP_OBJECT_REPR (stop));
}
}
if (next != NULL) {
- new_stop_repr = SP_OBJECT_REPR(stop)->duplicate();
+ new_stop_repr = SP_OBJECT_REPR(stop)->duplicate(SP_OBJECT_REPR(gradient)->document());
SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(stop));
} else {
next = stop;
- new_stop_repr = SP_OBJECT_REPR(sp_prev_stop(stop, gradient))->duplicate();
+ new_stop_repr = SP_OBJECT_REPR(sp_prev_stop(stop, gradient))->duplicate(SP_OBJECT_REPR(gradient)->document());
SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(sp_prev_stop(stop, gradient)));
}
diff --git a/src/xml/comment-node.h b/src/xml/comment-node.h
index c439d0d541345afee87f1f177a2a675c42ab345f..b804a00d95b8e9071389ad30470d2939dddc903c 100644 (file)
--- a/src/xml/comment-node.h
+++ b/src/xml/comment-node.h
Inkscape::XML::NodeType type() const { return Inkscape::XML::COMMENT_NODE; }
protected:
- SimpleNode *_duplicate() const { return new CommentNode(*this); }
+ SimpleNode *_duplicate(Document* doc) const { return new CommentNode(*this); }
};
}
diff --git a/src/xml/element-node.h b/src/xml/element-node.h
index b9b7a4034d386f58d85e06f626eac292a604cbfd..4bac55f83442160349bb853f9392376efa4f9334 100644 (file)
--- a/src/xml/element-node.h
+++ b/src/xml/element-node.h
Inkscape::XML::NodeType type() const { return Inkscape::XML::ELEMENT_NODE; }
protected:
- SimpleNode *_duplicate() const { return new ElementNode(*this); }
+ SimpleNode *_duplicate(Document* doc) const { return new ElementNode(*this); }
};
}
diff --git a/src/xml/node.h b/src/xml/node.h
index 7e27f1ff6ce238e12b7fc61f04b745544d302f9d..0b22b169ed5cb9bb888631577dc0a5119eb929db 100644 (file)
--- a/src/xml/node.h
+++ b/src/xml/node.h
virtual Document *document()=0;
virtual Document const *document() const=0;
- virtual Node *duplicate() const=0;
+ virtual Node *duplicate(Document *doc) const=0;
virtual Node *root()=0;
virtual Node const *root() const=0;
diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp
index 8540ff9f0ebc029a2afb1867d91346d7fd008263..e2954ddf3e25b0d778a3ece586641b3ec00d2343 100644 (file)
--- a/src/xml/repr-css.cpp
+++ b/src/xml/repr-css.cpp
using Inkscape::XML::SimpleNode;
using Inkscape::XML::Node;
using Inkscape::XML::NodeType;
+using Inkscape::XML::Document;
struct SPCSSAttrImpl : public SimpleNode, public SPCSSAttr {
public:
NodeType type() const { return Inkscape::XML::ELEMENT_NODE; }
protected:
- SimpleNode *_duplicate() const { return new SPCSSAttrImpl(*this); }
+ SimpleNode *_duplicate(Document* doc) const { return new SPCSSAttrImpl(*this); }
};
static void sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const *attr);
index 11d0ef4a246e6ffb6e55ffbc079b9777a3ce0752..ab563139d750259bba4e7d8b4ee00e09cadf01ff 100644 (file)
_initBindings();
}
- SimpleNode *_duplicate() const { return new SimpleDocument(*this); }
+ SimpleNode *_duplicate(Document* doc) const
+ {
+ return new SimpleDocument(*this);
+ }
private:
void _initBindings();
index f439243cdb2ccb49761abc03d9cc00144ef3ebc4..c8b0828c45d1e5c2a64fe2e48ce2d387cce8d3e8 100644 (file)
--- a/src/xml/simple-node.cpp
+++ b/src/xml/simple-node.cpp
_child_count(node._child_count),
_cached_positions_valid(node._cached_positions_valid)
{
- _document = NULL;
_document = NULL;
_parent = _next = NULL;
_first_child = _last_child = NULL;
for ( Node *child = node._first_child ;
child != NULL ; child = child->next() )
{
- Node *child_copy=child->duplicate();
+ Node *child_copy=child->duplicate(NULL); // FIXME
child_copy->_setParent(this);
if (_last_child) {
if (rch) {
rch->mergeFrom(child, key);
} else {
- rch = child->duplicate();
+ rch = child->duplicate(_document);
appendChild(rch);
rch->release();
}
} else {
- Node *rch=child->duplicate();
+ Node *rch=child->duplicate(_document);
appendChild(rch);
rch->release();
}
diff --git a/src/xml/simple-node.h b/src/xml/simple-node.h
index 3a25bc86c68f5bd4d63331b27aa828d10b844355..c843dadc5c87eb126ef7e601e288a0c2fa5758c2 100644 (file)
--- a/src/xml/simple-node.h
+++ b/src/xml/simple-node.h
return const_cast<SimpleNode *>(this)->document();
}
- Node *duplicate() const { return _duplicate(); }
+ Node *duplicate(Document* doc) const { return _duplicate(doc); }
Node *root();
Node const *root() const {
SimpleNode(int code);
SimpleNode(SimpleNode const &repr);
- virtual SimpleNode *_duplicate() const=0;
+ virtual SimpleNode *_duplicate(Document *doc) const=0;
public: // ideally these should be protected somehow...
void _setParent(Node *parent) { _parent = parent; }
diff --git a/src/xml/text-node.h b/src/xml/text-node.h
index bd6095f3b1658ea86f6c27f9a8f81b906efc2067..36f638ad90a29e7997dcb26a4e76d5b4f5acdab0 100644 (file)
--- a/src/xml/text-node.h
+++ b/src/xml/text-node.h
Inkscape::XML::NodeType type() const { return Inkscape::XML::TEXT_NODE; }
protected:
- SimpleNode *_duplicate() const { return new TextNode(*this); }
+ SimpleNode *_duplicate(Document* doc) const { return new TextNode(*this); }
};
}