selection-chemistry.cpp revision bddbc0c10cc801c67a4c27a98ef06c5fe5c50ac7
/** @file
* 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>
* Jon A. Cruz <jon@joncruz.org>
* Martin Sucha <martin.sucha-inkscape@jts-sro.sk>
* Abhishek Sharma
* Kris De Gussem <Kris.DeGussem@gmail.com>
* Tavmjong Bah <tavmjong@free.fr> (Symbol additions)
*
* Copyright (C) 1999-2010,2012 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 <gtkmm/clipboard.h>
#include "file.h"
#include "selection-chemistry.h"
// TOOD fixme: This should be moved into preference repr
#include "desktop.h"
#include "desktop-style.h"
#include "dir-util.h"
#include "layer-model.h"
#include "selection.h"
#include "ui/tools-switch.h"
#include "message-stack.h"
#include "sp-item-transform.h"
#include "sp-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 "sp-image.h"
#include "sp-rect.h"
#include "sp-ellipse.h"
#include "sp-star.h"
#include "sp-spiral.h"
#include "sp-switch.h"
#include "sp-polyline.h"
#include "sp-line.h"
#include "text-editing.h"
#include "display/sp-canvas.h"
#include "ui/tools/text-tool.h"
#include "ui/tools/connector-tool.h"
#include "sp-path.h"
#include "sp-conn-end.h"
#include "ui/tools/dropper-tool.h"
#include "xml/rebase-hrefs.h"
#include "style.h"
#include "document-private.h"
#include "document-undo.h"
#include "sp-gradient.h"
#include "sp-gradient-reference.h"
#include "sp-linear-gradient.h"
#include "sp-pattern.h"
#include "sp-symbol.h"
#include "sp-radial-gradient.h"
#include "ui/tools/gradient-tool.h"
#include "sp-namedview.h"
#include "preferences.h"
#include "sp-offset.h"
#include "sp-clippath.h"
#include "sp-mask.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 "xml/simple-document.h"
#include "sp-filter-reference.h"
#include "gradient-drag.h"
#include "uri-references.h"
#include "display/canvas-bpath.h"
#include "display/cairo-utils.h"
#include "inkscape.h"
#include "path-chemistry.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/multi-path-manipulator.h"
#include "sp-lpe-item.h"
#include "live_effects/effect.h"
#include "live_effects/effect-enum.h"
#include "live_effects/parameter/originalpath.h"
#include "enums.h"
#include "sp-item-group.h"
// For clippath editing
#include "ui/tools-switch.h"
#include "ui/tools/node-tool.h"
#include "ui/clipboard.h"
#include "verbs.h"
using Inkscape::DocumentUndo;
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. */
// helper for printing error messages, regardless of whether we have a GUI or not
// If desktop == NULL, errors will be shown on stderr
static void
selection_display_message(SPDesktop *desktop, Inkscape::MessageType msgType, Glib::ustring const &msg)
{
if (desktop) {
} else {
}
}
}
namespace Inkscape {
{
return;
}
}
}
{
} else {
}
}
{
}
} else {
// If nothing selected switch to selection tool
}
}
{
sp_select_same_fill_stroke_style(dt, true, true, true);
}
{
sp_select_same_fill_stroke_style(dt, true, false, false);
}
{
sp_select_same_fill_stroke_style(dt, false, true, false);
}
{
sp_select_same_fill_stroke_style(dt, false, false, true);
}
{
}
{
} else {
}
}
{
} else {
}
}
{
// TODO make this a virtual method of event context!
} else {
}
}
{
} else {
}
}
{
} else {
}
}
/*
* Fixes the current selection, removing locked objects from it
*/
{
if(!dt)
return;
for( std::vector<SPItem*>::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); i++ ) {
if( item &&
{
}
}
}
} // namespace Inkscape
/**
* Copies repr and its inherited css style elements, along with the accumulated transform 'full_t',
* then prepends the copy to 'clip'.
*/
static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, std::vector<Inkscape::XML::Node*> &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)
}
static void sp_selection_copy_impl(std::vector<SPItem*> const &items, std::vector<Inkscape::XML::Node*> &clip, Inkscape::XML::Document* xml_doc)
{
// Sort items:
// Copy item reprs:
if (item) {
} else {
}
}
}
// TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items.
static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector<Inkscape::XML::Node*> &clip)
{
// 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;
}
static void sp_selection_delete_impl(std::vector<SPItem*> const &items, bool propagate = true, bool propagate_descendants = true)
{
sp_object_ref(*i, NULL);
}
}
}
{
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;
}
// 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
for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){
if (relink_clones) {
}
if (fork_livepatheffects) {
if (newLPEObj) {
}
}
}
if (relink_clones) {
if (use) {
if (!orig) // orphaned
continue;
// 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";
}
}
} else {
if (offset) {
doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]);
}
}
}
}
}
}
if ( !suppressDone ) {
_("Duplicate"));
}
}
{
if (!selection)
return;
items[i]->deleteObject();
}
_("Delete all"));
}
/*
* Return a list of SPItems that are the children of 'list'
*
* list - source list of items to search in
* desktop - desktop associated with the source list
* exclude - list of items to exclude from result
* onlyvisible - TRUE includes only items visible on canvas
* onlysensitive - TRUE includes only non-locked items
* ingroups - TRUE to recursively get grouped items children
*/
std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude)
{
if (item &&
)
{
}
}
}
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;
std::vector<SPItem*> all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer()));
}
}
}
}
}
break;
}
case PREFS_SELECTION_LAYER_RECURSIVE: {
break;
}
default: {
break;
}
}
}
{
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);
}
static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) {
// Remember the position and parent of the topmost object.
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)
std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip);
// take pasted object (now in topmost_parent)
// make a copy
// remove pasted
// put its copy into group
}
}
}
// 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
}
{
// Check if something is selected.
selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>some objects</b> to group."));
return;
}
}
return 1;
return 0;
} else {
return -1;
}
}
{
selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select a <b>group</b> to ungroup."));
}
// first check whether there is anything to ungroup
for (std::vector<SPItem*>::const_iterator item = old_select.begin(); item!=old_select.end(); item++) {
}
}
selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection."));
return;
}
// If any of the clones refer to the groups, unlink them and replace them with successors
// in the items list.
}
}
}
// Unlink clones beginning from those with highest clone depth.
// This way we can be sure than no additional automatic unlinking happens,
// and the items in the list remain valid
}
// do the actual work
// ungroup only the groups marked earlier
// add the items resulting from ungrouping to the selection
} else {
// if not a group, keep in the selection
}
}
_("Ungroup"));
}
/** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */
{
bool has_groups = false;
if (!group) {
} 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 *
{
return NULL;
}
// Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor
return NULL;
}
return NULL;
}
}
}
/** Finds out the minimum common bbox of the selected items. */
{
r.unionWith((*i)->desktopVisualBounds());
}
return r;
}
// TODO determine if this is intentionally different from SPObject::getPrev()
{
}
return prev;
}
{
}
void
{
selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise."));
return;
}
if (!group) {
selection_display_message(desktop, 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) {
// for each selected object, find the next sibling
// if the sibling is an item AND overlaps our selection,
if (newItem) {
// AND if it's not one of our selected objects,
// move the selected object after that sibling
}
break;
}
}
}
}
}
//TRANSLATORS: "Raise" means "to raise an object" in the undo history
}
{
selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise to top."));
return;
}
if (!group) {
selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
return;
}
}
_("Raise to top"));
}
{
selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower."));
return;
}
if (!group) {
selection_display_message(desktop, 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) {
// for each selected object, find the prev sibling
// if the sibling is an item AND overlaps our selection,
if (newItem) {
// AND if it's not one of our selected objects,
// move the selected object before that sibling
if (put_after)
else
}
break;
}
}
}
}
}
//TRANSLATORS: "Lower" means "to lower an object" in the undo history
}
{
selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower to bottom."));
return;
}
if (!group) {
selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
return;
}
minpos = 0;
minpos += 1;
}
}
_("Lower to bottom"));
}
void
{
}
}
void
{
}
}
{
}
/**
* \pre item != NULL
*/
{
// CPPIFY:
// This function should only take SPItems, but currently SPString is not an Item.
// 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 = object->lastChild(); last_element != NULL; last_element = last_element->getPrev()) {
if ( last_element->style ) {
if (temp) {
}
break;
}
}
}
// Remove black-listed properties (those that should not be used in a default style)
if (!(dynamic_cast<SPText *>(object) || dynamic_cast<SPTSpan *>(object) || dynamic_cast<SPTRef *>(object) || dynamic_cast<SPString *>(object))) {
// do not copy text properties from non-text objects, it's confusing
}
if (item) {
if (ex != 1.0) {
}
}
return css;
}
{
}
{
}
}
{
}
}
{
_("Paste live path effect"));
}
}
{
if ( lpeitem->hasPathEffect() ) {
lpeitem->removeAllPathEffects(false);
}
}
}
{
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from."));
return;
}
}
_("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"));
}
}
/**
* Ensures that the clones of objects are not modified when moving objects between layers.
* Calls the same function as ungroup
*/
{
if (item) {
(oldparent->i2doc_affine())
}
}
}
{
// 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, 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
if (next) {
} else {
no_more = true;
}
if ( !suppressDone ) {
_("Lower to previous layer"));
}
} else {
no_more = true;
}
if (no_more) {
}
}
{
// check if something is selected
return;
}
if (moveto) {
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);
std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip);
if ( !suppressDone ) {
_("Move selection to layer"));
}
}
}
static 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
if (!contains_original && tref) {
}
return contains_original;
}
static bool
{
bool clone_with_original = false;
if (item) {
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::Affine const &affine, bool set_i2d, bool compensate, bool adjust_transf_center)
{
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 {
}
}
// An SVG element cannot have a transform. We could change 'x' and 'y' in response
// to a translation... but leave that for another day.
selection->desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG."));
break;
}
#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 = ((dynamic_cast<SPText *>(item) && item->firstChild() && dynamic_cast<SPTextPath *>(item->firstChild()))
&& selection->includes( sp_textpath_get_path_item(dynamic_cast<SPTextPath *>(item->firstChild())) ));
// ...both a flowtext and its frame?
bool transform_flowtext_with_frame = (dynamic_cast<SPFlowtext *>(item) && selection->includes( dynamic_cast<SPFlowtext *>(item)->get_frame(NULL))); // (only the first frame is checked so far)
// ...both an offset and its source?
bool transform_offset_with_source = (dynamic_cast<SPOffset *>(item) && dynamic_cast<SPOffset *>(item)->sourceHref) && selection->includes( sp_offset_get_source(dynamic_cast<SPOffset *>(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 (path) {
for (int n = 0; n < 2; ++n) {
sp_conn_end_detach(item, n);
}
}
} else {
}
}
// "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. */
if (transform_textpath_with_path) {
// 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)
if ( use ) {
}
}
}
}
} else if (transform_clone_with_original || transform_offset_with_source) {
// 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
{
if (parentItem) {
} else {
}
}
// we need to cancel out the move compensation, too
// find out the clone move, same as in sp_use_move_compensate
{
if (use) {
} else {
}
}
if (prefs_parallel) {
} else if (prefs_unmoved) {
//if (dynamic_cast<SPUse *>(sp_use_get_original(dynamic_cast<SPUse *>(item))))
// clone_move = Geom::identity();
}
} else if (transform_offset_with_source && (prefs_parallel || prefs_unmoved) && affine.isTranslation()){
if (prefs_parallel) {
} else if (prefs_unmoved) {
}
} else {
// just apply the result
}
} else {
if (set_i2d) {
}
}
if (adjust_transf_center) { // The transformation center should not be touched in case of pasting or importing, which is allowed by this if clause
// 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)
item->updateRepr();
}
}
}
}
{
return;
}
_("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)
{
}
{
}
/**
* 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
if (item) {
} else {
}
}
}
void
{
return;
if (!center) {
return;
}
( ( angle_degrees > 0 )
? "selector:rotate:ccw"
: "selector:rotate:cw" ),
_("Rotate"));
}
/*
* Selects all the visible items with the same fill and/or stroke color/style as the items in the current selection
*
* Params:
* desktop - set the selection on this desktop
* fill - select objects matching fill
* stroke - select objects matching stroke
*/
void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean stroke, gboolean style)
{
if (!desktop) {
return;
}
return;
}
std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y);
if(!SP_IS_GROUP(*iter)){
}
}
for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) {
}
else if (fill) {
}
else if (stroke) {
}
else if (style) {
}
}
}
/*
* Selects all the visible items with the same object type as the items in the current selection
*
* Params:
* desktop - set the selection on this desktop
*/
{
if (!desktop) {
return;
}
std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y);
for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) {
if (sel) {
} else {
}
}
}
/*
* Find all items in src list that have the same fill or stroke style as sel
* Return the list of matching items
*/
std::vector<SPItem*> sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type)
{
if (iter) {
match = false;
if (sel_paint->isColor() && iter_paint->isColor() // color == color comparision doesnt seem to work here.
match = true;
if ((dynamic_cast<SPLinearGradient *>(sel_server) || dynamic_cast<SPRadialGradient *>(sel_server) ||
(dynamic_cast<SPGradient *>(sel_server) && dynamic_cast<SPGradient *>(sel_server)->getVector()->isSwatch()))
&&
(dynamic_cast<SPGradient *>(iter_server) && dynamic_cast<SPGradient *>(iter_server)->getVector()->isSwatch()))) {
if (sel_vector == iter_vector) {
match = true;
}
match = true;
}
}
match = true;
match = true;
}
if (match) {
}
} else {
}
}
return matches;
}
{
if ( dynamic_cast<SPRect *>(i)) {
return ( dynamic_cast<SPRect *>(j) );
} else if (dynamic_cast<SPGenericEllipse *>(i)) {
return (dynamic_cast<SPGenericEllipse *>(j));
} else if (dynamic_cast<SPSpiral *>(i)) {
return (dynamic_cast<SPSpiral *>(j));
} else if (dynamic_cast<SPPath *>(i) || dynamic_cast<SPLine *>(i) || dynamic_cast<SPPolyLine *>(i)) {
} else if (dynamic_cast<SPText *>(i) || dynamic_cast<SPFlowtext *>(i) || dynamic_cast<SPTSpan *>(i) || dynamic_cast<SPTRef *>(i) || dynamic_cast<SPString *>(i)) {
return (dynamic_cast<SPText *>(j) || dynamic_cast<SPFlowtext *>(j) || dynamic_cast<SPTSpan *>(j) || dynamic_cast<SPTRef *>(j) || dynamic_cast<SPString *>(j));
} else if (dynamic_cast<SPUse *>(i)) {
return (dynamic_cast<SPUse *>(j)) ;
} else if (dynamic_cast<SPImage *>(i)) {
return (dynamic_cast<SPImage *>(j));
} else if (dynamic_cast<SPOffset *>(i) && dynamic_cast<SPOffset *>(i)->sourceHref) { // Linked offset
} else if (dynamic_cast<SPOffset *>(i) && !dynamic_cast<SPOffset *>(i)->sourceHref) { // Dynamic offset
}
return false;
}
/*
* Find all items in src list that have the same object type as sel by type
* Return the list of matching items
*/
{
}
}
return matches;
}
/*
* Find all items in src list that have the same stroke style as sel by type
* Return the list of matching items
*/
std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type)
{
bool match = false;
}
}
/*
* Stroke width needs to handle transformations, so call this function
* to get the transformed stroke width
*/
}
bool match_g;
if (iter) {
match_g=true;
match = true;
if (sel_style_for_width) {
}
}
}
}
}
match = true;
for (int i = 0; i < len; i++) {
match = false;
break;
}
}
}
if (match_g) {
}
} else {
}
}
return matches;
}
// 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) {
_("Move vertically"));
} else if (dy == 0) {
_("Move horizontally"));
} else {
_("Move"));
}
}
void
{
return;
}
// same as sp_selection_move but divide deltas by zoom factor
if (dx == 0) {
_("Move vertically by pixels"));
} else if (dy == 0) {
_("Move horizontally by pixels"));
} else {
_("Move"));
}
}
typedef struct Forward {
} Forward;
typedef struct ListReverse {
}
}
g_slist_free(i);
}
}
private:
if (!object) { // TODO check if this happens in practice
g_warning("Unexpected list overrun");
break;
}
}
return list;
}
} ListReverse;
template <typename D>
{
if (path) {
found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
}
} else {
}
}
} else {
if ( item &&
{
}
}
}
return found;
}
template <typename D>
SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
{
{
break;
}
}
}
// first, try from the current object
if (!next) { // if we ran out of objects, start over at the root
}
return next;
}
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<ListReverse>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
if (item) {
if ( SP_CYCLING == SP_CYCLE_FOCUS ) {
}
}
}
{
if (!dt) return;
if (lpeitem->hasPathEffect()) {
} else {
dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("The selection has no applied path effect."));
}
}
}
}
/*bool has_path_recursive(SPObject *obj)
{
if (!obj) return false;
if (SP_IS_PATH(obj)) {
return true;
}
if (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj)) {
for (SPObject *c = obj->children; c; c = c->next) {
if (has_path_recursive(c)) return true;
}
}
return false;
}*/
{
return;
/*if (!dt) return;
using namespace Inkscape::UI;
Inkscape::Selection *selection = dt->getSelection();
if (!selection || selection->isEmpty()) return;
GSList const *items = selection->itemList();
bool has_path = false;
for (GSList *i = const_cast<GSList*>(items); i; i= i->next) {
SPItem *item = SP_ITEM(i->data);
SPObject *search = clip
? (item->clip_ref ? item->clip_ref->getObject() : NULL)
: item->mask_ref ? item->mask_ref->getObject() : NULL;
has_path |= has_path_recursive(search);
if (has_path) break;
}
if (has_path) {
if (!tools_isactive(dt, TOOLS_NODES)) {
tools_switch(dt, TOOLS_NODES);
}
ink_node_tool_set_mode(INK_NODE_TOOL(dt->event_context),
clip ? NODE_TOOL_EDIT_CLIPPING_PATHS : NODE_TOOL_EDIT_MASKS);
} else if (clip) {
dt->messageStack()->flash(Inkscape::WARNING_MESSAGE,
_("The selection has no applied clip path."));
} else {
dt->messageStack()->flash(Inkscape::WARNING_MESSAGE,
_("The selection has no applied mask."));
}*/
}
/**
* If \a item is not entirely visible then adjust visible area to centre on the centre on of
* \a item.
*/
{
}
}
{
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
for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){
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
}
}
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;
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 (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;
}
if (use) {
// Unable to unlink use (external or invalid href?)
if (!unlink) {
continue;
}
} else /*if (SP_IS_TREF(use))*/ {
}
unlinked = true;
// Add ungrouped items to the 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;
}
if (use) {
} else {
} else {
} else {
if (flowtext) {
} else {
if (lpeItem) {
// check if the applied LPE is Clone original, if so, go to the refered path
Inkscape::LivePathEffect::Effect* lpe = lpeItem->getPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL);
if (lpe) {
if (Inkscape::LivePathEffect::OriginalPathParam *pathparam = dynamic_cast<Inkscape::LivePathEffect::OriginalPathParam *>(lpeparam)) {
}
}
}
}
}
}
}
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 (dynamic_cast<SPDefs *>(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) {
}
}
}
/**
* This creates a new path, applies the Original Path LPE, and has it refer to the selection.
*/
{
return;
}
if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) {
if (firstItem) {
os << "|";
} else {
}
}
}
if (firstItem) {
// create the LPE
{
desktop->doc()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to <defs> and assigns the 'id' attribute
}
// create the new path
{
// add the new clone to the top of the original's parent
if (clone_lpeitem) {
}
}
DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, _("Fill between many"));
// select the new object:
} else {
}
}
{
// sp_selection_tile has similar code
return;
}
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to marker."));
return;
}
doc->ensureUpToDate();
if ( !r || !c ) {
return;
}
// FIXME: Inverted Y coodinate
// calculate the transform to be applied to objects to move them to 0,0
//items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed?
// bottommost object, after sorting
{
if (parent) {
} else {
}
}
// Create a list of duplicates, to be pasted inside marker element.
}
if (apply) {
// Delete objects so that their clones don't get alerted;
// the objects will be restored inside the marker element.
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);
(void)mark_id;
// restore compensation setting
_("Objects to marker"));
}
}
} else {
}
}
{
return;
// we need to copy the list because it gets reset when objects are deleted
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides."));
return;
}
// If an object is earlier in the selection list than its clone, and it is deleted, then the clone will have changed
// and its entry in the selection list is invalid (crash).
// Therefore: first convert all, then delete all.
}
if (deleteitems) {
}
}
/*
* Convert objects to <symbol>. How that happens depends on what is selected:
*
* 1) A random selection of objects will be embedded into a single <symbol> element.
*
* 2) Except, a single <g> will have its content directly embedded into a <symbol>; the 'id' and
* 'style' of the <g> are transferred to the <symbol>.
*
* 3) Except, a single <g> with a transform that isn't a translation will keep the group when
* embedded into a <symbol> (with 'id' and 'style' transferred to <symbol>). This is because a
* <symbol> cannot have a transform. (If the transform is a pure translation, the translation
* is moved to the referencing <use> element that is created.)
*
* Possible improvements:
*
*
* For SVG2, set 'refX' 'refY' to object center (with compensating shift in <use>
* transformation).
*/
{
return;
}
// Check if something is selected.
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> to convert to symbol."));
return;
}
doc->ensureUpToDate();
// Keep track of parent, this is where <use> will be inserted.
// Find out if we have a single group
bool single_group = false;
if ( the_group ) {
single_group = true;
if( transform.isTranslation() ) {
// Create new list from group children.
// 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);
// Remove transform on group, updating clones.
// restore compensation setting
}
}
}
// Create new <symbol>
// For a single group, copy relevant attributes.
if( single_group ) {
// This should eventually be replaced by 'refX' and 'refY' once SVG WG approves it.
// It is done here for round-tripping
id += "_transform";
}
// Move selected items to new <symbol>
}
the_group->deleteObject(true);
}
// Create <use> pointing to new symbol (to replace the moved objects).
if( !transform.isIdentity() )
}
// Change selection to new <use> element.
// Clean up
}
/*
* Convert <symbol> to <g>. All <use> elements referencing symbol remain unchanged.
*/
{
return;
}
// Check if something is selected.
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a <b>symbol</b> to extract objects from."));
return;
}
// Make sure we have only one object in selection.
// Require that we really have a <symbol>.
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>symbol</b> in Symbol dialog to convert to group."));
return;
}
doc->ensureUpToDate();
// Create new <g> and insert in current layer
// Move all children of symbol to group
// Converting a group to a symbol inserts a group for non-translational transform.
// In converting a symbol back to a group we strip out the inserted group (or any other
// group that only adds a transform to the symbol content).
}
}
}
}
// Copy relevant attributes
// Need to delete <symbol>; all <use> elements that referenced <symbol> should
// auto-magically reference <g> (if <symbol> deleted after setting <g> 'id').
symbol->deleteObject(true);
// Change selection to new <g> element.
// Clean up
}
void
{
// sp_selection_to_marker has similar code
return;
}
// check if something is selected
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to pattern."));
return;
}
doc->ensureUpToDate();
if ( !r ) {
return;
}
// calculate the transform to be applied to objects to move them to 0,0
Geom::Point move_p = Geom::Point(0, doc->getHeight().value("px")) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y]));
// bottommost object, after sorting
{
if (parentItem) {
} else {
}
}
// remember the position of the first item
// 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);
// restore compensation setting
if (apply) {
// restore parent and position
}
_("Objects to pattern"));
}
{
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 (!basePat) {
continue;
}
did = true;
// 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)
doc->ensureUpToDate();
if (i) {
new_select.push_back(i);
} else {
}
}
}
}
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, Glib::ustring &filename, float *xdpi, float *ydpi)
{
return;
}
bool filename_search = TRUE;
bool xdpi_search = TRUE;
bool ydpi_search = TRUE;
for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){
gchar const *dpi_string;
if (filename_search) {
if (tmp){
}
else{
}
}
if (xdpi_search) {
if (dpi_string != NULL) {
xdpi_search = FALSE;
}
}
if (ydpi_search) {
if (dpi_string != NULL) {
ydpi_search = FALSE;
}
}
}
}
void sp_document_get_export_hints(SPDocument *doc, Glib::ustring &filename, float *xdpi, float *ydpi)
{
if(tmp)
{
}
else
{
}
if (dpi_string != NULL) {
}
dpi_string = NULL;
if (dpi_string != NULL) {
}
}
{
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 (!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
}
}
//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
res = Inkscape::Util::Quantity::convert(prefs_min, "in", "px") / MIN(bbox->width(), bbox->height());
} else {
// 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 96 dpi
}
}
}
// The width and height of the bitmap in pixels
unsigned width = (unsigned) floor(bbox->width() * Inkscape::Util::Quantity::convert(res, "px", "in"));
unsigned height =(unsigned) floor(bbox->height() * Inkscape::Util::Quantity::convert(res, "px", "in"));
// 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
{
if (parentItem) {
} else {
}
}
if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { // for default 96 dpi, snap it to pixel grid
shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone
}
t = Geom::Scale(1, -1) * Geom::Translate(shift_x, shift_y) * eek.inverse(); /// @fixme hardcoded doc2dt transform?
// TODO: avoid roundtrip via file
// Do the export
(guint32) 0xffffff00,
true, /*bool force_overwrite,*/
items);
// Run filter, if any
if (run) {
if(result == -1)
}
// Import the image back
if (pb) {
// Create the repr for the image
// TODO: avoid unnecessary roundtrip between data URI and decoded pixbuf
if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { // for default 96 dpi, snap it to pixel grid
} 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"));
}
}
/* Creates a mask or clipPath from selection.
* What is a clip group?
* A clip group is a tangled mess of XML that allows an object inside a group
* to clip the entire group using a few <use>s and generally irritating me.
*/
{
return;
}
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
return;
}
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)
std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip);
// take pasted object (now in topmost_parent)
// make a copy
// remove pasted
// put its copy into group
}
}
}
clone->setAttribute("inkscape:transform-center-x", inner->attribute("inkscape:transform-center-x"), false);
clone->setAttribute("inkscape:transform-center-y", inner->attribute("inkscape:transform-center-y"), false);
// add the new clone to the top of the original's parent
}
/**
* 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
*
*/
{
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
doc->ensureUpToDate();
// See lp bug #542004
// 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 {
}
}
} else if (!topmost) {
// topmost item is used as a mask, which is applied to other items in a selection
if (remove_original) {
}
items_to_select.push_back(*i);
}
} else {
i=*j;
}
if (remove_original) {
}
}
// group all those objects into one group
// and apply mask to that
// make a note we should ungroup this when unsetting mask
items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),static_cast<SPObject*>(i->data)));
}
}
// 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 {
}
// Node to apply mask to
if (grouping == PREFS_MASKOBJECT_GROUPING_SEPARATE) {
// make a note we should ungroup this when unsetting mask
}
}
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;
}
doc->ensureUpToDate();
// 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)
}
}
if (ungroup_masked && group) {
// if we had previously enclosed masked object in group,
// add it to list so we can ungroup it later
}
}
}
// restore mask objects into a document
for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) {
// 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
}
}
// ungroup marked groups added when setting mask
if (group) {
} else {
}
}
// rebuild selection
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
{
doc->ensureUpToDate();
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:fileencoding=utf-8:textwidth=99 :