diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-09-09 01:54:39 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-09-09 01:54:39 +0000 |
| commit | 30faf29165b1bcd936e9e0ca3ecc8b4bad4c94d2 (patch) | |
| tree | ff87b28b4f76e4b2ae947bd1bc28696cece68ce5 /src/ui/clipboard.cpp | |
| parent | Fix for bug: 1715433 :: Clone original LPE can no longer be used to fill a po... (diff) | |
| download | inkscape-30faf29165b1bcd936e9e0ca3ecc8b4bad4c94d2.tar.gz inkscape-30faf29165b1bcd936e9e0ca3ecc8b4bad4c94d2.zip | |
This commit is based on a coment on bug #1670644. And allow to fill the fill between many LPE widget that allow
attach all paths on the clipboard instead only one
Also added to this widget the option visible, to allow work with multiples paths wigout getting full cracy
Diffstat (limited to 'src/ui/clipboard.cpp')
| -rw-r--r-- | src/ui/clipboard.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 3cc8ac098..202c8d922 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -105,6 +105,7 @@ public: virtual bool pastePathEffect(ObjectSet *set); virtual Glib::ustring getPathParameter(SPDesktop* desktop); virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop); + virtual std::vector<Glib::ustring> getElementsOfType(SPDesktop *desktop, gchar const *type); virtual const gchar *getFirstObjectID(); ClipboardManagerImpl(); @@ -653,6 +654,54 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) } /** + * Get all objects id from the clipboard. + * @return A vector containing all IDs or empty if no shape or text item was found. + * type. Set to "*" to retrive all elements of the types vector inside, feel free to populate more + */ +std::vector<Glib::ustring> ClipboardManagerImpl::getElementsOfType(SPDesktop *desktop, gchar const *type) +{ + std::vector<Glib::ustring> result; + SPDocument *tempdoc = _retrieveClipboard(); // any target will do here + if ( tempdoc == NULL ) { + _userWarn(desktop, _("Nothing on the clipboard.")); + return result; + } + Inkscape::XML::Node *root = tempdoc->getReprRoot(); + + // 1293979: strip out the defs of the document + root->removeChild(tempdoc->getDefs()->getRepr()); + std::vector<Inkscape::XML::Node const *> reprs; + if (strcmp(type, "*") == 0){ + //TODO:Fill vector with all posible elements + std::vector<Glib::ustring> types; + types.push_back((Glib::ustring)"svg:path"); + types.push_back((Glib::ustring)"svg:circle"); + types.push_back((Glib::ustring)"svg:rect"); + types.push_back((Glib::ustring)"svg:ellipse"); + types.push_back((Glib::ustring)"svg:text"); + types.push_back((Glib::ustring)"svg:g"); + types.push_back((Glib::ustring)"svg:image"); + for (auto i=types.begin();i!=types.end();++i) { + Glib::ustring type_elem = *i; + std::vector<Inkscape::XML::Node const *> reprs_found = sp_repr_lookup_name_many(root, type_elem.c_str(), -1); // unlimited search depth + reprs.insert(reprs.end(), reprs_found.begin(), reprs_found.end()); + } + } else { + reprs = sp_repr_lookup_name_many(root, type, -1); // unlimited search depth + } + for (auto i=reprs.begin();i!=reprs.end();++i) { + Inkscape::XML::Node const * node = *i; + result.push_back(node->attribute("id")); + } + if ( result.empty() ) { + _userWarn(desktop, ((Glib::ustring)_("Clipboard does not contain any.") + (Glib::ustring)type).c_str()); + tempdoc->doUnref(); + return result; + } + return result; +} + +/** * Iterate over a list of items and copy them to the clipboard. */ void ClipboardManagerImpl::_copySelection(ObjectSet *selection) |
