Code

BUG 322116, PDF export does not use the highest quality for rasterized filter
[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);
171         
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     }
258    
259     if (css) {
260         gchar const *property = css ? sp_repr_css_property(css, "opacity", "1.000") : 0;
261            
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     }
287    
288     if (css) {
289         gchar const *property = css ? sp_repr_css_property(css, is_fill ? "fill-opacity": "stroke-opacity", "1.000") : 0;
290            
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)
305 {   
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     }
316    
317     if (css) {
318         gchar const *property = sp_repr_css_property(css, is_fill ? "fill" : "stroke", "#000");
319            
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();
343     
344     if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
345         sp_repr_css_set(repr, css_current, "style");
346     } else {
347         SPCSSAttr *css = prefs->getStyle(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;
651     int n_stroked = 0;
653     for (GSList const *i = objects; i != NULL; i = i->next) {
654         SPObject *obj = SP_OBJECT (i->data);
655         if (!SP_IS_ITEM(obj)) continue;
656         SPStyle *style = SP_OBJECT_STYLE (obj);
657         if (!style) continue;
659         if ( style->stroke.isNone() ) {
660             continue;
661         }
663         n_stroked ++;
665         Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
666         double sw = style->stroke_width.computed * i2d.descrim();
668         if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3)
669             same_sw = false;
670         prev_sw = sw;
672         avgwidth += sw;
673     }
675     if (n_stroked > 1)
676         avgwidth /= (n_stroked);
678     style_res->stroke_width.computed = avgwidth;
679     style_res->stroke_width.set = true;
681     if (n_stroked == 0) {
682         return QUERY_STYLE_NOTHING;
683     } else if (n_stroked == 1) {
684         return QUERY_STYLE_SINGLE;
685     } else {
686         if (same_sw)
687             return QUERY_STYLE_MULTIPLE_SAME;
688         else
689             return QUERY_STYLE_MULTIPLE_AVERAGED;
690     }
693 /**
694  * Write to style_res the average miter limit of a list of objects.
695  */
696 int
697 objects_query_miterlimit (GSList *objects, SPStyle *style_res)
699     if (g_slist_length(objects) == 0) {
700         /* No objects, set empty */
701         return QUERY_STYLE_NOTHING;
702     }
704     gdouble avgml = 0.0;
705     int n_stroked = 0;
707     gdouble prev_ml = -1;
708     bool same_ml = true;
710     for (GSList const *i = objects; i != NULL; i = i->next) {
711         SPObject *obj = SP_OBJECT (i->data);
712         if (!SP_IS_ITEM(obj)) continue;
713         SPStyle *style = SP_OBJECT_STYLE (obj);
714         if (!style) continue;
716         if ( style->stroke.isNone() ) {
717             continue;
718         }
720         n_stroked ++;
722         if (prev_ml != -1 && fabs(style->stroke_miterlimit.value - prev_ml) > 1e-3)
723             same_ml = false;
724         prev_ml = style->stroke_miterlimit.value;
726         avgml += style->stroke_miterlimit.value;
727     }
729     if (n_stroked > 1)
730         avgml /= (n_stroked);
732     style_res->stroke_miterlimit.value = avgml;
733     style_res->stroke_miterlimit.set = true;
735     if (n_stroked == 0) {
736         return QUERY_STYLE_NOTHING;
737     } else if (n_stroked == 1) {
738         return QUERY_STYLE_SINGLE;
739     } else {
740         if (same_ml)
741             return QUERY_STYLE_MULTIPLE_SAME;
742         else
743             return QUERY_STYLE_MULTIPLE_AVERAGED;
744     }
747 /**
748  * Write to style_res the stroke cap of a list of objects.
749  */
750 int
751 objects_query_strokecap (GSList *objects, SPStyle *style_res)
753     if (g_slist_length(objects) == 0) {
754         /* No objects, set empty */
755         return QUERY_STYLE_NOTHING;
756     }
758     int cap = -1;
759     gdouble prev_cap = -1;
760     bool same_cap = true;
761     int n_stroked = 0;
763     for (GSList const *i = objects; i != NULL; i = i->next) {
764         SPObject *obj = SP_OBJECT (i->data);
765         if (!SP_IS_ITEM(obj)) continue;
766         SPStyle *style = SP_OBJECT_STYLE (obj);
767         if (!style) continue;
769         if ( style->stroke.isNone() ) {
770             continue;
771         }
773         n_stroked ++;
775         if (prev_cap != -1 && style->stroke_linecap.value != prev_cap)
776             same_cap = false;
777         prev_cap = style->stroke_linecap.value;
779         cap = style->stroke_linecap.value;
780     }
782     style_res->stroke_linecap.value = cap;
783     style_res->stroke_linecap.set = true;
785     if (n_stroked == 0) {
786         return QUERY_STYLE_NOTHING;
787     } else if (n_stroked == 1) {
788         return QUERY_STYLE_SINGLE;
789     } else {
790         if (same_cap)
791             return QUERY_STYLE_MULTIPLE_SAME;
792         else
793             return QUERY_STYLE_MULTIPLE_DIFFERENT;
794     }
797 /**
798  * Write to style_res the stroke join of a list of objects.
799  */
800 int
801 objects_query_strokejoin (GSList *objects, SPStyle *style_res)
803     if (g_slist_length(objects) == 0) {
804         /* No objects, set empty */
805         return QUERY_STYLE_NOTHING;
806     }
808     int join = -1;
809     gdouble prev_join = -1;
810     bool same_join = true;
811     int n_stroked = 0;
813     for (GSList const *i = objects; i != NULL; i = i->next) {
814         SPObject *obj = SP_OBJECT (i->data);
815         if (!SP_IS_ITEM(obj)) continue;
816         SPStyle *style = SP_OBJECT_STYLE (obj);
817         if (!style) continue;
819         if ( style->stroke.isNone() ) {
820             continue;
821         }
823         n_stroked ++;
825         if (prev_join != -1 && style->stroke_linejoin.value != prev_join)
826             same_join = false;
827         prev_join = style->stroke_linejoin.value;
829         join = style->stroke_linejoin.value;
830     }
832     style_res->stroke_linejoin.value = join;
833     style_res->stroke_linejoin.set = true;
835     if (n_stroked == 0) {
836         return QUERY_STYLE_NOTHING;
837     } else if (n_stroked == 1) {
838         return QUERY_STYLE_SINGLE;
839     } else {
840         if (same_join)
841             return QUERY_STYLE_MULTIPLE_SAME;
842         else
843             return QUERY_STYLE_MULTIPLE_DIFFERENT;
844     }
847 /**
848  * Write to style_res the average font size and spacing of objects.
849  */
850 int
851 objects_query_fontnumbers (GSList *objects, SPStyle *style_res)
853     bool different = false;
855     double size = 0;
856     double letterspacing = 0;
857     double linespacing = 0;
858     bool linespacing_normal = false;
859     bool letterspacing_normal = false;
861     double size_prev = 0;
862     double letterspacing_prev = 0;
863     double linespacing_prev = 0;
865     /// \todo FIXME: add word spacing, kerns? rotates?
867     int texts = 0;
869     for (GSList const *i = objects; i != NULL; i = i->next) {
870         SPObject *obj = SP_OBJECT (i->data);
872         if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
873             && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
874             && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
875             continue;
877         SPStyle *style = SP_OBJECT_STYLE (obj);
878         if (!style) continue;
880         texts ++;
881         size += style->font_size.computed * Geom::Matrix(sp_item_i2d_affine(SP_ITEM(obj))).descrim(); /// \todo FIXME: we assume non-% units here
883         if (style->letter_spacing.normal) {
884             if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing))
885                 letterspacing_normal = true;
886         } else {
887             letterspacing += style->letter_spacing.computed; /// \todo FIXME: we assume non-% units here
888             letterspacing_normal = false;
889         }
891         double linespacing_current;
892         if (style->line_height.normal) {
893             linespacing_current = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
894             if (!different && (linespacing_prev == 0 || linespacing_prev == linespacing_current))
895                 linespacing_normal = true;
896         } else if (style->line_height.unit == SP_CSS_UNIT_PERCENT || style->font_size.computed == 0) {
897             linespacing_current = style->line_height.value;
898             linespacing_normal = false;
899         } else { // we need % here
900             linespacing_current = style->line_height.computed / style->font_size.computed;
901             linespacing_normal = false;
902         }
903         linespacing += linespacing_current;
905         if ((size_prev != 0 && style->font_size.computed != size_prev) ||
906             (letterspacing_prev != 0 && style->letter_spacing.computed != letterspacing_prev) ||
907             (linespacing_prev != 0 && linespacing_current != linespacing_prev)) {
908             different = true;
909         }
911         size_prev = style->font_size.computed;
912         letterspacing_prev = style->letter_spacing.computed;
913         linespacing_prev = linespacing_current;
915         // FIXME: we must detect MULTIPLE_DIFFERENT for these too
916         style_res->text_anchor.computed = style->text_anchor.computed;
917         style_res->writing_mode.computed = style->writing_mode.computed;
918     }
920     if (texts == 0)
921         return QUERY_STYLE_NOTHING;
923     if (texts > 1) {
924         size /= texts;
925         letterspacing /= texts;
926         linespacing /= texts;
927     }
929     style_res->font_size.computed = size;
930     style_res->font_size.type = SP_FONT_SIZE_LENGTH;
932     style_res->letter_spacing.normal = letterspacing_normal;
933     style_res->letter_spacing.computed = letterspacing;
935     style_res->line_height.normal = linespacing_normal;
936     style_res->line_height.computed = linespacing;
937     style_res->line_height.value = linespacing;
938     style_res->line_height.unit = SP_CSS_UNIT_PERCENT;
940     if (texts > 1) {
941         if (different) {
942             return QUERY_STYLE_MULTIPLE_AVERAGED;
943         } else {
944             return QUERY_STYLE_MULTIPLE_SAME;
945         }
946     } else {
947         return QUERY_STYLE_SINGLE;
948     }
951 /**
952  * Write to style_res the average font style of objects.
953  */
954 int
955 objects_query_fontstyle (GSList *objects, SPStyle *style_res)
957     bool different = false;
958     bool set = false;
960     int texts = 0;
962     for (GSList const *i = objects; i != NULL; i = i->next) {
963         SPObject *obj = SP_OBJECT (i->data);
965         if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
966             && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
967             && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
968             continue;
970         SPStyle *style = SP_OBJECT_STYLE (obj);
971         if (!style) continue;
973         texts ++;
975         if (set &&
976             font_style_to_pos(*style_res).signature() != font_style_to_pos(*style).signature() ) {
977             different = true;  // different styles
978         }
980         set = TRUE;
981         style_res->font_weight.value = style_res->font_weight.computed = style->font_weight.computed;
982         style_res->font_style.value = style_res->font_style.computed = style->font_style.computed;
983         style_res->font_stretch.value = style_res->font_stretch.computed = style->font_stretch.computed;
984         style_res->font_variant.value = style_res->font_variant.computed = style->font_variant.computed;
985         style_res->text_align.value = style_res->text_align.computed = style->text_align.computed;
986     }
988     if (texts == 0 || !set)
989         return QUERY_STYLE_NOTHING;
991     if (texts > 1) {
992         if (different) {
993             return QUERY_STYLE_MULTIPLE_DIFFERENT;
994         } else {
995             return QUERY_STYLE_MULTIPLE_SAME;
996         }
997     } else {
998         return QUERY_STYLE_SINGLE;
999     }
1002 /**
1003  * Write to style_res the average font family of objects.
1004  */
1005 int
1006 objects_query_fontfamily (GSList *objects, SPStyle *style_res)
1008     bool different = false;
1009     int texts = 0;
1011     if (style_res->text->font_family.value) {
1012         g_free(style_res->text->font_family.value);
1013         style_res->text->font_family.value = NULL;
1014     }
1015     style_res->text->font_family.set = FALSE;
1017     for (GSList const *i = objects; i != NULL; i = i->next) {
1018         SPObject *obj = SP_OBJECT (i->data);
1020         if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
1021             && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
1022             && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
1023             continue;
1025         SPStyle *style = SP_OBJECT_STYLE (obj);
1026         if (!style) continue;
1028         texts ++;
1030         if (style_res->text->font_family.value && style->text->font_family.value &&
1031             strcmp (style_res->text->font_family.value, style->text->font_family.value)) {
1032             different = true;  // different fonts
1033         }
1035         if (style_res->text->font_family.value) {
1036             g_free(style_res->text->font_family.value);
1037             style_res->text->font_family.value = NULL;
1038         }
1040         style_res->text->font_family.set = TRUE;
1041         style_res->text->font_family.value = g_strdup(style->text->font_family.value);
1042     }
1044     if (texts == 0 || !style_res->text->font_family.set)
1045         return QUERY_STYLE_NOTHING;
1047     if (texts > 1) {
1048         if (different) {
1049             return QUERY_STYLE_MULTIPLE_DIFFERENT;
1050         } else {
1051             return QUERY_STYLE_MULTIPLE_SAME;
1052         }
1053     } else {
1054         return QUERY_STYLE_SINGLE;
1055     }
1058 int
1059 objects_query_fontspecification (GSList *objects, SPStyle *style_res)
1061     bool different = false;
1062     int texts = 0;
1064     if (style_res->text->font_specification.value) {
1065         g_free(style_res->text->font_specification.value);
1066         style_res->text->font_specification.value = NULL;
1067     }
1068     style_res->text->font_specification.set = FALSE;
1070     for (GSList const *i = objects; i != NULL; i = i->next) {
1071         SPObject *obj = SP_OBJECT (i->data);
1073         if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
1074             && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
1075             && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
1076             continue;
1078         SPStyle *style = SP_OBJECT_STYLE (obj);
1079         if (!style) continue;
1081         texts ++;
1083         if (style_res->text->font_specification.value && style_res->text->font_specification.set &&   
1084             style->text->font_specification.value && style->text->font_specification.set &&
1085             strcmp (style_res->text->font_specification.value, style->text->font_specification.value)) {
1086             different = true;  // different fonts
1087         }
1088         
1089         if (style->text->font_specification.set) {
1091             if (style_res->text->font_specification.value) {
1092                 g_free(style_res->text->font_specification.value);
1093                 style_res->text->font_specification.value = NULL;
1094             }
1095     
1096             style_res->text->font_specification.set = TRUE;
1097             style_res->text->font_specification.value = g_strdup(style->text->font_specification.value);
1098         }
1099     }
1101     if (texts == 0)
1102         return QUERY_STYLE_NOTHING;
1104     if (texts > 1) {
1105         if (different) {
1106             return QUERY_STYLE_MULTIPLE_DIFFERENT;
1107         } else {
1108             return QUERY_STYLE_MULTIPLE_SAME;
1109         }
1110     } else {
1111         return QUERY_STYLE_SINGLE;
1112     }
1115 int
1116 objects_query_blend (GSList *objects, SPStyle *style_res)
1118     const int empty_prev = -2;
1119     const int complex_filter = 5;
1120     int blend = 0;
1121     float blend_prev = empty_prev;
1122     bool same_blend = true;
1123     guint items = 0;
1124     
1125     for (GSList const *i = objects; i != NULL; i = i->next) {
1126         SPObject *obj = SP_OBJECT (i->data);
1127         SPStyle *style = SP_OBJECT_STYLE (obj);
1128         if(!style || !SP_IS_ITEM(obj)) continue;
1130         items++;
1132         //if object has a filter
1133         if (style->filter.set && style->getFilter()) {
1134             int blurcount = 0;
1135             int blendcount = 0;
1137             // determine whether filter is simple (blend and/or blur) or complex
1138             for(SPObject *primitive_obj = style->getFilter()->children;
1139                 primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj);
1140                 primitive_obj = primitive_obj->next) {
1141                 SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
1142                 if(SP_IS_FEBLEND(primitive))
1143                     ++blendcount;
1144                 else if(SP_IS_GAUSSIANBLUR(primitive))
1145                     ++blurcount;
1146                 else {
1147                     blurcount = complex_filter;
1148                     break;
1149                 }
1150             }
1152             // simple filter
1153             if(blurcount == 1 || blendcount == 1) {
1154                 for(SPObject *primitive_obj = style->getFilter()->children;
1155                     primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj);
1156                     primitive_obj = primitive_obj->next) {
1157                     if(SP_IS_FEBLEND(primitive_obj)) {
1158                         SPFeBlend *spblend = SP_FEBLEND(primitive_obj);
1159                         blend = spblend->blend_mode;
1160                     }
1161                 }
1162             }
1163             else {
1164                 blend = complex_filter;
1165             }
1166         }
1167         // defaults to blend mode = "normal"
1168         else {
1169             blend = 0;
1170         }
1172         if(blend_prev != empty_prev && blend_prev != blend)
1173             same_blend = false;
1174         blend_prev = blend;
1175     }
1177     if (items > 0) {
1178         style_res->filter_blend_mode.value = blend;
1179     }
1181     if (items == 0) {
1182         return QUERY_STYLE_NOTHING;
1183     } else if (items == 1) {
1184         return QUERY_STYLE_SINGLE;
1185     } else {
1186         if(same_blend)
1187             return QUERY_STYLE_MULTIPLE_SAME;
1188         else
1189             return QUERY_STYLE_MULTIPLE_DIFFERENT;
1190     }
1193 /**
1194  * Write to style_res the average blurring of a list of objects.
1195  */
1196 int
1197 objects_query_blur (GSList *objects, SPStyle *style_res)
1199    if (g_slist_length(objects) == 0) {
1200         /* No objects, set empty */
1201         return QUERY_STYLE_NOTHING;
1202     }
1204     float blur_sum = 0;
1205     float blur_prev = -1;
1206     bool same_blur = true;
1207     guint blur_items = 0;
1208     guint items = 0;
1209     
1210     for (GSList const *i = objects; i != NULL; i = i->next) {
1211         SPObject *obj = SP_OBJECT (i->data);
1212         SPStyle *style = SP_OBJECT_STYLE (obj);
1213         if (!style) continue;
1214         if (!SP_IS_ITEM(obj)) continue;
1216         Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
1218         items ++;
1220         //if object has a filter
1221         if (style->filter.set && style->getFilter()) {
1222             //cycle through filter primitives
1223             SPObject *primitive_obj = style->getFilter()->children;
1224             while (primitive_obj) {
1225                 if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) {
1226                     SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
1227                     
1228                     //if primitive is gaussianblur
1229                     if(SP_IS_GAUSSIANBLUR(primitive)) {
1230                         SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive);
1231                         float num = spblur->stdDeviation.getNumber();
1232                         blur_sum += num * i2d.descrim();
1233                         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
1234                             same_blur = false;
1235                         blur_prev = num;
1236                         //TODO: deal with opt number, for the moment it's not necessary to the ui.
1237                         blur_items ++;
1238                     }
1239                 }
1240                 primitive_obj = primitive_obj->next;
1241             }
1242         }
1243     }
1245     if (items > 0) {
1246         if (blur_items > 0)
1247             blur_sum /= blur_items;
1248         style_res->filter_gaussianBlur_deviation.value = blur_sum;
1249     }
1251     if (items == 0) {
1252         return QUERY_STYLE_NOTHING;
1253     } else if (items == 1) {
1254         return QUERY_STYLE_SINGLE;
1255     } else {
1256         if (same_blur)
1257             return QUERY_STYLE_MULTIPLE_SAME;
1258         else
1259             return QUERY_STYLE_MULTIPLE_AVERAGED;
1260     }
1263 /**
1264  * Query the given list of objects for the given property, write
1265  * the result to style, return appropriate flag.
1266  */
1267 int
1268 sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property)
1270     if (property == QUERY_STYLE_PROPERTY_FILL) {
1271         return objects_query_fillstroke (list, style, true);
1272     } else if (property == QUERY_STYLE_PROPERTY_STROKE) {
1273         return objects_query_fillstroke (list, style, false);
1275     } else if (property == QUERY_STYLE_PROPERTY_STROKEWIDTH) {
1276         return objects_query_strokewidth (list, style);
1277     } else if (property == QUERY_STYLE_PROPERTY_STROKEMITERLIMIT) {
1278         return objects_query_miterlimit (list, style);
1279     } else if (property == QUERY_STYLE_PROPERTY_STROKECAP) {
1280         return objects_query_strokecap (list, style);
1281     } else if (property == QUERY_STYLE_PROPERTY_STROKEJOIN) {
1282         return objects_query_strokejoin (list, style);
1284     } else if (property == QUERY_STYLE_PROPERTY_MASTEROPACITY) {
1285         return objects_query_opacity (list, style);
1286         
1287     } else if (property == QUERY_STYLE_PROPERTY_FONT_SPECIFICATION) {
1288         return objects_query_fontspecification (list, style);
1289     } else if (property == QUERY_STYLE_PROPERTY_FONTFAMILY) {
1290         return objects_query_fontfamily (list, style);
1291     } else if (property == QUERY_STYLE_PROPERTY_FONTSTYLE) {
1292         return objects_query_fontstyle (list, style);
1293     } else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) {
1294         return objects_query_fontnumbers (list, style);
1296     } else if (property == QUERY_STYLE_PROPERTY_BLEND) {
1297         return objects_query_blend (list, style);
1298     } else if (property == QUERY_STYLE_PROPERTY_BLUR) {
1299         return objects_query_blur (list, style);
1300     }
1301     return QUERY_STYLE_NOTHING;
1305 /**
1306  * Query the subselection (if any) or selection on the given desktop for the given property, write
1307  * the result to style, return appropriate flag.
1308  */
1309 int
1310 sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
1312     int ret = desktop->_query_style_signal.emit(style, property);
1314     if (ret != QUERY_STYLE_NOTHING)
1315         return ret; // subselection returned a style, pass it on
1317     // otherwise, do querying and averaging over selection
1318     return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property);
1321 /**
1322  * Do the same as sp_desktop_query_style for all (defined) style properties, return true if at 
1323  * least one of the properties did not return QUERY_STYLE_NOTHING.
1324  */
1325 bool
1326 sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
1328         int result_family = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
1329         int result_fstyle = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
1330         int result_fnumbers = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
1331         int result_fill = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FILL);
1332         int result_stroke = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKE);
1333         int result_strokewidth = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEWIDTH);
1334         int result_strokemiterlimit = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
1335         int result_strokecap = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKECAP);
1336         int result_strokejoin = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEJOIN);
1337         int result_opacity = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
1338         int result_blur = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR);
1339         
1340         return (result_family != QUERY_STYLE_NOTHING || 
1341                 result_fstyle != QUERY_STYLE_NOTHING || 
1342                 result_fnumbers != QUERY_STYLE_NOTHING || 
1343                 result_fill != QUERY_STYLE_NOTHING || 
1344                 result_stroke != QUERY_STYLE_NOTHING || 
1345                 result_opacity != QUERY_STYLE_NOTHING || 
1346                 result_strokewidth != QUERY_STYLE_NOTHING || 
1347                 result_strokemiterlimit != QUERY_STYLE_NOTHING ||
1348                 result_strokecap != QUERY_STYLE_NOTHING ||
1349                 result_strokejoin != QUERY_STYLE_NOTHING ||
1350                 result_blur != QUERY_STYLE_NOTHING);
1354 /*
1355   Local Variables:
1356   mode:c++
1357   c-file-style:"stroustrup"
1358   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1359   indent-tabs-mode:nil
1360   fill-column:99
1361   End:
1362 */
1363 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :