summaryrefslogtreecommitdiffstats
path: root/src/selection-chemistry.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-18 18:07:14 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-18 18:07:14 +0000
commite77956b4dbd029c9f6949f81fe083606f995c624 (patch)
tree74adda4df8986d65f70efb341c6235277361fd35 /src/selection-chemistry.cpp
parentupdated code to work on 0.92 code (diff)
parentLatvian translation update (diff)
downloadinkscape-e77956b4dbd029c9f6949f81fe083606f995c624.tar.gz
inkscape-e77956b4dbd029c9f6949f81fe083606f995c624.zip
update to trunk
(bzr r12588.1.39)
Diffstat (limited to 'src/selection-chemistry.cpp')
-rw-r--r--src/selection-chemistry.cpp346
1 files changed, 166 insertions, 180 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index ffa149cee..5e8fd5e07 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -38,7 +38,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "layer-model.h"
#include "selection.h"
#include "ui/tools-switch.h"
-#include "desktop-handles.h"
+
#include "message-stack.h"
#include "sp-item-transform.h"
#include "sp-marker.h"
@@ -99,7 +99,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "display/curve.h"
#include "display/canvas-bpath.h"
#include "display/cairo-utils.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "path-chemistry.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/multi-path-manipulator.h"
@@ -177,8 +177,8 @@ void SelectionHelper::selectNone(SPDesktop *dt)
if (nt && !nt->_selected_nodes->empty()) {
nt->_selected_nodes->clear();
- } else if (!sp_desktop_selection(dt)->isEmpty()) {
- sp_desktop_selection(dt)->clear();
+ } else if (!dt->getSelection()->isEmpty()) {
+ dt->getSelection()->clear();
} else {
// If nothing selected switch to selection tool
tools_switch(dt, TOOLS_SELECT);
@@ -202,7 +202,7 @@ void SelectionHelper::selectSameStrokeColor(SPDesktop *dt)
void SelectionHelper::selectSameStrokeStyle(SPDesktop *dt)
{
- sp_select_same_stroke_style(dt);
+ sp_select_same_fill_stroke_style(dt, false, false, true);
}
void SelectionHelper::selectSameObjectType(SPDesktop *dt)
@@ -277,7 +277,7 @@ void SelectionHelper::fixSelection(SPDesktop *dt)
if(!dt)
return;
- Inkscape::Selection *selection = sp_desktop_selection(dt);
+ Inkscape::Selection *selection = dt->getSelection();
GSList *items = NULL;
@@ -402,12 +402,12 @@ void sp_selection_delete(SPDesktop *desktop)
if (tools_isactive(desktop, TOOLS_TEXT))
if (Inkscape::UI::Tools::sp_text_delete_selection(desktop->event_context)) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Delete text"));
return;
}
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -429,7 +429,7 @@ void sp_selection_delete(SPDesktop *desktop)
*/
tools_switch( desktop, tools_active( desktop ) );
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_DELETE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_DELETE,
_("Delete"));
}
@@ -454,7 +454,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
SPDocument *doc = desktop->doc();
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -521,11 +521,9 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
if (!strcmp(orig->getId(), old_ids[j])) {
// we have both orig and clone in selection, relink
// std::cout << id << " old, its ori: " << orig->getId() << "; will relink:" << new_ids[i] << " to " << new_ids[j] << "\n";
- gchar *newref = g_strdup_printf("#%s", new_ids[j]);
SPObject *new_clone = doc->getObjectById(new_ids[i]);
- new_clone->getRepr()->setAttribute("xlink:href", newref);
+ new_clone->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]);
new_clone->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- g_free(newref);
}
}
} else {
@@ -534,9 +532,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
for (guint j = 0; j < old_ids.size(); j++) {
gchar *source_href = offset->sourceHref;
if (source_href && source_href[0]=='#' && !strcmp(source_href+1, old_ids[j])) {
- gchar *newref = g_strdup_printf("#%s", new_ids[j]);
- doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", newref);
- g_free(newref);
+ doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]);
}
}
}
@@ -546,7 +542,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
if ( !suppressDone ) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_DUPLICATE,
_("Duplicate"));
}
@@ -613,7 +609,7 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i
if (!dt)
return;
- Inkscape::Selection *selection = sp_desktop_selection(dt);
+ Inkscape::Selection *selection = dt->getSelection();
g_return_if_fail(dynamic_cast<SPGroup *>(dt->currentLayer()));
@@ -1146,7 +1142,7 @@ sp_undo(SPDesktop *desktop, SPDocument *)
// No re/undo while dragging, too dangerous.
if(desktop->getCanvas()->is_dragging) return;
- if (!DocumentUndo::undo(sp_desktop_document(desktop))) {
+ if (!DocumentUndo::undo(desktop->getDocument())) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo."));
}
}
@@ -1157,7 +1153,7 @@ sp_redo(SPDesktop *desktop, SPDocument *)
// No re/undo while dragging, too dangerous.
if(desktop->getCanvas()->is_dragging) return;
- if (!DocumentUndo::redo(sp_desktop_document(desktop))) {
+ if (!DocumentUndo::redo(desktop->getDocument())) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo."));
}
}
@@ -1230,7 +1226,7 @@ void sp_selection_paste(SPDesktop *desktop, bool in_place)
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
if (cm->paste(desktop, in_place)) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE, _("Paste"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE, _("Paste"));
}
}
@@ -1238,7 +1234,7 @@ void sp_selection_paste_style(SPDesktop *desktop)
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
if (cm->pasteStyle(desktop)) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_STYLE, _("Paste style"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_STYLE, _("Paste style"));
}
}
@@ -1247,7 +1243,7 @@ void sp_selection_paste_livepatheffect(SPDesktop *desktop)
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
if (cm->pastePathEffect(desktop)) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT,
_("Paste live path effect"));
}
}
@@ -1266,7 +1262,7 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop)
{
if (desktop == NULL) return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -1281,7 +1277,7 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop)
}
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT,
_("Remove live path effect"));
}
@@ -1289,7 +1285,7 @@ void sp_selection_remove_filter(SPDesktop *desktop)
{
if (desktop == NULL) return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -1302,7 +1298,7 @@ void sp_selection_remove_filter(SPDesktop *desktop)
sp_desktop_set_style(desktop, css);
sp_repr_css_attr_unref(css);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_FILTER,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_REMOVE_FILTER,
_("Remove filter"));
}
@@ -1311,7 +1307,7 @@ void sp_selection_paste_size(SPDesktop *desktop, bool apply_x, bool apply_y)
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
if (cm->pasteSize(desktop, false, apply_x, apply_y)) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_SIZE,
_("Paste size"));
}
}
@@ -1320,14 +1316,33 @@ void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool a
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
if (cm->pasteSize(desktop, true, apply_x, apply_y)) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY,
_("Paste size separately"));
}
}
+/**
+ * Ensures that the clones of objects are not modified when moving objects between layers.
+ * Calls the same function as ungroup
+ */
+void sp_selection_change_layer_maintain_clones(GSList const *items,SPObject *where)
+{
+ for (const GSList *i = items; i != NULL; i = i->next) {
+ SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(i->data));
+ if (item) {
+ SPItem *oldparent = dynamic_cast<SPItem *>(item->parent);
+ SPItem *newparent = dynamic_cast<SPItem *>(where);
+ sp_item_group_ungroup_handle_clones(item,
+ (oldparent->i2doc_affine())
+ *((newparent->i2doc_affine()).inverse()));
+ }
+ }
+}
+
+
void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone)
{
- Inkscape::Selection *selection = sp_desktop_selection(dt);
+ Inkscape::Selection *selection = dt->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -1340,15 +1355,16 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone)
bool no_more = false; // Set to true, if no more layers above
SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer());
if (next) {
+ sp_selection_change_layer_maintain_clones(items,next);
GSList *temp_clip = NULL;
sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc());
sp_selection_delete_impl(items, false, false);
next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
GSList *copied;
if (next) {
- copied = sp_selection_paste_impl(sp_desktop_document(dt), next, &temp_clip);
+ copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip);
} else {
- copied = sp_selection_paste_impl(sp_desktop_document(dt), dt->currentLayer(), &temp_clip);
+ copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip);
no_more = true;
}
selection->setReprList((GSList const *) copied);
@@ -1356,7 +1372,7 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone)
if (temp_clip) g_slist_free(temp_clip);
if (next) dt->setCurrentLayer(next);
if ( !suppressDone ) {
- DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_NEXT,
+ DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT,
_("Raise to next layer"));
}
} else {
@@ -1372,7 +1388,7 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone)
void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
{
- Inkscape::Selection *selection = sp_desktop_selection(dt);
+ Inkscape::Selection *selection = dt->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -1385,15 +1401,16 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
bool no_more = false; // Set to true, if no more layers below
SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer());
if (next) {
+ sp_selection_change_layer_maintain_clones(items,next);
GSList *temp_clip = NULL;
sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
sp_selection_delete_impl(items, false, false);
next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
GSList *copied;
if (next) {
- copied = sp_selection_paste_impl(sp_desktop_document(dt), next, &temp_clip);
+ copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip);
} else {
- copied = sp_selection_paste_impl(sp_desktop_document(dt), dt->currentLayer(), &temp_clip);
+ copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip);
no_more = true;
}
selection->setReprList((GSList const *) copied);
@@ -1401,7 +1418,7 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
if (temp_clip) g_slist_free(temp_clip);
if (next) dt->setCurrentLayer(next);
if ( !suppressDone ) {
- DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_PREV,
+ DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV,
_("Lower to previous layer"));
}
} else {
@@ -1417,7 +1434,7 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone)
{
- Inkscape::Selection *selection = sp_desktop_selection(dt);
+ Inkscape::Selection *selection = dt->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -1428,16 +1445,17 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone)
GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));
if (moveto) {
+ sp_selection_change_layer_maintain_clones(items,moveto);
GSList *temp_clip = NULL;
sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
sp_selection_delete_impl(items, false, false);
- GSList *copied = sp_selection_paste_impl(sp_desktop_document(dt), moveto, &temp_clip);
+ GSList *copied = sp_selection_paste_impl(dt->getDocument(), moveto, &temp_clip);
selection->setReprList((GSList const *) copied);
g_slist_free(copied);
if (temp_clip) g_slist_free(temp_clip);
if (moveto) dt->setCurrentLayer(moveto);
if ( !suppressDone ) {
- DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO,
+ DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO,
_("Move selection to layer"));
}
}
@@ -1690,7 +1708,7 @@ void sp_selection_remove_transform(SPDesktop *desktop)
if (desktop == NULL)
return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
GSList const *l = const_cast<GSList *>(selection->reprList());
while (l != NULL) {
@@ -1698,7 +1716,7 @@ void sp_selection_remove_transform(SPDesktop *desktop)
l = l->next;
}
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_FLATTEN,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN,
_("Remove transform"));
}
@@ -1788,7 +1806,7 @@ void sp_selection_move_relative(Inkscape::Selection *selection, double dx, doubl
*/
void sp_selection_rotate_90(SPDesktop *desktop, bool ccw)
{
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty())
return;
@@ -1804,7 +1822,7 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw)
}
}
- DocumentUndo::done(sp_desktop_document(desktop),
+ DocumentUndo::done(desktop->getDocument(),
ccw ? SP_VERB_OBJECT_ROTATE_90_CCW : SP_VERB_OBJECT_ROTATE_90_CW,
ccw ? _("Rotate 90\xc2\xb0 CCW") : _("Rotate 90\xc2\xb0 CW"));
}
@@ -1822,7 +1840,7 @@ sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees)
sp_selection_rotate_relative(selection, *center, angle_degrees);
- DocumentUndo::maybeDone(sp_desktop_document(selection->desktop()),
+ DocumentUndo::maybeDone(selection->desktop()->getDocument(),
( ( angle_degrees > 0 )
? "selector:rotate:ccw"
: "selector:rotate:cw" ),
@@ -1856,21 +1874,22 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea
GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL);
GSList *all_matches = NULL;
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) {
SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(sel_iter->data));
GSList *matches = all_list;
- if (fill) {
- matches = sp_get_same_fill_or_stroke_color(sel, matches, SP_FILL_COLOR);
+ if (fill && stroke && style) {
+ matches = sp_get_same_style(sel, matches);
+ }
+ else if (fill) {
+ matches = sp_get_same_style(sel, matches, SP_FILL_COLOR);
}
- if (stroke) {
- matches = sp_get_same_fill_or_stroke_color(sel, matches, SP_STROKE_COLOR);
+ else if (stroke) {
+ matches = sp_get_same_style(sel, matches, SP_STROKE_COLOR);
}
- if (style) {
- matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_WIDTH);
- matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_DASHES);
- matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_MARKERS);
+ else if (style) {
+ matches = sp_get_same_style(sel, matches,SP_STROKE_STYLE_ALL);
}
all_matches = g_slist_concat (all_matches, matches);
}
@@ -1909,7 +1928,7 @@ void sp_select_same_object_type(SPDesktop *desktop)
GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL);
GSList *matches = all_list;
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) {
SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(sel_iter->data));
@@ -1931,49 +1950,7 @@ void sp_select_same_object_type(SPDesktop *desktop)
}
}
-/*
- * Selects all the visible items with the same stroke style as the items in the current selection
- *
- * Params:
- * desktop - set the selection on this desktop
- */
-void sp_select_same_stroke_style(SPDesktop *desktop)
-{
- if (!desktop) {
- return;
- }
-
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
- bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
- bool ingroups = TRUE;
-
- GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL);
- GSList *matches = all_list;
-
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
- for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) {
- SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(sel_iter->data));
- if (sel) {
- matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_WIDTH);
- matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_DASHES);
- matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_MARKERS);
- } else {
- g_assert_not_reached();
- }
- }
-
- selection->clear();
- selection->setList(matches);
-
- if (matches) {
- g_slist_free(matches);
- }
- if (all_list) {
- g_slist_free(all_list);
- }
-}
/*
* Find all items in src list that have the same fill or stroke style as sel
@@ -2083,7 +2060,7 @@ GSList *sp_get_same_object_type(SPItem *sel, GSList *src)
for (GSList *i = src; i != NULL; i = i->next) {
SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
- if (item && item_type_match(sel, item)) {
+ if (item && item_type_match(sel, item) && !item->cloned) {
matches = g_slist_prepend (matches, item);
}
}
@@ -2091,19 +2068,24 @@ GSList *sp_get_same_object_type(SPItem *sel, GSList *src)
return matches;
}
+GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrokeStyleType type);
+
/*
* Find all items in src list that have the same stroke style as sel by type
* Return the list of matching items
*/
-GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type)
+GSList *sp_get_same_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type)
{
GSList *matches = NULL;
- gboolean match = false;
+ bool match = false;
SPStyle *sel_style = sel->style;
- if (type == SP_FILL_COLOR || type == SP_STROKE_COLOR) {
- return sp_get_same_fill_or_stroke_color(sel, src, type);
+ if (type == SP_FILL_COLOR || type == SP_STYLE_ALL) {
+ src = sp_get_same_fill_or_stroke_color(sel, src, SP_FILL_COLOR);
+ }
+ if (type == SP_STROKE_COLOR || type == SP_STYLE_ALL) {
+ src = sp_get_same_fill_or_stroke_color(sel, src, SP_STROKE_COLOR);
}
/*
@@ -2112,39 +2094,42 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy
*/
GSList *objects = NULL;
SPStyle *sel_style_for_width = NULL;
- if (type == SP_STROKE_STYLE_WIDTH) {
+ if (type == SP_STROKE_STYLE_WIDTH || type == SP_STROKE_STYLE_ALL || type==SP_STYLE_ALL ) {
objects = g_slist_prepend(objects, sel);
- sel_style_for_width = sp_style_new (SP_ACTIVE_DOCUMENT);
+ sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT);
objects_query_strokewidth (objects, sel_style_for_width);
}
-
+ bool match_g;
for (GSList *i = src; i != NULL; i = i->next) {
SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
if (iter) {
+ match_g=true;
SPStyle *iter_style = iter->style;
- match = false;
+ match = true;
- if (type == SP_STROKE_STYLE_WIDTH) {
+ if (type == SP_STROKE_STYLE_WIDTH|| type == SP_STROKE_STYLE_ALL|| type==SP_STYLE_ALL) {
match = (sel_style->stroke_width.set == iter_style->stroke_width.set);
if (sel_style->stroke_width.set && iter_style->stroke_width.set) {
GSList *objects = NULL;
objects = g_slist_prepend(objects, iter);
- SPStyle *iter_style_for_width = sp_style_new (SP_ACTIVE_DOCUMENT);
- objects_query_strokewidth (objects, iter_style_for_width);
+ SPStyle tmp_style(SP_ACTIVE_DOCUMENT);
+ objects_query_strokewidth (objects, &tmp_style);
if (sel_style_for_width) {
- match = (sel_style_for_width->stroke_width.computed == iter_style_for_width->stroke_width.computed);
+ match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed);
}
g_slist_free(objects);
}
}
- else if (type == SP_STROKE_STYLE_DASHES ) {
+ match_g = match_g && match;
+ if (type == SP_STROKE_STYLE_DASHES|| type == SP_STROKE_STYLE_ALL || type==SP_STYLE_ALL) {
match = (sel_style->stroke_dasharray.set == iter_style->stroke_dasharray.set);
if (sel_style->stroke_dasharray.set && iter_style->stroke_dasharray.set) {
match = (sel_style->stroke_dasharray.values == iter_style->stroke_dasharray.values);
}
}
- else if (type == SP_STROKE_STYLE_MARKERS) {
+ match_g = match_g && match;
+ if (type == SP_STROKE_STYLE_MARKERS|| type == SP_STROKE_STYLE_ALL|| type==SP_STYLE_ALL) {
match = true;
int len = sizeof(sel_style->marker)/sizeof(SPIString);
for (int i = 0; i < len; i++) {
@@ -2156,8 +2141,9 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy
}
}
}
-
- if (match) {
+ match_g = match_g && match;
+ if (match_g) {
+ while (iter->cloned) iter=dynamic_cast<SPItem *>(iter->parent);
matches = g_slist_prepend(matches, iter);
}
} else {
@@ -2165,6 +2151,7 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy
}
}
+ if( sel_style_for_width != NULL ) delete sel_style_for_width;
g_slist_free(objects);
return matches;
@@ -2209,7 +2196,7 @@ sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle)
sp_selection_rotate_relative(selection, *center, zangle);
- DocumentUndo::maybeDone(sp_desktop_document(selection->desktop()),
+ DocumentUndo::maybeDone(selection->desktop()->getDocument(),
( (angle > 0)
? "selector:rotate:ccw"
: "selector:rotate:cw" ),
@@ -2239,7 +2226,7 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow)
double const times = 1.0 + grow / max_len;
sp_selection_scale_relative(selection, center, Geom::Scale(times, times));
- DocumentUndo::maybeDone(sp_desktop_document(selection->desktop()),
+ DocumentUndo::maybeDone(selection->desktop()->getDocument(),
( (grow > 0)
? "selector:scale:larger"
: "selector:scale:smaller" ),
@@ -2268,7 +2255,7 @@ sp_selection_scale_times(Inkscape::Selection *selection, gdouble times)
Geom::Point const center(sel_bbox->midpoint());
sp_selection_scale_relative(selection, center, Geom::Scale(times, times));
- DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_CONTEXT_SELECT,
+ DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_CONTEXT_SELECT,
_("Scale by whole factor"));
}
@@ -2380,7 +2367,7 @@ void
sp_selection_item_next(SPDesktop *desktop)
{
g_return_if_fail(desktop != NULL);
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
@@ -2407,10 +2394,10 @@ sp_selection_item_next(SPDesktop *desktop)
void
sp_selection_item_prev(SPDesktop *desktop)
{
- SPDocument *document = sp_desktop_document(desktop);
+ SPDocument *document = desktop->getDocument();
g_return_if_fail(document != NULL);
g_return_if_fail(desktop != NULL);
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
@@ -2438,7 +2425,7 @@ void sp_selection_next_patheffect_param(SPDesktop * dt)
{
if (!dt) return;
- Inkscape::Selection *selection = sp_desktop_selection(dt);
+ Inkscape::Selection *selection = dt->getSelection();
if ( selection && !selection->isEmpty() ) {
SPItem *item = selection->singleItem();
if ( SPLPEItem *lpeitem = dynamic_cast<SPLPEItem*>(item) ) {
@@ -2471,7 +2458,7 @@ void sp_selection_edit_clip_or_mask(SPDesktop * /*dt*/, bool /*clip*/)
/*if (!dt) return;
using namespace Inkscape::UI;
- Inkscape::Selection *selection = sp_desktop_selection(dt);
+ Inkscape::Selection *selection = dt->getSelection();
if (!selection || selection->isEmpty()) return;
GSList const *items = selection->itemList();
@@ -2611,7 +2598,7 @@ void sp_selection_clone(SPDesktop *desktop)
return;
}
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
@@ -2652,7 +2639,7 @@ void sp_selection_clone(SPDesktop *desktop)
Inkscape::GC::release(clone);
}
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_CLONE,
C_("Action", "Clone"));
selection->setReprList(newsel);
@@ -2666,7 +2653,7 @@ sp_selection_relink(SPDesktop *desktop)
if (!desktop)
return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>clones</b> to relink."));
@@ -2701,7 +2688,7 @@ sp_selection_relink(SPDesktop *desktop)
if (!relinked) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to relink</b> in the selection."));
} else {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNLINK_CLONE,
_("Relink clone"));
}
}
@@ -2713,7 +2700,7 @@ sp_selection_unlink(SPDesktop *desktop)
if (!desktop)
return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>clones</b> to unlink."));
@@ -2775,7 +2762,7 @@ sp_selection_unlink(SPDesktop *desktop)
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection."));
}
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNLINK_CLONE,
_("Unlink clone"));
}
@@ -2785,7 +2772,7 @@ sp_select_clone_original(SPDesktop *desktop)
if (desktop == NULL)
return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
SPItem *item = selection->singleItem();
@@ -2860,7 +2847,7 @@ sp_select_clone_original(SPDesktop *desktop)
curve->moveto(a->midpoint());
curve->lineto(b->midpoint());
- SPCanvasItem * canvasitem = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), curve);
+ SPCanvasItem * canvasitem = sp_canvas_bpath_new(desktop->getTempGroup(), curve);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvasitem), 0x0000ddff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT, 5, 3);
sp_canvas_item_show(canvasitem);
curve->unref();
@@ -2884,17 +2871,19 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop)
if (desktop == NULL) {
return;
}
-
+
+ Inkscape::Selection *selection = desktop->getSelection();
+
Inkscape::SVGOStringStream os;
SPObject * firstItem = NULL;
- for (const GSList * item = desktop->selection->itemList(); item != NULL; item = item->next) {
+ for (const GSList * item = selection->itemList(); item != NULL; item = item->next) {
if (SP_IS_SHAPE(item->data) || SP_IS_TEXT(item->data)) {
if (firstItem) {
os << "|";
} else {
firstItem = SP_ITEM(item->data);
}
- os << "#" << SP_ITEM(item->data)->getId() << ",0";
+ os << '#' << SP_ITEM(item->data)->getId() << ",0";
}
}
if (firstItem) {
@@ -2905,10 +2894,10 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop)
Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect");
{
lpe_repr->setAttribute("effect", "fill_between_many");
- lpe_repr->setAttribute("linkedpaths", os.str().c_str());
+ lpe_repr->setAttribute("linkedpaths", os.str());
desktop->doc()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to <defs> and assigns the 'id' attribute
}
- const gchar * lpe_id = lpe_repr->attribute("id");
+ std::string lpe_id_href = std::string("#") + lpe_repr->attribute("id");
Inkscape::GC::release(lpe_repr);
// create the new path
@@ -2920,13 +2909,15 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop)
SPObject *clone_obj = desktop->doc()->getObjectById(clone->attribute("id"));
SPLPEItem *clone_lpeitem = dynamic_cast<SPLPEItem *>(clone_obj);
if (clone_lpeitem) {
- gchar *href = g_strdup_printf("#%s", lpe_id);
- clone_lpeitem->addPathEffect(href, false);
- g_free(href);
+ clone_lpeitem->addPathEffect(lpe_id_href, false);
}
}
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, _("Fill between many"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, _("Fill between many"));
+ // select the new object:
+ selection->set(clone);
+
+ Inkscape::GC::release(clone);
} else {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to fill."));
}
@@ -2939,10 +2930,10 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
return;
}
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -3040,8 +3031,8 @@ void sp_selection_to_guides(SPDesktop *desktop)
if (desktop == NULL)
return;
- SPDocument *doc = sp_desktop_document(desktop);
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ SPDocument *doc = desktop->getDocument();
+ Inkscape::Selection *selection = desktop->getSelection();
// we need to copy the list because it gets reset when objects are deleted
GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));
@@ -3098,10 +3089,10 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
return;
}
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// Check if something is selected.
if (selection->isEmpty()) {
@@ -3172,9 +3163,9 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
the_group->getAttribute("inkscape:transform-center-y"));
the_group->setAttribute("style", NULL);
- std::string id = symbol_repr->attribute("id");
+ Glib::ustring id = symbol_repr->attribute("id");
id += "_transform";
- the_group->setAttribute("id", id.c_str());
+ the_group->setAttribute("id", id);
}
@@ -3192,10 +3183,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
// Create <use> pointing to new symbol (to replace the moved objects).
Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
- const gchar *symbol_id = symbol_repr->attribute("id");
- gchar *href_str = g_strdup_printf("#%s", symbol_id);
- clone->setAttribute("xlink:href", href_str, false);
- g_free(href_str);
+ clone->setAttribute("xlink:href", Glib::ustring("#")+symbol_repr->attribute("id"), false);
the_parent_repr->appendChild(clone);
@@ -3223,10 +3211,10 @@ void sp_selection_unsymbol(SPDesktop *desktop)
return;
}
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// Check if something is selected.
if (selection->isEmpty()) {
@@ -3286,11 +3274,11 @@ void sp_selection_unsymbol(SPDesktop *desktop)
// Need to delete <symbol>; all <use> elements that referenced <symbol> should
// auto-magically reference <g> (if <symbol> deleted after setting <g> 'id').
Glib::ustring id = symbol->getAttribute("id");
- group->setAttribute("id",id.c_str());
+ group->setAttribute("id", id);
symbol->deleteObject(true);
// Change selection to new <g> element.
- SPItem *group_item = static_cast<SPItem *>(sp_desktop_document(desktop)->getObjectByRepr(group));
+ SPItem *group_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(group));
selection->set(group_item);
// Clean up
@@ -3308,10 +3296,10 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
return;
}
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -3403,7 +3391,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
// restore parent and position
parent->getRepr()->appendChild(rect);
rect->setPosition(pos > 0 ? pos : 0);
- SPItem *rectangle = static_cast<SPItem *>(sp_desktop_document(desktop)->getObjectByRepr(rect));
+ SPItem *rectangle = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(rect));
Inkscape::GC::release(rect);
@@ -3423,10 +3411,10 @@ void sp_selection_untile(SPDesktop *desktop)
return;
}
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -3493,7 +3481,7 @@ void sp_selection_untile(SPDesktop *desktop)
if (!did) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No pattern fills</b> in the selection."));
} else {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNTILE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNTILE,
_("Pattern to objects"));
selection->setList(new_select);
}
@@ -3578,10 +3566,10 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
return;
}
- SPDocument *document = sp_desktop_document(desktop);
+ SPDocument *document = desktop->getDocument();
Inkscape::XML::Document *xml_doc = document->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -3628,7 +3616,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
directory = g_path_get_dirname( document->getURI() );
}
if (directory == NULL) {
- directory = homedir_path(NULL);
+ directory = INKSCAPE.homedir_path(NULL);
}
gchar *filepath = g_build_filename(directory, basename, NULL);
g_free(directory);
@@ -3796,10 +3784,10 @@ void sp_selection_set_clipgroup(SPDesktop *desktop)
if (desktop == NULL) {
return;
}
- SPDocument* doc = sp_desktop_document(desktop);
+ SPDocument* doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
return;
@@ -3912,10 +3900,10 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
return;
}
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
bool is_empty = selection->isEmpty();
@@ -4084,9 +4072,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
Inkscape::GC::release(group);
}
- gchar *value_str = g_strdup_printf("url(#%s)", mask_id);
- apply_mask_to->setAttribute(attributeName, value_str);
- g_free(value_str);
+ apply_mask_to->setAttribute(attributeName, Glib::ustring("url(#") + mask_id + ')');
}
@@ -4117,9 +4103,9 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
return;
}
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
@@ -4210,7 +4196,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
parent->appendChild(repr);
repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0);
- SPItem *mask_item = static_cast<SPItem *>(sp_desktop_document(desktop)->getObjectByRepr(repr));
+ SPItem *mask_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(repr));
items_to_select = g_slist_prepend(items_to_select, mask_item);
// transform mask, so it is moved the same spot where mask was applied
@@ -4258,7 +4244,7 @@ bool
fit_canvas_to_selection(SPDesktop *desktop, bool with_margins)
{
g_return_val_if_fail(desktop != NULL, false);
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
g_return_val_if_fail(doc != NULL, false);
g_return_val_if_fail(desktop->selection != NULL, false);
@@ -4283,7 +4269,7 @@ void
verb_fit_canvas_to_selection(SPDesktop *const desktop)
{
if (fit_canvas_to_selection(desktop)) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_SELECTION,
_("Fit Page to Selection"));
}
}
@@ -4311,8 +4297,8 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins)
void
verb_fit_canvas_to_drawing(SPDesktop *desktop)
{
- if (fit_canvas_to_drawing(sp_desktop_document(desktop))) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_DRAWING,
+ if (fit_canvas_to_drawing(desktop->getDocument())) {
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_DRAWING,
_("Fit Page to Drawing"));
}
}
@@ -4324,7 +4310,7 @@ verb_fit_canvas_to_drawing(SPDesktop *desktop)
*/
void fit_canvas_to_selection_or_drawing(SPDesktop *desktop) {
g_return_if_fail(desktop != NULL);
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
g_return_if_fail(doc != NULL);
g_return_if_fail(desktop->selection != NULL);
@@ -4333,7 +4319,7 @@ void fit_canvas_to_selection_or_drawing(SPDesktop *desktop) {
? fit_canvas_to_drawing(doc, true)
: fit_canvas_to_selection(desktop, true) );
if (changed) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING,
_("Fit Page to Selection or Drawing"));
}
};