From c263637743407a181ac2f12226727553bda6cb37 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Mon, 28 Jul 2014 17:25:41 -0400 Subject: Fix for copy&paste clone original with clip-path/mask Fixed bugs: - https://launchpad.net/bugs/1293979 (bzr r13478) --- src/ui/clipboard.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/ui/clipboard.cpp') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 8e2502545..1209b19cd 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -601,6 +601,12 @@ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop) */ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) { + // https://bugs.launchpad.net/inkscape/+bug/1293979 + // basically, when we do a depth-first search, we're stopping + // at the first object to be or . + // but that could then return the id of the object's + // clip path or mask, not the original path! + SPDocument *tempdoc = _retrieveClipboard(); // any target will do here if ( tempdoc == NULL ) { _userWarn(desktop, _("Nothing on the clipboard.")); @@ -608,6 +614,9 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) } Inkscape::XML::Node *root = tempdoc->getReprRoot(); + // 1293979: strip out the defs of the document + root->removeChild(tempdoc->getDefs()->getRepr()); + Inkscape::XML::Node *repr = sp_repr_lookup_name(root, "svg:path", -1); // unlimited search depth if ( repr == NULL ) { repr = sp_repr_lookup_name(root, "svg:text", -1); -- cgit v1.2.3 From 156cf3323a936c7dfccd9e09458cd8b5d174b7fe Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 5 Oct 2014 19:24:27 -0400 Subject: Move more UI code into ui/ (bzr r13341.1.253) --- src/ui/clipboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/clipboard.cpp') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 1209b19cd..40500cf15 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -76,7 +76,7 @@ #include "svg/css-ostringstream.h" // used in copy #include "ui/tools/text-tool.h" #include "text-editing.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "path-chemistry.h" #include "util/units.h" #include "helper/png-write.h" -- cgit v1.2.3 From e2ae473da92a1f96e307e3f1f3e206cad7bd1c38 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 23 Oct 2014 19:33:47 -0700 Subject: Initial removal of box3d outdated GTKish macros. (bzr r13634) --- src/ui/clipboard.cpp | 131 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 53 deletions(-) (limited to 'src/ui/clipboard.cpp') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 1209b19cd..031a92924 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -505,12 +505,15 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a // resize each object in the selection if (separately) { for (GSList *i = const_cast(selection->itemList()) ; i ; i = i->next) { - SPItem *item = SP_ITEM(i->data); - Geom::OptRect obj_size = item->desktopVisualBounds(); - if ( !obj_size ) { - continue; + SPItem *item = dynamic_cast(static_cast(i->data)); + if (item) { + Geom::OptRect obj_size = item->desktopVisualBounds(); + if ( obj_size ) { + sp_item_scale_rel(item, _getScale(desktop, min, max, *obj_size, apply_x, apply_y)); + } + } else { + g_assert_not_reached(); } - sp_item_scale_rel(item, _getScale(desktop, min, max, *obj_size, apply_x, apply_y)); } } // resize the selection as a whole @@ -640,7 +643,12 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) GSList const *items = selection->itemList(); // copy the defs used by all items for (GSList *i = const_cast(items) ; i != NULL ; i = i->next) { - _copyUsedDefs(SP_ITEM (i->data)); + SPItem *item = dynamic_cast(static_cast(i->data)); + if (item) { + _copyUsedDefs(item); + } else { + g_assert_not_reached(); + } } // copy the representation of the items @@ -648,36 +656,38 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) sorted_items = g_slist_sort(sorted_items, (GCompareFunc) sp_object_compare_position); for (GSList *i = sorted_items ; i ; i = i->next) { - if (!SP_IS_ITEM(i->data)) { - continue; + SPItem *item = dynamic_cast(static_cast(i->data)); + if (item) { + Inkscape::XML::Node *obj = item->getRepr(); + Inkscape::XML::Node *obj_copy = _copyNode(obj, _doc, _root); + + // copy complete inherited style + SPCSSAttr *css = sp_repr_css_attr_inherited(obj, "style"); + sp_repr_css_set(obj_copy, css, "style"); + sp_repr_css_attr_unref(css); + + // write the complete accumulated transform passed to us + // (we're dealing with unattached representations, so we write to their attributes + // instead of using sp_item_set_transform) + gchar *transform_str = sp_svg_transform_write(item->i2doc_affine()); + obj_copy->setAttribute("transform", transform_str); + g_free(transform_str); } - Inkscape::XML::Node *obj = reinterpret_cast(i->data)->getRepr(); - Inkscape::XML::Node *obj_copy = _copyNode(obj, _doc, _root); - - // copy complete inherited style - SPCSSAttr *css = sp_repr_css_attr_inherited(obj, "style"); - sp_repr_css_set(obj_copy, css, "style"); - sp_repr_css_attr_unref(css); - - // write the complete accumulated transform passed to us - // (we're dealing with unattached representations, so we write to their attributes - // instead of using sp_item_set_transform) - gchar *transform_str = sp_svg_transform_write(SP_ITEM(i->data)->i2doc_affine()); - obj_copy->setAttribute("transform", transform_str); - g_free(transform_str); } // copy style for Paste Style action if (sorted_items) { - if (SP_IS_ITEM(sorted_items->data)) { - SPCSSAttr *style = take_style_from_item((SPItem *) sorted_items->data); + SPObject *object = static_cast(sorted_items->data); + SPItem *item = dynamic_cast(object); + if (item) { + SPCSSAttr *style = take_style_from_item(item); sp_repr_css_set(_clipnode, style, "style"); sp_repr_css_attr_unref(style); } // copy path effect from the first path - if (SP_IS_OBJECT(sorted_items->data)) { - gchar const *effect = reinterpret_cast(sorted_items->data)->getRepr()->attribute("inkscape:path-effect"); + if (object) { + gchar const *effect =object->getRepr()->attribute("inkscape:path-effect"); if (effect) { _clipnode->setAttribute("inkscape:path-effect", effect); } @@ -704,35 +714,38 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) if (style && (style->fill.isPaintserver())) { SPPaintServer *server = item->style->getFillPaintServer(); - if ( SP_IS_LINEARGRADIENT(server) || SP_IS_RADIALGRADIENT(server) ) { - _copyGradient(SP_GRADIENT(server)); + if ( dynamic_cast(server) || dynamic_cast(server) ) { + _copyGradient(dynamic_cast(server)); } - if ( SP_IS_PATTERN(server) ) { - _copyPattern(SP_PATTERN(server)); + SPPattern *pattern = dynamic_cast(server); + if ( pattern ) { + _copyPattern(pattern); } } if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = item->style->getStrokePaintServer(); - if ( SP_IS_LINEARGRADIENT(server) || SP_IS_RADIALGRADIENT(server) ) { - _copyGradient(SP_GRADIENT(server)); + if ( dynamic_cast(server) || dynamic_cast(server) ) { + _copyGradient(dynamic_cast(server)); } - if ( SP_IS_PATTERN(server) ) { - _copyPattern(SP_PATTERN(server)); + SPPattern *pattern = dynamic_cast(server); + if ( pattern ) { + _copyPattern(pattern); } } // For shapes, copy all of the shape's markers - if (SP_IS_SHAPE(item)) { - SPShape *shape = SP_SHAPE (item); + SPShape *shape = dynamic_cast(item); + if (shape) { for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { if (shape->_marker[i]) { _copyNode(shape->_marker[i]->getRepr(), _doc, _defs); } } } + // For lpe items, copy lpe stack if applicable - if (SP_IS_LPE_ITEM(item)) { - SPLPEItem *lpeitem = SP_LPE_ITEM (item); + SPLPEItem *lpeitem = dynamic_cast(item); + if (lpeitem) { if (lpeitem->hasPathEffect()) { for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it) { @@ -743,14 +756,24 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } } } + // For 3D boxes, copy perspectives - if (SP_IS_BOX3D(item)) { - _copyNode(box3d_get_perspective(SP_BOX3D(item))->getRepr(), _doc, _defs); + { + SPBox3D *box = dynamic_cast(item); + if (box) { + _copyNode(box3d_get_perspective(box)->getRepr(), _doc, _defs); + } } + // Copy text paths - if (SP_IS_TEXT_TEXTPATH(item)) { - _copyTextPath(SP_TEXTPATH(item->firstChild())); + { + SPText *text = dynamic_cast(item); + SPTextPath *textpath = (text) ? dynamic_cast(text->firstChild()) : NULL; + if (textpath) { + _copyTextPath(textpath); + } } + // Copy clipping objects if (item->clip_ref){ if (item->clip_ref->getObject()) { @@ -764,8 +787,9 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) _copyNode(mask->getRepr(), _doc, _defs); // recurse into the mask for its gradients etc. for (SPObject *o = mask->children ; o != NULL ; o = o->next) { - if (SP_IS_ITEM(o)) { - _copyUsedDefs(SP_ITEM(o)); + SPItem *childItem = dynamic_cast(o); + if (childItem) { + _copyUsedDefs(childItem); } } } @@ -774,15 +798,16 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) // Copy filters if (style->getFilter()) { SPObject *filter = style->getFilter(); - if (SP_IS_FILTER(filter)) { + if (dynamic_cast(filter)) { _copyNode(filter->getRepr(), _doc, _defs); } } // recurse for (SPObject *o = item->children ; o != NULL ; o = o->next) { - if (SP_IS_ITEM(o)) { - _copyUsedDefs(SP_ITEM(o)); + SPItem *childItem = dynamic_cast(o); + if (childItem) { + _copyUsedDefs(childItem); } } } @@ -817,10 +842,10 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) // items in the pattern may also use gradients and other patterns, so recurse for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) { - if (!SP_IS_ITEM (child)) { - continue; + SPItem *childItem = dynamic_cast(child); + if (childItem) { + _copyUsedDefs(childItem); } - _copyUsedDefs(SP_ITEM(child)); } if (pattern->ref){ pattern = pattern->ref->getObject(); @@ -939,13 +964,13 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta if ( item == NULL ) { return; } - if ( SP_IS_RECT(item) ) { + if ( dynamic_cast(item) ) { return; } - if (SP_IS_LPE_ITEM(item)) + SPLPEItem *lpeitem = dynamic_cast(item); + if (lpeitem) { - SPLPEItem *lpeitem = SP_LPE_ITEM(item); // for each effect in the stack, check if we need to fork it before adding it to the item lpeitem->forkPathEffectsIfNecessary(1); -- cgit v1.2.3 From 0d7c3ee0a778bfc2f5e5cbc1701ee6cd12e62012 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 24 Oct 2014 21:50:14 -0700 Subject: Cleaned casts from sp-shape by fixing member type. (bzr r13638) --- src/ui/clipboard.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/clipboard.cpp') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 031a92924..4b4b14c22 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -54,6 +54,7 @@ #include <2geom/transforms.h> #include "box3d.h" #include "gradient-drag.h" +#include "marker.h" #include "sp-item.h" #include "sp-item-transform.h" // for sp_item_scale_rel, used in _pasteSize #include "sp-path.h" -- cgit v1.2.3 From 510c80b1b2d9a4ee700bd152d320c6963bccd358 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 15 Nov 2014 07:52:51 -0500 Subject: scale symbols when changing document units (Bug 1365451) Fixed bugs: - https://launchpad.net/bugs/1365451 (bzr r13709) --- src/ui/clipboard.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/ui/clipboard.cpp') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 931a295d8..153ed9830 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -330,6 +330,13 @@ void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const* use->setAttribute("xlink:href", id.c_str() ); // Set a default style in rather than so it can be changed. use->setAttribute("style", style ); + + Inkscape::XML::Node *nv_repr = sp_desktop_namedview(inkscape_active_desktop())->getRepr(); + gdouble scale_units = Inkscape::Util::Quantity::convert(1, nv_repr->attribute("inkscape:document-units"), "px"); + gchar *transform_str = sp_svg_transform_write(Geom::Scale(scale_units, scale_units)); + use->setAttribute("transform", transform_str); + g_free(transform_str); + _root->appendChild(use); // This min and max sets offsets, we don't have any so set to zero. -- cgit v1.2.3