selection-chemistry.cpp revision ba0842a4240ac9f46ab11d856227468237284186
#define __SP_SELECTION_CHEMISTRY_C__
/** @file
* @brief Miscellanous operations on selected items
*/
/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
* MenTaLguY <mental@rydia.net>
* bulia byak <buliabyak@users.sf.net>
* Andrius R. <knutux@gmail.com>
*
* Copyright (C) 1999-2006 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "selection-chemistry.h"
#include <gtkmm/clipboard.h>
#include "desktop.h"
#include "desktop-style.h"
#include "dir-util.h"
#include "selection.h"
#include "tools-switch.h"
#include "desktop-handles.h"
#include "message-stack.h"
#include "sp-item-transform.h"
#include "marker.h"
#include "sp-use.h"
#include "sp-textpath.h"
#include "sp-tspan.h"
#include "sp-tref.h"
#include "sp-flowtext.h"
#include "sp-flowregion.h"
#include "text-editing.h"
#include "text-context.h"
#include "connector-context.h"
#include "sp-path.h"
#include "sp-conn-end.h"
#include "dropper-context.h"
#include "libnr/nr-matrix-rotate-ops.h"
#include "libnr/nr-matrix-translate-ops.h"
#include "libnr/nr-scale-ops.h"
#include <libnr/nr-matrix-ops.h>
#include "xml/rebase-hrefs.h"
#include "style.h"
#include "document-private.h"
#include "sp-gradient.h"
#include "sp-gradient-reference.h"
#include "sp-linear-gradient-fns.h"
#include "sp-pattern.h"
#include "sp-radial-gradient-fns.h"
#include "sp-namedview.h"
#include "preferences.h"
#include "sp-offset.h"
#include "sp-clippath.h"
#include "sp-mask.h"
#include "file.h"
#include "helper/png-write.h"
#include "layer-fns.h"
#include "context-fns.h"
#include <map>
#include <cstring>
#include <string>
#include "sp-item.h"
#include "box3d.h"
#include "persp3d.h"
#include "unit-constants.h"
#include "xml/simple-document.h"
#include "sp-filter-reference.h"
#include "gradient-drag.h"
#include "uri-references.h"
#include "libnr/nr-convert2geom.h"
#include "display/canvas-bpath.h"
#include "inkscape-private.h"
// For clippath editing
#include "tools-switch.h"
#include "shape-editor.h"
#include "node-context.h"
#include "nodepath.h"
#include "ui/clipboard.h"
using Geom::X;
using Geom::Y;
/* The clipboard handling is in ui/clipboard.cpp now. There are some legacy functions left here,
because the layer manipulation code uses them. It should be rewritten specifically
for that purpose. */
/**
* Copies repr and its inherited css style elements, along with the accumulated transform 'full_t',
* then prepends the copy to 'clip'.
*/
void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Matrix full_t, GSList **clip, Inkscape::XML::Document* xml_doc)
{
// copy complete inherited style
// write the complete accumulated transform passed to us
// (we're dealing with unattached repr, so we write to its attr
// instead of using sp_item_set_transform)
}
{
// Sort items:
// Copy item reprs:
sp_selection_copy_one(SP_OBJECT_REPR(i->data), sp_item_i2doc_affine(SP_ITEM(i->data)), clip, xml_doc);
}
}
{
// add objects to document
// premultiply the item transform by the accumulated parent transform in the paste layer
if (!local.isIdentity()) {
if (t_str)
// (we're dealing with unattached repr, so we write to its attr instead of using sp_item_set_transform)
}
}
return copied;
}
void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true)
{
}
}
}
{
return;
}
_("Delete text"));
return;
}
// check if something is selected
return;
}
/* a tool may have set up private information in it's selection context
* that depends on desktop items. I think the only sane way to deal with
* this currently is to reset the current tool, which will reset it's
* associated selection context. For example: deleting an object
* while moving it around the canvas.
*/
_("Delete"));
}
{
if (!obj)
return;
if (SP_IS_GROUP(obj)) {
for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
}
}
}
{
return;
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate."));
return;
}
// sorting items from different parents sorts each parent's subset without possibly mixing
// them, just what we need
while (reprs) {
if (relink_clones) {
}
}
if (relink_clones) {
if (!orig) // orphaned
continue;
// we have both orig and clone in selection, relink
// std::cout << id << " old, its ori: " << SP_OBJECT_ID(orig) << "; will relink:" << new_ids[i] << " to " << new_ids[j] << "\n";
}
}
}
}
}
if ( !suppressDone ) {
_("Duplicate"));
}
}
{
if (!dt)
return;
while (items) {
}
_("Delete all"));
}
GSList *
get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, GSList const *exclude)
{
for (SPObject *child = sp_object_first_child(SP_OBJECT(from)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (SP_IS_ITEM(child) &&
)
{
}
}
}
return list;
}
{
if (!dt)
return;
PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
if (invert) {
}
if (force_all_layers)
switch (inlayer) {
case PREFS_SELECTION_LAYER: {
return;
}
}
}
}
}
break;
}
case PREFS_SELECTION_LAYER_RECURSIVE: {
break;
}
default: {
break;
}
}
if (items) {
}
}
{
sp_edit_select_all_full(desktop, false, false);
}
{
sp_edit_select_all_full(desktop, true, false);
}
{
sp_edit_select_all_full(desktop, false, true);
}
{
sp_edit_select_all_full(desktop, true, true);
}
{
return;
// Check if something is selected.
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>some objects</b> to group."));
return;
}
// Remember the position and parent of the topmost object.
while (p) {
topmost --; // only reduce count for those items deleted from topmost_parent
} else { // move it to topmost_parent first
// At this point, current may already have no item, due to its being a clone whose original is already moved away
// So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform
if (t_str)
// FIXME: when moving both clone and original from a transformed group (either by
// parent becomes embedded into original itself, and this affects its clones. Fix
// this by remembering the transform diffs we write to each item into an array and
// then, if this is clone, looking up its original in that array and pre-multiplying
// it by the inverse of that original's transform diff.
// paste into topmost_parent (temporarily)
if (copied) { // if success,
// take pasted object (now in topmost_parent)
// make a copy
// remove pasted
// put its copy into group
}
}
p = g_slist_remove(p, current);
}
// Add the new group to the topmost members' parent
// Move to the position of the topmost, reduced by the number of items deleted from topmost_parent
_("Group"));
}
{
return;
return;
}
// Get a copy of current selection.
bool ungrouped = false;
i != NULL;
i = i->next)
{
// when ungrouping cloned groups with their originals, some objects that were selected may no more exist due to unlinking
if (!SP_IS_OBJECT(group)) {
continue;
}
/* We do not allow ungrouping <svg> etc. (lauris) */
if (strcmp(SP_OBJECT_REPR(group)->name(), "svg:g") && strcmp(SP_OBJECT_REPR(group)->name(), "svg:switch")) {
// keep the non-group item in the new selection
continue;
}
/* This is not strictly required, but is nicer to rely on group ::destroy (lauris) */
ungrouped = true;
// Add ungrouped items to the new selection.
}
if (new_select) { // Set new selection.
}
if (!ungrouped) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection."));
}
_("Ungroup"));
}
/** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */
GSList *
{
bool has_groups = false;
} else {
has_groups = true;
}
}
}
if (has_groups) { // recurse if we unwrapped a group - it may have contained others
}
return out;
}
/** If items in the list have a common parent, return it, otherwise return NULL */
static SPGroup *
{
if (!items) {
return NULL;
}
/* Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor */
if (!SP_IS_GROUP(parent)) {
return NULL;
}
return NULL;
}
}
}
/** Finds out the minimum common bbox of the selected items. */
{
}
return r;
}
SPObject *
{
if (!SP_IS_GROUP(parent)) {
return NULL;
}
return i;
}
return NULL;
}
void
{
if (!desktop)
return;
if (!items) {
return;
}
if (!group) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
return;
}
/* Construct reverse-ordered list of selected children. */
// Determine the common bbox of the selected items.
// Iterate over all objects in the selection (starting from top).
if (selected) {
while (rev) {
// for each selected object, find the next sibling
// if the sibling is an item AND overlaps our selection,
if (SP_IS_ITEM(newref)) {
// AND if it's not one of our selected objects,
// move the selected object after that sibling
}
break;
}
}
}
}
} else {
}
//TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
// "Raise" means "to raise an object" in the undo history
Q_("undo_action|Raise"));
}
{
return;
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise to top."));
return;
}
if (!group) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
return;
}
}
_("Raise to top"));
}
void
{
return;
if (!items) {
return;
}
if (!group) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
return;
}
// Determine the common bbox of the selected items.
/* Construct direct-ordered list of selected children. */
// Iterate over all objects in the selection (starting from top).
if (selected) {
while (rev) {
// for each selected object, find the prev sibling
// if the sibling is an item AND overlaps our selection,
if (SP_IS_ITEM(newref)) {
// AND if it's not one of our selected objects,
// move the selected object before that sibling
if (put_after)
else
}
break;
}
}
}
}
} else {
}
_("Lower"));
}
{
return;
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower to bottom."));
return;
}
if (!group) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
return;
}
minpos = 0;
while (!SP_IS_ITEM(pc)) {
minpos += 1;
}
}
_("Lower to bottom"));
}
void
{
}
void
{
}
{
}
/**
* \pre item != NULL
*/
{
// write the complete cascaded style, context-free
return NULL;
// if this is a text with exactly one tspan child, merge the style of that tspan as well
// If this is a group, merge the style of its topmost (last) child with style
for (SPObject *last_element = item->lastChild(); last_element != NULL; last_element = SP_OBJECT_PREV(last_element)) {
if (temp) {
}
break;
}
}
}
// do not copy text properties from non-text objects, it's confusing
}
if (ex != 1.0) {
}
return css;
}
void sp_selection_copy()
{
}
{
}
{
if (cm->pasteStyle())
}
{
if (cm->pastePathEffect())
_("Paste live path effect"));
}
{
}
}
{
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from."));
return;
}
for ( GSList const *itemlist = selection->itemList(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) {
}
_("Remove live path effect"));
}
{
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove filters from."));
return;
}
_("Remove filter"));
}
{
_("Paste size"));
}
{
_("Paste size separately"));
}
{
// check if something is selected
dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to move to the layer above."));
return;
}
bool no_more = false; // Set to true, if no more layers above
if (next) {
sp_selection_delete_impl(items, false, false);
next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
if (next) {
} else {
no_more = true;
}
if ( !suppressDone ) {
_("Raise to next layer"));
}
} else {
no_more = true;
}
if (no_more) {
}
}
{
// check if something is selected
dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to move to the layer below."));
return;
}
bool no_more = false; // Set to true, if no more layers below
if (next) {
sp_selection_copy_impl(items, &temp_clip, sp_document_repr_doc(dt->doc())); // 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
if (next) {
} else {
no_more = true;
}
if ( !suppressDone ) {
_("Lower to previous layer"));
}
} else {
no_more = true;
}
if (no_more) {
}
}
bool
{
bool contains_original = false;
{
if (item_use == item_use_first)
break;
}
// If it's a tref, check whether the object containing the character
// data is part of the selection
}
return contains_original;
}
bool
{
bool clone_with_original = false;
if (clone_with_original)
break;
}
return clone_with_original;
}
/** Apply matrix to the selection. \a set_i2d is normally true, which means objects are in the
original transform, synced with their reprs, and need to jump to the new transform in one go. A
value of set_i2d==false is only used by seltrans when it's dragging objects live (not outlines); in
that case, items are already in the new position, but the repr is in the old, and this function
then simply updates the repr from item->transform.
*/
void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix const &affine, bool set_i2d, bool compensate)
{
return;
// For each perspective with a box in selection, check whether all boxes are selected and
// unlink all non-selected boxes.
// create a new perspective as a copy of the current one and link the selected boxes to it
} else {
}
}
#if 0 /* Re-enable this once persistent guides have a graphical indication.
At the time of writing, this is the only place to re-enable. */
#endif
// we're moving both a clone and its original or any ancestor in clone chain?
// ...both a text-on-path and its path?
bool transform_textpath_with_path = (SP_IS_TEXT_TEXTPATH(item) && selection->includes( sp_textpath_get_path_item(SP_TEXTPATH(sp_object_first_child(SP_OBJECT(item)))) ));
// ...both a flowtext and its frame?
bool transform_flowtext_with_frame = (SP_IS_FLOWTEXT(item) && selection->includes( SP_FLOWTEXT(item)->get_frame(NULL))); // (only the first frame is checked so far)
// ...both an offset and its source?
bool transform_offset_with_source = (SP_IS_OFFSET(item) && SP_OFFSET(item)->sourceHref) && selection->includes( sp_offset_get_source(SP_OFFSET(item)) );
// If we're moving a connector, we want to detach it
// from shapes that aren't part of the selection, but
// leave it attached if they are
if (cc_item_is_connector(item)) {
for (int n = 0; n < 2; ++n) {
sp_conn_end_detach(item, n);
}
}
}
// "clones are unmoved when original is moved" preference
int compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
/* If this is a clone and it's selected along with its original, do not move it;
* it will feel the transform of its original and respond to it itself.
* Without this, a clone is doubly transformed, very unintuitive.
*
* Same for textpath if we are also doing ANY transform to its path: do not touch textpath,
* letters cannot be squeezed or rotated anyway, they only refill the changed path.
* Same for linked offset if we are also moving its source: do not move it. */
// Restore item->transform field from the repr, in case it was changed by seltrans.
} else if (transform_flowtext_with_frame) {
// apply the inverse of the region's transform to the <use> so that the flow remains
// the same (even though the output itself gets transformed)
continue;
sp_item_write_transform(SP_USE(use), SP_OBJECT_REPR(use), item->transform.inverse(), NULL, compensate);
}
}
} else if (transform_clone_with_original) {
// We are transforming a clone along with its original. The below matrix juggling is
// necessary to ensure that they transform as a whole, i.e. the clone's induced
// transform and its move compensation are both cancelled out.
// restore item->transform field from the repr, in case it was changed by seltrans
// calculate the matrix we need to apply to the clone to cancel its induced transform from its original
// we need to cancel out the move compensation, too
// find out the clone move, same as in sp_use_move_compensate
if (prefs_parallel) {
} else if (prefs_unmoved) {
//if (SP_IS_USE(sp_use_get_original(SP_USE(item))))
// clone_move = Geom::identity();
}
} else {
// just apply the result
}
} else {
if (set_i2d) {
}
}
// if we're moving the actual object, not just updating the repr, we can transform the
// center by the same matrix (only necessary for non-translations)
}
}
}
{
return;
while (l != NULL) {
l = l->next;
}
_("Remove transform"));
}
void
{
return;
if ( !bbox ) {
return;
}
}
void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point const &align, Geom::Scale const &scale)
{
return;
if ( !bbox ) {
return;
}
// FIXME: ARBITRARY LIMIT: don't try to scale above 1 Mpx, it won't display properly and will crash sooner or later anyway
{
return;
}
}
void
sp_selection_rotate_relative(Inkscape::Selection *selection, Geom::Point const ¢er, gdouble const angle_degrees)
{
}
void
sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy)
{
dx, 1,
0, 0);
}
void sp_selection_move_relative(Inkscape::Selection *selection, Geom::Point const &move, bool compensate)
{
}
{
}
/**
* @brief Rotates selected objects 90 degrees, either clock-wise or counter-clockwise, depending on the value of ccw
*/
{
return;
Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw
}
}
void
{
return;
if (!center) {
return;
}
( ( angle_degrees > 0 )
? "selector:rotate:ccw"
: "selector:rotate:cw" ),
_("Rotate"));
}
// helper function:
static
unsigned i = 0;
if (p[X] < m[X]) {
i = 1;
}
if (p[Y] < m[Y]) {
i = 3 - i;
}
return r.corner(i);
}
/**
\param angle the angle in "angular pixels", i.e. how many visible pixels must move the outermost point of the rotated object
*/
void
{
return;
return;
}
( (angle > 0)
? "selector:rotate:ccw"
: "selector:rotate:cw" ),
_("Rotate by pixels"));
}
void
{
return;
if (!bbox) {
return;
}
// you can't scale "do nizhe pola" (below zero)
return;
}
( (grow > 0)
? "selector:scale:larger"
: "selector:scale:smaller" ),
_("Scale"));
}
void
{
}
void
{
return;
if (!sel_bbox) {
return;
}
_("Scale by whole factor"));
}
void
{
return;
}
if (dx == 0) {
sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT,
_("Move vertically"));
} else if (dy == 0) {
sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT,
_("Move horizontally"));
} else {
_("Move"));
}
}
void
{
return;
}
// same as sp_selection_move but divide deltas by zoom factor
if (dx == 0) {
sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT,
_("Move vertically by pixels"));
} else if (dy == 0) {
sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT,
_("Move horizontally by pixels"));
} else {
_("Move"));
}
}
namespace {
template <typename D>
template <typename D>
struct Forward {
};
struct Reverse {
}
}
g_slist_free(i);
}
}
private:
}
return list;
}
};
}
void
{
PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
if (PREFS_SELECTION_ALL != inlayer) {
} else {
}
SPItem *item=next_item_from_list<Forward>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
if (item) {
if ( SP_CYCLING == SP_CYCLE_FOCUS ) {
}
}
}
void
{
PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
if (PREFS_SELECTION_ALL != inlayer) {
} else {
}
SPItem *item=next_item_from_list<Reverse>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
if (item) {
if ( SP_CYCLING == SP_CYCLE_FOCUS ) {
}
}
}
{
if (!dt) return;
} else {
dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("The selection has no applied path effect."));
}
}
}
}
{
if (!dt) return;
if ( item ) {
if (clip)
else
if (obj) {
// obj is a group object, the children are the actual clippers
if ( SP_IS_ITEM(child) ) {
// If not already in nodecontext, goto it!
}
// TODO: should we set the item for nodepath or knotholder or both? seems to work with both.
if (np) {
// take colors from prefs (same as used in outline mode)
sp_nodepath_show_helperpath(np, true);
}
break; // break out of for loop after 1st encountered item
}
}
} else if (clip) {
} else {
}
}
}
}
namespace {
template <typename D>
SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
{
while (items) {
{
break;
}
}
}
// first, try from the current object
if (!next) { // if we ran out of objects, start over at the root
}
return next;
}
template <typename D>
{
if (path) {
found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
}
} else {
}
}
} else if ( SP_IS_ITEM(object) &&
{
}
}
return found;
}
}
/**
* If \a item is not entirely visible then adjust visible area to centre on the centre on of
* \a item.
*/
{
}
}
void
{
return;
// check if something is selected
return;
}
// sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need
while (reprs) {
clone->setAttribute("inkscape:transform-center-x", sel_repr->attribute("inkscape:transform-center-x"), false);
clone->setAttribute("inkscape:transform-center-y", sel_repr->attribute("inkscape:transform-center-y"), false);
// add the new clone to the top of the original's parent
}
// TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
Q_("action|Clone"));
}
void
{
if (!desktop)
return;
return;
}
if (!newid) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Copy an <b>object</b> to clipboard to relink clones to."));
return;
}
// Get a copy of current selection.
bool relinked = false;
{
continue;
relinked = true;
}
if (!relinked) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to relink</b> in the selection."));
} else {
_("Relink clone"));
}
}
void
{
if (!desktop)
return;
return;
}
// Get a copy of current selection.
bool unlinked = false;
{
if (SP_IS_TEXT(item)) {
if (tspan) {
}
// Set unlink to true, and fall into the next if which
// will include this text item in the new selection
unlinked = true;
}
// keep the non-use item in the new selection
continue;
}
} else /*if (SP_IS_TREF(use))*/ {
}
unlinked = true;
// Add ungrouped items to the new selection.
}
if (new_select) { // set new selection
}
if (!unlinked) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection."));
}
_("Unlink clone"));
}
void
{
return;
gchar const *error = _("Select a <b>clone</b> to go to its original. Select a <b>linked offset</b> to go to its source. Select a <b>text on path</b> to go to the path. Select a <b>flowed text</b> to go to its frame.");
// Check if other than two objects are selected
return;
}
} else if (SP_IS_TEXT_TEXTPATH(item)) {
} else if (SP_IS_FLOWTEXT(item)) {
} else { // it's an object that we don't know what to do with
return;
}
if (!original) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>Cannot find</b> the object to select (orphaned clone, offset, textpath, flowed text?)"));
return;
}
if (SP_IS_DEFS(o)) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The object you're trying to select is <b>not visible</b> (it is in <defs>)"));
return;
}
}
if (original) {
if (highlight) {
if ( a && b ) {
// draw a flashing line between the objects
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvasitem), 0x0000ddff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT, 5, 3);
}
}
if (SP_CYCLING == SP_CYCLE_FOCUS) {
}
}
}
{
return;
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to marker."));
return;
}
if ( !r || !c ) {
return;
}
// calculate the transform to be applied to objects to move them to 0,0
// bottommost object, after sorting
// remember the position of the first item
(void)pos; // TODO check why this was remembered
// create a list of duplicates
}
if (apply) {
// delete objects so that their clones don't get alerted; this object will be restored shortly
item->deleteObject(false);
}
}
// Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals
// without disturbing clones.
// See ActorAlign::on_button_click() in src/ui/dialog/align-and-distribute.cpp
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
* parent_transform.inverse() ),
parent_transform * move);
(void)mark_id;
// restore compensation setting
_("Objects to marker"));
}
}
} else {
if (deleteitem) {
}
}
}
{
return;
// we need to copy the list because it gets reset when objects are deleted
if (!items) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides."));
return;
}
}
}
void
{
return;
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to pattern."));
return;
}
if ( !r ) {
return;
}
// calculate the transform to be applied to objects to move them to 0,0
Geom::Point move_p = Geom::Point(0, sp_document_height(doc)) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y]));
// bottommost object, after sorting
// remember the position of the first item
// create a list of duplicates
}
// restore the z-order after prepends
if (apply) {
// delete objects so that their clones don't get alerted; this object will be restored shortly
item->deleteObject(false);
}
}
// Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals
// without disturbing clones.
// See ActorAlign::on_button_click() in src/ui/dialog/align-and-distribute.cpp
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
parent_transform * move);
// restore compensation setting
if (apply) {
// restore parent and position
}
_("Objects to pattern"));
}
void
{
return;
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object with pattern fill</b> to extract objects from."));
return;
}
bool did = false;
continue;
if (!SP_IS_PATTERN(server))
continue;
did = true;
for (SPObject *child = sp_object_first_child(SP_OBJECT(pattern)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
// FIXME: relink clones to the new canvas objects
// use SPObject::setid when mental finishes it to steal ids of
// this is needed to make sure the new item has curve (simply requestDisplayUpdate does not work)
}
}
if (!did) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No pattern fills</b> in the selection."));
} else {
_("Pattern to objects"));
}
}
void
sp_selection_get_export_hints(Inkscape::Selection *selection, char const **filename, float *xdpi, float *ydpi)
{
return;
}
bool filename_search = TRUE;
bool xdpi_search = TRUE;
bool ydpi_search = TRUE;
xdpi_search &&
gchar const *dpi_string;
if (filename_search) {
}
if (xdpi_search) {
dpi_string = NULL;
if (dpi_string != NULL) {
xdpi_search = FALSE;
}
}
if (ydpi_search) {
dpi_string = NULL;
if (dpi_string != NULL) {
ydpi_search = FALSE;
}
}
}
}
void
{
gchar const *dpi_string;
dpi_string = NULL;
if (dpi_string != NULL) {
}
dpi_string = NULL;
if (dpi_string != NULL) {
}
}
void
{
return;
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to make a bitmap copy."));
return;
}
// set "busy" cursor
// Get the bounding box of the selection
if (NR_RECT_DFLS_TEST_EMPTY(&bbox)) {
return; // exceptional situation, so not bother with a translatable error message, just quit quietly
}
// List of the items to show; all others will be hidden
// Sort items so that the topmost comes last
// Generate a random value from the current time (you may create bitmap from the same object(s)
// multiple times, and this is done so that they don't clash)
// Create the filename.
current);
// Imagemagick is known not to handle spaces in filenames, so we replace anything but letters,
// digits, and a few other chars, with "_"
g_strcanon(basename, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.=+~$#@^&!?", '_');
// Build the complete path by adding document base dir, if set, otherwise home dir
if (SP_DOCUMENT_URI(document)) {
}
}
//g_print("%s\n", filepath);
// Remember parent and z-order of the topmost one
// Calculate resolution
double res;
if (0 < prefs_res) {
// If it's given explicitly in prefs, take it
} else if (0 < prefs_min) {
// If minsize is given, look up minimum bitmap size (default 250 pixels) and calculate resolution from it
} else {
char const *hint_filename;
// take resolution hint from the selected objects
if (hint_xdpi != 0) {
} else {
// take resolution hint from the document
if (hint_xdpi != 0) {
} else {
// if all else fails, take the default 90 dpi
}
}
}
// The width and height of the bitmap in pixels
// Find out if we have to run an external filter
// filter command is given;
// see if we have a parameter to pass to it
// if the param string ends with %, interpret it as a percentage of the image's max dimension
// the first param is always the image filename, the second is param1
} else {
// otherwise pass the param1 unchanged
}
} else {
// run without extra parameter
}
}
// Calculate the matrix that will be applied to the image so that it exactly overlaps the source objects
shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone
}
// Do the export
(guint32) 0xffffff00,
true, /*bool force_overwrite,*/
items);
// Run filter, if any
if (run) {
int retval;
}
// Import the image back
if (pb) {
// Create the repr for the image
{
}
} else {
}
// Write transform
gchar *c=sp_svg_transform_write(t);
g_free(c);
// add the new repr to the parent
// move to the saved position
// Set selection to the new image
// Clean up
// Complete undoable transaction
_("Create bitmap"));
}
}
/**
* \brief Creates a mask or clipPath from selection
* Two different modes:
* and is applied to current layer
* otherwise, topmost object is used as mask for other objects
* If \a apply_clip_path parameter is true, clipPath is created, otherwise mask
*
*/
void
{
return;
// check if something is selected
if ( apply_to_layer && is_empty) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
return;
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to."));
return;
}
// FIXME: temporary patch to prevent crash!
if (clone_with_original) {
}
// /END FIXME
// create a list of duplicates
if (apply_to_layer) {
// all selected items are used for mask, which is applied to a layer
if (remove_original) {
}
}
} else if (!topmost) {
// topmost item is used as a mask, which is applied to other items in a selection
if (remove_original) {
}
}
} else {
}
if (remove_original) {
}
}
// inverted object transform should be applied to a mask object,
// as mask is calculated in user space (after applying transform)
Inkscape::XML::Node *dup = reinterpret_cast<Inkscape::XML::Node *>(mask_item->data)->duplicate(xml_doc);
}
if (apply_clip_path) {
} else {
}
}
item->deleteObject(false);
}
if (apply_clip_path)
else
}
return;
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove clippath or mask from."));
return;
}
// SPObject* refers to a group containing the clipped path or mask itself,
// whereas SPItem* refers to the item being clipped or masked
if (remove_original) {
if (apply_clip_path) {
} else {
}
// collect distinct mask object (and associate with item to apply transform)
}
}
}
// restore mask objects into a document
for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) {
for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
// Collect all clipped paths and masks within a single group
}
if (!obj->isReferenced()) {
// delete from defs if no other object references this mask
obj->deleteObject(false);
}
// Iterate through all clipped paths / masks
// insert into parent, restore pos
// transform mask, so it is moved the same spot where mask was applied
}
}
if (apply_clip_path)
else
}
/**
* \param with_margins margins defined in the xml under <sodipodi:namedview>
* "fit-margin-..." attributes. See SPDocument::fitToRect.
* \return true if an undoable change should be recorded.
*/
bool
{
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to fit canvas to."));
return false;
}
if (bbox) {
return true;
} else {
return false;
}
}
/**
* Fit canvas to the bounding box of the selection, as an undoable action.
*/
void
{
if (fit_canvas_to_selection(desktop)) {
_("Fit Page to Selection"));
}
}
/**
* \param with_margins margins defined in the xml under <sodipodi:namedview>
* "fit-margin-..." attributes. See SPDocument::fitToRect.
*/
bool
{
if (bbox) {
return true;
} else {
return false;
}
}
void
{
_("Fit Page to Drawing"));
}
}
/**
* Fits canvas to selection or drawing with margins from <sodipodi:namedview>
* "fit-margin-..." attributes. See SPDocument::fitToRect and
* ui/dialog/page-sizer.
*/
? fit_canvas_to_drawing(doc, true)
: fit_canvas_to_selection(desktop, true) );
if (changed) {
_("Fit Page to Selection or Drawing"));
}
};
// don't operate on layers
}
//don't recurse into locked layers
}
}
}
}
}
}
}
if (!dt) return;
if (layer_only) {
} else {
}
}
}
}
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :