diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2018-03-07 13:47:42 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2018-03-07 13:47:42 +0000 |
| commit | 0326e4287a1f6a4f52d9a3998adf8670e25c85da (patch) | |
| tree | c46729df7d9b1c42222ebda19f688d2aa691aea6 /src/object/sp-path.cpp | |
| parent | Remove unused includes, etc. (diff) | |
| download | inkscape-0326e4287a1f6a4f52d9a3998adf8670e25c85da.tar.gz inkscape-0326e4287a1f6a4f52d9a3998adf8670e25c85da.zip | |
Promote the path 'd' attribute to a property per SVG 2. Try 2.
See e88644b0 for first attempt and for comments.
Diffstat (limited to 'src/object/sp-path.cpp')
| -rw-r--r-- | src/object/sp-path.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/object/sp-path.cpp b/src/object/sp-path.cpp index a0c7f098d..bad843a05 100644 --- a/src/object/sp-path.cpp +++ b/src/object/sp-path.cpp @@ -279,6 +279,42 @@ void SPPath::update(SPCtx *ctx, guint flags) { flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore } + // Our code depends on 'd' being an attribute (LPE's, etc.). To support 'd' as a property, we + // check it here (after the style property has been evaluated, this allows us to properly + // handled precedence of property vs attribute). If we read in a 'd' set by styling, convert it + // to an attribute. We'll convert it back on output. + + d_source = style->d.style_src; + + if (style->d.set && + + (d_source == SP_STYLE_SRC_STYLE_PROP || d_source == SP_STYLE_SRC_STYLE_SHEET) ) { + + if (style->d.value) { + + Geom::PathVector pv = sp_svg_read_pathv(style->d.value); + SPCurve *curve = new SPCurve(pv); + if (curve) { + + // Update curve + this->setCurveInsync(curve, TRUE); + curve->unref(); + + // Convert from property to attribute (convert back on write) + getRepr()->setAttribute("d", style->d.value); + + SPCSSAttr *css = sp_repr_css_attr( getRepr(), "style"); + sp_repr_css_unset_property ( css, "d"); + sp_repr_css_set ( getRepr(), css, "style" ); + sp_repr_css_attr_unref ( css ); + + style->d.style_src = SP_STYLE_SRC_ATTRIBUTE; + } else { + // Do nothing... don't overwrite 'd' from attribute + } + } + } + SPShape::update(ctx, flags); this->connEndPair.update(); |
