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 | |
| 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')
| -rw-r--r-- | src/object/sp-path.cpp | 36 | ||||
| -rw-r--r-- | src/object/sp-path.h | 20 |
2 files changed, 48 insertions, 8 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(); diff --git a/src/object/sp-path.h b/src/object/sp-path.h index 572fd648d..0530a396a 100644 --- a/src/object/sp-path.h +++ b/src/object/sp-path.h @@ -18,6 +18,7 @@ #include "sp-shape.h" #include "sp-conn-end-pair.h" +#include "style-internal.h" // For SPStyleSrc class SPCurve; @@ -47,19 +48,22 @@ public: // should be made protected public: SPConnEndPair connEndPair; - virtual void build(SPDocument *document, Inkscape::XML::Node *repr); - virtual void release(); - virtual void update(SPCtx* ctx, unsigned int flags); + virtual void build(SPDocument *document, Inkscape::XML::Node *repr); + virtual void release(); + virtual void update(SPCtx* ctx, unsigned int flags); - virtual void set(unsigned int key, char const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); + virtual void set(unsigned int key, char const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); - virtual const char* displayName() const; - virtual char* description() const; - virtual Geom::Affine set_transform(Geom::Affine const &transform); + virtual const char* displayName() const; + virtual char* description() const; + virtual Geom::Affine set_transform(Geom::Affine const &transform); virtual void convert_to_guides() const; virtual void update_patheffect(bool write); + +private: + SPStyleSrc d_source; // Source of 'd' value, saved for output. }; #endif // SEEN_SP_PATH_H |
