Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / desktop-style.cpp
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 "box3d-side.h"
49 /**
50  * Set color on selection on desktop.
51  */
52 void
53 sp_desktop_set_color(SPDesktop *desktop, ColorRGBA const &color, bool is_relative, bool fill)
54 {
55     /// \todo relative color setting
56     if (is_relative) {
57         g_warning("FIXME: relative color setting not yet implemented");
58         return;
59     }
61     guint32 rgba = SP_RGBA32_F_COMPOSE(color[0], color[1], color[2], color[3]);
62     gchar b[64];
63     sp_svg_write_color(b, sizeof(b), rgba);
64     SPCSSAttr *css = sp_repr_css_attr_new();
65     if (fill) {
66         sp_repr_css_set_property(css, "fill", b);
67         Inkscape::CSSOStringStream osalpha;
68         osalpha << color[3];
69         sp_repr_css_set_property(css, "fill-opacity", osalpha.str().c_str());
70     } else {
71         sp_repr_css_set_property(css, "stroke", b);
72         Inkscape::CSSOStringStream osalpha;
73         osalpha << color[3];
74         sp_repr_css_set_property(css, "stroke-opacity", osalpha.str().c_str());
75     }
77     sp_desktop_set_style(desktop, css);
79     sp_repr_css_attr_unref(css);
80 }
82 /**
83  * Apply style on object and children, recursively.
84  */
85 void
86 sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
87 {
88     // non-items should not have style
89     if (!SP_IS_ITEM(o))
90         return;
92     // 1. tspans with role=line are not regular objects in that they are not supposed to have style of their own,
93     // but must always inherit from the parent text. Same for textPath.
94     // However, if the line tspan or textPath contains some style (old file?), we reluctantly set our style to it too.
96     // 2. Generally we allow setting style on clones, but when it's inside flowRegion, do not touch
97     // it, be it clone or not; it's just styleless shape (because that's how Inkscape does
98     // flowtext).
100     if (!(skip_lines
101           && ((SP_IS_TSPAN(o) && SP_TSPAN(o)->role == SP_TSPAN_ROLE_LINE)
102               || SP_IS_FLOWDIV(o)
103               || SP_IS_FLOWPARA(o)
104               || SP_IS_TEXTPATH(o))
105           && !SP_OBJECT_REPR(o)->attribute("style"))
106         &&
107         !(SP_IS_FLOWREGION(o) ||
108           SP_IS_FLOWREGIONEXCLUDE(o) ||
109           (SP_IS_USE(o) &&
110            SP_OBJECT_PARENT(o) &&
111            (SP_IS_FLOWREGION(SP_OBJECT_PARENT(o)) ||
112             SP_IS_FLOWREGIONEXCLUDE(SP_OBJECT_PARENT(o))
113            )
114           )
115          )
116         ) {
118         SPCSSAttr *css_set = sp_repr_css_attr_new();
119         sp_repr_css_merge(css_set, css);
121         // Scale the style by the inverse of the accumulated parent transform in the paste context.
122         {
123             Geom::Matrix const local(sp_item_i2doc_affine(SP_ITEM(o)));
124             double const ex(local.descrim());
125             if ( ( ex != 0. )
126                  && ( ex != 1. ) ) {
127                 sp_css_attr_scale(css_set, 1/ex);
128             }
129         }
131         sp_repr_css_change(SP_OBJECT_REPR(o), css_set, "style");
133         sp_repr_css_attr_unref(css_set);
134     }
136     // setting style on child of clone spills into the clone original (via shared repr), don't do it!
137     if (SP_IS_USE(o))
138         return;
140     for (SPObject *child = sp_object_first_child(SP_OBJECT(o)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
141         if (sp_repr_css_property(css, "opacity", NULL) != NULL) {
142             // Unset properties which are accumulating and thus should not be set recursively.
143             // 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.
144             SPCSSAttr *css_recurse = sp_repr_css_attr_new();
145             sp_repr_css_merge(css_recurse, css);
146             sp_repr_css_set_property(css_recurse, "opacity", NULL);
147             sp_desktop_apply_css_recursive(child, css_recurse, skip_lines);
148             sp_repr_css_attr_unref(css_recurse);
149         } else {
150             sp_desktop_apply_css_recursive(child, css, skip_lines);
151         }
152     }
155 /**
156  * Apply style on selection on desktop.
157  */
158 void
159 sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current)
161     if (write_current) {
162         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
163         // 1. Set internal value
164         sp_repr_css_merge(desktop->current, css);
166         // 1a. Write to prefs; make a copy and unset any URIs first
167         SPCSSAttr *css_write = sp_repr_css_attr_new();
168         sp_repr_css_merge(css_write, css);
169         sp_css_attr_unset_uris(css_write);
170         prefs->mergeStyle("/desktop/style", css_write);
172         for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) {
173             /* last used styles for 3D box faces are stored separately */
174             if (SP_IS_BOX3D_SIDE (i->data)) {
175                 const char * descr  = box3d_side_axes_string(SP_BOX3D_SIDE(i->data));
176                 if (descr != NULL) {
177                     prefs->mergeStyle(Glib::ustring("/desktop/") + descr + "/style", css_write);
178                 }
179             }
180         }
181         sp_repr_css_attr_unref(css_write);
182     }
184     if (!change)
185         return;
187 // 2. Emit signal
188     bool intercepted = desktop->_set_style_signal.emit(css);
190 /** \todo
191  * FIXME: in set_style, compensate pattern and gradient fills, stroke width,
192  * rect corners, font size for the object's own transform so that pasting
193  * fills does not depend on preserve/optimize.
194  */
196 // 3. If nobody has intercepted the signal, apply the style to the selection
197     if (!intercepted) {
198         for (GSList const *i = desktop->selection->itemList(); i != NULL; i = i->next) {
199             /// \todo if the style is text-only, apply only to texts?
200             sp_desktop_apply_css_recursive(SP_OBJECT(i->data), css, true);
201         }
202     }
205 /**
206  * Return the desktop's current style.
207  */
208 SPCSSAttr *
209 sp_desktop_get_style(SPDesktop *desktop, bool with_text)
211     SPCSSAttr *css = sp_repr_css_attr_new();
212     sp_repr_css_merge(css, desktop->current);
213     if (!css->attributeList()) {
214         sp_repr_css_attr_unref(css);
215         return NULL;
216     } else {
217         if (!with_text) {
218             css = sp_css_attr_unset_text(css);
219         }
220         return css;
221     }
224 /**
225  * Return the desktop's current color.
226  */
227 guint32
228 sp_desktop_get_color(SPDesktop *desktop, bool is_fill)
230     guint32 r = 0; // if there's no color, return black
231     gchar const *property = sp_repr_css_property(desktop->current,
232                                                  is_fill ? "fill" : "stroke",
233                                                  "#000");
235     if (desktop->current && property) { // if there is style and the property in it,
236         if (strncmp(property, "url", 3)) { // and if it's not url,
237             // read it
238             r = sp_svg_read_color(property, r);
239         }
240     }
242     return r;
245 double
246 sp_desktop_get_master_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool *has_opacity)
248     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
249     SPCSSAttr *css = NULL;
250     gfloat value = 1.0; // default if nothing else found
251     if (has_opacity)
252         *has_opacity = false;
253     if (prefs->getBool(tool + "/usecurrent")) {
254         css = sp_desktop_get_style(desktop, true);
255     } else {
256         css = prefs->getStyle(tool + "/style");
257     }
259     if (css) {
260         gchar const *property = css ? sp_repr_css_property(css, "opacity", "1.000") : 0;
262         if (desktop->current && property) { // if there is style and the property in it,
263             if ( !sp_svg_number_read_f(property, &value) ) {
264                 value = 1.0; // things failed. set back to the default
265             } else {
266                 if (has_opacity)
267                    *has_opacity = false;
268             }
269         }
271         sp_repr_css_attr_unref(css);
272     }
274     return value;
276 double
277 sp_desktop_get_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill)
279     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
280     SPCSSAttr *css = NULL;
281     gfloat value = 1.0; // default if nothing else found
282     if (prefs->getBool(tool + "/usecurrent")) {
283         css = sp_desktop_get_style(desktop, true);
284     } else {
285         css = prefs->getStyle(tool + "/style");
286     }
288     if (css) {
289         gchar const *property = css ? sp_repr_css_property(css, is_fill ? "fill-opacity": "stroke-opacity", "1.000") : 0;
291         if (desktop->current && property) { // if there is style and the property in it,
292             if ( !sp_svg_number_read_f(property, &value) ) {
293                 value = 1.0; // things failed. set back to the default
294             }
295         }
297         sp_repr_css_attr_unref(css);
298     }
300     return value;
303 guint32
304 sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill, bool *has_color)
306     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
307     SPCSSAttr *css = NULL;
308     guint32 r = 0; // if there's no color, return black
309     if (has_color)
310         *has_color = false;
311     if (prefs->getBool(tool + "/usecurrent")) {
312         css = sp_desktop_get_style(desktop, true);
313     } else {
314         css = prefs->getStyle(tool + "/style");
315     }
317     if (css) {
318         gchar const *property = sp_repr_css_property(css, is_fill ? "fill" : "stroke", "#000");
320         if (desktop->current && property) { // if there is style and the property in it,
321             if (strncmp(property, "url", 3) && strncmp(property, "none", 4)) { // and if it's not url or none,
322                 // read it
323                 r = sp_svg_read_color(property, r);
324                 if (has_color)
325                     *has_color = true;
326             }
327         }
329         sp_repr_css_attr_unref(css);
330     }
332     return r | 0xff;
335 /**
336  * Apply the desktop's current style or the tool style to repr.
337  */
338 void
339 sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool_path, bool with_text)
341     SPCSSAttr *css_current = sp_desktop_get_style(desktop, with_text);
342     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
344     if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
345         sp_repr_css_set(repr, css_current, "style");
346     } else {
347         SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style");
348         sp_repr_css_set(repr, css, "style");
349         sp_repr_css_attr_unref(css);
350     }
351     if (css_current) {
352         sp_repr_css_attr_unref(css_current);
353     }
356 /**
357  * Returns the font size (in SVG pixels) of the text tool style (if text
358  * tool uses its own style) or desktop style (otherwise).
359 */
360 double
361 sp_desktop_get_font_size_tool(SPDesktop *desktop)
363     (void)desktop; // TODO cleanup
364     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
365     Glib::ustring desktop_style = prefs->getString("/desktop/style");
366     Glib::ustring style_str;
367     if ((prefs->getBool("/tools/text/usecurrent")) && !desktop_style.empty()) {
368         style_str = desktop_style;
369     } else {
370         style_str = prefs->getString("/tools/text/style");
371     }
373     double ret = 12;
374     if (!style_str.empty()) {
375         SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT);
376         sp_style_merge_from_style_string(style, style_str.data());
377         ret = style->font_size.computed;
378         sp_style_unref(style);
379     }
380     return ret;
383 /** Determine average stroke width, simple method */
384 // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually
385 gdouble
386 stroke_average_width (GSList const *objects)
388     if (g_slist_length ((GSList *) objects) == 0)
389         return NR_HUGE;
391     gdouble avgwidth = 0.0;
392     bool notstroked = true;
393     int n_notstroked = 0;
395     for (GSList const *l = objects; l != NULL; l = l->next) {
396         if (!SP_IS_ITEM (l->data))
397             continue;
399         Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data));
401         SPObject *object = SP_OBJECT(l->data);
403         if ( object->style->stroke.isNone() ) {
404             ++n_notstroked;   // do not count nonstroked objects
405             continue;
406         } else {
407             notstroked = false;
408         }
410         avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * i2d.descrim();
411     }
413     if (notstroked)
414         return NR_HUGE;
416     return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked);
419 /**
420  * Write to style_res the average fill or stroke of list of objects, if applicable.
421  */
422 int
423 objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill)
425     if (g_slist_length(objects) == 0) {
426         /* No objects, set empty */
427         return QUERY_STYLE_NOTHING;
428     }
430     SPIPaint *paint_res = isfill? &style_res->fill : &style_res->stroke;
431     bool paintImpossible = true;
432     paint_res->set = TRUE;
434     SVGICCColor* iccColor = 0;
435     bool iccSeen = false;
436     gfloat c[4];
437     c[0] = c[1] = c[2] = c[3] = 0.0;
438     gint num = 0;
440     gfloat prev[3];
441     prev[0] = prev[1] = prev[2] = 0.0;
442     bool same_color = true;
444     for (GSList const *i = objects; i != NULL; i = i->next) {
445         SPObject *obj = SP_OBJECT (i->data);
446         SPStyle *style = SP_OBJECT_STYLE (obj);
447         if (!style) continue;
449         SPIPaint *paint = isfill? &style->fill : &style->stroke;
451         // We consider paint "effectively set" for anything within text hierarchy
452         SPObject *parent = SP_OBJECT_PARENT (obj);
453         bool paint_effectively_set =
454             paint->set || (SP_IS_TEXT(parent) || SP_IS_TEXTPATH(parent) || SP_IS_TSPAN(parent)
455             || SP_IS_FLOWTEXT(parent) || SP_IS_FLOWDIV(parent) || SP_IS_FLOWPARA(parent)
456             || SP_IS_FLOWTSPAN(parent) || SP_IS_FLOWLINE(parent));
458         // 1. Bail out with QUERY_STYLE_MULTIPLE_DIFFERENT if necessary
460         if ((!paintImpossible) && (!paint->isSameType(*paint_res) || (paint_res->set != paint_effectively_set))) {
461             return QUERY_STYLE_MULTIPLE_DIFFERENT;  // different types of paint
462         }
464         if (paint_res->set && paint->set && paint_res->isPaintserver()) {
465             // both previous paint and this paint were a server, see if the servers are compatible
467             SPPaintServer *server_res = isfill? SP_STYLE_FILL_SERVER (style_res) : SP_STYLE_STROKE_SERVER (style_res);
468             SPPaintServer *server = isfill? SP_STYLE_FILL_SERVER (style) : SP_STYLE_STROKE_SERVER (style);
470             if (SP_IS_LINEARGRADIENT (server_res)) {
472                 if (!SP_IS_LINEARGRADIENT(server))
473                    return QUERY_STYLE_MULTIPLE_DIFFERENT;  // different kind of server
475                 SPGradient *vector = sp_gradient_get_vector ( SP_GRADIENT (server), FALSE );
476                 SPGradient *vector_res = sp_gradient_get_vector ( SP_GRADIENT (server_res), FALSE );
477                 if (vector_res != vector)
478                    return QUERY_STYLE_MULTIPLE_DIFFERENT;  // different gradient vectors
480             } else if (SP_IS_RADIALGRADIENT (server_res)) {
482                 if (!SP_IS_RADIALGRADIENT(server))
483                    return QUERY_STYLE_MULTIPLE_DIFFERENT;  // different kind of server
485                 SPGradient *vector = sp_gradient_get_vector ( SP_GRADIENT (server), FALSE );
486                 SPGradient *vector_res = sp_gradient_get_vector ( SP_GRADIENT (server_res), FALSE );
487                 if (vector_res != vector)
488                    return QUERY_STYLE_MULTIPLE_DIFFERENT;  // different gradient vectors
490             } else if (SP_IS_PATTERN (server_res)) {
492                 if (!SP_IS_PATTERN(server))
493                    return QUERY_STYLE_MULTIPLE_DIFFERENT;  // different kind of server
495                 SPPattern *pat = pattern_getroot (SP_PATTERN (server));
496                 SPPattern *pat_res = pattern_getroot (SP_PATTERN (server_res));
497                 if (pat_res != pat)
498                    return QUERY_STYLE_MULTIPLE_DIFFERENT;  // different pattern roots
499             }
500         }
502         // 2. Sum color, copy server from paint to paint_res
504         if (paint_res->set && paint_effectively_set && paint->isColor()) {
505             gfloat d[3];
506             sp_color_get_rgb_floatv (&paint->value.color, d);
508             // Check if this color is the same as previous
509             if (paintImpossible) {
510                 prev[0] = d[0];
511                 prev[1] = d[1];
512                 prev[2] = d[2];
513                 paint_res->setColor(d[0], d[1], d[2]);
514                 iccColor = paint->value.color.icc;
515                 iccSeen = true;
516             } else {
517                 if (same_color && (prev[0] != d[0] || prev[1] != d[1] || prev[2] != d[2]))
518                     same_color = false;
519                 if ( iccSeen ) {
520                     if(paint->value.color.icc) {
521                         // TODO fix this
522                         iccColor = 0;
523                     }
524                 }
525             }
527             // average color
528             c[0] += d[0];
529             c[1] += d[1];
530             c[2] += d[2];
531             c[3] += SP_SCALE24_TO_FLOAT (isfill? style->fill_opacity.value : style->stroke_opacity.value);
532             num ++;
533         }
535        paintImpossible = false;
536        paint_res->colorSet = paint->colorSet;
537        paint_res->currentcolor = paint->currentcolor;
538        if (paint_res->set && paint_effectively_set && paint->isPaintserver()) { // copy the server
539            if (isfill) {
540                sp_style_set_to_uri_string (style_res, true, style->getFillURI());
541            } else {
542                sp_style_set_to_uri_string (style_res, false, style->getStrokeURI());
543            }
544        }
545        paint_res->set = paint_effectively_set;
546        style_res->fill_rule.computed = style->fill_rule.computed; // no averaging on this, just use the last one
547     }
549     // After all objects processed, divide the color if necessary and return
550     if (paint_res->set && paint_res->isColor()) { // set the color
551         g_assert (num >= 1);
553         c[0] /= num;
554         c[1] /= num;
555         c[2] /= num;
556         c[3] /= num;
557         paint_res->setColor(c[0], c[1], c[2]);
558         if (isfill) {
559             style_res->fill_opacity.value = SP_SCALE24_FROM_FLOAT (c[3]);
560         } else {
561             style_res->stroke_opacity.value = SP_SCALE24_FROM_FLOAT (c[3]);
562         }
565         if ( iccSeen && iccColor ) {
566             // TODO check for existing
567             SVGICCColor* tmp = new SVGICCColor(*iccColor);
568             paint_res->value.color.icc = tmp;
569         }
571         if (num > 1) {
572             if (same_color)
573                 return QUERY_STYLE_MULTIPLE_SAME;
574             else
575                 return QUERY_STYLE_MULTIPLE_AVERAGED;
576         } else {
577             return QUERY_STYLE_SINGLE;
578         }
579     }
581     // Not color
582     if (g_slist_length(objects) > 1) {
583         return QUERY_STYLE_MULTIPLE_SAME;
584     } else {
585         return QUERY_STYLE_SINGLE;
586     }
589 /**
590  * Write to style_res the average opacity of a list of objects.
591  */
592 int
593 objects_query_opacity (GSList *objects, SPStyle *style_res)
595     if (g_slist_length(objects) == 0) {
596         /* No objects, set empty */
597         return QUERY_STYLE_NOTHING;
598     }
600     gdouble opacity_sum = 0;
601     gdouble opacity_prev = -1;
602     bool same_opacity = true;
603     guint opacity_items = 0;
606     for (GSList const *i = objects; i != NULL; i = i->next) {
607         SPObject *obj = SP_OBJECT (i->data);
608         SPStyle *style = SP_OBJECT_STYLE (obj);
609         if (!style) continue;
611         double opacity = SP_SCALE24_TO_FLOAT(style->opacity.value);
612         opacity_sum += opacity;
613         if (opacity_prev != -1 && opacity != opacity_prev)
614             same_opacity = false;
615         opacity_prev = opacity;
616         opacity_items ++;
617     }
618     if (opacity_items > 1)
619         opacity_sum /= opacity_items;
621     style_res->opacity.value = SP_SCALE24_FROM_FLOAT(opacity_sum);
623     if (opacity_items == 0) {
624         return QUERY_STYLE_NOTHING;
625     } else if (opacity_items == 1) {
626         return QUERY_STYLE_SINGLE;
627     } else {
628         if (same_opacity)
629             return QUERY_STYLE_MULTIPLE_SAME;
630         else
631             return QUERY_STYLE_MULTIPLE_AVERAGED;
632     }
635 /**
636  * Write to style_res the average stroke width of a list of objects.
637  */
638 int
639 objects_query_strokewidth (GSList *objects, SPStyle *style_res)
641     if (g_slist_length(objects) == 0) {
642         /* No objects, set empty */
643         return QUERY_STYLE_NOTHING;
644     }
646     gdouble avgwidth = 0.0;
648     gdouble prev_sw = -1;
649     bool same_sw = true;
650     bool noneSet = true; // is stroke set to none?
652     int n_stroked = 0;
654     for (GSList const *i = objects; i != NULL; i = i->next) {
655         SPObject *obj = SP_OBJECT (i->data);
656         if (!SP_IS_ITEM(obj)) continue;
657         SPStyle *style = SP_OBJECT_STYLE (obj);
658         if (!style) continue;
660         if ( style->stroke.isNone() && !(
661                                 style->marker[SP_MARKER_LOC].set || // stroke width affects markers, so if there's no stroke but only markers then we should
662                                 style->marker[SP_MARKER_LOC_START].set || // still calculate the stroke width
663                                 style->marker[SP_MARKER_LOC_MID].set ||
664                                 style->marker[SP_MARKER_LOC_END].set))
665                 {
666             continue;
667         }
669         n_stroked ++;
671         noneSet &= style->stroke.isNone();
673         Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
674         double sw = style->stroke_width.computed * i2d.descrim();
676         if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3)
677             same_sw = false;
678         prev_sw = sw;
680         avgwidth += sw;
681     }
683     if (n_stroked > 1)
684         avgwidth /= (n_stroked);
686     style_res->stroke_width.computed = avgwidth;
687     style_res->stroke_width.set = true;
688     style_res->stroke.noneSet = noneSet; // Will only be true if none of the selected objects has it's stroke set.
690     if (n_stroked == 0) {
691         return QUERY_STYLE_NOTHING;
692     } else if (n_stroked == 1) {
693         return QUERY_STYLE_SINGLE;
694     } else {
695         if (same_sw)
696             return QUERY_STYLE_MULTIPLE_SAME;
697         else
698             return QUERY_STYLE_MULTIPLE_AVERAGED;
699     }
702 /**
703  * Write to style_res the average miter limit of a list of objects.
704  */
705 int
706 objects_query_miterlimit (GSList *objects, SPStyle *style_res)
708     if (g_slist_length(objects) == 0) {
709         /* No objects, set empty */
710         return QUERY_STYLE_NOTHING;
711     }
713     gdouble avgml = 0.0;
714     int n_stroked = 0;
716     gdouble prev_ml = -1;
717     bool same_ml = true;
719     for (GSList const *i = objects; i != NULL; i = i->next) {
720         SPObject *obj = SP_OBJECT (i->data);
721         if (!SP_IS_ITEM(obj)) continue;
722         SPStyle *style = SP_OBJECT_STYLE (obj);
723         if (!style) continue;
725         if ( style->stroke.isNone() ) {
726             continue;
727         }
729         n_stroked ++;
731         if (prev_ml != -1 && fabs(style->stroke_miterlimit.value - prev_ml) > 1e-3)
732             same_ml = false;
733         prev_ml = style->stroke_miterlimit.value;
735         avgml += style->stroke_miterlimit.value;
736     }
738     if (n_stroked > 1)
739         avgml /= (n_stroked);
741     style_res->stroke_miterlimit.value = avgml;
742     style_res->stroke_miterlimit.set = true;
744     if (n_stroked == 0) {
745         return QUERY_STYLE_NOTHING;
746     } else if (n_stroked == 1) {
747         return QUERY_STYLE_SINGLE;
748     } else {
749         if (same_ml)
750             return QUERY_STYLE_MULTIPLE_SAME;
751         else
752             return QUERY_STYLE_MULTIPLE_AVERAGED;
753     }
756 /**
757  * Write to style_res the stroke cap of a list of objects.
758  */
759 int
760 objects_query_strokecap (GSList *objects, SPStyle *style_res)
762     if (g_slist_length(objects) == 0) {
763         /* No objects, set empty */
764         return QUERY_STYLE_NOTHING;
765     }
767     int cap = -1;
768     gdouble prev_cap = -1;
769     bool same_cap = true;
770     int n_stroked = 0;
772     for (GSList const *i = objects; i != NULL; i = i->next) {
773         SPObject *obj = SP_OBJECT (i->data);
774         if (!SP_IS_ITEM(obj)) continue;
775         SPStyle *style = SP_OBJECT_STYLE (obj);
776         if (!style) continue;
778         if ( style->stroke.isNone() ) {
779             continue;
780         }
782         n_stroked ++;
784         if (prev_cap != -1 && style->stroke_linecap.value != prev_cap)
785             same_cap = false;
786         prev_cap = style->stroke_linecap.value;
788         cap = style->stroke_linecap.value;
789     }
791     style_res->stroke_linecap.value = cap;
792     style_res->stroke_linecap.set = true;
794     if (n_stroked == 0) {
795         return QUERY_STYLE_NOTHING;
796     } else if (n_stroked == 1) {
797         return QUERY_STYLE_SINGLE;
798     } else {
799         if (same_cap)
800             return QUERY_STYLE_MULTIPLE_SAME;
801         else
802             return QUERY_STYLE_MULTIPLE_DIFFERENT;
803     }
806 /**
807  * Write to style_res the stroke join of a list of objects.
808  */
809 int
810 objects_query_strokejoin (GSList *objects, SPStyle *style_res)
812     if (g_slist_length(objects) == 0) {
813         /* No objects, set empty */
814         return QUERY_STYLE_NOTHING;
815     }
817     int join = -1;
818     gdouble prev_join = -1;
819     bool same_join = true;
820     int n_stroked = 0;
822     for (GSList const *i = objects; i != NULL; i = i->next) {
823         SPObject *obj = SP_OBJECT (i->data);
824         if (!SP_IS_ITEM(obj)) continue;
825         SPStyle *style = SP_OBJECT_STYLE (obj);
826         if (!style) continue;
828         if ( style->stroke.isNone() ) {
829             continue;
830         }
832         n_stroked ++;
834         if (prev_join != -1 && style->stroke_linejoin.value != prev_join)
835             same_join = false;
836         prev_join = style->stroke_linejoin.value;
838         join = style->stroke_linejoin.value;
839     }
841     style_res->stroke_linejoin.value = join;
842     style_res->stroke_linejoin.set = true;
844     if (n_stroked == 0) {
845         return QUERY_STYLE_NOTHING;
846     } else if (n_stroked == 1) {
847         return QUERY_STYLE_SINGLE;
848     } else {
849         if (same_join)
850             return QUERY_STYLE_MULTIPLE_SAME;
851         else
852             return QUERY_STYLE_MULTIPLE_DIFFERENT;
853     }
856 /**
857  * Write to style_res the average font size and spacing of objects.
858  */
859 int
860 objects_query_fontnumbers (GSList *objects, SPStyle *style_res)
862     bool different = false;
864     double size = 0;
865     double letterspacing = 0;
866     double linespacing = 0;
867     bool linespacing_normal = false;
868     bool letterspacing_normal = false;
870     double size_prev = 0;
871     double letterspacing_prev = 0;
872     double linespacing_prev = 0;
874     /// \todo FIXME: add word spacing, kerns? rotates?
876     int texts = 0;
878     for (GSList const *i = objects; i != NULL; i = i->next) {
879         SPObject *obj = SP_OBJECT (i->data);
881         if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
882             && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
883             && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
884             continue;
886         SPStyle *style = SP_OBJECT_STYLE (obj);
887         if (!style) continue;
889         texts ++;
890         size += style->font_size.computed * Geom::Matrix(sp_item_i2d_affine(SP_ITEM(obj))).descrim(); /// \todo FIXME: we assume non-% units here
892         if (style->letter_spacing.normal) {
893             if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing))
894                 letterspacing_normal = true;
895         } else {
896             letterspacing += style->letter_spacing.computed; /// \todo FIXME: we assume non-% units here
897             letterspacing_normal = false;
898         }
900         double linespacing_current;
901         if (style->line_height.normal) {
902             linespacing_current = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
903             if (!different && (linespacing_prev == 0 || linespacing_prev == linespacing_current))
904                 linespacing_normal = true;
905         } else if (style->line_height.unit == SP_CSS_UNIT_PERCENT || style->font_size.computed == 0) {
906             linespacing_current = style->line_height.value;
907             linespacing_normal = false;
908         } else { // we need % here
909             linespacing_current = style->line_height.computed / style->font_size.computed;
910             linespacing_normal = false;
911         }
912         linespacing += linespacing_current;
914         if ((size_prev != 0 && style->font_size.computed != size_prev) ||
915             (letterspacing_prev != 0 && style->letter_spacing.computed != letterspacing_prev) ||
916             (linespacing_prev != 0 && linespacing_current != linespacing_prev)) {
917             different = true;
918         }
920         size_prev = style->font_size.computed;
921         letterspacing_prev = style->letter_spacing.computed;
922         linespacing_prev = linespacing_current;
924         // FIXME: we must detect MULTIPLE_DIFFERENT for these too
925         style_res->text_anchor.computed = style->text_anchor.computed;
926         style_res->writing_mode.computed = style->writing_mode.computed;
927     }
929     if (texts == 0)
930         return QUERY_STYLE_NOTHING;
932     if (texts > 1) {
933         size /= texts;
934         letterspacing /= texts;
935         linespacing /= texts;
936     }
938     style_res->font_size.computed = size;
939     style_res->font_size.type = SP_FONT_SIZE_LENGTH;
941     style_res->letter_spacing.normal = letterspacing_normal;
942     style_res->letter_spacing.computed = letterspacing;
944     style_res->line_height.normal = linespacing_normal;
945     style_res->line_height.computed = linespacing;
946     style_res->line_height.value = linespacing;
947     style_res->line_height.unit = SP_CSS_UNIT_PERCENT;
949     if (texts > 1) {
950         if (different) {
951             return QUERY_STYLE_MULTIPLE_AVERAGED;
952         } else {
953             return QUERY_STYLE_MULTIPLE_SAME;
954         }
955     } else {
956         return QUERY_STYLE_SINGLE;
957     }
960 /**
961  * Write to style_res the average font style of objects.
962  */
963 int
964 objects_query_fontstyle (GSList *objects, SPStyle *style_res)
966     bool different = false;
967     bool set = false;
969     int texts = 0;
971     for (GSList const *i = objects; i != NULL; i = i->next) {
972         SPObject *obj = SP_OBJECT (i->data);
974         if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
975             && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
976             && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
977             continue;
979         SPStyle *style = SP_OBJECT_STYLE (obj);
980         if (!style) continue;
982         texts ++;
984         if (set &&
985             font_style_to_pos(*style_res).signature() != font_style_to_pos(*style).signature() ) {
986             different = true;  // different styles
987         }
989         set = TRUE;
990         style_res->font_weight.value = style_res->font_weight.computed = style->font_weight.computed;
991         style_res->font_style.value = style_res->font_style.computed = style->font_style.computed;
992         style_res->font_stretch.value = style_res->font_stretch.computed = style->font_stretch.computed;
993         style_res->font_variant.value = style_res->font_variant.computed = style->font_variant.computed;
994         style_res->text_align.value = style_res->text_align.computed = style->text_align.computed;
995     }
997     if (texts == 0 || !set)
998         return QUERY_STYLE_NOTHING;
1000     if (texts > 1) {
1001         if (different) {
1002             return QUERY_STYLE_MULTIPLE_DIFFERENT;
1003         } else {
1004             return QUERY_STYLE_MULTIPLE_SAME;
1005         }
1006     } else {
1007         return QUERY_STYLE_SINGLE;
1008     }
1011 /**
1012  * Write to style_res the average font family of objects.
1013  */
1014 int
1015 objects_query_fontfamily (GSList *objects, SPStyle *style_res)
1017     bool different = false;
1018     int texts = 0;
1020     if (style_res->text->font_family.value) {
1021         g_free(style_res->text->font_family.value);
1022         style_res->text->font_family.value = NULL;
1023     }
1024     style_res->text->font_family.set = FALSE;
1026     for (GSList const *i = objects; i != NULL; i = i->next) {
1027         SPObject *obj = SP_OBJECT (i->data);
1029         if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
1030             && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
1031             && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
1032             continue;
1034         SPStyle *style = SP_OBJECT_STYLE (obj);
1035         if (!style) continue;
1037         texts ++;
1039         if (style_res->text->font_family.value && style->text->font_family.value &&
1040             strcmp (style_res->text->font_family.value, style->text->font_family.value)) {
1041             different = true;  // different fonts
1042         }
1044         if (style_res->text->font_family.value) {
1045             g_free(style_res->text->font_family.value);
1046             style_res->text->font_family.value = NULL;
1047         }
1049         style_res->text->font_family.set = TRUE;
1050         style_res->text->font_family.value = g_strdup(style->text->font_family.value);
1051     }
1053     if (texts == 0 || !style_res->text->font_family.set)
1054         return QUERY_STYLE_NOTHING;
1056     if (texts > 1) {
1057         if (different) {
1058             return QUERY_STYLE_MULTIPLE_DIFFERENT;
1059         } else {
1060             return QUERY_STYLE_MULTIPLE_SAME;
1061         }
1062     } else {
1063         return QUERY_STYLE_SINGLE;
1064     }
1067 int
1068 objects_query_fontspecification (GSList *objects, SPStyle *style_res)
1070     bool different = false;
1071     int texts = 0;
1073     if (style_res->text->font_specification.value) {
1074         g_free(style_res->text->font_specification.value);
1075         style_res->text->font_specification.value = NULL;
1076     }
1077     style_res->text->font_specification.set = FALSE;
1079     for (GSList const *i = objects; i != NULL; i = i->next) {
1080         SPObject *obj = SP_OBJECT (i->data);
1082         if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
1083             && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
1084             && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
1085             continue;
1087         SPStyle *style = SP_OBJECT_STYLE (obj);
1088         if (!style) continue;
1090         texts ++;
1092         if (style_res->text->font_specification.value && style_res->text->font_specification.set &&
1093             style->text->font_specification.value && style->text->font_specification.set &&
1094             strcmp (style_res->text->font_specification.value, style->text->font_specification.value)) {
1095             different = true;  // different fonts
1096         }
1098         if (style->text->font_specification.set) {
1100             if (style_res->text->font_specification.value) {
1101                 g_free(style_res->text->font_specification.value);
1102                 style_res->text->font_specification.value = NULL;
1103             }
1105             style_res->text->font_specification.set = TRUE;
1106             style_res->text->font_specification.value = g_strdup(style->text->font_specification.value);
1107         }
1108     }
1110     if (texts == 0)
1111         return QUERY_STYLE_NOTHING;
1113     if (texts > 1) {
1114         if (different) {
1115             return QUERY_STYLE_MULTIPLE_DIFFERENT;
1116         } else {
1117             return QUERY_STYLE_MULTIPLE_SAME;
1118         }
1119     } else {
1120         return QUERY_STYLE_SINGLE;
1121     }
1124 int
1125 objects_query_blend (GSList *objects, SPStyle *style_res)
1127     const int empty_prev = -2;
1128     const int complex_filter = 5;
1129     int blend = 0;
1130     float blend_prev = empty_prev;
1131     bool same_blend = true;
1132     guint items = 0;
1134     for (GSList const *i = objects; i != NULL; i = i->next) {
1135         SPObject *obj = SP_OBJECT (i->data);
1136         SPStyle *style = SP_OBJECT_STYLE (obj);
1137         if(!style || !SP_IS_ITEM(obj)) continue;
1139         items++;
1141         //if object has a filter
1142         if (style->filter.set && style->getFilter()) {
1143             int blurcount = 0;
1144             int blendcount = 0;
1146             // determine whether filter is simple (blend and/or blur) or complex
1147             for(SPObject *primitive_obj = style->getFilter()->children;
1148                 primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj);
1149                 primitive_obj = primitive_obj->next) {
1150                 SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
1151                 if(SP_IS_FEBLEND(primitive))
1152                     ++blendcount;
1153                 else if(SP_IS_GAUSSIANBLUR(primitive))
1154                     ++blurcount;
1155                 else {
1156                     blurcount = complex_filter;
1157                     break;
1158                 }
1159             }
1161             // simple filter
1162             if(blurcount == 1 || blendcount == 1) {
1163                 for(SPObject *primitive_obj = style->getFilter()->children;
1164                     primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj);
1165                     primitive_obj = primitive_obj->next) {
1166                     if(SP_IS_FEBLEND(primitive_obj)) {
1167                         SPFeBlend *spblend = SP_FEBLEND(primitive_obj);
1168                         blend = spblend->blend_mode;
1169                     }
1170                 }
1171             }
1172             else {
1173                 blend = complex_filter;
1174             }
1175         }
1176         // defaults to blend mode = "normal"
1177         else {
1178             blend = 0;
1179         }
1181         if(blend_prev != empty_prev && blend_prev != blend)
1182             same_blend = false;
1183         blend_prev = blend;
1184     }
1186     if (items > 0) {
1187         style_res->filter_blend_mode.value = blend;
1188     }
1190     if (items == 0) {
1191         return QUERY_STYLE_NOTHING;
1192     } else if (items == 1) {
1193         return QUERY_STYLE_SINGLE;
1194     } else {
1195         if(same_blend)
1196             return QUERY_STYLE_MULTIPLE_SAME;
1197         else
1198             return QUERY_STYLE_MULTIPLE_DIFFERENT;
1199     }
1202 /**
1203  * Write to style_res the average blurring of a list of objects.
1204  */
1205 int
1206 objects_query_blur (GSList *objects, SPStyle *style_res)
1208    if (g_slist_length(objects) == 0) {
1209         /* No objects, set empty */
1210         return QUERY_STYLE_NOTHING;
1211     }
1213     float blur_sum = 0;
1214     float blur_prev = -1;
1215     bool same_blur = true;
1216     guint blur_items = 0;
1217     guint items = 0;
1219     for (GSList const *i = objects; i != NULL; i = i->next) {
1220         SPObject *obj = SP_OBJECT (i->data);
1221         SPStyle *style = SP_OBJECT_STYLE (obj);
1222         if (!style) continue;
1223         if (!SP_IS_ITEM(obj)) continue;
1225         Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
1227         items ++;
1229         //if object has a filter
1230         if (style->filter.set && style->getFilter()) {
1231             //cycle through filter primitives
1232             SPObject *primitive_obj = style->getFilter()->children;
1233             while (primitive_obj) {
1234                 if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) {
1235                     SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
1237                     //if primitive is gaussianblur
1238                     if(SP_IS_GAUSSIANBLUR(primitive)) {
1239                         SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive);
1240                         float num = spblur->stdDeviation.getNumber();
1241                         blur_sum += num * i2d.descrim();
1242                         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
1243                             same_blur = false;
1244                         blur_prev = num;
1245                         //TODO: deal with opt number, for the moment it's not necessary to the ui.
1246                         blur_items ++;
1247                     }
1248                 }
1249                 primitive_obj = primitive_obj->next;
1250             }
1251         }
1252     }
1254     if (items > 0) {
1255         if (blur_items > 0)
1256             blur_sum /= blur_items;
1257         style_res->filter_gaussianBlur_deviation.value = blur_sum;
1258     }
1260     if (items == 0) {
1261         return QUERY_STYLE_NOTHING;
1262     } else if (items == 1) {
1263         return QUERY_STYLE_SINGLE;
1264     } else {
1265         if (same_blur)
1266             return QUERY_STYLE_MULTIPLE_SAME;
1267         else
1268             return QUERY_STYLE_MULTIPLE_AVERAGED;
1269     }
1272 /**
1273  * Query the given list of objects for the given property, write
1274  * the result to style, return appropriate flag.
1275  */
1276 int
1277 sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property)
1279     if (property == QUERY_STYLE_PROPERTY_FILL) {
1280         return objects_query_fillstroke (list, style, true);
1281     } else if (property == QUERY_STYLE_PROPERTY_STROKE) {
1282         return objects_query_fillstroke (list, style, false);
1284     } else if (property == QUERY_STYLE_PROPERTY_STROKEWIDTH) {
1285         return objects_query_strokewidth (list, style);
1286     } else if (property == QUERY_STYLE_PROPERTY_STROKEMITERLIMIT) {
1287         return objects_query_miterlimit (list, style);
1288     } else if (property == QUERY_STYLE_PROPERTY_STROKECAP) {
1289         return objects_query_strokecap (list, style);
1290     } else if (property == QUERY_STYLE_PROPERTY_STROKEJOIN) {
1291         return objects_query_strokejoin (list, style);
1293     } else if (property == QUERY_STYLE_PROPERTY_MASTEROPACITY) {
1294         return objects_query_opacity (list, style);
1296     } else if (property == QUERY_STYLE_PROPERTY_FONT_SPECIFICATION) {
1297         return objects_query_fontspecification (list, style);
1298     } else if (property == QUERY_STYLE_PROPERTY_FONTFAMILY) {
1299         return objects_query_fontfamily (list, style);
1300     } else if (property == QUERY_STYLE_PROPERTY_FONTSTYLE) {
1301         return objects_query_fontstyle (list, style);
1302     } else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) {
1303         return objects_query_fontnumbers (list, style);
1305     } else if (property == QUERY_STYLE_PROPERTY_BLEND) {
1306         return objects_query_blend (list, style);
1307     } else if (property == QUERY_STYLE_PROPERTY_BLUR) {
1308         return objects_query_blur (list, style);
1309     }
1310     return QUERY_STYLE_NOTHING;
1314 /**
1315  * Query the subselection (if any) or selection on the given desktop for the given property, write
1316  * the result to style, return appropriate flag.
1317  */
1318 int
1319 sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
1321     int ret = desktop->_query_style_signal.emit(style, property);
1323     if (ret != QUERY_STYLE_NOTHING)
1324         return ret; // subselection returned a style, pass it on
1326     // otherwise, do querying and averaging over selection
1327     if (desktop->selection != NULL) {
1328         return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property);
1329     }
1331     return QUERY_STYLE_NOTHING;
1334 /**
1335  * Do the same as sp_desktop_query_style for all (defined) style properties, return true if at
1336  * least one of the properties did not return QUERY_STYLE_NOTHING.
1337  */
1338 bool
1339 sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
1341         int result_family = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
1342         int result_fstyle = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
1343         int result_fnumbers = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
1344         int result_fill = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FILL);
1345         int result_stroke = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKE);
1346         int result_strokewidth = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEWIDTH);
1347         int result_strokemiterlimit = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
1348         int result_strokecap = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKECAP);
1349         int result_strokejoin = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEJOIN);
1350         int result_opacity = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
1351         int result_blur = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR);
1353         return (result_family != QUERY_STYLE_NOTHING ||
1354                 result_fstyle != QUERY_STYLE_NOTHING ||
1355                 result_fnumbers != QUERY_STYLE_NOTHING ||
1356                 result_fill != QUERY_STYLE_NOTHING ||
1357                 result_stroke != QUERY_STYLE_NOTHING ||
1358                 result_opacity != QUERY_STYLE_NOTHING ||
1359                 result_strokewidth != QUERY_STYLE_NOTHING ||
1360                 result_strokemiterlimit != QUERY_STYLE_NOTHING ||
1361                 result_strokecap != QUERY_STYLE_NOTHING ||
1362                 result_strokejoin != QUERY_STYLE_NOTHING ||
1363                 result_blur != QUERY_STYLE_NOTHING);
1367 /*
1368   Local Variables:
1369   mode:c++
1370   c-file-style:"stroustrup"
1371   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1372   indent-tabs-mode:nil
1373   fill-column:99
1374   End:
1375 */
1376 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :