diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-03-27 08:21:53 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-03-27 08:21:53 +0000 |
| commit | 122389c971716a2c686bdd992e5a06aa0baff187 (patch) | |
| tree | 81c735e731eb42ea123f852fc1909087684a1398 /src/ui/clipboard.cpp | |
| parent | * configure.ac: s/0.45+devel/0.46+devel/. (diff) | |
| download | inkscape-122389c971716a2c686bdd992e5a06aa0baff187.tar.gz inkscape-122389c971716a2c686bdd992e5a06aa0baff187.zip | |
add method to lookup path object id from Clipboard
(bzr r5201)
Diffstat (limited to 'src/ui/clipboard.cpp')
| -rw-r--r-- | src/ui/clipboard.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 0f9223054..31a943365 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -95,6 +95,7 @@ public: virtual bool pasteSize(bool, bool, bool); virtual bool pastePathEffect(); virtual Glib::ustring getPathParameter(); + virtual Glib::ustring getPathObjectId(); ClipboardManagerImpl(); ~ClipboardManagerImpl(); @@ -438,6 +439,30 @@ Glib::ustring ClipboardManagerImpl::getPathParameter() /** + * @brief Get path object id from the clipboard + * @return The retrieved path id string (contents of the id attribute), or "" if no path was found + */ +Glib::ustring ClipboardManagerImpl::getPathObjectId() +{ + SPDocument *tempdoc = _retrieveClipboard(); // any target will do here + if ( tempdoc == NULL ) { + _userWarn(SP_ACTIVE_DESKTOP, _("Nothing on the clipboard.")); + return ""; + } + Inkscape::XML::Node + *root = sp_document_repr_root(tempdoc), + *path = sp_repr_lookup_name(root, "svg:path", -1); // unlimited search depth + if ( path == NULL ) { + _userWarn(SP_ACTIVE_DESKTOP, _("Clipboard does not contain a path.")); + sp_document_unref(tempdoc); + return ""; + } + gchar const *svgd = path->attribute("id"); + return svgd; +} + + +/** * @brief Iterate over a list of items and copy them to the clipboard. */ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) |
