index 851fc3a3bf9780828aceef86cafe852a00bcd538..4da9b33b86e15680b3588c2cee35c1ab2826a41d 100644 (file)
GSList *clipboard = NULL;
GSList *defs_clipboard = NULL;
SPCSSAttr *style_clipboard = NULL;
+NR::Rect size_clipboard(NR::Point(0,0), NR::Point(0,0));
static void sp_copy_stuff_used_by_item(GSList **defs_clip, SPItem *item, const GSList *items);
g_free (query);
}
+ size_clipboard = selection->bounds();
+
g_slist_free ((GSList *) items);
}
sp_document_done(SP_DT_DOCUMENT (desktop));
}
+void sp_selection_paste_size (bool apply_x, bool apply_y)
+{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if (desktop == NULL) return;
+
+ Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+
+ // check if something is in the clipboard
+ if (size_clipboard.extent(NR::X) < 1e-6 || size_clipboard.extent(NR::Y) < 1e-6) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing on the clipboard."));
+ return;
+ }
+
+ // check if something is selected
+ if (selection->isEmpty()) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to paste size to."));
+ return;
+ }
+
+ NR::Rect current = selection->bounds();
+ if (current.extent(NR::X) < 1e-6 || current.extent(NR::Y) < 1e-6) {
+ return;
+ }
+
+ double scale_x = size_clipboard.extent(NR::X) / current.extent(NR::X);
+ double scale_y = size_clipboard.extent(NR::Y) / current.extent(NR::Y);
+
+ sp_selection_scale_relative (selection, current.midpoint(),
+ NR::scale(
+ apply_x? scale_x : (desktop->isToolboxButtonActive ("lock")? scale_y : 1.0),
+ apply_y? scale_y : (desktop->isToolboxButtonActive ("lock")? scale_x : 1.0)));
+
+ sp_document_done(SP_DT_DOCUMENT (desktop));
+}
+
+void sp_selection_paste_size_separately (bool apply_x, bool apply_y)
+{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if (desktop == NULL) return;
+
+ Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+
+ // check if something is in the clipboard
+ if (size_clipboard.extent(NR::X) < 1e-6 || size_clipboard.extent(NR::Y) < 1e-6) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing on the clipboard."));
+ return;
+ }
+
+ // check if something is selected
+ if (selection->isEmpty()) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to paste size to."));
+ return;
+ }
+
+ for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {
+ SPItem *item = SP_ITEM(l->data);
+
+ NR::Rect current = sp_item_bbox_desktop(item);
+ if (current.extent(NR::X) < 1e-6 || current.extent(NR::Y) < 1e-6) {
+ continue;
+ }
+
+ double scale_x = size_clipboard.extent(NR::X) / current.extent(NR::X);
+ double scale_y = size_clipboard.extent(NR::Y) / current.extent(NR::Y);
+
+ sp_item_scale_rel (item,
+ NR::scale(
+ apply_x? scale_x : (desktop->isToolboxButtonActive ("lock")? scale_y : 1.0),
+ apply_y? scale_y : (desktop->isToolboxButtonActive ("lock")? scale_x : 1.0)));
+
+ }
+
+ sp_document_done(SP_DT_DOCUMENT (desktop));
+}
+
void sp_selection_to_next_layer ()
{
SPDesktop *dt = SP_ACTIVE_DESKTOP;
sp_repr_set_attr(clone, "x", "0");
sp_repr_set_attr(clone, "y", "0");
sp_repr_set_attr(clone, "xlink:href", g_strdup_printf("#%s", sel_repr->attribute("id")));
+
+ sp_repr_set_attr(clone, "inkscape:transform-center-x", sel_repr->attribute("inkscape:transform-center-x"));
+ sp_repr_set_attr(clone, "inkscape:transform-center-y", sel_repr->attribute("inkscape:transform-center-y"));
// add the new clone to the top of the original's parent
parent->appendChild(clone);