From a20cd65b75663cfc99e1afd16769be0256f4067f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 18 Mar 2010 23:21:16 -0700 Subject: [PATCH] Cleanup of SP_ACTIVE_DESKTOP to prepare clipboard code for reuse. --- src/connector-context.cpp | 3 ++ src/connector-context.h | 12 ++--- src/live_effects/parameter/path.cpp | 4 +- src/selection-chemistry.cpp | 79 ++++++++++++++------------- src/selection-chemistry.h | 2 +- src/ui/clipboard.cpp | 82 +++++++++++++---------------- src/ui/clipboard.h | 20 +++---- src/verbs.cpp | 2 +- 8 files changed, 101 insertions(+), 103 deletions(-) diff --git a/src/connector-context.cpp b/src/connector-context.cpp index ba6c067c0..b0e192190 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -233,6 +233,9 @@ static void shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *nam gpointer data); +static char* cc_knot_tips[] = { _("Connection point: click or drag to create a new connector"), + _("Connection point: click to select, drag to move") }; + /*static Geom::Point connector_drag_origin_w(0, 0); static bool connector_within_tolerance = false;*/ static SPEventContextClass *parent_class; diff --git a/src/connector-context.h b/src/connector-context.h index bc16609de..bd3805e96 100644 --- a/src/connector-context.h +++ b/src/connector-context.h @@ -47,8 +47,6 @@ enum { SP_CONNECTOR_CONTEXT_DRAWING_MODE, SP_CONNECTOR_CONTEXT_EDITING_MODE }; -static char* cc_knot_tips[] = { _("Connection point: click or drag to create a new connector"), - _("Connection point: click to select, drag to move") }; typedef std::map ConnectionPointMap; @@ -70,16 +68,16 @@ struct SPConnectorContext : public SPEventContext { SPCanvasItem *red_bpath; SPCurve *red_curve; guint32 red_color; - + // Green curve SPCurve *green_curve; - + // The new connector SPItem *newconn; Avoid::ConnRef *newConnRef; gdouble curvature; bool isOrthogonal; - + // The active shape SPItem *active_shape; Inkscape::XML::Node *active_shape_repr; @@ -90,7 +88,7 @@ struct SPConnectorContext : public SPEventContext { Inkscape::XML::Node *active_conn_repr; sigc::connection sel_changed_connection; - + // The activehandle SPKnot *active_handle; @@ -99,7 +97,7 @@ struct SPConnectorContext : public SPEventContext { SPItem *clickeditem; SPKnot *clickedhandle; - + ConnectionPointMap connpthandles; SPKnot *endpt_handle[2]; guint endpt_handler_id[2]; diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 94540a255..d8d5b0a7c 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -412,7 +412,7 @@ void PathParam::on_paste_button_click() { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - Glib::ustring svgd = cm->getPathParameter(); + Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP); paste_param_path(svgd.data()); sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Paste path parameter")); @@ -429,7 +429,7 @@ void PathParam::on_link_button_click() { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - Glib::ustring pathid = cm->getShapeOrTextObjectId(); + Glib::ustring pathid = cm->getShapeOrTextObjectId(SP_ACTIVE_DESKTOP); if (pathid == "") { return; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 5d6394316..17875075e 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -559,13 +559,13 @@ void sp_edit_invert_in_all_layers(SPDesktop *desktop) void sp_selection_group_impl(GSList const *reprs_to_group, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { GSList *p = g_slist_copy((GSList *) reprs_to_group); - + p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position); - + // Remember the position and parent of the topmost object. gint topmost = ((Inkscape::XML::Node *) g_slist_last(p)->data)->position(); Inkscape::XML::Node *topmost_parent = ((Inkscape::XML::Node *) g_slist_last(p)->data)->parent(); - + while (p) { Inkscape::XML::Node *current = (Inkscape::XML::Node *) p->data; @@ -639,10 +639,10 @@ void sp_selection_group(SPDesktop *desktop) GSList const *l = (GSList *) selection->reprList(); - + Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - - sp_selection_group_impl(l, group, xml_doc, doc); + + sp_selection_group_impl(l, group, xml_doc, doc); sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_GROUP, _("Group")); @@ -1009,7 +1009,7 @@ sp_redo(SPDesktop *desktop, SPDocument *) void sp_selection_cut(SPDesktop *desktop) { - sp_selection_copy(); + sp_selection_copy(desktop); sp_selection_delete(desktop); } @@ -1054,33 +1054,36 @@ take_style_from_item(SPItem *item) } -void sp_selection_copy() +void sp_selection_copy(SPDesktop *desktop) { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - cm->copy(); + cm->copy(desktop); } void sp_selection_paste(SPDesktop *desktop, bool in_place) { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - if (cm->paste(in_place)) + if (cm->paste(desktop, in_place)) { sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE, _("Paste")); + } } void sp_selection_paste_style(SPDesktop *desktop) { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - if (cm->pasteStyle()) + if (cm->pasteStyle(desktop)) { sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_STYLE, _("Paste style")); + } } void sp_selection_paste_livepatheffect(SPDesktop *desktop) { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - if (cm->pastePathEffect()) + if (cm->pastePathEffect(desktop)) { sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT, _("Paste live path effect")); + } } @@ -1140,17 +1143,19 @@ void sp_selection_remove_filter(SPDesktop *desktop) void sp_selection_paste_size(SPDesktop *desktop, bool apply_x, bool apply_y) { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - if (cm->pasteSize(false, apply_x, apply_y)) + if (cm->pasteSize(desktop, false, apply_x, apply_y)) { sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE, _("Paste size")); + } } void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool apply_y) { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - if (cm->pasteSize(true, apply_x, apply_y)) + if (cm->pasteSize(desktop, true, apply_x, apply_y)) { sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, _("Paste size separately")); + } } void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) @@ -2907,34 +2912,34 @@ sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_la g_slist_free(items); items = NULL; - + if (apply_to_items && grouping == PREFS_MASKOBJECT_GROUPING_ALL) { // group all those objects into one group // and apply mask to that Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - + // make a note we should ungroup this when unsetting mask group->setAttribute("inkscape:groupmode", "maskhelper"); - + GSList *reprs_to_group = NULL; - + for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { reprs_to_group = g_slist_prepend(reprs_to_group, SP_OBJECT_REPR(i->data)); selection->remove(SP_OBJECT(i->data)); } reprs_to_group = g_slist_reverse(reprs_to_group); - + sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); - + g_slist_free(reprs_to_group); - + // apply clip/mask only to newly created group g_slist_free(apply_to_items); apply_to_items = NULL; apply_to_items = g_slist_prepend(apply_to_items, doc->getObjectByRepr(group)); - + selection->add(group); - + Inkscape::GC::release(group); } @@ -2964,13 +2969,13 @@ sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_la Inkscape::XML::Node *current = SP_OBJECT_REPR(i->data); // Node to apply mask to Inkscape::XML::Node *apply_mask_to = current; - + if (grouping == PREFS_MASKOBJECT_GROUPING_SEPARATE) { // enclose current node in group, and apply crop/mask on that Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); // make a note we should ungroup this when unsetting mask group->setAttribute("inkscape:groupmode", "maskhelper"); - + Inkscape::XML::Node *spnew = current->duplicate(xml_doc); gint position = current->position(); selection->remove(current); @@ -2978,17 +2983,17 @@ sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_la sp_repr_unparent(current); group->appendChild(spnew); group->setPosition(position); - + // Apply clip/mask to group instead apply_mask_to = group; - + selection->add(group); - Inkscape::GC::release(spnew); + Inkscape::GC::release(spnew); Inkscape::GC::release(group); } - + apply_mask_to->setAttribute(attributeName, g_strdup_printf("url(#%s)", mask_id)); - + } g_slist_free(mask_items); @@ -3027,9 +3032,9 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; std::map referenced_objects; - + GSList *items_to_ungroup = NULL; - + // SPObject* refers to a group containing the clipped path or mask itself, // whereas SPItem* refers to the item being clipped or masked for (GSList const *i = selection->itemList(); NULL != i; i = i->next) { @@ -3051,17 +3056,17 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { } SP_OBJECT_REPR(i->data)->setAttribute(attributeName, "none"); - + if (ungroup_masked && SP_IS_GROUP(i->data)) { // if we had previously enclosed masked object in group, // add it to list so we can ungroup it later SPGroup *item = SP_GROUP(i->data); - + // ungroup only groups we created when setting clip/mask if (item->layerMode() == SPGroup::MASK_HELPER) { items_to_ungroup = g_slist_prepend(items_to_ungroup, item); } - + } } @@ -3103,7 +3108,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { g_slist_free(items_to_move); } - + // ungroup marked groups added when setting mask for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) { selection->remove(SP_GROUP(i->data)); @@ -3112,7 +3117,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { selection->addList(children); g_slist_free(children); } - + g_slist_free(items_to_ungroup); if (apply_clip_path) diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index e06c32e72..1f975975a 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -75,7 +75,7 @@ void sp_selection_lower_to_bottom(SPDesktop *desktop); SPCSSAttr *take_style_from_item (SPItem *item); void sp_selection_cut(SPDesktop *desktop); -void sp_selection_copy(); +void sp_selection_copy(SPDesktop *desktop); void sp_selection_paste(SPDesktop *desktop, bool in_place); void sp_selection_paste_style(SPDesktop *desktop); void sp_selection_paste_livepatheffect(SPDesktop *desktop); diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index d0b555f84..dd1f981b5 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -106,14 +106,14 @@ namespace UI { */ class ClipboardManagerImpl : public ClipboardManager { public: - virtual void copy(); + virtual void copy(SPDesktop *desktop); virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *); - virtual bool paste(bool in_place); - virtual bool pasteStyle(); - virtual bool pasteSize(bool, bool, bool); - virtual bool pastePathEffect(); - virtual Glib::ustring getPathParameter(); - virtual Glib::ustring getShapeOrTextObjectId(); + virtual bool paste(SPDesktop *desktop, bool in_place); + virtual bool pasteStyle(SPDesktop *desktop); + virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y); + virtual bool pastePathEffect(SPDesktop *desktop); + virtual Glib::ustring getPathParameter(SPDesktop* desktop); + virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop); virtual const gchar *getFirstObjectID(); ClipboardManagerImpl(); @@ -127,10 +127,10 @@ private: void _copyTextPath(SPTextPath *); Inkscape::XML::Node *_copyNode(Inkscape::XML::Node *, Inkscape::XML::Document *, Inkscape::XML::Node *); - void _pasteDocument(SPDocument *, bool in_place); - void _pasteDefs(SPDocument *); - bool _pasteImage(); - bool _pasteText(); + void _pasteDocument(SPDesktop *desktop, SPDocument *clipdoc, bool in_place); + void _pasteDefs(SPDesktop *desktop, SPDocument *clipdoc); + bool _pasteImage(SPDocument *doc); + bool _pasteText(SPDesktop *desktop); SPCSSAttr *_parseColor(const Glib::ustring &); void _applyPathEffect(SPItem *, gchar const *); SPDocument *_retrieveClipboard(Glib::ustring = ""); @@ -143,7 +143,7 @@ private: void _createInternalClipboard(); void _discardInternalClipboard(); Inkscape::XML::Node *_createClipNode(); - Geom::Scale _getScale(Geom::Point const &, Geom::Point const &, Geom::Rect const &, bool, bool); + Geom::Scale _getScale(SPDesktop *desktop, Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y); Glib::ustring _getBestTarget(); void _setClipboardTargets(); void _setClipboardColor(guint32); @@ -194,9 +194,8 @@ ClipboardManagerImpl::~ClipboardManagerImpl() {} /** * @brief Copy selection contents to the clipboard */ -void ClipboardManagerImpl::copy() +void ClipboardManagerImpl::copy(SPDesktop *desktop) { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; if ( desktop == NULL ) { return; } @@ -303,10 +302,9 @@ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam * @brief Paste from the system clipboard into the active desktop * @param in_place Whether to put the contents where they were when copied */ -bool ClipboardManagerImpl::paste(bool in_place) +bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place) { // do any checking whether we really are able to paste before requesting the contents - SPDesktop *desktop = SP_ACTIVE_DESKTOP; if ( desktop == NULL ) { return false; } @@ -322,11 +320,11 @@ bool ClipboardManagerImpl::paste(bool in_place) // if there is an image on the clipboard, paste it if ( target == CLIPBOARD_GDK_PIXBUF_TARGET ) { - return _pasteImage(); + return _pasteImage(desktop->doc()); } // if there's only text, paste it into a selected text object or create a new one if ( target == CLIPBOARD_TEXT_TARGET ) { - return _pasteText(); + return _pasteText(desktop); } // otherwise, use the import extensions @@ -336,7 +334,7 @@ bool ClipboardManagerImpl::paste(bool in_place) return false; } - _pasteDocument(tempdoc, in_place); + _pasteDocument(desktop, tempdoc, in_place); sp_document_unref(tempdoc); return true; @@ -382,9 +380,8 @@ const gchar *ClipboardManagerImpl::getFirstObjectID() /** * @brief Implements the Paste Style action */ -bool ClipboardManagerImpl::pasteStyle() +bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { return false; } @@ -415,7 +412,7 @@ bool ClipboardManagerImpl::pasteStyle() bool pasted = false; if (clipnode) { - _pasteDefs(tempdoc); + _pasteDefs(desktop, tempdoc); SPCSSAttr *style = sp_repr_css_attr(clipnode, "style"); sp_desktop_set_style(desktop, style); pasted = true; @@ -435,13 +432,12 @@ bool ClipboardManagerImpl::pasteStyle() * @param apply_x Whether to scale the width of objects / selection * @param apply_y Whether to scale the height of objects / selection */ -bool ClipboardManagerImpl::pasteSize(bool separately, bool apply_x, bool apply_y) +bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y) { if (!apply_x && !apply_y) { return false; // pointless parameters } - SPDesktop *desktop = SP_ACTIVE_DESKTOP; if ( desktop == NULL ) { return false; } @@ -475,7 +471,7 @@ bool ClipboardManagerImpl::pasteSize(bool separately, bool apply_x, bool apply_y if ( !obj_size ) { continue; } - sp_item_scale_rel(item, _getScale(min, max, *obj_size, apply_x, apply_y)); + sp_item_scale_rel(item, _getScale(desktop, min, max, *obj_size, apply_x, apply_y)); } } // resize the selection as a whole @@ -483,7 +479,7 @@ bool ClipboardManagerImpl::pasteSize(bool separately, bool apply_x, bool apply_y Geom::OptRect sel_size = selection->bounds(); if ( sel_size ) { sp_selection_scale_relative(selection, sel_size->midpoint(), - _getScale(min, max, *sel_size, apply_x, apply_y)); + _getScale(desktop, min, max, *sel_size, apply_x, apply_y)); } } pasted = true; @@ -496,12 +492,11 @@ bool ClipboardManagerImpl::pasteSize(bool separately, bool apply_x, bool apply_y /** * @brief Applies a path effect from the clipboard to the selected path */ -bool ClipboardManagerImpl::pastePathEffect() +bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) { /** @todo FIXME: pastePathEffect crashes when moving the path with the applied effect, segfaulting in fork_private_if_necessary(). */ - SPDesktop *desktop = SP_ACTIVE_DESKTOP; if ( desktop == NULL ) { return false; } @@ -519,7 +514,7 @@ bool ClipboardManagerImpl::pastePathEffect() if ( clipnode ) { gchar const *effectstack = clipnode->attribute("inkscape:path-effect"); if ( effectstack ) { - _pasteDefs(tempdoc); + _pasteDefs(desktop, tempdoc); // make sure all selected items are converted to paths first (i.e. rectangles) sp_selected_to_lpeitems(desktop); for (GSList *itemptr = const_cast(selection->itemList()) ; itemptr ; itemptr = itemptr->next) { @@ -542,18 +537,18 @@ bool ClipboardManagerImpl::pastePathEffect() * @brief Get LPE path data from the clipboard * @return The retrieved path data (contents of the d attribute), or "" if no path was found */ -Glib::ustring ClipboardManagerImpl::getPathParameter() +Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop) { SPDocument *tempdoc = _retrieveClipboard(); // any target will do here if ( tempdoc == NULL ) { - _userWarn(SP_ACTIVE_DESKTOP, _("Nothing on the clipboard.")); + _userWarn(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.")); + _userWarn(desktop, _("Clipboard does not contain a path.")); sp_document_unref(tempdoc); return ""; } @@ -566,11 +561,11 @@ Glib::ustring ClipboardManagerImpl::getPathParameter() * @brief Get object id of a shape or text item from the clipboard * @return The retrieved id string (contents of the id attribute), or "" if no shape or text item was found */ -Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId() +Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) { SPDocument *tempdoc = _retrieveClipboard(); // any target will do here if ( tempdoc == NULL ) { - _userWarn(SP_ACTIVE_DESKTOP, _("Nothing on the clipboard.")); + _userWarn(desktop, _("Nothing on the clipboard.")); return ""; } Inkscape::XML::Node *root = sp_document_repr_root(tempdoc); @@ -581,7 +576,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId() } if ( repr == NULL ) { - _userWarn(SP_ACTIVE_DESKTOP, _("Clipboard does not contain a path.")); + _userWarn(desktop, _("Clipboard does not contain a path.")); sp_document_unref(tempdoc); return ""; } @@ -816,9 +811,8 @@ Inkscape::XML::Node *ClipboardManagerImpl::_copyNode(Inkscape::XML::Node *node, * @param in_place Whether to paste the selection where it was when copied * @pre @c clipdoc is not empty and items can be added to the current layer */ -void ClipboardManagerImpl::_pasteDocument(SPDocument *clipdoc, bool in_place) +void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPDocument *target_document = sp_desktop_document(desktop); Inkscape::XML::Node *root = sp_document_repr_root(clipdoc), @@ -826,7 +820,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDocument *clipdoc, bool in_place) Inkscape::XML::Document *target_xmldoc = sp_document_repr_doc(target_document); // copy definitions - _pasteDefs(clipdoc); + _pasteDefs(desktop, clipdoc); // copy objects GSList *pasted_objects = NULL; @@ -895,10 +889,9 @@ void ClipboardManagerImpl::_pasteDocument(SPDocument *clipdoc, bool in_place) * @param clipdoc The document to paste * @pre @c clipdoc != NULL and pasting into the active document is possible */ -void ClipboardManagerImpl::_pasteDefs(SPDocument *clipdoc) +void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) { // boilerplate vars copied from _pasteDocument - SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPDocument *target_document = sp_desktop_document(desktop); Inkscape::XML::Node *root = sp_document_repr_root(clipdoc), @@ -917,9 +910,8 @@ void ClipboardManagerImpl::_pasteDefs(SPDocument *clipdoc) /** * @brief Retrieve a bitmap image from the clipboard and paste it into the active document */ -bool ClipboardManagerImpl::_pasteImage() +bool ClipboardManagerImpl::_pasteImage(SPDocument *doc) { - SPDocument *doc = SP_ACTIVE_DOCUMENT; if ( doc == NULL ) { return false; } @@ -957,9 +949,8 @@ bool ClipboardManagerImpl::_pasteImage() /** * @brief Paste text into the selected text object or create a new one to hold it */ -bool ClipboardManagerImpl::_pasteText() +bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; if ( desktop == NULL ) { return false; } @@ -1300,9 +1291,8 @@ void ClipboardManagerImpl::_discardInternalClipboard() /** * @brief Get the scale to resize an item, based on the command and desktop state */ -Geom::Scale ClipboardManagerImpl::_getScale(Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y) +Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y) { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; double scale_x = 1.0; double scale_y = 1.0; diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h index 54c05ac0d..6020ecdd8 100644 --- a/src/ui/clipboard.h +++ b/src/ui/clipboard.h @@ -6,8 +6,10 @@ */ /* Authors: * Krzysztof Kosiński + * Jon A. Cruz * * Copyright (C) 2008 authors + * Copyright (C) 2010 Jon A. Cruz * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -39,16 +41,16 @@ namespace UI { class ClipboardManager { public: - virtual void copy() = 0; + virtual void copy(SPDesktop *desktop) = 0; virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *) = 0; - virtual bool paste(bool in_place = false) = 0; - virtual bool pasteStyle() = 0; - virtual bool pasteSize(bool separately, bool apply_x, bool apply_y) = 0; - virtual bool pastePathEffect() = 0; - virtual Glib::ustring getPathParameter() = 0; - virtual Glib::ustring getShapeOrTextObjectId() = 0; + virtual bool paste(SPDesktop *desktop, bool in_place = false) = 0; + virtual bool pasteStyle(SPDesktop *desktop) = 0; + virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y) = 0; + virtual bool pastePathEffect(SPDesktop *desktop) = 0; + virtual Glib::ustring getPathParameter(SPDesktop* desktop) = 0; + virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop) = 0; virtual const gchar *getFirstObjectID() = 0; - + static ClipboardManager *get(); protected: ClipboardManager(); // singleton @@ -56,7 +58,7 @@ protected: private: ClipboardManager(const ClipboardManager &); ///< no copy ClipboardManager &operator=(const ClipboardManager &); ///< no assign - + static ClipboardManager *_instance; }; diff --git a/src/verbs.cpp b/src/verbs.cpp index f9a544186..dc1116953 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -845,7 +845,7 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/) sp_selection_cut(dt); break; case SP_VERB_EDIT_COPY: - sp_selection_copy(); + sp_selection_copy(dt); break; case SP_VERB_EDIT_PASTE: sp_selection_paste(dt, false); -- 2.30.2