Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

Glib::ustring Inkscape::UI::ClipboardManagerImpl::getShapeOrTextObjectId (  ) [virtual]

Get object id of a shape or text item from the clipboard.

Returns:
The retrieved id string (contents of the id attribute), or "" if no shape or text item was found

Implements Inkscape::UI::ClipboardManager.

Definition at line 540 of file clipboard.cpp.

References _retrieveClipboard(), _userWarn(), Inkscape::XML::Node::attribute(), and sp_repr_lookup_name().

{
    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);

    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);

    if ( repr == NULL ) {
        _userWarn(SP_ACTIVE_DESKTOP, _("Clipboard does not contain a path."));
        sp_document_unref(tempdoc);
        return "";
    }
    gchar const *svgd = repr->attribute("id");
    return svgd;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index