diff --git a/src/id-clash.cpp b/src/id-clash.cpp index 328159165dacd0fb306199f55f57a5a4dbd954ba..f008a07e925758def763f8c7eeaae5af7dfcf12c 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -24,6 +24,7 @@ #include "object/sp-gradient.h" #include "object/sp-object.h" +#include "object/sp-text.h" #include "object/sp-paint-server.h" #include "object/sp-root.h" #include "style.h" @@ -155,6 +156,16 @@ find_references(SPObject *elem, refmap_type &refmap) } } + /* Special check for shape-inside */ + SPText *text = dynamic_cast(elem); + if (text && style->shape_inside.set) { + std::vector shapes = text->get_shapes(); + for (auto shape: shapes) { + IdReference idref = { REF_STYLE, elem, "shape-inside" }; + refmap[shape.c_str()].push_back(idref); + } + } + /* check for url(#...) references in markers */ const gchar *markers[4] = { "", "marker-start", "marker-mid", "marker-end" }; for (unsigned i = SP_MARKER_LOC_START; i < SP_MARKER_LOC_QTY; i++) { @@ -228,9 +239,10 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc, // Change to the new ID elem->setAttribute("id", new_id); - // Make a note of this change, if we need to fix up refs to it - if (refmap.find(old_id) != refmap.end()) - id_changes->push_back(id_changeitem_type(elem, old_id)); + // Make a note of this change, if we need to fix up refs to it + if (refmap.find(old_id) != refmap.end()) { + id_changes->push_back(id_changeitem_type(elem, old_id)); + } } } diff --git a/src/object/sp-text.cpp b/src/object/sp-text.cpp index 63e1352d60204ef5bc17075180d62d2e3f43a032..41e83ce5c95bb8948756a91be7ae68baadc6dd97 100644 --- a/src/object/sp-text.cpp +++ b/src/object/sp-text.cpp @@ -1060,7 +1060,7 @@ std::vector SPText::get_shapes() const std::vector shapes; char const *val; if (style->shape_inside.set && (val = style->shape_inside.value())) { - static Glib::RefPtr regex = Glib::Regex::create("url\\(#([A-z0-9#]*)\\)"); + static Glib::RefPtr regex = Glib::Regex::create("url\\(#([^\\)]*)\\)"); Glib::MatchInfo matchInfo; // Glib::Regex::match stack-use-after-scope workaround diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 733f1c018701f8116d4951703b41a83b7394be61..bcb753ca00a2c209f32b971feab527a923c7eb25 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -867,15 +867,24 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } } - // Copy text paths + // Copy text elements { SPText *text = dynamic_cast(item); - SPTextPath *textpath = (text) ? dynamic_cast(text->firstChild()) : nullptr; - if (textpath) { - _copyTextPath(textpath); + if (text) { + // Copy text paths + SPTextPath *textpath = dynamic_cast(text->firstChild()); + if (textpath) { + _copyTextPath(textpath); + } + // Copy text shape-inside + Inkscape::XML::Node* rectangle = text->get_first_rectangle(); + if (rectangle) { + _copyNode(rectangle, _doc, _defs); + } } } + // Copy clipping objects if (SPObject *clip = item->getClipObject()) { _copyNode(clip->getRepr(), _doc, _defs);