From 8b04d0db6c55e36935690d37defb6f9b68945796 Mon Sep 17 00:00:00 2001 From: johnce Date: Wed, 5 Aug 2009 05:40:36 +0000 Subject: SPDocument->Document (bzr r8404) --- src/style.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/style.cpp') diff --git a/src/style.cpp b/src/style.cpp index dd8169282..e564aa60b 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -84,10 +84,10 @@ static void sp_style_read_istring(SPIString *val, gchar const *str); static void sp_style_read_ilength(SPILength *val, gchar const *str); static void sp_style_read_ilengthornormal(SPILengthOrNormal *val, gchar const *str); static void sp_style_read_itextdecoration(SPITextDecoration *val, gchar const *str); -static void sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document); -static void sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document); +static void sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, Document *document); +static void sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, Document *document); static void sp_style_read_ifontsize(SPIFontSize *val, gchar const *str); -static void sp_style_read_ifilter(gchar const *str, SPStyle *style, SPDocument *document); +static void sp_style_read_ifilter(gchar const *str, SPStyle *style, Document *document); static void sp_style_read_penum(SPIEnum *val, Inkscape::XML::Node *repr, gchar const *key, SPStyleEnum const *dict, bool can_explicitly_inherit); static void sp_style_read_plength(SPILength *val, Inkscape::XML::Node *repr, gchar const *key); @@ -443,7 +443,7 @@ sp_style_stroke_paint_server_ref_changed(SPObject *old_ref, SPObject *ref, SPSty * Returns a new SPStyle object with settings as per sp_style_clear(). */ SPStyle * -sp_style_new(SPDocument *document) +sp_style_new(Document *document) { SPStyle *const style = g_new0(SPStyle, 1); @@ -1086,7 +1086,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) break; } case SP_PROP_MARKER: - /* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */ + /* TODO: Call sp_uri_reference_resolve(Document *document, guchar const *uri) */ /* style->marker[SP_MARKER_LOC] = g_quark_from_string(val); */ if (!style->marker[SP_MARKER_LOC].set) { g_free(style->marker[SP_MARKER_LOC].value); @@ -1097,7 +1097,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) break; case SP_PROP_MARKER_START: - /* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */ + /* TODO: Call sp_uri_reference_resolve(Document *document, guchar const *uri) */ if (!style->marker[SP_MARKER_LOC_START].set) { g_free(style->marker[SP_MARKER_LOC_START].value); style->marker[SP_MARKER_LOC_START].value = g_strdup(val); @@ -1106,7 +1106,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) } break; case SP_PROP_MARKER_MID: - /* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */ + /* TODO: Call sp_uri_reference_resolve(Document *document, guchar const *uri) */ if (!style->marker[SP_MARKER_LOC_MID].set) { g_free(style->marker[SP_MARKER_LOC_MID].value); style->marker[SP_MARKER_LOC_MID].value = g_strdup(val); @@ -1115,7 +1115,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) } break; case SP_PROP_MARKER_END: - /* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */ + /* TODO: Call sp_uri_reference_resolve(Document *document, guchar const *uri) */ if (!style->marker[SP_MARKER_LOC_END].set) { g_free(style->marker[SP_MARKER_LOC_END].value); style->marker[SP_MARKER_LOC_END].value = g_strdup(val); @@ -2111,7 +2111,7 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare static void -sp_style_set_ipaint_to_uri(SPStyle *style, SPIPaint *paint, const Inkscape::URI *uri, SPDocument *document) +sp_style_set_ipaint_to_uri(SPStyle *style, SPIPaint *paint, const Inkscape::URI *uri, Document *document) { // it may be that this style's SPIPaint has not yet created its URIReference; // now that we have a document, we can create it here @@ -2561,7 +2561,7 @@ sp_style_clear(SPStyle *style) /** \todo fixme: Do that text manipulation via parents */ SPObject *object = style->object; - SPDocument *document = style->document; + Document *document = style->document; gint const refcount = style->refcount; SPTextStyle *text = style->text; unsigned const text_private = style->text_private; @@ -3089,7 +3089,7 @@ sp_style_read_itextdecoration(SPITextDecoration *val, gchar const *str) * \param document Ignored */ static void -sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document) +sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, Document *document) { (void)style; // TODO (void)document; // TODO @@ -3114,7 +3114,7 @@ sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocume * \pre paint == \&style.fill || paint == \&style.stroke. */ static void -sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document) +sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, Document *document) { while (g_ascii_isspace(*str)) { ++str; @@ -3248,7 +3248,7 @@ sp_style_read_ifontsize(SPIFontSize *val, gchar const *str) * Set SPIFilter object from string. */ static void -sp_style_read_ifilter(gchar const *str, SPStyle * style, SPDocument *document) +sp_style_read_ifilter(gchar const *str, SPStyle * style, Document *document) { SPIFilter *f = &(style->filter); /* Try all possible values: inherit, none, uri */ -- cgit v1.2.3 From 51c2905fd3e99955db2d823b79abb763d8097028 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Thu, 6 Aug 2009 14:17:17 +0000 Subject: Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. (bzr r8422) --- src/style.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/style.cpp') diff --git a/src/style.cpp b/src/style.cpp index e564aa60b..dd8169282 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -84,10 +84,10 @@ static void sp_style_read_istring(SPIString *val, gchar const *str); static void sp_style_read_ilength(SPILength *val, gchar const *str); static void sp_style_read_ilengthornormal(SPILengthOrNormal *val, gchar const *str); static void sp_style_read_itextdecoration(SPITextDecoration *val, gchar const *str); -static void sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, Document *document); -static void sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, Document *document); +static void sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document); +static void sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document); static void sp_style_read_ifontsize(SPIFontSize *val, gchar const *str); -static void sp_style_read_ifilter(gchar const *str, SPStyle *style, Document *document); +static void sp_style_read_ifilter(gchar const *str, SPStyle *style, SPDocument *document); static void sp_style_read_penum(SPIEnum *val, Inkscape::XML::Node *repr, gchar const *key, SPStyleEnum const *dict, bool can_explicitly_inherit); static void sp_style_read_plength(SPILength *val, Inkscape::XML::Node *repr, gchar const *key); @@ -443,7 +443,7 @@ sp_style_stroke_paint_server_ref_changed(SPObject *old_ref, SPObject *ref, SPSty * Returns a new SPStyle object with settings as per sp_style_clear(). */ SPStyle * -sp_style_new(Document *document) +sp_style_new(SPDocument *document) { SPStyle *const style = g_new0(SPStyle, 1); @@ -1086,7 +1086,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) break; } case SP_PROP_MARKER: - /* TODO: Call sp_uri_reference_resolve(Document *document, guchar const *uri) */ + /* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */ /* style->marker[SP_MARKER_LOC] = g_quark_from_string(val); */ if (!style->marker[SP_MARKER_LOC].set) { g_free(style->marker[SP_MARKER_LOC].value); @@ -1097,7 +1097,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) break; case SP_PROP_MARKER_START: - /* TODO: Call sp_uri_reference_resolve(Document *document, guchar const *uri) */ + /* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */ if (!style->marker[SP_MARKER_LOC_START].set) { g_free(style->marker[SP_MARKER_LOC_START].value); style->marker[SP_MARKER_LOC_START].value = g_strdup(val); @@ -1106,7 +1106,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) } break; case SP_PROP_MARKER_MID: - /* TODO: Call sp_uri_reference_resolve(Document *document, guchar const *uri) */ + /* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */ if (!style->marker[SP_MARKER_LOC_MID].set) { g_free(style->marker[SP_MARKER_LOC_MID].value); style->marker[SP_MARKER_LOC_MID].value = g_strdup(val); @@ -1115,7 +1115,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) } break; case SP_PROP_MARKER_END: - /* TODO: Call sp_uri_reference_resolve(Document *document, guchar const *uri) */ + /* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */ if (!style->marker[SP_MARKER_LOC_END].set) { g_free(style->marker[SP_MARKER_LOC_END].value); style->marker[SP_MARKER_LOC_END].value = g_strdup(val); @@ -2111,7 +2111,7 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare static void -sp_style_set_ipaint_to_uri(SPStyle *style, SPIPaint *paint, const Inkscape::URI *uri, Document *document) +sp_style_set_ipaint_to_uri(SPStyle *style, SPIPaint *paint, const Inkscape::URI *uri, SPDocument *document) { // it may be that this style's SPIPaint has not yet created its URIReference; // now that we have a document, we can create it here @@ -2561,7 +2561,7 @@ sp_style_clear(SPStyle *style) /** \todo fixme: Do that text manipulation via parents */ SPObject *object = style->object; - Document *document = style->document; + SPDocument *document = style->document; gint const refcount = style->refcount; SPTextStyle *text = style->text; unsigned const text_private = style->text_private; @@ -3089,7 +3089,7 @@ sp_style_read_itextdecoration(SPITextDecoration *val, gchar const *str) * \param document Ignored */ static void -sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, Document *document) +sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document) { (void)style; // TODO (void)document; // TODO @@ -3114,7 +3114,7 @@ sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, Document * \pre paint == \&style.fill || paint == \&style.stroke. */ static void -sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, Document *document) +sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document) { while (g_ascii_isspace(*str)) { ++str; @@ -3248,7 +3248,7 @@ sp_style_read_ifontsize(SPIFontSize *val, gchar const *str) * Set SPIFilter object from string. */ static void -sp_style_read_ifilter(gchar const *str, SPStyle * style, Document *document) +sp_style_read_ifilter(gchar const *str, SPStyle * style, SPDocument *document) { SPIFilter *f = &(style->filter); /* Try all possible values: inherit, none, uri */ -- cgit v1.2.3 From 9cc89eaa165ec2a27c81bca683dfd5f546f890eb Mon Sep 17 00:00:00 2001 From: bulia byak Date: Sat, 22 Aug 2009 18:16:34 +0000 Subject: fix 272408 and address fixmes: fix inheriting of dasharray and dashoffset, make them correctly handle inherit values; test case for the bug is added to the testsuite (bzr r8519) --- src/style.cpp | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'src/style.cpp') diff --git a/src/style.cpp b/src/style.cpp index dd8169282..0b946f348 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -711,11 +711,14 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr) sp_style_read_dash(style, val); } } + if (!style->stroke_dashoffset_set) { - /* fixme */ val = repr->attribute("stroke-dashoffset"); if (sp_svg_number_read_d(val, &style->stroke_dash.offset)) { style->stroke_dashoffset_set = TRUE; + } else if (val && !strcmp(val, "inherit")) { + style->stroke_dashoffset_set = TRUE; + style->stroke_dashoffset_inherit = TRUE; } else { style->stroke_dashoffset_set = FALSE; } @@ -1146,9 +1149,11 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) break; case SP_PROP_STROKE_DASHOFFSET: if (!style->stroke_dashoffset_set) { - /* fixme */ if (sp_svg_number_read_d(val, &style->stroke_dash.offset)) { style->stroke_dashoffset_set = TRUE; + } else if (val && !strcmp(val, "inherit")) { + style->stroke_dashoffset_set = TRUE; + style->stroke_dashoffset_inherit = TRUE; } else { style->stroke_dashoffset_set = FALSE; } @@ -1526,11 +1531,7 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent) style->stroke_miterlimit.value = parent->stroke_miterlimit.value; } - if (!style->stroke_dasharray_set && parent->stroke_dasharray_set) { - /** \todo - * This code looks wrong. Why does the logic differ from the - * above properties? Similarly dashoffset below. - */ + if (!style->stroke_dasharray_set || style->stroke_dasharray_inherit) { style->stroke_dash.n_dash = parent->stroke_dash.n_dash; if (style->stroke_dash.n_dash > 0) { style->stroke_dash.dash = g_new(gdouble, style->stroke_dash.n_dash); @@ -1538,7 +1539,7 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent) } } - if (!style->stroke_dashoffset_set && parent->stroke_dashoffset_set) { + if (!style->stroke_dashoffset_set || style->stroke_dashoffset_inherit) { style->stroke_dash.offset = parent->stroke_dash.offset; } @@ -2100,10 +2101,11 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare } /* Note: this will need length handling once dasharray_offset supports units. */ - if (!style->stroke_dashoffset_set && parent->stroke_dashoffset_set) { + if ((!style->stroke_dashoffset_set || style->stroke_dashoffset_inherit) && parent->stroke_dashoffset_set && !parent->stroke_dashoffset_inherit) { style->stroke_dash.offset = parent->stroke_dash.offset; style->stroke_dashoffset_set = parent->stroke_dashoffset_set; - /* fixme: we don't currently allow stroke-dashoffset to be `inherit'. TODO: Try to + style->stroke_dashoffset_inherit = parent->stroke_dashoffset_inherit; + /* TODO: Try to * represent it as a normal SPILength; though will need to do something about existing * users of stroke_dash.offset and stroke_dashoffset_set. */ } @@ -2326,9 +2328,13 @@ sp_style_write_string(SPStyle const *const style, guint const flags) /** \todo fixme: */ if (style->stroke_dashoffset_set) { - Inkscape::CSSOStringStream os; - os << "stroke-dashoffset:" << style->stroke_dash.offset << ";"; - p += g_strlcpy(p, os.str().c_str(), c + BMAX - p); + if (style->stroke_dashoffset_inherit) { + p += g_snprintf(p, c + BMAX - p, "stroke-dashoffset:inherit;"); + } else { + Inkscape::CSSOStringStream os; + os << "stroke-dashoffset:" << style->stroke_dash.offset << ";"; + p += g_strlcpy(p, os.str().c_str(), c + BMAX - p); + } } else if (flags == SP_STYLE_FLAG_ALWAYS) { p += g_snprintf(p, c + BMAX - p, "stroke-dashoffset:0;"); } @@ -2478,9 +2484,13 @@ sp_style_write_difference(SPStyle const *const from, SPStyle const *const to) } /* fixme: */ if (from->stroke_dashoffset_set) { - Inkscape::CSSOStringStream os; - os << "stroke-dashoffset:" << from->stroke_dash.offset << ";"; - p += g_strlcpy(p, os.str().c_str(), c + BMAX - p); + if (from->stroke_dashoffset_inherit) { + p += g_snprintf(p, c + BMAX - p, "stroke-dashoffset:inherit;"); + } else { + Inkscape::CSSOStringStream os; + os << "stroke-dashoffset:" << from->stroke_dash.offset << ";"; + p += g_strlcpy(p, os.str().c_str(), c + BMAX - p); + } } p += sp_style_write_iscale24(p, c + BMAX - p, "stroke-opacity", &from->stroke_opacity, &to->stroke_opacity, SP_STYLE_FLAG_IFDIFF); } @@ -2559,6 +2569,9 @@ sp_style_clear(SPStyle *style) g_free(style->stroke_dash.dash); } + style->stroke_dasharray_inherit = FALSE; + style->stroke_dashoffset_inherit = FALSE; + /** \todo fixme: Do that text manipulation via parents */ SPObject *object = style->object; SPDocument *document = style->document; -- cgit v1.2.3