desktop-style.cpp revision f8663560deb57dfd332026dbc1f25ae8b9904863
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Desktop style management
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Authors:
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * bulia byak
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * verbalshadow
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Copyright (C) 2004, 2006 authors
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Released under GNU GPL, read the file 'COPYING' for more information
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Set color on selection on desktop.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxsp_desktop_set_color(SPDesktop *desktop, ColorRGBA const &color, bool is_relative, bool fill)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /// \todo relative color setting
c533a883a71cff9ff32df1c53c31201e1cbf371fhx g_warning("FIXME: relative color setting not yet implemented");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx guint32 rgba = SP_RGBA32_F_COMPOSE(color[0], color[1], color[2], color[3]);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx sp_repr_css_set_property(css, "fill-opacity", osalpha.str().c_str());
c533a883a71cff9ff32df1c53c31201e1cbf371fhx sp_repr_css_set_property(css, "stroke-opacity", osalpha.str().c_str());
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Apply style on object and children, recursively.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxsp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // non-items should not have style
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // 1. tspans with role=line are not regular objects in that they are not supposed to have style of their own,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // but must always inherit from the parent text. Same for textPath.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // However, if the line tspan or textPath contains some style (old file?), we reluctantly set our style to it too.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // 2. Generally we allow setting style on clones, but when it's inside flowRegion, do not touch
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // it, be it clone or not; it's just styleless shape (because that's how Inkscape does
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // flowtext).
c533a883a71cff9ff32df1c53c31201e1cbf371fhx && ((SP_IS_TSPAN(o) && SP_TSPAN(o)->role == SP_TSPAN_ROLE_LINE)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // Scale the style by the inverse of the accumulated parent transform in the paste context.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx Geom::Matrix const local(sp_item_i2doc_affine(SP_ITEM(o)));
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if ( ( ex != 0. )
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // setting style on child of clone spills into the clone original (via shared repr), don't do it!
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (SPObject *child = sp_object_first_child(SP_OBJECT(o)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (sp_repr_css_property(css, "opacity", NULL) != NULL) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // Unset properties which are accumulating and thus should not be set recursively.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // 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.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx sp_desktop_apply_css_recursive(child, css_recurse, skip_lines);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Apply style on selection on desktop.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxsp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx Inkscape::Preferences *prefs = Inkscape::Preferences::get();
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // 1. Set internal value
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // 1a. Write to prefs; make a copy and unset any URIs first
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* last used styles for 3D box faces are stored separately */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx const char * descr = box3d_side_axes_string(SP_BOX3D_SIDE(i->data));
c533a883a71cff9ff32df1c53c31201e1cbf371fhx prefs->mergeStyle(Glib::ustring("/desktop/") + descr + "/style", css_write);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx// 2. Emit signal
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * FIXME: in set_style, compensate pattern and gradient fills, stroke width,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * rect corners, font size for the object's own transform so that pasting
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * fills does not depend on preserve/optimize.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx// 3. If nobody has intercepted the signal, apply the style to the selection
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = desktop->selection->itemList(); i != NULL; i = i->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /// \todo if the style is text-only, apply only to texts?
c533a883a71cff9ff32df1c53c31201e1cbf371fhx sp_desktop_apply_css_recursive(SP_OBJECT(i->data), css, true);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Return the desktop's current style.
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China * Return the desktop's current color.
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing Chinasp_desktop_get_color(SPDesktop *desktop, bool is_fill)
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China guint32 r = 0; // if there's no color, return black
c533a883a71cff9ff32df1c53c31201e1cbf371fhx gchar const *property = sp_repr_css_property(desktop->current,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (desktop->current && property) { // if there is style and the property in it,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (strncmp(property, "url", 3)) { // and if it's not url,
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // read it
c533a883a71cff9ff32df1c53c31201e1cbf371fhxsp_desktop_get_master_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool *has_opacity)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx Inkscape::Preferences *prefs = Inkscape::Preferences::get();
c533a883a71cff9ff32df1c53c31201e1cbf371fhx gchar const *property = css ? sp_repr_css_property(css, "opacity", "1.000") : 0;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (desktop->current && property) { // if there is style and the property in it,
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing Chinasp_desktop_get_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx Inkscape::Preferences *prefs = Inkscape::Preferences::get();
43439c96b8398c01c375889c79bed72d78fb4c39hx gchar const *property = css ? sp_repr_css_property(css, is_fill ? "fill-opacity": "stroke-opacity", "1.000") : 0;
43439c96b8398c01c375889c79bed72d78fb4c39hx if (desktop->current && property) { // if there is style and the property in it,
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if ( !sp_svg_number_read_f(property, &value) ) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China value = 1.0; // things failed. set back to the default
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China sp_repr_css_attr_unref(css);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return value;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing Chinasp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill, bool *has_color)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China Inkscape::Preferences *prefs = Inkscape::Preferences::get();
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China SPCSSAttr *css = NULL;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China guint32 r = 0; // if there's no color, return black
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (has_color)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China *has_color = false;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (prefs->getBool(tool + "/usecurrent")) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China css = sp_desktop_get_style(desktop, true);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China css = prefs->getStyle(tool + "/style");
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China gchar const *property = sp_repr_css_property(css, is_fill ? "fill" : "stroke", "#000");
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (desktop->current && property) { // if there is style and the property in it,
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (strncmp(property, "url", 3) && strncmp(property, "none", 4)) { // and if it's not url or none,
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China r = sp_svg_read_color(property, r);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (has_color)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China *has_color = true;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return r | 0xff;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Apply the desktop's current style or the tool style to repr.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxsp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool_path, bool with_text)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan SPCSSAttr *css_current = sp_desktop_get_style(desktop, with_text);
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan Inkscape::Preferences *prefs = Inkscape::Preferences::get();
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
f3c4902c7f91725a7b538a3d82f1993bff02944fpengcheng chen - Sun Microsystems - Beijing China sp_repr_css_attr_unref(css);
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (css_current) {
6f12def440a1ce798ab128210a43414d173669f0pengcheng chen - Sun Microsystems - Beijing China sp_repr_css_attr_unref(css_current);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Returns the font size (in SVG pixels) of the text tool style (if text
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * tool uses its own style) or desktop style (otherwise).
c533a883a71cff9ff32df1c53c31201e1cbf371fhx Inkscape::Preferences *prefs = Inkscape::Preferences::get();
c533a883a71cff9ff32df1c53c31201e1cbf371fhx Glib::ustring desktop_style = prefs->getString("/desktop/style");
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if ((prefs->getBool("/tools/text/usecurrent")) && !desktop_style.empty()) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx sp_style_merge_from_style_string(style, style_str.data());
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China sp_style_unref(style);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx/** Determine average stroke width, simple method */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx// see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool notstroked = true;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *l = objects; l != NULL; l = l->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data));
c533a883a71cff9ff32df1c53c31201e1cbf371fhx avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * i2d.descrim();
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Write to style_res the average fill or stroke of list of objects, if applicable.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxobjects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* No objects, set empty */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx SPIPaint *paint_res = isfill? &style_res->fill : &style_res->stroke;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool iccSeen = false;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool same_color = true;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer for (GSList const *i = objects; i != NULL; i = i->next) {
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan if (!style) continue;
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan SPIPaint *paint = isfill? &style->fill : &style->stroke;
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer // We consider paint "effectively set" for anything within text hierarchy
c533a883a71cff9ff32df1c53c31201e1cbf371fhx paint->set || (SP_IS_TEXT(parent) || SP_IS_TEXTPATH(parent) || SP_IS_TSPAN(parent)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx || SP_IS_FLOWTEXT(parent) || SP_IS_FLOWDIV(parent) || SP_IS_FLOWPARA(parent)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // 1. Bail out with QUERY_STYLE_MULTIPLE_DIFFERENT if necessary
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if ((!paintImpossible) && (!paint->isSameType(*paint_res) || (paint_res->set != paint_effectively_set))) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return QUERY_STYLE_MULTIPLE_DIFFERENT; // different types of paint
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (paint_res->set && paint->set && paint_res->isPaintserver()) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // both previous paint and this paint were a server, see if the servers are compatible
c533a883a71cff9ff32df1c53c31201e1cbf371fhx SPPaintServer *server_res = isfill? SP_STYLE_FILL_SERVER (style_res) : SP_STYLE_STROKE_SERVER (style_res);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx SPPaintServer *server = isfill? SP_STYLE_FILL_SERVER (style) : SP_STYLE_STROKE_SERVER (style);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server
c533a883a71cff9ff32df1c53c31201e1cbf371fhx SPGradient *vector = sp_gradient_get_vector ( SP_GRADIENT (server), FALSE );
c533a883a71cff9ff32df1c53c31201e1cbf371fhx SPGradient *vector_res = sp_gradient_get_vector ( SP_GRADIENT (server_res), FALSE );
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return QUERY_STYLE_MULTIPLE_DIFFERENT; // different gradient vectors
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (!SP_IS_RADIALGRADIENT(server))
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server
d62cb7fff63265824a8e6725a3bcef698f6134c9hx SPGradient *vector = sp_gradient_get_vector ( SP_GRADIENT (server), FALSE );
d62cb7fff63265824a8e6725a3bcef698f6134c9hx SPGradient *vector_res = sp_gradient_get_vector ( SP_GRADIENT (server_res), FALSE );
d62cb7fff63265824a8e6725a3bcef698f6134c9hx return QUERY_STYLE_MULTIPLE_DIFFERENT; // different gradient vectors
09539a3c2da6fef054f5306232ef0480de261eabpengcheng chen - Sun Microsystems - Beijing China if (!SP_IS_PATTERN(server))
09539a3c2da6fef054f5306232ef0480de261eabpengcheng chen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server
09539a3c2da6fef054f5306232ef0480de261eabpengcheng chen - Sun Microsystems - Beijing China SPPattern *pat = pattern_getroot (SP_PATTERN (server));
09539a3c2da6fef054f5306232ef0480de261eabpengcheng chen - Sun Microsystems - Beijing China SPPattern *pat_res = pattern_getroot (SP_PATTERN (server_res));
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China if (pat_res != pat)
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_DIFFERENT; // different pattern roots
d62cb7fff63265824a8e6725a3bcef698f6134c9hx // 2. Sum color, copy server from paint to paint_res
d62cb7fff63265824a8e6725a3bcef698f6134c9hx if (paint_res->set && paint_effectively_set && paint->isColor()) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // Check if this color is the same as previous
c533a883a71cff9ff32df1c53c31201e1cbf371fhx prev[0] = d[0];
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (same_color && (prev[0] != d[0] || prev[1] != d[1] || prev[2] != d[2]))
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // TODO fix this
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // average color
c533a883a71cff9ff32df1c53c31201e1cbf371fhx c[0] += d[0];
c533a883a71cff9ff32df1c53c31201e1cbf371fhx c[3] += SP_SCALE24_TO_FLOAT (isfill? style->fill_opacity.value : style->stroke_opacity.value);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (paint_res->set && paint_effectively_set && paint->isPaintserver()) { // copy the server
c533a883a71cff9ff32df1c53c31201e1cbf371fhx sp_style_set_to_uri_string (style_res, true, style->getFillURI());
c533a883a71cff9ff32df1c53c31201e1cbf371fhx sp_style_set_to_uri_string (style_res, false, style->getStrokeURI());
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->fill_rule.computed = style->fill_rule.computed; // no averaging on this, just use the last one
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // After all objects processed, divide the color if necessary and return
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (paint_res->set && paint_res->isColor()) { // set the color
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China g_assert (num >= 1);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China paint_res->setColor(c[0], c[1], c[2]);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (isfill) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China style_res->fill_opacity.value = SP_SCALE24_FROM_FLOAT (c[3]);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China style_res->stroke_opacity.value = SP_SCALE24_FROM_FLOAT (c[3]);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if ( iccSeen && iccColor ) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China // TODO check for existing
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China SVGICCColor* tmp = new SVGICCColor(*iccColor);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China paint_res->value.color.icc = tmp;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (num > 1) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (same_color)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_SAME;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_AVERAGED;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return QUERY_STYLE_SINGLE;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (g_slist_length(objects) > 1) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_SAME;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return QUERY_STYLE_SINGLE;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China * Write to style_res the average opacity of a list of objects.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxobjects_query_opacity (GSList *objects, SPStyle *style_res)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* No objects, set empty */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool same_opacity = true;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China for (GSList const *i = objects; i != NULL; i = i->next) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China SPObject *obj = SP_OBJECT (i->data);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx double opacity = SP_SCALE24_TO_FLOAT(style->opacity.value);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China opacity_items ++;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->opacity.value = SP_SCALE24_FROM_FLOAT(opacity_sum);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return QUERY_STYLE_SINGLE;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Write to style_res the average stroke width of a list of objects.
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing Chinaobjects_query_strokewidth (GSList *objects, SPStyle *style_res)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* No objects, set empty */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool same_sw = true;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = objects; i != NULL; i = i->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style->marker[SP_MARKER_LOC].set || // stroke width affects markers, so if there's no stroke but only markers then we should
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style->marker[SP_MARKER_LOC_START].set || // still calculate the stroke width
c533a883a71cff9ff32df1c53c31201e1cbf371fhx double sw = style->stroke_width.computed * i2d.descrim();
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China if (n_stroked > 1)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China avgwidth /= (n_stroked);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->stroke.noneSet = noneSet; // Will only be true if none of the selected objects has it's stroke set.
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China if (n_stroked == 0) {
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China if (same_sw)
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_SAME;
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_AVERAGED;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Write to style_res the average miter limit of a list of objects.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxobjects_query_miterlimit (GSList *objects, SPStyle *style_res)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* No objects, set empty */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool same_ml = true;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China for (GSList const *i = objects; i != NULL; i = i->next) {
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China SPObject *obj = SP_OBJECT (i->data);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China n_stroked ++;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (prev_ml != -1 && fabs(style->stroke_miterlimit.value - prev_ml) > 1e-3)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China same_ml = false;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China prev_ml = style->stroke_miterlimit.value;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China style_res->stroke_miterlimit.value = avgml;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (n_stroked == 0) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_SAME;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_AVERAGED;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Write to style_res the stroke cap of a list of objects.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxobjects_query_strokecap (GSList *objects, SPStyle *style_res)
19d332fefbc61327bb6187d0eb818629f3b52c6ffei feng - Sun Microsystems - Beijing China /* No objects, set empty */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool same_cap = true;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = objects; i != NULL; i = i->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (prev_cap != -1 && style->stroke_linecap.value != prev_cap)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (n_stroked == 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Write to style_res the stroke join of a list of objects.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxobjects_query_strokejoin (GSList *objects, SPStyle *style_res)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* No objects, set empty */
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China gdouble prev_join = -1;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China bool same_join = true;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China int n_stroked = 0;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = objects; i != NULL; i = i->next) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China SPObject *obj = SP_OBJECT (i->data);
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (!SP_IS_ITEM(obj)) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (prev_join != -1 && style->stroke_linejoin.value != prev_join)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China join = style->stroke_linejoin.value;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China style_res->stroke_linejoin.value = join;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (n_stroked == 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Write to style_res the average font size and spacing of objects.
d62cb7fff63265824a8e6725a3bcef698f6134c9hxobjects_query_fontnumbers (GSList *objects, SPStyle *style_res)
d62cb7fff63265824a8e6725a3bcef698f6134c9hx bool different = false;
d62cb7fff63265824a8e6725a3bcef698f6134c9hx double size = 0;
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China bool linespacing_normal = false;
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China bool letterspacing_normal = false;
d40f4da491abdcae192eb797766f5f44772a832fpengcheng chen - Sun Microsystems - Beijing China double size_prev = 0;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /// \todo FIXME: add word spacing, kerns? rotates?
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = objects; i != NULL; i = i->next) {
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx size += style->font_size.computed * Geom::Matrix(sp_item_i2d_affine(SP_ITEM(obj))).descrim(); /// \todo FIXME: we assume non-% units here
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing))
c533a883a71cff9ff32df1c53c31201e1cbf371fhx letterspacing += style->letter_spacing.computed; /// \todo FIXME: we assume non-% units here
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if (style->line_height.normal) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx linespacing_current = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!different && (linespacing_prev == 0 || linespacing_prev == linespacing_current))
c533a883a71cff9ff32df1c53c31201e1cbf371fhx } else if (style->line_height.unit == SP_CSS_UNIT_PERCENT || style->font_size.computed == 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx } else { // we need % here
c533a883a71cff9ff32df1c53c31201e1cbf371fhx linespacing_current = style->line_height.computed / style->font_size.computed;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China linespacing_normal = false;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China linespacing += linespacing_current;
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China if ((size_prev != 0 && style->font_size.computed != size_prev) ||
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China (letterspacing_prev != 0 && style->letter_spacing.computed != letterspacing_prev) ||
cdc64593cc1046229f4ac4daf5ead688b5efe6ebxinghua wen - Sun Microsystems - Beijing China (linespacing_prev != 0 && linespacing_current != linespacing_prev)) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // FIXME: we must detect MULTIPLE_DIFFERENT for these too
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->text_anchor.computed = style->text_anchor.computed;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->writing_mode.computed = style->writing_mode.computed;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China size /= texts;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China letterspacing /= texts;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China linespacing /= texts;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China style_res->font_size.computed = size;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China style_res->font_size.type = SP_FONT_SIZE_LENGTH;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China style_res->letter_spacing.normal = letterspacing_normal;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China style_res->letter_spacing.computed = letterspacing;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China style_res->line_height.normal = linespacing_normal;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China style_res->line_height.computed = linespacing;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China style_res->line_height.value = linespacing;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China style_res->line_height.unit = SP_CSS_UNIT_PERCENT;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China if (texts > 1) {
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China if (different) {
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_AVERAGED;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_SAME;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China return QUERY_STYLE_SINGLE;
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China * Write to style_res the average font style of objects.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxobjects_query_fontstyle (GSList *objects, SPStyle *style_res)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool different = false;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool set = false;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = objects; i != NULL; i = i->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx font_style_to_pos(*style_res).signature() != font_style_to_pos(*style).signature() ) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->font_weight.value = style_res->font_weight.computed = style->font_weight.computed;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->font_style.value = style_res->font_style.computed = style->font_style.computed;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->font_stretch.value = style_res->font_stretch.computed = style->font_stretch.computed;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->font_variant.value = style_res->font_variant.computed = style->font_variant.computed;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->text_align.value = style_res->text_align.computed = style->text_align.computed;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Write to style_res the average font family of objects.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxobjects_query_fontfamily (GSList *objects, SPStyle *style_res)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool different = false;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = objects; i != NULL; i = i->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (style_res->text->font_family.value && style->text->font_family.value &&
c533a883a71cff9ff32df1c53c31201e1cbf371fhx strcmp (style_res->text->font_family.value, style->text->font_family.value)) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->text->font_family.value = g_strdup(style->text->font_family.value);
c533a883a71cff9ff32df1c53c31201e1cbf371fhxobjects_query_fontspecification (GSList *objects, SPStyle *style_res)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool different = false;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = objects; i != NULL; i = i->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (style_res->text->font_specification.value && style_res->text->font_specification.set &&
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style->text->font_specification.value && style->text->font_specification.set &&
c533a883a71cff9ff32df1c53c31201e1cbf371fhx strcmp (style_res->text->font_specification.value, style->text->font_specification.value)) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->text->font_specification.value = g_strdup(style->text->font_specification.value);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool same_blend = true;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = objects; i != NULL; i = i->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx //if object has a filter
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // determine whether filter is simple (blend and/or blur) or complex
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for(SPObject *primitive_obj = style->getFilter()->children;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // simple filter
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for(SPObject *primitive_obj = style->getFilter()->children;
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China blend = complex_filter;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // defaults to blend mode = "normal"
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (items > 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (items == 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Write to style_res the average blurring of a list of objects.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx /* No objects, set empty */
c533a883a71cff9ff32df1c53c31201e1cbf371fhx bool same_blur = true;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx for (GSList const *i = objects; i != NULL; i = i->next) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (!style) continue;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx //if object has a filter
c533a883a71cff9ff32df1c53c31201e1cbf371fhx //cycle through filter primitives
c533a883a71cff9ff32df1c53c31201e1cbf371fhx SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx //if primitive is gaussianblur
c533a883a71cff9ff32df1c53c31201e1cbf371fhx 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
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China same_blur = false;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx //TODO: deal with opt number, for the moment it's not necessary to the ui.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (items > 0) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx style_res->filter_gaussianBlur_deviation.value = blur_sum;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (items == 0) {
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China return QUERY_STYLE_MULTIPLE_SAME;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Query the given list of objects for the given property, write
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China * the result to style, return appropriate flag.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxsp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx } else if (property == QUERY_STYLE_PROPERTY_STROKEWIDTH) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx } else if (property == QUERY_STYLE_PROPERTY_STROKEMITERLIMIT) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx } else if (property == QUERY_STYLE_PROPERTY_STROKEJOIN) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx } else if (property == QUERY_STYLE_PROPERTY_MASTEROPACITY) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx } else if (property == QUERY_STYLE_PROPERTY_FONT_SPECIFICATION) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx } else if (property == QUERY_STYLE_PROPERTY_FONTFAMILY) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx } else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) {
d2a61391af480de12cf4264080d7254a6de96e2apengcheng chen - Sun Microsystems - Beijing China } else if (property == QUERY_STYLE_PROPERTY_BLUR) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Query the subselection (if any) or selection on the given desktop for the given property, write
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * the result to style, return appropriate flag.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxsp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int ret = desktop->_query_style_signal.emit(style, property);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx // otherwise, do querying and averaging over selection
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Do the same as sp_desktop_query_style for all (defined) style properties, return true if at
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * least one of the properties did not return QUERY_STYLE_NOTHING.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxsp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_family = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_fstyle = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_fnumbers = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_fill = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_FILL);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_stroke = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKE);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_strokewidth = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEWIDTH);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_strokemiterlimit = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_strokecap = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKECAP);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_strokejoin = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEJOIN);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_opacity = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx int result_blur = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR);
b510adae7e8895b2bf58eda3537fd56df35302e4fei feng - Sun Microsystems - Beijing China result_fstyle != QUERY_STYLE_NOTHING ||
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China result_opacity != QUERY_STYLE_NOTHING ||
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China result_strokewidth != QUERY_STYLE_NOTHING ||
c533a883a71cff9ff32df1c53c31201e1cbf371fhx Local Variables:
c533a883a71cff9ff32df1c53c31201e1cbf371fhx c-file-style:"stroustrup"
c533a883a71cff9ff32df1c53c31201e1cbf371fhx c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
c533a883a71cff9ff32df1c53c31201e1cbf371fhx indent-tabs-mode:nil
c533a883a71cff9ff32df1c53c31201e1cbf371fhx fill-column:99
c50ced99bb75273dc8c4c36876d2e8f59a64f4b1pengcheng chen - Sun Microsystems - Beijing China// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :