summaryrefslogtreecommitdiffstats
path: root/src/selection-chemistry.cpp
diff options
context:
space:
mode:
authoralexandru.roman <alexroman5g@gmail.com>2017-01-21 22:28:05 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2017-01-21 22:28:05 +0000
commite8dcb5062f6114a9fb06d496ab5d906aec405c78 (patch)
treea65d2125ceae6bd4ee9f5074962755e932dadaf1 /src/selection-chemistry.cpp
parentFixes typos in strings. Some typos in Inkscape 0.92 LPE UI (diff)
downloadinkscape-e8dcb5062f6114a9fb06d496ab5d906aec405c78.tar.gz
inkscape-e8dcb5062f6114a9fb06d496ab5d906aec405c78.zip
Fix "swap fill and stroke" for multiple objects in selection
Add verb and shortcut possibility Fixed bugs: - https://launchpad.net/bugs/367360 - https://launchpad.net/bugs/675690 (bzr r15428)
Diffstat (limited to 'src/selection-chemistry.cpp')
-rw-r--r--src/selection-chemistry.cpp71
1 files changed, 70 insertions, 1 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index f8ab33ac4..67972cabb 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -97,6 +97,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#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::pasteStyle()
}
}
-
void ObjectSet::pastePathEffect()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
@@ -4169,6 +4169,75 @@ bool ObjectSet::fitCanvas(bool with_margins, bool skip_undo)
}
}
+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 <sodipodi:namedview>