1 #define __SP_DESKTOP_STYLE_C__
3 /** \file
4 * Desktop style management
5 *
6 * Authors:
7 * bulia byak
8 * verbalshadow
9 *
10 * Copyright (C) 2004, 2006 authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #include <string>
16 #include <cstring>
18 #include "desktop.h"
19 #include "color-rgba.h"
20 #include "svg/css-ostringstream.h"
21 #include "svg/svg.h"
22 #include "svg/svg-color.h"
23 #include "selection.h"
24 #include "inkscape.h"
25 #include "style.h"
26 #include "preferences.h"
27 #include "sp-use.h"
28 #include "filters/blend.h"
29 #include "sp-filter.h"
30 #include "sp-filter-reference.h"
31 #include "sp-gaussian-blur.h"
32 #include "sp-flowtext.h"
33 #include "sp-flowregion.h"
34 #include "sp-flowdiv.h"
35 #include "sp-linear-gradient.h"
36 #include "sp-pattern.h"
37 #include "sp-radial-gradient.h"
38 #include "sp-textpath.h"
39 #include "sp-tref.h"
40 #include "sp-tspan.h"
41 #include "xml/repr.h"
42 #include "libnrtype/font-style-to-pos.h"
43 #include "sp-path.h"
45 #include "desktop-style.h"
46 #include "svg/svg-icc-color.h"
47 #include "svg/svg-device-color.h"
48 #include "box3d-side.h"
50 /**
51 * Set color on selection on desktop.
52 */
53 void
54 sp_desktop_set_color(SPDesktop *desktop, ColorRGBA const &color, bool is_relative, bool fill)
55 {
56 /// \todo relative color setting
57 if (is_relative) {
58 g_warning("FIXME: relative color setting not yet implemented");
59 return;
60 }
62 guint32 rgba = SP_RGBA32_F_COMPOSE(color[0], color[1], color[2], color[3]);
63 gchar b[64];
64 sp_svg_write_color(b, sizeof(b), rgba);
65 SPCSSAttr *css = sp_repr_css_attr_new();
66 if (fill) {
67 sp_repr_css_set_property(css, "fill", b);
68 Inkscape::CSSOStringStream osalpha;
69 osalpha << color[3];
70 sp_repr_css_set_property(css, "fill-opacity", osalpha.str().c_str());
71 } else {
72 sp_repr_css_set_property(css, "stroke", b);
73 Inkscape::CSSOStringStream osalpha;
74 osalpha << color[3];
75 sp_repr_css_set_property(css, "stroke-opacity", osalpha.str().c_str());
76 }
78 sp_desktop_set_style(desktop, css);
80 sp_repr_css_attr_unref(css);
81 }
83 /**
84 * Apply style on object and children, recursively.
85 */
86 void
87 sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
88 {
89 // non-items should not have style
90 if (!SP_IS_ITEM(o))
91 return;
93 // 1. tspans with role=line are not regular objects in that they are not supposed to have style of their own,
94 // but must always inherit from the parent text. Same for textPath.
95 // However, if the line tspan or textPath contains some style (old file?), we reluctantly set our style to it too.
97 // 2. Generally we allow setting style on clones, but when it's inside flowRegion, do not touch
98 // it, be it clone or not; it's just styleless shape (because that's how Inkscape does
99 // flowtext).
101 if (!(skip_lines
102 && ((SP_IS_TSPAN(o) && SP_TSPAN(o)->role == SP_TSPAN_ROLE_LINE)
103 || SP_IS_FLOWDIV(o)
104 || SP_IS_FLOWPARA(o)
105 || SP_IS_TEXTPATH(o))
106 && !SP_OBJECT_REPR(o)->attribute("style"))
107 &&
108 !(SP_IS_FLOWREGION(o) ||
109 SP_IS_FLOWREGIONEXCLUDE(o) ||
110 (SP_IS_USE(o) &&
111 SP_OBJECT_PARENT(o) &&
112 (SP_IS_FLOWREGION(SP_OBJECT_PARENT(o)) ||
113 SP_IS_FLOWREGIONEXCLUDE(SP_OBJECT_PARENT(o))
114 )
115 )
116 )
117 ) {
119 SPCSSAttr *css_set = sp_repr_css_attr_new();
120 sp_repr_css_merge(css_set, css);
122 // Scale the style by the inverse of the accumulated parent transform in the paste context.
123 {
124 Geom::Matrix const local(sp_item_i2doc_affine(SP_ITEM(o)));
125 double const ex(local.descrim());
126 if ( ( ex != 0. )
127 && ( ex != 1. ) ) {
128 sp_css_attr_scale(css_set, 1/ex);
129 }
130 }
132 sp_repr_css_change(SP_OBJECT_REPR(o), css_set, "style");
134 sp_repr_css_attr_unref(css_set);
135 }
137 // setting style on child of clone spills into the clone original (via shared repr), don't do it!
138 if (SP_IS_USE(o))
139 return;
141 for (SPObject *child = sp_object_first_child(SP_OBJECT(o)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
142 if (sp_repr_css_property(css, "opacity", NULL) != NULL) {
143 // Unset properties which are accumulating and thus should not be set recursively.
144 // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group.
145 SPCSSAttr *css_recurse = sp_repr_css_attr_new();
146 sp_repr_css_merge(css_recurse, css);
147 sp_repr_css_set_property(css_recurse, "opacity", NULL);
148 sp_desktop_apply_css_recursive(child, css_recurse, skip_lines);
149 sp_repr_css_attr_unref(css_recurse);
150 } else {
151 sp_desktop_apply_css_recursive(child, css, skip_lines);
152 }
153 }
154 }
156 /**
157 * Apply style on selection on desktop.
158 */
159 void
160 sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current)
161 {
162 if (write_current) {
163 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
164 // 1. Set internal value
165 sp_repr_css_merge(desktop->current, css);
167 // 1a. Write to prefs; make a copy and unset any URIs first
168 SPCSSAttr *css_write = sp_repr_css_attr_new();
169 sp_repr_css_merge(css_write, css);
170 sp_css_attr_unset_uris(css_write);
171 prefs->mergeStyle("/desktop/style", css_write);
173 for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) {
174 /* last used styles for 3D box faces are stored separately */
175 if (SP_IS_BOX3D_SIDE (i->data)) {
176 const char * descr = box3d_side_axes_string(SP_BOX3D_SIDE(i->data));
177 if (descr != NULL) {
178 prefs->mergeStyle(Glib::ustring("/desktop/") + descr + "/style", css_write);
179 }
180 }
181 }
182 sp_repr_css_attr_unref(css_write);
183 }
185 if (!change)
186 return;
188 // 2. Emit signal
189 bool intercepted = desktop->_set_style_signal.emit(css);
191 /** \todo
192 * FIXME: in set_style, compensate pattern and gradient fills, stroke width,
193 * rect corners, font size for the object's own transform so that pasting
194 * fills does not depend on preserve/optimize.
195 */
197 // 3. If nobody has intercepted the signal, apply the style to the selection
198 if (!intercepted) {
199 for (GSList const *i = desktop->selection->itemList(); i != NULL; i = i->next) {
200 /// \todo if the style is text-only, apply only to texts?
201 sp_desktop_apply_css_recursive(SP_OBJECT(i->data), css, true);
202 }
203 }
204 }
206 /**
207 * Return the desktop's current style.
208 */
209 SPCSSAttr *
210 sp_desktop_get_style(SPDesktop *desktop, bool with_text)
211 {
212 SPCSSAttr *css = sp_repr_css_attr_new();
213 sp_repr_css_merge(css, desktop->current);
214 if (!css->attributeList()) {
215 sp_repr_css_attr_unref(css);
216 return NULL;
217 } else {
218 if (!with_text) {
219 css = sp_css_attr_unset_text(css);
220 }
221 return css;
222 }
223 }
225 /**
226 * Return the desktop's current color.
227 */
228 guint32
229 sp_desktop_get_color(SPDesktop *desktop, bool is_fill)
230 {
231 guint32 r = 0; // if there's no color, return black
232 gchar const *property = sp_repr_css_property(desktop->current,
233 is_fill ? "fill" : "stroke",
234 "#000");
236 if (desktop->current && property) { // if there is style and the property in it,
237 if (strncmp(property, "url", 3)) { // and if it's not url,
238 // read it
239 r = sp_svg_read_color(property, r);
240 }
241 }
243 return r;
244 }
246 double
247 sp_desktop_get_master_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool *has_opacity)
248 {
249 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
250 SPCSSAttr *css = NULL;
251 gfloat value = 1.0; // default if nothing else found
252 if (has_opacity)
253 *has_opacity = false;
254 if (prefs->getBool(tool + "/usecurrent")) {
255 css = sp_desktop_get_style(desktop, true);
256 } else {
257 css = prefs->getStyle(tool + "/style");
258 }
260 if (css) {
261 gchar const *property = css ? sp_repr_css_property(css, "opacity", "1.000") : 0;
263 if (desktop->current && property) { // if there is style and the property in it,
264 if ( !sp_svg_number_read_f(property, &value) ) {
265 value = 1.0; // things failed. set back to the default
266 } else {
267 if (has_opacity)
268 *has_opacity = false;
269 }
270 }
272 sp_repr_css_attr_unref(css);
273 }
275 return value;
276 }
277 double
278 sp_desktop_get_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill)
279 {
280 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
281 SPCSSAttr *css = NULL;
282 gfloat value = 1.0; // default if nothing else found
283 if (prefs->getBool(tool + "/usecurrent")) {
284 css = sp_desktop_get_style(desktop, true);
285 } else {
286 css = prefs->getStyle(tool + "/style");
287 }
289 if (css) {
290 gchar const *property = css ? sp_repr_css_property(css, is_fill ? "fill-opacity": "stroke-opacity", "1.000") : 0;
292 if (desktop->current && property) { // if there is style and the property in it,
293 if ( !sp_svg_number_read_f(property, &value) ) {
294 value = 1.0; // things failed. set back to the default
295 }
296 }
298 sp_repr_css_attr_unref(css);
299 }
301 return value;
302 }
304 guint32
305 sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill, bool *has_color)
306 {
307 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
308 SPCSSAttr *css = NULL;
309 guint32 r = 0; // if there's no color, return black
310 if (has_color)
311 *has_color = false;
312 if (prefs->getBool(tool + "/usecurrent")) {
313 css = sp_desktop_get_style(desktop, true);
314 } else {
315 css = prefs->getStyle(tool + "/style");
316 }
318 if (css) {
319 gchar const *property = sp_repr_css_property(css, is_fill ? "fill" : "stroke", "#000");
321 if (desktop->current && property) { // if there is style and the property in it,
322 if (strncmp(property, "url", 3) && strncmp(property, "none", 4)) { // and if it's not url or none,
323 // read it
324 r = sp_svg_read_color(property, r);
325 if (has_color)
326 *has_color = true;
327 }
328 }
330 sp_repr_css_attr_unref(css);
331 }
333 return r | 0xff;
334 }
336 /**
337 * Apply the desktop's current style or the tool style to repr.
338 */
339 void
340 sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool_path, bool with_text)
341 {
342 SPCSSAttr *css_current = sp_desktop_get_style(desktop, with_text);
343 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
345 if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
346 sp_repr_css_set(repr, css_current, "style");
347 } else {
348 SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style");
349 sp_repr_css_set(repr, css, "style");
350 sp_repr_css_attr_unref(css);
351 }
352 if (css_current) {
353 sp_repr_css_attr_unref(css_current);
354 }
355 }
357 /**
358 * Returns the font size (in SVG pixels) of the text tool style (if text
359 * tool uses its own style) or desktop style (otherwise).
360 */
361 double
362 sp_desktop_get_font_size_tool(SPDesktop *desktop)
363 {
364 (void)desktop; // TODO cleanup
365 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
366 Glib::ustring desktop_style = prefs->getString("/desktop/style");
367 Glib::ustring style_str;
368 if ((prefs->getBool("/tools/text/usecurrent")) && !desktop_style.empty()) {
369 style_str = desktop_style;
370 } else {
371 style_str = prefs->getString("/tools/text/style");
372 }
374 double ret = 12;
375 if (!style_str.empty()) {
376 SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT);
377 sp_style_merge_from_style_string(style, style_str.data());
378 ret = style->font_size.computed;
379 sp_style_unref(style);
380 }
381 return ret;
382 }
384 /** Determine average stroke width, simple method */
385 // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually
386 gdouble
387 stroke_average_width (GSList const *objects)
388 {
389 if (g_slist_length ((GSList *) objects) == 0)
390 return NR_HUGE;
392 gdouble avgwidth = 0.0;
393 bool notstroked = true;
394 int n_notstroked = 0;
396 for (GSList const *l = objects; l != NULL; l = l->next) {
397 if (!SP_IS_ITEM (l->data))
398 continue;
400 Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data));
402 SPObject *object = SP_OBJECT(l->data);
404 if ( object->style->stroke.isNone() ) {
405 ++n_notstroked; // do not count nonstroked objects
406 continue;
407 } else {
408 notstroked = false;
409 }
411 avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * i2d.descrim();
412 }
414 if (notstroked)
415 return NR_HUGE;
417 return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked);
418 }
420 /**
421 * Write to style_res the average fill or stroke of list of objects, if applicable.
422 */
423 int
424 objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill)
425 {
426 if (g_slist_length(objects) == 0) {
427 /* No objects, set empty */
428 return QUERY_STYLE_NOTHING;
429 }
431 SPIPaint *paint_res = isfill? &style_res->fill : &style_res->stroke;
432 bool paintImpossible = true;
433 paint_res->set = TRUE;
435 SVGICCColor* iccColor = 0;
436 SVGDeviceColor* devColor = 0;
438 bool iccSeen = false;
439 gfloat c[4];
440 c[0] = c[1] = c[2] = c[3] = 0.0;
441 gint num = 0;
443 gfloat prev[3];
444 prev[0] = prev[1] = prev[2] = 0.0;
445 bool same_color = true;
447 for (GSList const *i = objects; i != NULL; i = i->next) {
448 SPObject *obj = SP_OBJECT (i->data);
449 SPStyle *style = SP_OBJECT_STYLE (obj);
450 if (!style) continue;
452 SPIPaint *paint = isfill? &style->fill : &style->stroke;
454 // We consider paint "effectively set" for anything within text hierarchy
455 SPObject *parent = SP_OBJECT_PARENT (obj);
456 bool paint_effectively_set =
457 paint->set || (SP_IS_TEXT(parent) || SP_IS_TEXTPATH(parent) || SP_IS_TSPAN(parent)
458 || SP_IS_FLOWTEXT(parent) || SP_IS_FLOWDIV(parent) || SP_IS_FLOWPARA(parent)
459 || SP_IS_FLOWTSPAN(parent) || SP_IS_FLOWLINE(parent));
461 // 1. Bail out with QUERY_STYLE_MULTIPLE_DIFFERENT if necessary
463 if ((!paintImpossible) && (!paint->isSameType(*paint_res) || (paint_res->set != paint_effectively_set))) {
464 return QUERY_STYLE_MULTIPLE_DIFFERENT; // different types of paint
465 }
467 if (paint_res->set && paint->set && paint_res->isPaintserver()) {
468 // both previous paint and this paint were a server, see if the servers are compatible
470 SPPaintServer *server_res = isfill? SP_STYLE_FILL_SERVER (style_res) : SP_STYLE_STROKE_SERVER (style_res);
471 SPPaintServer *server = isfill? SP_STYLE_FILL_SERVER (style) : SP_STYLE_STROKE_SERVER (style);
473 if (SP_IS_LINEARGRADIENT (server_res)) {
475 if (!SP_IS_LINEARGRADIENT(server))
476 return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server
478 SPGradient *vector = SP_GRADIENT(server)->getVector();
479 SPGradient *vector_res = SP_GRADIENT(server_res)->getVector();
480 if (vector_res != vector)
481 return QUERY_STYLE_MULTIPLE_DIFFERENT; // different gradient vectors
483 } else if (SP_IS_RADIALGRADIENT (server_res)) {
485 if (!SP_IS_RADIALGRADIENT(server))
486 return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server
488 SPGradient *vector = SP_GRADIENT(server)->getVector();
489 SPGradient *vector_res = SP_GRADIENT(server_res)->getVector();
490 if (vector_res != vector)
491 return QUERY_STYLE_MULTIPLE_DIFFERENT; // different gradient vectors
493 } else if (SP_IS_PATTERN (server_res)) {
495 if (!SP_IS_PATTERN(server))
496 return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server
498 SPPattern *pat = pattern_getroot (SP_PATTERN (server));
499 SPPattern *pat_res = pattern_getroot (SP_PATTERN (server_res));
500 if (pat_res != pat)
501 return QUERY_STYLE_MULTIPLE_DIFFERENT; // different pattern roots
502 }
503 }
505 // 2. Sum color, copy server from paint to paint_res
507 if (paint_res->set && paint_effectively_set && paint->isColor()) {
508 gfloat d[3];
509 sp_color_get_rgb_floatv (&paint->value.color, d);
511 // Check if this color is the same as previous
512 if (paintImpossible) {
513 prev[0] = d[0];
514 prev[1] = d[1];
515 prev[2] = d[2];
516 paint_res->setColor(d[0], d[1], d[2]);
517 iccColor = paint->value.color.icc;
518 iccSeen = true;
519 } else {
520 if (same_color && (prev[0] != d[0] || prev[1] != d[1] || prev[2] != d[2]))
521 same_color = false;
522 if ( iccSeen ) {
523 if(paint->value.color.icc) {
524 // TODO fix this
525 iccColor = 0;
526 }
527 }
528 }
530 // average color
531 c[0] += d[0];
532 c[1] += d[1];
533 c[2] += d[2];
534 c[3] += SP_SCALE24_TO_FLOAT (isfill? style->fill_opacity.value : style->stroke_opacity.value);
536 // average device color
537 unsigned int it;
538 if (i==objects /*if this is the first object in the GList*/
539 && paint->value.color.device){
540 devColor = new SVGDeviceColor(*paint->value.color.device);
541 for (it=0; it < paint->value.color.device->colors.size(); it++){
542 devColor->colors[it] = 0;
543 }
544 }
546 if (devColor && paint->value.color.device && paint->value.color.device->type == devColor->type){
547 for (it=0; it < paint->value.color.device->colors.size(); it++){
548 devColor->colors[it] += paint->value.color.device->colors[it];
549 }
550 }
552 num ++;
553 }
555 paintImpossible = false;
556 paint_res->colorSet = paint->colorSet;
557 paint_res->currentcolor = paint->currentcolor;
558 if (paint_res->set && paint_effectively_set && paint->isPaintserver()) { // copy the server
559 if (isfill) {
560 sp_style_set_to_uri_string (style_res, true, style->getFillURI());
561 } else {
562 sp_style_set_to_uri_string (style_res, false, style->getStrokeURI());
563 }
564 }
565 paint_res->set = paint_effectively_set;
566 style_res->fill_rule.computed = style->fill_rule.computed; // no averaging on this, just use the last one
567 }
569 // After all objects processed, divide the color if necessary and return
570 if (paint_res->set && paint_res->isColor()) { // set the color
571 g_assert (num >= 1);
573 c[0] /= num;
574 c[1] /= num;
575 c[2] /= num;
576 c[3] /= num;
577 paint_res->setColor(c[0], c[1], c[2]);
578 if (isfill) {
579 style_res->fill_opacity.value = SP_SCALE24_FROM_FLOAT (c[3]);
580 } else {
581 style_res->stroke_opacity.value = SP_SCALE24_FROM_FLOAT (c[3]);
582 }
585 if ( iccSeen && iccColor ) {
586 // TODO check for existing
587 SVGICCColor* tmp = new SVGICCColor(*iccColor);
588 paint_res->value.color.icc = tmp;
589 }
591 // divide and store the device-color
592 if (devColor){
593 for (unsigned int it=0; it < devColor->colors.size(); it++){
594 devColor->colors[it] /= num;
595 }
596 paint_res->value.color.device = devColor;
597 }
599 if (num > 1) {
600 if (same_color)
601 return QUERY_STYLE_MULTIPLE_SAME;
602 else
603 return QUERY_STYLE_MULTIPLE_AVERAGED;
604 } else {
605 return QUERY_STYLE_SINGLE;
606 }
607 }
609 // Not color
610 if (g_slist_length(objects) > 1) {
611 return QUERY_STYLE_MULTIPLE_SAME;
612 } else {
613 return QUERY_STYLE_SINGLE;
614 }
615 }
617 /**
618 * Write to style_res the average opacity of a list of objects.
619 */
620 int
621 objects_query_opacity (GSList *objects, SPStyle *style_res)
622 {
623 if (g_slist_length(objects) == 0) {
624 /* No objects, set empty */
625 return QUERY_STYLE_NOTHING;
626 }
628 gdouble opacity_sum = 0;
629 gdouble opacity_prev = -1;
630 bool same_opacity = true;
631 guint opacity_items = 0;
634 for (GSList const *i = objects; i != NULL; i = i->next) {
635 SPObject *obj = SP_OBJECT (i->data);
636 SPStyle *style = SP_OBJECT_STYLE (obj);
637 if (!style) continue;
639 double opacity = SP_SCALE24_TO_FLOAT(style->opacity.value);
640 opacity_sum += opacity;
641 if (opacity_prev != -1 && opacity != opacity_prev)
642 same_opacity = false;
643 opacity_prev = opacity;
644 opacity_items ++;
645 }
646 if (opacity_items > 1)
647 opacity_sum /= opacity_items;
649 style_res->opacity.value = SP_SCALE24_FROM_FLOAT(opacity_sum);
651 if (opacity_items == 0) {
652 return QUERY_STYLE_NOTHING;
653 } else if (opacity_items == 1) {
654 return QUERY_STYLE_SINGLE;
655 } else {
656 if (same_opacity)
657 return QUERY_STYLE_MULTIPLE_SAME;
658 else
659 return QUERY_STYLE_MULTIPLE_AVERAGED;
660 }
661 }
663 /**
664 * Write to style_res the average stroke width of a list of objects.
665 */
666 int
667 objects_query_strokewidth (GSList *objects, SPStyle *style_res)
668 {
669 if (g_slist_length(objects) == 0) {
670 /* No objects, set empty */
671 return QUERY_STYLE_NOTHING;
672 }
674 gdouble avgwidth = 0.0;
676 gdouble prev_sw = -1;
677 bool same_sw = true;
678 bool noneSet = true; // is stroke set to none?
680 int n_stroked = 0;
682 for (GSList const *i = objects; i != NULL; i = i->next) {
683 SPObject *obj = SP_OBJECT (i->data);
684 if (!SP_IS_ITEM(obj)) continue;
685 SPStyle *style = SP_OBJECT_STYLE (obj);
686 if (!style) continue;
688 if ( style->stroke.isNone() && !(
689 style->marker[SP_MARKER_LOC].set || // stroke width affects markers, so if there's no stroke but only markers then we should
690 style->marker[SP_MARKER_LOC_START].set || // still calculate the stroke width
691 style->marker[SP_MARKER_LOC_MID].set ||
692 style->marker[SP_MARKER_LOC_END].set))
693 {
694 continue;
695 }
697 n_stroked ++;
699 noneSet &= style->stroke.isNone();
701 Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
702 double sw = style->stroke_width.computed * i2d.descrim();
704 if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3)
705 same_sw = false;
706 prev_sw = sw;
708 avgwidth += sw;
709 }
711 if (n_stroked > 1)
712 avgwidth /= (n_stroked);
714 style_res->stroke_width.computed = avgwidth;
715 style_res->stroke_width.set = true;
716 style_res->stroke.noneSet = noneSet; // Will only be true if none of the selected objects has it's stroke set.
718 if (n_stroked == 0) {
719 return QUERY_STYLE_NOTHING;
720 } else if (n_stroked == 1) {
721 return QUERY_STYLE_SINGLE;
722 } else {
723 if (same_sw)
724 return QUERY_STYLE_MULTIPLE_SAME;
725 else
726 return QUERY_STYLE_MULTIPLE_AVERAGED;
727 }
728 }
730 /**
731 * Write to style_res the average miter limit of a list of objects.
732 */
733 int
734 objects_query_miterlimit (GSList *objects, SPStyle *style_res)
735 {
736 if (g_slist_length(objects) == 0) {
737 /* No objects, set empty */
738 return QUERY_STYLE_NOTHING;
739 }
741 gdouble avgml = 0.0;
742 int n_stroked = 0;
744 gdouble prev_ml = -1;
745 bool same_ml = true;
747 for (GSList const *i = objects; i != NULL; i = i->next) {
748 SPObject *obj = SP_OBJECT (i->data);
749 if (!SP_IS_ITEM(obj)) continue;
750 SPStyle *style = SP_OBJECT_STYLE (obj);
751 if (!style) continue;
753 if ( style->stroke.isNone() ) {
754 continue;
755 }
757 n_stroked ++;
759 if (prev_ml != -1 && fabs(style->stroke_miterlimit.value - prev_ml) > 1e-3)
760 same_ml = false;
761 prev_ml = style->stroke_miterlimit.value;
763 avgml += style->stroke_miterlimit.value;
764 }
766 if (n_stroked > 1)
767 avgml /= (n_stroked);
769 style_res->stroke_miterlimit.value = avgml;
770 style_res->stroke_miterlimit.set = true;
772 if (n_stroked == 0) {
773 return QUERY_STYLE_NOTHING;
774 } else if (n_stroked == 1) {
775 return QUERY_STYLE_SINGLE;
776 } else {
777 if (same_ml)
778 return QUERY_STYLE_MULTIPLE_SAME;
779 else
780 return QUERY_STYLE_MULTIPLE_AVERAGED;
781 }
782 }
784 /**
785 * Write to style_res the stroke cap of a list of objects.
786 */
787 int
788 objects_query_strokecap (GSList *objects, SPStyle *style_res)
789 {
790 if (g_slist_length(objects) == 0) {
791 /* No objects, set empty */
792 return QUERY_STYLE_NOTHING;
793 }
795 int cap = -1;
796 gdouble prev_cap = -1;
797 bool same_cap = true;
798 int n_stroked = 0;
800 for (GSList const *i = objects; i != NULL; i = i->next) {
801 SPObject *obj = SP_OBJECT (i->data);
802 if (!SP_IS_ITEM(obj)) continue;
803 SPStyle *style = SP_OBJECT_STYLE (obj);
804 if (!style) continue;
806 if ( style->stroke.isNone() ) {
807 continue;
808 }
810 n_stroked ++;
812 if (prev_cap != -1 && style->stroke_linecap.value != prev_cap)
813 same_cap = false;
814 prev_cap = style->stroke_linecap.value;
816 cap = style->stroke_linecap.value;
817 }
819 style_res->stroke_linecap.value = cap;
820 style_res->stroke_linecap.set = true;
822 if (n_stroked == 0) {
823 return QUERY_STYLE_NOTHING;
824 } else if (n_stroked == 1) {
825 return QUERY_STYLE_SINGLE;
826 } else {
827 if (same_cap)
828 return QUERY_STYLE_MULTIPLE_SAME;
829 else
830 return QUERY_STYLE_MULTIPLE_DIFFERENT;
831 }
832 }
834 /**
835 * Write to style_res the stroke join of a list of objects.
836 */
837 int
838 objects_query_strokejoin (GSList *objects, SPStyle *style_res)
839 {
840 if (g_slist_length(objects) == 0) {
841 /* No objects, set empty */
842 return QUERY_STYLE_NOTHING;
843 }
845 int join = -1;
846 gdouble prev_join = -1;
847 bool same_join = true;
848 int n_stroked = 0;
850 for (GSList const *i = objects; i != NULL; i = i->next) {
851 SPObject *obj = SP_OBJECT (i->data);
852 if (!SP_IS_ITEM(obj)) continue;
853 SPStyle *style = SP_OBJECT_STYLE (obj);
854 if (!style) continue;
856 if ( style->stroke.isNone() ) {
857 continue;
858 }
860 n_stroked ++;
862 if (prev_join != -1 && style->stroke_linejoin.value != prev_join)
863 same_join = false;
864 prev_join = style->stroke_linejoin.value;
866 join = style->stroke_linejoin.value;
867 }
869 style_res->stroke_linejoin.value = join;
870 style_res->stroke_linejoin.set = true;
872 if (n_stroked == 0) {
873 return QUERY_STYLE_NOTHING;
874 } else if (n_stroked == 1) {
875 return QUERY_STYLE_SINGLE;
876 } else {
877 if (same_join)
878 return QUERY_STYLE_MULTIPLE_SAME;
879 else
880 return QUERY_STYLE_MULTIPLE_DIFFERENT;
881 }
882 }
884 /**
885 * Write to style_res the average font size and spacing of objects.
886 */
887 int
888 objects_query_fontnumbers (GSList *objects, SPStyle *style_res)
889 {
890 bool different = false;
892 double size = 0;
893 double letterspacing = 0;
894 double linespacing = 0;
895 bool linespacing_normal = false;
896 bool letterspacing_normal = false;
898 double size_prev = 0;
899 double letterspacing_prev = 0;
900 double linespacing_prev = 0;
902 /// \todo FIXME: add word spacing, kerns? rotates?
904 int texts = 0;
906 for (GSList const *i = objects; i != NULL; i = i->next) {
907 SPObject *obj = SP_OBJECT (i->data);
909 if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
910 && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
911 && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
912 continue;
914 SPStyle *style = SP_OBJECT_STYLE (obj);
915 if (!style) continue;
917 texts ++;
918 size += style->font_size.computed * Geom::Matrix(sp_item_i2d_affine(SP_ITEM(obj))).descrim(); /// \todo FIXME: we assume non-% units here
920 if (style->letter_spacing.normal) {
921 if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing))
922 letterspacing_normal = true;
923 } else {
924 letterspacing += style->letter_spacing.computed; /// \todo FIXME: we assume non-% units here
925 letterspacing_normal = false;
926 }
928 double linespacing_current;
929 if (style->line_height.normal) {
930 linespacing_current = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
931 if (!different && (linespacing_prev == 0 || linespacing_prev == linespacing_current))
932 linespacing_normal = true;
933 } else if (style->line_height.unit == SP_CSS_UNIT_PERCENT || style->font_size.computed == 0) {
934 linespacing_current = style->line_height.value;
935 linespacing_normal = false;
936 } else { // we need % here
937 linespacing_current = style->line_height.computed / style->font_size.computed;
938 linespacing_normal = false;
939 }
940 linespacing += linespacing_current;
942 if ((size_prev != 0 && style->font_size.computed != size_prev) ||
943 (letterspacing_prev != 0 && style->letter_spacing.computed != letterspacing_prev) ||
944 (linespacing_prev != 0 && linespacing_current != linespacing_prev)) {
945 different = true;
946 }
948 size_prev = style->font_size.computed;
949 letterspacing_prev = style->letter_spacing.computed;
950 linespacing_prev = linespacing_current;
952 // FIXME: we must detect MULTIPLE_DIFFERENT for these too
953 style_res->text_anchor.computed = style->text_anchor.computed;
954 style_res->writing_mode.computed = style->writing_mode.computed;
955 }
957 if (texts == 0)
958 return QUERY_STYLE_NOTHING;
960 if (texts > 1) {
961 size /= texts;
962 letterspacing /= texts;
963 linespacing /= texts;
964 }
966 style_res->font_size.computed = size;
967 style_res->font_size.type = SP_FONT_SIZE_LENGTH;
969 style_res->letter_spacing.normal = letterspacing_normal;
970 style_res->letter_spacing.computed = letterspacing;
972 style_res->line_height.normal = linespacing_normal;
973 style_res->line_height.computed = linespacing;
974 style_res->line_height.value = linespacing;
975 style_res->line_height.unit = SP_CSS_UNIT_PERCENT;
977 if (texts > 1) {
978 if (different) {
979 return QUERY_STYLE_MULTIPLE_AVERAGED;
980 } else {
981 return QUERY_STYLE_MULTIPLE_SAME;
982 }
983 } else {
984 return QUERY_STYLE_SINGLE;
985 }
986 }
988 /**
989 * Write to style_res the average font style of objects.
990 */
991 int
992 objects_query_fontstyle (GSList *objects, SPStyle *style_res)
993 {
994 bool different = false;
995 bool set = false;
997 int texts = 0;
999 for (GSList const *i = objects; i != NULL; i = i->next) {
1000 SPObject *obj = SP_OBJECT (i->data);
1002 if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
1003 && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
1004 && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
1005 continue;
1007 SPStyle *style = SP_OBJECT_STYLE (obj);
1008 if (!style) continue;
1010 texts ++;
1012 if (set &&
1013 font_style_to_pos(*style_res).signature() != font_style_to_pos(*style).signature() ) {
1014 different = true; // different styles
1015 }
1017 set = TRUE;
1018 style_res->font_weight.value = style_res->font_weight.computed = style->font_weight.computed;
1019 style_res->font_style.value = style_res->font_style.computed = style->font_style.computed;
1020 style_res->font_stretch.value = style_res->font_stretch.computed = style->font_stretch.computed;
1021 style_res->font_variant.value = style_res->font_variant.computed = style->font_variant.computed;
1022 style_res->text_align.value = style_res->text_align.computed = style->text_align.computed;
1023 }
1025 if (texts == 0 || !set)
1026 return QUERY_STYLE_NOTHING;
1028 if (texts > 1) {
1029 if (different) {
1030 return QUERY_STYLE_MULTIPLE_DIFFERENT;
1031 } else {
1032 return QUERY_STYLE_MULTIPLE_SAME;
1033 }
1034 } else {
1035 return QUERY_STYLE_SINGLE;
1036 }
1037 }
1039 /**
1040 * Write to style_res the average font family of objects.
1041 */
1042 int
1043 objects_query_fontfamily (GSList *objects, SPStyle *style_res)
1044 {
1045 bool different = false;
1046 int texts = 0;
1048 if (style_res->text->font_family.value) {
1049 g_free(style_res->text->font_family.value);
1050 style_res->text->font_family.value = NULL;
1051 }
1052 style_res->text->font_family.set = FALSE;
1054 for (GSList const *i = objects; i != NULL; i = i->next) {
1055 SPObject *obj = SP_OBJECT (i->data);
1057 if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
1058 && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
1059 && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
1060 continue;
1062 SPStyle *style = SP_OBJECT_STYLE (obj);
1063 if (!style) continue;
1065 texts ++;
1067 if (style_res->text->font_family.value && style->text->font_family.value &&
1068 strcmp (style_res->text->font_family.value, style->text->font_family.value)) {
1069 different = true; // different fonts
1070 }
1072 if (style_res->text->font_family.value) {
1073 g_free(style_res->text->font_family.value);
1074 style_res->text->font_family.value = NULL;
1075 }
1077 style_res->text->font_family.set = TRUE;
1078 style_res->text->font_family.value = g_strdup(style->text->font_family.value);
1079 }
1081 if (texts == 0 || !style_res->text->font_family.set)
1082 return QUERY_STYLE_NOTHING;
1084 if (texts > 1) {
1085 if (different) {
1086 return QUERY_STYLE_MULTIPLE_DIFFERENT;
1087 } else {
1088 return QUERY_STYLE_MULTIPLE_SAME;
1089 }
1090 } else {
1091 return QUERY_STYLE_SINGLE;
1092 }
1093 }
1095 int
1096 objects_query_fontspecification (GSList *objects, SPStyle *style_res)
1097 {
1098 bool different = false;
1099 int texts = 0;
1101 if (style_res->text->font_specification.value) {
1102 g_free(style_res->text->font_specification.value);
1103 style_res->text->font_specification.value = NULL;
1104 }
1105 style_res->text->font_specification.set = FALSE;
1107 for (GSList const *i = objects; i != NULL; i = i->next) {
1108 SPObject *obj = SP_OBJECT (i->data);
1110 if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
1111 && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
1112 && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
1113 continue;
1115 SPStyle *style = SP_OBJECT_STYLE (obj);
1116 if (!style) continue;
1118 texts ++;
1120 if (style_res->text->font_specification.value && style_res->text->font_specification.set &&
1121 style->text->font_specification.value && style->text->font_specification.set &&
1122 strcmp (style_res->text->font_specification.value, style->text->font_specification.value)) {
1123 different = true; // different fonts
1124 }
1126 if (style->text->font_specification.set) {
1128 if (style_res->text->font_specification.value) {
1129 g_free(style_res->text->font_specification.value);
1130 style_res->text->font_specification.value = NULL;
1131 }
1133 style_res->text->font_specification.set = TRUE;
1134 style_res->text->font_specification.value = g_strdup(style->text->font_specification.value);
1135 }
1136 }
1138 if (texts == 0)
1139 return QUERY_STYLE_NOTHING;
1141 if (texts > 1) {
1142 if (different) {
1143 return QUERY_STYLE_MULTIPLE_DIFFERENT;
1144 } else {
1145 return QUERY_STYLE_MULTIPLE_SAME;
1146 }
1147 } else {
1148 return QUERY_STYLE_SINGLE;
1149 }
1150 }
1152 int
1153 objects_query_blend (GSList *objects, SPStyle *style_res)
1154 {
1155 const int empty_prev = -2;
1156 const int complex_filter = 5;
1157 int blend = 0;
1158 float blend_prev = empty_prev;
1159 bool same_blend = true;
1160 guint items = 0;
1162 for (GSList const *i = objects; i != NULL; i = i->next) {
1163 SPObject *obj = SP_OBJECT (i->data);
1164 SPStyle *style = SP_OBJECT_STYLE (obj);
1165 if(!style || !SP_IS_ITEM(obj)) continue;
1167 items++;
1169 //if object has a filter
1170 if (style->filter.set && style->getFilter()) {
1171 int blurcount = 0;
1172 int blendcount = 0;
1174 // determine whether filter is simple (blend and/or blur) or complex
1175 for(SPObject *primitive_obj = style->getFilter()->children;
1176 primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj);
1177 primitive_obj = primitive_obj->next) {
1178 SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
1179 if(SP_IS_FEBLEND(primitive))
1180 ++blendcount;
1181 else if(SP_IS_GAUSSIANBLUR(primitive))
1182 ++blurcount;
1183 else {
1184 blurcount = complex_filter;
1185 break;
1186 }
1187 }
1189 // simple filter
1190 if(blurcount == 1 || blendcount == 1) {
1191 for(SPObject *primitive_obj = style->getFilter()->children;
1192 primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj);
1193 primitive_obj = primitive_obj->next) {
1194 if(SP_IS_FEBLEND(primitive_obj)) {
1195 SPFeBlend *spblend = SP_FEBLEND(primitive_obj);
1196 blend = spblend->blend_mode;
1197 }
1198 }
1199 }
1200 else {
1201 blend = complex_filter;
1202 }
1203 }
1204 // defaults to blend mode = "normal"
1205 else {
1206 blend = 0;
1207 }
1209 if(blend_prev != empty_prev && blend_prev != blend)
1210 same_blend = false;
1211 blend_prev = blend;
1212 }
1214 if (items > 0) {
1215 style_res->filter_blend_mode.value = blend;
1216 }
1218 if (items == 0) {
1219 return QUERY_STYLE_NOTHING;
1220 } else if (items == 1) {
1221 return QUERY_STYLE_SINGLE;
1222 } else {
1223 if(same_blend)
1224 return QUERY_STYLE_MULTIPLE_SAME;
1225 else
1226 return QUERY_STYLE_MULTIPLE_DIFFERENT;
1227 }
1228 }
1230 /**
1231 * Write to style_res the average blurring of a list of objects.
1232 */
1233 int
1234 objects_query_blur (GSList *objects, SPStyle *style_res)
1235 {
1236 if (g_slist_length(objects) == 0) {
1237 /* No objects, set empty */
1238 return QUERY_STYLE_NOTHING;
1239 }
1241 float blur_sum = 0;
1242 float blur_prev = -1;
1243 bool same_blur = true;
1244 guint blur_items = 0;
1245 guint items = 0;
1247 for (GSList const *i = objects; i != NULL; i = i->next) {
1248 SPObject *obj = SP_OBJECT (i->data);
1249 SPStyle *style = SP_OBJECT_STYLE (obj);
1250 if (!style) continue;
1251 if (!SP_IS_ITEM(obj)) continue;
1253 Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
1255 items ++;
1257 //if object has a filter
1258 if (style->filter.set && style->getFilter()) {
1259 //cycle through filter primitives
1260 SPObject *primitive_obj = style->getFilter()->children;
1261 while (primitive_obj) {
1262 if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) {
1263 SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
1265 //if primitive is gaussianblur
1266 if(SP_IS_GAUSSIANBLUR(primitive)) {
1267 SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive);
1268 float num = spblur->stdDeviation.getNumber();
1269 blur_sum += num * i2d.descrim();
1270 if (blur_prev != -1 && fabs (num - blur_prev) > 1e-2) // rather low tolerance because difference in blur radii is much harder to notice than e.g. difference in sizes
1271 same_blur = false;
1272 blur_prev = num;
1273 //TODO: deal with opt number, for the moment it's not necessary to the ui.
1274 blur_items ++;
1275 }
1276 }
1277 primitive_obj = primitive_obj->next;
1278 }
1279 }
1280 }
1282 if (items > 0) {
1283 if (blur_items > 0)
1284 blur_sum /= blur_items;
1285 style_res->filter_gaussianBlur_deviation.value = blur_sum;
1286 }
1288 if (items == 0) {
1289 return QUERY_STYLE_NOTHING;
1290 } else if (items == 1) {
1291 return QUERY_STYLE_SINGLE;
1292 } else {
1293 if (same_blur)
1294 return QUERY_STYLE_MULTIPLE_SAME;
1295 else
1296 return QUERY_STYLE_MULTIPLE_AVERAGED;
1297 }
1298 }
1300 /**
1301 * Query the given list of objects for the given property, write
1302 * the result to style, return appropriate flag.
1303 */
1304 int
1305 sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property)
1306 {
1307 if (property == QUERY_STYLE_PROPERTY_FILL) {
1308 return objects_query_fillstroke (list, style, true);
1309 } else if (property == QUERY_STYLE_PROPERTY_STROKE) {
1310 return objects_query_fillstroke (list, style, false);
1312 } else if (property == QUERY_STYLE_PROPERTY_STROKEWIDTH) {
1313 return objects_query_strokewidth (list, style);
1314 } else if (property == QUERY_STYLE_PROPERTY_STROKEMITERLIMIT) {
1315 return objects_query_miterlimit (list, style);
1316 } else if (property == QUERY_STYLE_PROPERTY_STROKECAP) {
1317 return objects_query_strokecap (list, style);
1318 } else if (property == QUERY_STYLE_PROPERTY_STROKEJOIN) {
1319 return objects_query_strokejoin (list, style);
1321 } else if (property == QUERY_STYLE_PROPERTY_MASTEROPACITY) {
1322 return objects_query_opacity (list, style);
1324 } else if (property == QUERY_STYLE_PROPERTY_FONT_SPECIFICATION) {
1325 return objects_query_fontspecification (list, style);
1326 } else if (property == QUERY_STYLE_PROPERTY_FONTFAMILY) {
1327 return objects_query_fontfamily (list, style);
1328 } else if (property == QUERY_STYLE_PROPERTY_FONTSTYLE) {
1329 return objects_query_fontstyle (list, style);
1330 } else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) {
1331 return objects_query_fontnumbers (list, style);
1333 } else if (property == QUERY_STYLE_PROPERTY_BLEND) {
1334 return objects_query_blend (list, style);
1335 } else if (property == QUERY_STYLE_PROPERTY_BLUR) {
1336 return objects_query_blur (list, style);
1337 }
1338 return QUERY_STYLE_NOTHING;
1339 }
1342 /**
1343 * Query the subselection (if any) or selection on the given desktop for the given property, write
1344 * the result to style, return appropriate flag.
1345 */
1346 int
1347 sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
1348 {
1349 int ret = desktop->_query_style_signal.emit(style, property);
1351 if (ret != QUERY_STYLE_NOTHING)
1352 return ret; // subselection returned a style, pass it on
1354 // otherwise, do querying and averaging over selection
1355 if (desktop->selection != NULL) {
1356 return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property);
1357 }
1359 return QUERY_STYLE_NOTHING;
1360 }
1362 /**
1363 * Do the same as sp_desktop_query_style for all (defined) style properties, return true if at
1364 * least one of the properties did not return QUERY_STYLE_NOTHING.
1365 */
1366 bool
1367 sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
1368 {
1369 int result_family = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
1370 int result_fstyle = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
1371 int result_fnumbers = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
1372 int result_fill = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FILL);
1373 int result_stroke = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKE);
1374 int result_strokewidth = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEWIDTH);
1375 int result_strokemiterlimit = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
1376 int result_strokecap = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKECAP);
1377 int result_strokejoin = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEJOIN);
1378 int result_opacity = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
1379 int result_blur = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR);
1381 return (result_family != QUERY_STYLE_NOTHING ||
1382 result_fstyle != QUERY_STYLE_NOTHING ||
1383 result_fnumbers != QUERY_STYLE_NOTHING ||
1384 result_fill != QUERY_STYLE_NOTHING ||
1385 result_stroke != QUERY_STYLE_NOTHING ||
1386 result_opacity != QUERY_STYLE_NOTHING ||
1387 result_strokewidth != QUERY_STYLE_NOTHING ||
1388 result_strokemiterlimit != QUERY_STYLE_NOTHING ||
1389 result_strokecap != QUERY_STYLE_NOTHING ||
1390 result_strokejoin != QUERY_STYLE_NOTHING ||
1391 result_blur != QUERY_STYLE_NOTHING);
1392 }
1395 /*
1396 Local Variables:
1397 mode:c++
1398 c-file-style:"stroustrup"
1399 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1400 indent-tabs-mode:nil
1401 fill-column:99
1402 End:
1403 */
1404 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :