diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 3b5cd31364718eee2e84d029a2c2aee866a4045d..12913fd858d97fc53900b32ec71f8f4c97fe8aa4 100644 (file)
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
sp_selected_path_combine(SPDesktop *desktop)
{
Inkscape::Selection *selection = sp_desktop_selection(desktop);
- Document *doc = sp_desktop_document(desktop);
+ SPDocument *doc = sp_desktop_document(desktop);
if (g_slist_length((GSList *) selection->itemList()) < 1) {
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine."));
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;
- 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
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);
+ // delete the topmost.
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
// 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,
+ SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_COMBINE,
_("Combine"));
selection->set(repr);
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;
desktop->clearWaitingCursor();
if (did) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_BREAK_APART,
+ SPDocumentUndo::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."));
if (interactive) {
desktop->clearWaitingCursor();
if (did) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE,
+ SPDocumentUndo::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."));
}
}
+/** 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
-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;
@@ -328,7 +360,14 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec
items = items->next) {
SPItem *item = SP_ITEM(items->data);
- Document *document = item->document;
+ 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
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item)) {
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
}
if (!curve)
desktop->clearWaitingCursor();
if (did) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE,
+ SPDocumentUndo::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."));