diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 99ee78ade932963fbb01cabfca7e7f0411965935..bec3c5cbff27f23c51bd27e83da0d13fad7c6c6c 100644 (file)
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
-#define __SP_PATH_CHEMISTRY_C__
-
/*
* Here are handlers for modifying selections, specific to paths
*
/*
* Here are handlers for modifying selections, specific to paths
*
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 1999-2008 Authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Copyright (C) 1999-2008 Authors
* Copyright (C) 2001-2002 Ximian, Inc.
#include "selection-chemistry.h"
#include "path-chemistry.h"
#include "selection-chemistry.h"
#include "path-chemistry.h"
+using Inkscape::DocumentUndo;
+
void
sp_selected_path_combine(SPDesktop *desktop)
{
void
sp_selected_path_combine(SPDesktop *desktop)
{
SPItem *first = NULL;
Inkscape::XML::Node *parent = NULL;
SPItem *first = NULL;
Inkscape::XML::Node *parent = NULL;
+ if (did) {
+ selection->clear();
+ }
+
for (GSList *i = items; i != NULL; i = i->next) { // going from top to bottom
SPItem *item = (SPItem *) i->data;
if (!SP_IS_PATH(item))
continue;
for (GSList *i = items; i != NULL; i = i->next) { // going from top to bottom
SPItem *item = (SPItem *) i->data;
if (!SP_IS_PATH(item))
continue;
- did = true;
+
+ if (!did) {
+ selection->clear();
+ did = true;
+ }
SPCurve *c = sp_path_get_curve_for_edit(SP_PATH(item));
if (first == NULL) { // this is the topmost path
SPCurve *c = sp_path_get_curve_for_edit(SP_PATH(item));
if (first == NULL) { // this is the topmost path
g_slist_free(items);
if (did) {
g_slist_free(items);
if (did) {
- selection->clear();
-
- // delete the topmost one so that its clones don't get alerted; this object will be
- // restored shortly, with the same id
SP_OBJECT(first)->deleteObject(false);
SP_OBJECT(first)->deleteObject(false);
+ // delete the topmost.
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
// restore id, transform, path effect, and style
repr->setAttribute("id", id);
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
// restore id, transform, path effect, and style
repr->setAttribute("id", id);
- if (transform) repr->setAttribute("transform", transform);
+ if (transform) {
+ repr->setAttribute("transform", transform);
+ }
repr->setAttribute("style", style);
g_free(style);
repr->setAttribute("style", style);
g_free(style);
// set path data corresponding to new curve
gchar *dstring = sp_svg_write_path(curve->get_pathvector());
curve->unref();
// set path data corresponding to new curve
gchar *dstring = sp_svg_write_path(curve->get_pathvector());
curve->unref();
- if (path_effect)
+ if (path_effect) {
repr->setAttribute("inkscape:original-d", dstring);
repr->setAttribute("inkscape:original-d", dstring);
- else
+ } else {
repr->setAttribute("d", dstring);
repr->setAttribute("d", dstring);
+ }
g_free(dstring);
// add the new group to the parent of the topmost
g_free(dstring);
// add the new group to the parent of the topmost
// move to the position of the topmost, reduced by the number of deleted items
repr->setPosition(position > 0 ? position : 0);
// move to the position of the topmost, reduced by the number of deleted items
repr->setPosition(position > 0 ? position : 0);
- sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_COMBINE,
- _("Combine"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_COMBINE,
+ _("Combine"));
selection->set(repr);
selection->set(repr);
gint pos = SP_OBJECT_REPR(item)->position();
char const *id = SP_OBJECT_REPR(item)->attribute("id");
gint pos = SP_OBJECT_REPR(item)->position();
char const *id = SP_OBJECT_REPR(item)->attribute("id");
- gchar *style = g_strdup(SP_OBJECT(item)->repr->attribute("style"));
- gchar *path_effect = g_strdup(SP_OBJECT(item)->repr->attribute("inkscape:path-effect"));
+ // XML Tree being used directly here while it shouldn't be...
+ gchar *style = g_strdup(SP_OBJECT(item)->getRepr()->attribute("style"));
+ // XML Tree being used directly here while it shouldn't be...
+ gchar *path_effect = g_strdup(SP_OBJECT(item)->getRepr()->attribute("inkscape:path-effect"));
Geom::PathVector apv = curve->get_pathvector() * SP_ITEM(path)->transform;
Geom::PathVector apv = curve->get_pathvector() * SP_ITEM(path)->transform;
desktop->clearWaitingCursor();
if (did) {
desktop->clearWaitingCursor();
if (did) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_BREAK_APART,
- _("Break apart"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_BREAK_APART,
+ _("Break apart"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to break apart in the selection."));
}
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to break apart in the selection."));
}
if (interactive) {
desktop->clearWaitingCursor();
if (did) {
if (interactive) {
desktop->clearWaitingCursor();
if (did) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE,
- _("Object to path"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE,
+ _("Object to path"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No objects</b> to convert to path in the selection."));
return;
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No objects</b> to convert to path in the selection."));
return;
}
}
}
}
+/** Converts the selected items to LPEItems if they are not already so; e.g. SPRects) */
+void sp_selected_to_lpeitems(SPDesktop *desktop)
+{
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+
+ if (selection->isEmpty()) {
+ return;
+ }
+
+ bool did = false;
+
+ GSList *selected = g_slist_copy((GSList *) selection->itemList());
+ GSList *to_select = NULL;
+ selection->clear();
+ GSList *items = g_slist_copy(selected);
+
+ did = sp_item_list_to_curves(items, &selected, &to_select, true);
+
+ g_slist_free (items);
+ selection->setReprList(to_select);
+ selection->addList(selected);
+ g_slist_free (to_select);
+ g_slist_free (selected);
+}
+
bool
bool
-sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select)
+sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems)
{
bool did = false;
{
bool did = false;
@@ -330,6 +367,13 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec
SPItem *item = SP_ITEM(items->data);
SPDocument *document = item->document;
SPItem *item = SP_ITEM(items->data);
SPDocument *document = item->document;
+ if ( skip_all_lpeitems &&
+ SP_IS_LPE_ITEM(item) &&
+ !SP_IS_GROUP(item) ) // also convert objects in an SPGroup when skip_all_lpeitems is set.
+ {
+ continue;
+ }
+
if (SP_IS_PATH(item) && !SP_PATH(item)->original_curve) {
continue; // already a path, and no path effect
}
if (SP_IS_PATH(item) && !SP_PATH(item)->original_curve) {
continue; // already a path, and no path effect
}
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item)) {
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item)) {
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
}
if (!curve)
}
if (!curve)
desktop->clearWaitingCursor();
if (did) {
desktop->clearWaitingCursor();
if (did) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE,
- _("Reverse path"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE,
+ _("Reverse path"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection."));
}
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection."));
}
fill-column:99
End:
*/
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :