=== modified file 'share/keys/default.xml'
--- share/keys/default.xml 2016-10-08 06:16:53 +0000
+++ share/keys/default.xml 2017-01-21 19:17:04 +0000
@@ -383,6 +383,8 @@
+
+
=== modified file 'share/keys/inkscape.xml'
--- share/keys/inkscape.xml 2016-10-08 06:16:53 +0000
+++ share/keys/inkscape.xml 2017-01-19 20:23:51 +0000
@@ -382,6 +382,7 @@
+
=== modified file 'src/object-set.h'
--- src/object-set.h 2016-11-09 00:23:41 +0000
+++ src/object-set.h 2017-01-21 01:25:56 +0000
@@ -447,7 +447,7 @@
// various
void getExportHints(Glib::ustring &filename, float *xdpi, float *ydpi);
bool fitCanvas(bool with_margins, bool skip_undo = false);
-
+ void swapFillStroke();
protected:
virtual void _connectSignals(SPObject* object) {};
=== modified file 'src/selection-chemistry.cpp'
--- src/selection-chemistry.cpp 2016-11-06 22:07:52 +0000
+++ src/selection-chemistry.cpp 2017-01-21 20:31:23 +0000
@@ -97,6 +97,7 @@
#include "live_effects/parameter/originalpath.h"
#include "layer-manager.h"
#include "object-set.h"
+#include "svg/svg-color.h"
// For clippath editing
#include "ui/tools/node-tool.h"
@@ -1242,7 +1243,6 @@
}
}
-
void ObjectSet::pastePathEffect()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
@@ -4169,6 +4169,75 @@
}
}
+void ObjectSet::swapFillStroke()
+{
+ if (desktop() == NULL) {
+ return;
+ }
+
+ SPIPaint *paint;
+ SPPaintServer *server;
+ Glib::ustring _paintserver_id;
+
+ auto list= items();
+ for (auto itemlist=list.begin();itemlist!=list.end();++itemlist) {
+ SPItem *item = *itemlist;
+
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+
+ _paintserver_id.clear();
+ paint = &(item->style->fill);
+ if (paint->set && paint->isNone())
+ sp_repr_css_set_property (css, "stroke", "none");
+ else if (paint->set && paint->isColor()) {
+ guint32 color = paint->value.color.toRGBA32(SP_SCALE24_TO_FLOAT (item->style->fill_opacity.value));
+ gchar c[64];
+ sp_svg_write_color (c, sizeof(c), color);
+ sp_repr_css_set_property (css, "stroke", c);
+ }
+ else if (!paint->set)
+ sp_repr_css_unset_property (css, "stroke");
+ else if (paint->set && paint->isPaintserver()) {
+ server = SP_STYLE_FILL_SERVER(item->style);
+ if (server) {
+ Inkscape::XML::Node *srepr = server->getRepr();
+ _paintserver_id += "url(#";
+ _paintserver_id += srepr->attribute("id");
+ _paintserver_id += ")";
+ sp_repr_css_set_property (css, "stroke", _paintserver_id.c_str());
+ }
+ }
+
+ _paintserver_id.clear();
+ paint = &(item->style->stroke);
+ if (paint->set && paint->isNone())
+ sp_repr_css_set_property (css, "fill", "none");
+ else if (paint->set && paint->isColor()) {
+ guint32 color = paint->value.color.toRGBA32(SP_SCALE24_TO_FLOAT (item->style->stroke_opacity.value));
+ gchar c[64];
+ sp_svg_write_color (c, sizeof(c), color);
+ sp_repr_css_set_property (css, "fill", c);
+ }
+ else if (!paint->set)
+ sp_repr_css_unset_property (css, "fill");
+ else if (paint->set && paint->isPaintserver()) {
+ server = SP_STYLE_STROKE_SERVER(item->style);
+ if (server) {
+ Inkscape::XML::Node *srepr = server->getRepr();
+ _paintserver_id += "url(#";
+ _paintserver_id += srepr->attribute("id");
+ _paintserver_id += ")";
+ sp_repr_css_set_property (css, "fill", _paintserver_id.c_str());
+ }
+ }
+
+ sp_desktop_apply_css_recursive(item, css, true);
+ sp_repr_css_attr_unref (css);
+ }
+
+ DocumentUndo::done(document(), SP_VERB_EDIT_SWAP_FILL_STROKE,
+ _("Swap fill and stroke of an object"));
+}
/**
* \param with_margins margins defined in the xml under
=== modified file 'src/ui/widget/selected-style.cpp'
--- src/ui/widget/selected-style.cpp 2016-11-09 08:10:41 +0000
+++ src/ui/widget/selected-style.cpp 2017-01-21 21:43:22 +0000
@@ -781,62 +781,7 @@
}
void SelectedStyle::on_fillstroke_swap() {
- SPCSSAttr *css = sp_repr_css_attr_new ();
-
- switch (_mode[SS_FILL]) {
- case SS_NA:
- case SS_MANY:
- break;
- case SS_NONE:
- sp_repr_css_set_property (css, "stroke", "none");
- break;
- case SS_UNSET:
- sp_repr_css_unset_property (css, "stroke");
- break;
- case SS_COLOR:
- gchar c[64];
- sp_svg_write_color (c, sizeof(c), _thisselected[SS_FILL]);
- sp_repr_css_set_property (css, "stroke", c);
- break;
- case SS_LGRADIENT:
- case SS_RGRADIENT:
-#ifdef WITH_MESH
- case SS_MGRADIENT:
-#endif
- case SS_PATTERN:
- sp_repr_css_set_property (css, "stroke", _paintserver_id[SS_FILL].c_str());
- break;
- }
-
- switch (_mode[SS_STROKE]) {
- case SS_NA:
- case SS_MANY:
- break;
- case SS_NONE:
- sp_repr_css_set_property (css, "fill", "none");
- break;
- case SS_UNSET:
- sp_repr_css_unset_property (css, "fill");
- break;
- case SS_COLOR:
- gchar c[64];
- sp_svg_write_color (c, sizeof(c), _thisselected[SS_STROKE]);
- sp_repr_css_set_property (css, "fill", c);
- break;
- case SS_LGRADIENT:
- case SS_RGRADIENT:
-#ifdef WITH_MESH
- case SS_MGRADIENT:
-#endif
- case SS_PATTERN:
- sp_repr_css_set_property (css, "fill", _paintserver_id[SS_STROKE].c_str());
- break;
- }
-
- sp_desktop_set_style (_desktop, css);
- sp_repr_css_attr_unref (css);
- DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
- _("Swap fill and stroke"));
+ _desktop->getSelection()->swapFillStroke();
}
void SelectedStyle::on_fill_edit() {
=== modified file 'src/verbs.cpp'
--- src/verbs.cpp 2016-12-27 15:49:22 +0000
+++ src/verbs.cpp 2017-01-21 01:25:24 +0000
@@ -1086,6 +1086,9 @@
case SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER:
sp_selection_next_patheffect_param(dt);
break;
+ case SP_VERB_EDIT_SWAP_FILL_STROKE:
+ dt->selection->swapFillStroke();
+ break;
case SP_VERB_EDIT_LINK_COLOR_PROFILE:
break;
case SP_VERB_EDIT_REMOVE_COLOR_PROFILE:
@@ -2585,6 +2588,8 @@
N_("Create four guides aligned with the page borders"), NULL),
new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next path effect parameter"),
N_("Show next editable path effect parameter"), INKSCAPE_ICON("path-effect-parameter-next")),
+ new EditVerb(SP_VERB_EDIT_SWAP_FILL_STROKE, "EditSwapFillStroke", N_("Swap fill and stroke"),
+ N_("Swap fill and stroke of an object"), NULL),
// Selection
new SelectionVerb(SP_VERB_SELECTION_TO_FRONT, "SelectionToFront", N_("Raise to _Top"),
=== modified file 'src/verbs.h'
--- src/verbs.h 2016-10-27 17:13:05 +0000
+++ src/verbs.h 2017-01-18 14:49:35 +0000
@@ -110,6 +110,7 @@
SP_VERB_EDIT_GUIDES_TOGGLE_LOCK,
SP_VERB_EDIT_GUIDES_AROUND_PAGE,
SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER,
+ SP_VERB_EDIT_SWAP_FILL_STROKE,
/* Selection */
SP_VERB_SELECTION_TO_FRONT,
SP_VERB_SELECTION_TO_BACK,