From 41b9f5f4416766ca01eedd79e2d8c201d677ab99 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Mon, 20 Mar 2006 04:24:12 +0000 Subject: [PATCH] copy clippaths, masks, and mask gradients to defs_clipboard --- src/selection-chemistry.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index a92cb1a73..91686d277 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -842,10 +842,10 @@ void sp_copy_pattern (GSList **defs_clip, SPPattern *pattern) } } -void sp_copy_marker (GSList **defs_clip, SPMarker *marker) +void sp_copy_single (GSList **defs_clip, SPObject *thing) { - Inkscape::XML::Node *marker_repr = SP_OBJECT_REPR(marker)->duplicate(); - *defs_clip = g_slist_prepend (*defs_clip, marker_repr); + Inkscape::XML::Node *duplicate_repr = SP_OBJECT_REPR(thing)->duplicate(); + *defs_clip = g_slist_prepend (*defs_clip, duplicate_repr); } @@ -884,7 +884,7 @@ 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_marker (defs_clip, SP_MARKER (shape->marker[i])); + sp_copy_single (defs_clip, SP_OBJECT (shape->marker[i])); } } } @@ -893,6 +893,20 @@ void sp_copy_stuff_used_by_item (GSList **defs_clip, SPItem *item, const GSList sp_copy_textpath_path (defs_clip, SP_TEXTPATH(sp_object_first_child(SP_OBJECT(item))), items); } + if (item->clip_ref->getObject()) { + sp_copy_single (defs_clip, item->clip_ref->getObject()); + } + + if (item->mask_ref->getObject()) { + SPObject *mask = item->mask_ref->getObject(); + sp_copy_single (defs_clip, mask); + // 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); + } + } + // recurse for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) { if (SP_IS_ITEM(o)) -- 2.30.2