diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index edb925135b3169f97079d08a3be358a3a5199abc..2afcd610958061c993ea5ee53304a946cadd41ba 100644 (file)
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
#include "desktop-style.h"
#include "svg/svg-icc-color.h"
+#include "svg/svg-device-color.h"
#include "box3d-side.h"
/**
@@ -344,7 +345,7 @@ sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib:
if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
sp_repr_css_set(repr, css_current, "style");
} else {
- SPCSSAttr *css = prefs->getStyle(tool_path + "/style");
+ SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style");
sp_repr_css_set(repr, css, "style");
sp_repr_css_attr_unref(css);
}
@@ -432,6 +433,8 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill
paint_res->set = TRUE;
SVGICCColor* iccColor = 0;
+ SVGDeviceColor* devColor = 0;
+
bool iccSeen = false;
gfloat c[4];
c[0] = c[1] = c[2] = c[3] = 0.0;
@@ -529,6 +532,23 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill
c[1] += d[1];
c[2] += d[2];
c[3] += SP_SCALE24_TO_FLOAT (isfill? style->fill_opacity.value : style->stroke_opacity.value);
+
+ // average device color
+ unsigned int it;
+ if (i==objects /*if this is the first object in the GList*/
+ && paint->value.color.device){
+ devColor = new SVGDeviceColor(*paint->value.color.device);
+ for (it=0; it < paint->value.color.device->colors.size(); it++){
+ devColor->colors[it] = 0;
+ }
+ }
+
+ if (devColor && paint->value.color.device && paint->value.color.device->type == devColor->type){
+ for (it=0; it < paint->value.color.device->colors.size(); it++){
+ devColor->colors[it] += paint->value.color.device->colors[it];
+ }
+ }
+
num ++;
}
@@ -568,6 +588,14 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill
paint_res->value.color.icc = tmp;
}
+ // divide and store the device-color
+ if (devColor){
+ for (unsigned int it=0; it < devColor->colors.size(); it++){
+ devColor->colors[it] /= num;
+ }
+ paint_res->value.color.device = devColor;
+ }
+
if (num > 1) {
if (same_color)
return QUERY_STYLE_MULTIPLE_SAME;
return ret; // subselection returned a style, pass it on
// otherwise, do querying and averaging over selection
- return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property);
+ if (desktop->selection != NULL) {
+ return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property);
+ }
+
+ return QUERY_STYLE_NOTHING;
}
/**