From 1636c1dd1651780d01759676b194312529f211f7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sat, 25 Jun 2016 22:24:26 +0200 Subject: Moved next functions, added namespace, renamed range functions (bzr r14954.1.10) --- src/splivarot.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 1bc6da3e1..d4ef3f9c2 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -335,7 +335,7 @@ void sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description) { SPDocument *doc = selection->layers()->getDocument(); - std::vector il= selection->itemList(); + std::vector il= selection->items(); // allow union on a single object for the purpose of removing self overlapse (svn log, revision 13334) if ( (il.size() < 2) && (bop != bool_op_union)) { @@ -689,7 +689,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } } else { // find out the bottom object - std::vector sorted(selection->reprList()); + std::vector sorted(selection->xmlNodes()); sort(sorted.begin(),sorted.end(),sp_repr_compare_position_bool); @@ -1157,7 +1157,7 @@ sp_selected_path_outline(SPDesktop *desktop) bool scale_stroke = prefs->getBool("/options/transform/stroke", true); prefs->setBool("/options/transform/stroke", true); bool did = false; - std::vector il(selection->itemList()); + std::vector il(selection->items()); for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = *l; @@ -1771,7 +1771,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) } bool did = false; - std::vector il(selection->itemList()); + std::vector il(selection->items()); for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = *l; SPCurve *curve = NULL; @@ -2196,7 +2196,7 @@ sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool ju return; } - std::vector items(selection->itemList()); + std::vector items(selection->items()); bool didSomething = sp_selected_path_simplify_items(desktop, selection, items, threshold, -- cgit v1.2.3 From 22262f2db6747eb516283b92abcfd348c700911a Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Fri, 1 Jul 2016 20:57:32 +0200 Subject: Added xmlNodes as range function (bzr r14954.1.12) --- src/splivarot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index d4ef3f9c2..09d74a010 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -689,7 +689,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } } else { // find out the bottom object - std::vector sorted(selection->xmlNodes()); + std::vector sorted(selection->xmlNodes().begin(), selection->xmlNodes().end()); sort(sorted.begin(),sorted.end(),sp_repr_compare_position_bool); -- cgit v1.2.3 From d1947e768272c703674129d5c583204ff2b59251 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 13 Jul 2016 13:36:19 +0200 Subject: Second part of new SPObject children list (bzr r14954.1.19) --- src/splivarot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index b1f324be2..4ac9143f0 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -883,9 +883,9 @@ void item_outline_add_marker_child( SPItem const *item, Geom::Affine marker_tran // note: a marker child item can be an item group! if (SP_IS_GROUP(item)) { // recurse through all childs: - for (SPObject const *o = item->firstChild() ; o ; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - item_outline_add_marker_child(SP_ITEM(o), tr, pathv_in); + for (auto& o: item->_children) { + if ( SP_IS_ITEM(&o) ) { + item_outline_add_marker_child(SP_ITEM(&o), tr, pathv_in); } } } else { -- cgit v1.2.3 From 24d3f50003ca3cec6a03a7f5267cc4fe5588c69f Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 13:17:21 +0200 Subject: Renamed children list in SPObject (bzr r14954.1.21) --- src/splivarot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 4ac9143f0..a4c4ac6cd 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -883,7 +883,7 @@ void item_outline_add_marker_child( SPItem const *item, Geom::Affine marker_tran // note: a marker child item can be an item group! if (SP_IS_GROUP(item)) { // recurse through all childs: - for (auto& o: item->_children) { + for (auto& o: item->children) { if ( SP_IS_ITEM(&o) ) { item_outline_add_marker_child(SP_ITEM(&o), tr, pathv_in); } -- cgit v1.2.3 From a227e8d45e7eaa6bf25d8ab65fbd404bc4597306 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 20 Jul 2016 13:45:05 +0200 Subject: Changed signatures of boolean functions (bzr r14954.1.24) --- src/splivarot.cpp | 170 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 106 insertions(+), 64 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index a4c4ac6cd..54b9bff2c 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -13,7 +13,6 @@ */ #ifdef HAVE_CONFIG_H -# include #endif #include @@ -23,14 +22,11 @@ #include "xml/repr.h" #include "svg/svg.h" #include "sp-path.h" -#include "sp-shape.h" #include "sp-image.h" #include "sp-marker.h" -#include "enums.h" #include "sp-text.h" #include "sp-flowtext.h" #include "text-editing.h" -#include "sp-item-group.h" #include "style.h" #include "document.h" #include "document-undo.h" @@ -38,15 +34,9 @@ #include "message-stack.h" #include "selection.h" -#include "desktop.h" -#include "display/canvas-bpath.h" -#include "display/curve.h" #include -#include "preferences.h" -#include "xml/repr.h" #include "xml/repr-sorting.h" -#include <2geom/pathvector.h> #include <2geom/svg-path-writer.h> #include "helper/geom.h" @@ -57,65 +47,96 @@ #include "verbs.h" #include "2geom/svg-path-parser.h" // to get from SVG on boolean to Geom::Path +enum BoolOpErrors { + DONE, + DONE_NO_PATH, + DONE_NO_ACTION, + ERR_TOO_LESS_PATHS_1, + ERR_TOO_LESS_PATHS_2, + ERR_NO_PATHS, + ERR_Z_ORDER +}; + using Inkscape::DocumentUndo; bool Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who); -void sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb=SP_VERB_NONE, const Glib::ustring description=""); +void sp_selected_path_boolop_ui(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, + const unsigned int verb = SP_VERB_NONE, const Glib::ustring description = ""); +BoolOpErrors sp_selected_path_boolop(Inkscape::ObjectSet *set, bool_op bop); void sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset); void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating); void sp_selected_path_union(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_union, SP_VERB_SELECTION_UNION, _("Union")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_union, SP_VERB_SELECTION_UNION, _("Union")); } void -sp_selected_path_union_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) +sp_selected_path_union_skip_undo(Inkscape::ObjectSet *set) { - sp_selected_path_boolop(selection, desktop, bool_op_union, SP_VERB_NONE, _("Union")); + sp_selected_path_boolop(set, bool_op_union); } void sp_selected_path_intersect(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection")); +} + +void +sp_selected_path_intersect_skip_undo(Inkscape::ObjectSet *set) +{ + sp_selected_path_boolop(set, bool_op_inters); } void sp_selected_path_diff(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference")); } void -sp_selected_path_diff_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) +sp_selected_path_diff_skip_undo(Inkscape::ObjectSet *set) { - sp_selected_path_boolop(selection, desktop, bool_op_diff, SP_VERB_NONE, _("Difference")); + sp_selected_path_boolop(set, bool_op_diff); } void sp_selected_path_symdiff(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion")); } + +void +sp_selected_path_symdiff_skip_undo(Inkscape::ObjectSet *set) +{ + sp_selected_path_boolop(set, bool_op_symdiff); +} + void sp_selected_path_cut(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division")); } void -sp_selected_path_cut_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) +sp_selected_path_cut_skip_undo(Inkscape::ObjectSet *set) { - sp_selected_path_boolop(selection, desktop, bool_op_cut, SP_VERB_NONE, _("Division")); + sp_selected_path_boolop(set, bool_op_cut); } void sp_selected_path_slice(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_slice, SP_VERB_SELECTION_SLICE, _("Cut path")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_slice, SP_VERB_SELECTION_SLICE, _("Cut path")); +} + +void +sp_selected_path_slice_skip_undo(Inkscape::ObjectSet *set) +{ + sp_selected_path_boolop(set, bool_op_slice); } // helper for printing error messages, regardless of whether we have a GUI or not @@ -331,20 +352,17 @@ Geom::PathVector pathliv_to_pathvector(Path *pathliv){ // boolean operations on the desktop // take the source paths from the file, do the operation, delete the originals and add the results -void -sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description) +BoolOpErrors sp_selected_path_boolop(Inkscape::ObjectSet * set, bool_op bop) { - SPDocument *doc = selection->layers()->getDocument(); - std::vector il(selection->items().begin(), selection->items().end()); - + SPDocument *doc = set->desktop()->getDocument(); + std::vector il(set->items().begin(), set->items().end()); + // allow union on a single object for the purpose of removing self overlapse (svn log, revision 13334) - if ( (il.size() < 2) && (bop != bool_op_union)) { - boolop_display_error_message(desktop, _("Select at least 2 paths to perform a boolean operation.")); - return; + if (il.size() < 2 && bop != bool_op_union) { + return ERR_TOO_LESS_PATHS_2; } - else if ( il.size() < 1 ) { - boolop_display_error_message(desktop, _("Select at least 1 path to perform a boolean union.")); - return; + else if (il.size() < 1) { + return ERR_TOO_LESS_PATHS_1; } g_assert(!il.empty()); @@ -360,8 +378,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool Inkscape::XML::Node *b = il.back()->getRepr(); if (a == NULL || b == NULL) { - boolop_display_error_message(desktop, _("Unable to determine the z-order of the objects selected for difference, XOR, division, or path cut.")); - return; + return ERR_Z_ORDER; } if (Ancetre(a, b)) { @@ -375,8 +392,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // find their lowest common ancestor Inkscape::XML::Node *parent = LCA(a, b); if (parent == NULL) { - boolop_display_error_message(desktop, _("Unable to determine the z-order of the objects selected for difference, XOR, division, or path cut.")); - return; + return ERR_Z_ORDER; } // find the children of the LCA that lead from it to the a and b @@ -405,8 +421,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool SPItem *item = *l; if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item) && !SP_IS_FLOWTEXT(item)) { - boolop_display_error_message(desktop, _("One of the objects is not a path, cannot perform boolean operation.")); - return; + return ERR_NO_PATHS; } } @@ -439,7 +454,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (originaux[curOrig] == NULL || originaux[curOrig]->descr_cmd.size() <= 1) { for (int i = curOrig; i >= 0; i--) delete originaux[i]; - return; + return DONE_NO_ACTION; } curOrig++; } @@ -500,18 +515,18 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool bool zeroA = theShapeA->numberOfEdges() == 0; bool zeroB = theShapeB->numberOfEdges() == 0; if (zeroA || zeroB) { - // We might need to do a swap. Apply the above rules depending on operation type. - bool resultIsB = ((bop == bool_op_union || bop == bool_op_symdiff) && zeroA) - || ((bop == bool_op_inters) && zeroB) - || (bop == bool_op_diff); + // We might need to do a swap. Apply the above rules depending on operation type. + bool resultIsB = ((bop == bool_op_union || bop == bool_op_symdiff) && zeroA) + || ((bop == bool_op_inters) && zeroB) + || (bop == bool_op_diff); if (resultIsB) { - // Swap A and B to use B as the result + // Swap A and B to use B as the result Shape *swap = theShapeB; theShapeB = theShapeA; theShapeA = swap; } } else { - // Just do the Boolean operation as usual + // Just do the Boolean operation as usual // les elements arrivent en ordre inverse dans la liste theShape->Booleen(theShapeB, theShapeA, bop); Shape *swap = theShape; @@ -672,24 +687,23 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ (*l)->deleteObject(); } - DocumentUndo::done(doc, SP_VERB_NONE, description); - selection->clear(); + set->clear(); delete res; - return; + return DONE_NO_PATH; } // get the source path object SPObject *source; if ( bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { if (reverseOrderForOp) { - source = il[0]; + source = il[0]; } else { - source = il.back(); + source = il.back(); } } else { // find out the bottom object - std::vector sorted(selection->xmlNodes().begin(), selection->xmlNodes().end()); + std::vector sorted(set->xmlNodes().begin(), set->xmlNodes().end()); sort(sorted.begin(),sorted.end(),sp_repr_compare_position_bool); @@ -717,7 +731,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool gchar *title = source->title(); gchar *desc = source->desc(); // remove source paths - selection->clear(); + set->clear(); for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ // if this is the bottommost object, if (!strcmp(reinterpret_cast(*l)->getRepr()->attribute("id"), id)) { @@ -796,7 +810,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // move to the saved position repr->setPosition(pos > 0 ? pos : 0); - selection->add(repr); + set->add(doc->getObjectByRepr(repr)); Inkscape::GC::release(repr); delete resPath[i]; @@ -824,14 +838,14 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool repr->setAttribute("id", id); parent->appendChild(repr); if (title) { - doc->getObjectByRepr(repr)->setTitle(title); - } + doc->getObjectByRepr(repr)->setTitle(title); + } if (desc) { - doc->getObjectByRepr(repr)->setDesc(desc); + doc->getObjectByRepr(repr)->setDesc(desc); } - repr->setPosition(pos > 0 ? pos : 0); + repr->setPosition(pos > 0 ? pos : 0); - selection->add(repr); + set->add(doc->getObjectByRepr(repr)); Inkscape::GC::release(repr); } @@ -839,11 +853,39 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (title) g_free(title); if (desc) g_free(desc); - if (verb != SP_VERB_NONE) { - DocumentUndo::done(doc, verb, description); - } - delete res; + + return DONE; +} + +void sp_selected_path_boolop_ui(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, + const Glib::ustring description) +{ + SPDocument *doc = selection->desktop()->getDocument(); + BoolOpErrors returnCode = sp_selected_path_boolop(selection, bop); + switch(returnCode) { + case ERR_TOO_LESS_PATHS_1: + boolop_display_error_message(desktop, _("Select at least 1 path to perform a boolean union.")); + return; + case ERR_TOO_LESS_PATHS_2: + boolop_display_error_message(desktop, _("Select at least 2 paths to perform a boolean operation.")); + return; + case ERR_NO_PATHS: + boolop_display_error_message(desktop, _("One of the objects is not a path, cannot perform boolean operation.")); + return; + case ERR_Z_ORDER: + boolop_display_error_message(desktop, _("Unable to determine the z-order of the objects selected for difference, XOR, division, or path cut.")); + return; + case DONE_NO_PATH: + DocumentUndo::done(doc, SP_VERB_NONE, description); + return; + case DONE: + DocumentUndo::done(doc, verb, description); + return; + case DONE_NO_ACTION: + default: + return; + } } static -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/splivarot.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index a8018f6c2..2edb52191 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -13,7 +13,6 @@ */ #ifdef HAVE_CONFIG_H -# include #endif #include @@ -23,14 +22,11 @@ #include "xml/repr.h" #include "svg/svg.h" #include "sp-path.h" -#include "sp-shape.h" #include "sp-image.h" #include "sp-marker.h" -#include "enums.h" #include "sp-text.h" #include "sp-flowtext.h" #include "text-editing.h" -#include "sp-item-group.h" #include "style.h" #include "document.h" #include "document-undo.h" @@ -39,14 +35,9 @@ #include "selection.h" #include "desktop.h" -#include "display/canvas-bpath.h" -#include "display/curve.h" #include -#include "preferences.h" -#include "xml/repr.h" #include "xml/repr-sorting.h" -#include <2geom/pathvector.h> #include <2geom/svg-path-writer.h> #include "helper/geom.h" -- cgit v1.2.3 From c95b03989b70f33ff3d54f2e644673ab518ac68b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 3 Aug 2016 22:41:01 +0200 Subject: Add legacy verb SP_VERB_SELECTION_OUTLINE_LEGACY as pointed in bug 1556592#14 (bzr r15036) --- src/splivarot.cpp | 83 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 36 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 2edb52191..c2e5a2f2e 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -841,7 +841,7 @@ static void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine marker_transform, Geom::Scale stroke_scale, Geom::Affine transform, Inkscape::XML::Node *g_repr, Inkscape::XML::Document *xml_doc, SPDocument * doc, - SPDesktop *desktop ) + SPDesktop *desktop , bool legacy) { SPMarker* marker = SP_MARKER (marker_object); SPItem* marker_item = sp_item_first_item_child(marker_object); @@ -865,7 +865,9 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine m_repr->setPosition(0); SPItem *marker_item = (SPItem *) doc->getObjectByRepr(m_repr); marker_item->doWriteTransform(m_repr, tr); - sp_item_path_outline(marker_item, desktop); + if (!legacy) { + sp_item_path_outline(marker_item, desktop, legacy); + } } } @@ -1140,7 +1142,7 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) } bool -sp_item_path_outline(SPItem *item, SPDesktop *desktop) +sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy) { bool did = false; Inkscape::Selection *selection = desktop->getSelection(); @@ -1150,10 +1152,13 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) } SPGroup *group = dynamic_cast(item); if (group) { + if (legacy) { + return false; + } std::vector const item_list = sp_item_group_item_list(group); for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { SPItem *subitem = *iter; - sp_item_path_outline(subitem, desktop); + sp_item_path_outline(subitem, desktop, legacy); } } else { if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) @@ -1375,23 +1380,24 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) g_repr->setPosition(pos > 0 ? pos : 0); //The fill - Inkscape::XML::Node *fill = NULL; - gchar const *f_val = sp_repr_css_property(ncsf, "fill", NULL); - if (f_val) { - fill = xml_doc->createElement("svg:path"); - sp_repr_css_change(fill, ncsf, "style"); - - sp_repr_css_attr_unref(ncsf); - - gchar *str = sp_svg_write_path( pathv ); - fill->setAttribute("d", str); - g_free(str); - - if (mask) - fill->setAttribute("mask", mask); - if (clip_path) - fill->setAttribute("clip-path", clip_path); + if (!legacy) { + gchar const *f_val = sp_repr_css_property(ncsf, "fill", NULL); + if (f_val) { + fill = xml_doc->createElement("svg:path"); + sp_repr_css_change(fill, ncsf, "style"); + + sp_repr_css_attr_unref(ncsf); + + gchar *str = sp_svg_write_path( pathv ); + fill->setAttribute("d", str); + g_free(str); + + if (mask) + fill->setAttribute("mask", mask); + if (clip_path) + fill->setAttribute("clip-path", clip_path); + } } // restore title, description, id, transform g_repr->setAttribute("id", id); @@ -1403,22 +1409,25 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) if (desc) { newitem->setDesc(desc); } - SPShape *shape = SP_SHAPE(item); Geom::PathVector const & pathv = curve->get_pathvector(); Inkscape::XML::Node *markers = NULL; if(SP_SHAPE(item)->hasMarkers ()) { - markers = xml_doc->createElement("svg:g"); - g_repr->appendChild(markers); - markers->setPosition(pos > 0 ? pos : 0); + if (!legacy) { + markers = xml_doc->createElement("svg:g"); + g_repr->appendChild(markers); + markers->setPosition(pos > 0 ? pos : 0); + } else { + markers = g_repr; + } // START marker for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START if ( SPObject *marker_obj = shape->_marker[i] ) { Geom::Affine const m (sp_shape_marker_get_transform_at_start(pathv.front().front())); sp_selected_path_outline_add_marker( marker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); } } // MID marker @@ -1433,7 +1442,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) Geom::Affine const m (sp_shape_marker_get_transform_at_start(path_it->front())); sp_selected_path_outline_add_marker( midmarker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); } // MID position if (path_it->size_default() > 1) { @@ -1448,7 +1457,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) Geom::Affine const m (sp_shape_marker_get_transform(*curve_it1, *curve_it2)); sp_selected_path_outline_add_marker( midmarker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); ++curve_it1; ++curve_it2; @@ -1460,7 +1469,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) Geom::Affine const m = sp_shape_marker_get_transform_at_end(lastcurve); sp_selected_path_outline_add_marker( midmarker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); } } } @@ -1479,18 +1488,20 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) Geom::Affine const m = sp_shape_marker_get_transform_at_end(lastcurve); sp_selected_path_outline_add_marker( marker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); } } - if (mask) - markers->setAttribute("mask", mask); - if (clip_path) - markers->setAttribute("clip-path", clip_path); + if (!legacy) { + if (mask) + markers->setAttribute("mask", mask); + if (clip_path) + markers->setAttribute("clip-path", clip_path); + } } gchar const *paint_order = sp_repr_css_property(ncss, "paint-order", NULL); SPIPaintOrder temp; temp.read( paint_order ); - if (temp.layer[0] != SP_CSS_PAINT_ORDER_NORMAL) { + if (temp.layer[0] != SP_CSS_PAINT_ORDER_NORMAL && !legacy) { if (temp.layer[0] == SP_CSS_PAINT_ORDER_FILL) { if (temp.layer[1] == SP_CSS_PAINT_ORDER_STROKE) { @@ -1615,7 +1626,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) } void -sp_selected_path_outline(SPDesktop *desktop) +sp_selected_path_outline(SPDesktop *desktop, bool legacy) { Inkscape::Selection *selection = desktop->getSelection(); @@ -1630,7 +1641,7 @@ sp_selected_path_outline(SPDesktop *desktop) std::vector il(selection->itemList()); for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = *l; - did = sp_item_path_outline(item, desktop); + did = sp_item_path_outline(item, desktop, legacy); } prefs->setBool("/options/transform/stroke", scale_stroke); -- cgit v1.2.3 From 31bb43ed5a135c1a65eadb30dd81b0de59bf2569 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 2 Sep 2016 21:32:55 +0200 Subject: Bug fixes to stroke to path pointed by CR (bzr r15100) --- src/splivarot.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 7a5df4c97..6b9fd5f83 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1197,6 +1197,8 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy) { bool did = false; Inkscape::Selection *selection = desktop->getSelection(); + SPDocument * doc = desktop->getDocument(); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); SPLPEItem *lpeitem = SP_LPE_ITEM(item); if (lpeitem) { lpeitem->removeAllPathEffects(true); @@ -1422,8 +1424,6 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy) } if (SP_IS_SHAPE(item)) { - SPDocument * doc = desktop->getDocument(); - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *g_repr = xml_doc->createElement("svg:g"); // add the group to the parent @@ -1435,7 +1435,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy) Inkscape::XML::Node *fill = NULL; if (!legacy) { gchar const *f_val = sp_repr_css_property(ncsf, "fill", NULL); - if (f_val) { + if( !item->style->fill.noneSet ){ fill = xml_doc->createElement("svg:path"); sp_repr_css_change(fill, ncsf, "style"); @@ -1637,14 +1637,21 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy) if( fill || stroke || markers ) { did = true; } + Inkscape::XML::Node *out = NULL; if (!fill && !markers) { - g_repr = stroke; - } - if (!fill && !stroke) { - g_repr = markers; - } - if (!markers && !stroke) { - g_repr = fill; + out = stroke; + parent->mergeFrom(g_repr, ""); + parent->removeChild(g_repr); + } else if (!fill && !stroke) { + out = markers; + parent->mergeFrom(g_repr, ""); + parent->removeChild(g_repr); + } else if (!markers && !stroke) { + out = fill; + parent->mergeFrom(g_repr, ""); + parent->removeChild(g_repr); + } else { + out = g_repr; } //bug lp:1290573 : completely destroy the old object first @@ -1653,7 +1660,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy) if( selection->includes(item) ){ selection->remove(item); item->deleteObject(false); - selection->add(g_repr); + selection->add(out); } else { item->deleteObject(false); } -- cgit v1.2.3