From 054adec9bea2b1473badbfcbb2ad0c4616269759 Mon Sep 17 00:00:00 2001 From: bulia byak Date: Sun, 15 Jun 2008 16:22:56 +0000 Subject: new command: relink clone to copied object (bzr r5948) --- src/ui/clipboard.cpp | 35 +++++++++++++++++++++++++++++++++++ src/ui/clipboard.h | 1 + 2 files changed, 36 insertions(+) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 991a69911..8907b3b0c 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -95,6 +95,7 @@ public: virtual bool pastePathEffect(); virtual Glib::ustring getPathParameter(); virtual Glib::ustring getShapeOrTextObjectId(); + virtual const gchar *getFirstObjectID(); ClipboardManagerImpl(); ~ClipboardManagerImpl(); @@ -273,6 +274,40 @@ bool ClipboardManagerImpl::paste(bool in_place) return true; } +/** + * @brief Returns the id of the first visible copied object + */ +const gchar *ClipboardManagerImpl::getFirstObjectID() +{ + SPDocument *tempdoc = _retrieveClipboard("image/x-inkscape-svg"); + if ( tempdoc == NULL ) { + return NULL; + } + + Inkscape::XML::Node + *root = sp_document_repr_root(tempdoc); + + if (!root) + return NULL; + + Inkscape::XML::Node *ch = sp_repr_children(root); + while (ch != NULL && + strcmp(ch->name(), "svg:g") && + strcmp(ch->name(), "svg:path") && + strcmp(ch->name(), "svg:use") && + strcmp(ch->name(), "svg:text") && + strcmp(ch->name(), "svg:image") && + strcmp(ch->name(), "svg:rect") + ) + ch = ch->next(); + + if (ch) { + return ch->attribute("id"); + } + + return NULL; +} + /** * @brief Implements the Paste Style action diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h index 609f2a93c..54c05ac0d 100644 --- a/src/ui/clipboard.h +++ b/src/ui/clipboard.h @@ -47,6 +47,7 @@ public: virtual bool pastePathEffect() = 0; virtual Glib::ustring getPathParameter() = 0; virtual Glib::ustring getShapeOrTextObjectId() = 0; + virtual const gchar *getFirstObjectID() = 0; static ClipboardManager *get(); protected: -- cgit v1.2.3