X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fpath-chemistry.cpp;h=7eb84b13724df0aa7770af83f9eb440bb333da7e;hb=03a65c733a473cd92d50132961d02c3910417f72;hp=1cd7480aa6692a5fd459f3997cec650d9a69a0eb;hpb=fdc44da6a01ea7605271feed15df61005ddd0219;p=inkscape.git diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 1cd7480aa..7eb84b137 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -19,6 +19,7 @@ #include "xml/repr.h" #include "svg/svg.h" #include "display/curve.h" +#include #include #include "sp-path.h" #include "sp-text.h" @@ -27,14 +28,16 @@ #include "text-editing.h" #include "style.h" #include "inkscape.h" +#include "desktop.h" #include "document.h" #include "message-stack.h" #include "selection.h" #include "desktop-handles.h" +#include "path-chemistry.h" + /* Helper functions for sp_selected_path_to_curves */ static void sp_selected_path_to_curves0(gboolean do_document_done, guint32 text_grouping_policy); -static Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy); enum { /* Not used yet. This is the placeholder of Lauris's idea. */ SP_TOCURVE_INTERACTIVE = 1 << 0, @@ -98,7 +101,7 @@ sp_selected_path_combine(void) NArtBpath *abp = nr_artpath_affine(SP_CURVE_BPATH(c), SP_ITEM(path)->transform); sp_curve_unref(c); gchar *str = sp_svg_write_path(abp); - nr_free(abp); + g_free(abp); dstring = g_string_append(dstring, str); g_free(str); @@ -117,7 +120,8 @@ sp_selected_path_combine(void) g_slist_free(items); - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); // restore id repr->setAttribute("id", id); @@ -134,7 +138,8 @@ sp_selected_path_combine(void) // move to the position of the topmost, reduced by the number of deleted items repr->setPosition(topmost > 0 ? topmost + 1 : 0); - sp_document_done(sp_desktop_document(desktop)); + sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_COMBINE, + _("Combine")); selection->set(repr); @@ -192,10 +197,11 @@ sp_selected_path_break_apart(void) sp_curve_unref(curve); - for (GSList *l = g_slist_reverse(list); l != NULL; l = l->next) { + GSList *reprs = NULL; + for (GSList *l = list; l != NULL; l = l->next) { curve = (SPCurve *) l->data; - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Node *repr = parent->document()->createElement("svg:path"); repr->setAttribute("style", style); gchar *str = sp_svg_write_path(SP_CURVE_BPATH(curve)); @@ -212,18 +218,22 @@ sp_selected_path_break_apart(void) if (l == list) repr->setAttribute("id", id); - selection->add(repr); + reprs = g_slist_prepend (reprs, repr); Inkscape::GC::release(repr); } + selection->setReprList(reprs); + + g_slist_free(reprs); g_slist_free(list); g_free(style); } if (did) { - sp_document_done(sp_desktop_document(desktop)); + sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_BREAK_APART, + _("Break apart")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No path(s) to break apart in the selection.")); return; @@ -273,7 +283,7 @@ sp_selected_path_to_curves0(gboolean interactive, guint32 text_grouping_policy) selection->remove(item); - // it's going to resurrect, so we delete without advertisement + // It's going to resurrect, so we delete without notifying listeners. SP_OBJECT(item)->deleteObject(false); // restore id @@ -283,13 +293,16 @@ sp_selected_path_to_curves0(gboolean interactive, guint32 text_grouping_policy) // move to the saved position repr->setPosition(pos > 0 ? pos : 0); + /* Buglet: We don't re-add the (new version of the) object to the selection of any other + * desktops where it was previously selected. */ selection->add(repr); Inkscape::GC::release(repr); } if (interactive) { if (did) { - sp_document_done(sp_desktop_document(desktop)); + sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE, + _("Object to path")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No objects to convert to path in the selection.")); return; @@ -297,7 +310,7 @@ sp_selected_path_to_curves0(gboolean interactive, guint32 text_grouping_policy) } } -static Inkscape::XML::Node * +Inkscape::XML::Node * sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy) { if (!item) @@ -313,7 +326,8 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy) if (!curve) return NULL; - Inkscape::XML::Node *repr = sp_repr_new("svg:path"); + Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(item)->document(); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); /* Transformation */ repr->setAttribute("transform", SP_OBJECT_REPR(item)->attribute("transform")); /* Style */ @@ -321,6 +335,17 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy) SP_OBJECT_STYLE(SP_OBJECT_PARENT(item))); repr->setAttribute("style", style_str); g_free(style_str); + + /* Mask */ + gchar *mask_str = (gchar *) SP_OBJECT_REPR(item)->attribute("mask"); + if ( mask_str ) + repr->setAttribute("mask", mask_str); + + /* Clip path */ + gchar *clip_path_str = (gchar *) SP_OBJECT_REPR(item)->attribute("clip-path"); + if ( clip_path_str ) + repr->setAttribute("clip-path", clip_path_str); + /* Rotation center */ sp_repr_set_attr(repr, "inkscape:transform-center-x", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-x")); sp_repr_set_attr(repr, "inkscape:transform-center-y", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-y")); @@ -366,7 +391,8 @@ sp_selected_path_reverse() } if (did) { - sp_document_done(sp_desktop_document(desktop)); + sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE, + _("Reverse path")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No paths to reverse in the selection.")); }