diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-04-21 22:09:55 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-04-21 22:09:55 +0000 |
| commit | 5e4fd475d24a74972756cd9b10ef0812d98d14a8 (patch) | |
| tree | 40f441e9b77f4fcdda3af3376440b4a398e67d27 /src/object/sp-path.cpp | |
| parent | Update POT files (diff) | |
| download | inkscape-5e4fd475d24a74972756cd9b10ef0812d98d14a8.tar.gz inkscape-5e4fd475d24a74972756cd9b10ef0812d98d14a8.zip | |
Fixes for d promote to property
Diffstat (limited to 'src/object/sp-path.cpp')
| -rw-r--r-- | src/object/sp-path.cpp | 70 |
1 files changed, 33 insertions, 37 deletions
diff --git a/src/object/sp-path.cpp b/src/object/sp-path.cpp index a4724a8e7..b47f63c9e 100644 --- a/src/object/sp-path.cpp +++ b/src/object/sp-path.cpp @@ -125,7 +125,40 @@ void SPPath::build(SPDocument *document, Inkscape::XML::Node *repr) { sp_conn_end_pair_build(this); SPShape::build(document, repr); + // 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 + } + } + } // this->readAttr( "inkscape:original-d" ); // bug #1299948 // Why we take the long way of doing this probably needs some explaining: // @@ -279,44 +312,7 @@ 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(); } |
