diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2018-02-18 00:56:29 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2018-02-18 00:56:29 +0000 |
| commit | 9d6b0e851f455225558c58ee007788bf6b8e3ee3 (patch) | |
| tree | d36617c75f27083e26896269bdbf4a165f150e05 /src | |
| parent | Promote the path 'd' attribute to a property per SVG 2. (diff) | |
| download | inkscape-9d6b0e851f455225558c58ee007788bf6b8e3ee3.tar.gz inkscape-9d6b0e851f455225558c58ee007788bf6b8e3ee3.zip | |
Revert "Promote the path 'd' attribute to a property per SVG 2."
Needs further testing.
This reverts commit e88644b0f3481c78a9563dbf9ee6b76ab6674583.
Diffstat (limited to 'src')
| -rw-r--r-- | src/attributes.cpp | 5 | ||||
| -rw-r--r-- | src/attributes.h | 13 | ||||
| -rw-r--r-- | src/object/sp-path.cpp | 79 | ||||
| -rw-r--r-- | src/object/sp-path.h | 20 | ||||
| -rw-r--r-- | src/style.cpp | 10 | ||||
| -rw-r--r-- | src/style.h | 5 |
6 files changed, 30 insertions, 102 deletions
diff --git a/src/attributes.cpp b/src/attributes.cpp index 7a3916f6d..6522563af 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -138,6 +138,7 @@ static SPStyleProp const props[] = { {SP_ATTR_X, "x"}, {SP_ATTR_Y, "y"}, /* SPPath */ + {SP_ATTR_D, "d"}, {SP_ATTR_INKSCAPE_ORIGINAL_D, "inkscape:original-d"}, /* (Note: XML representation of connectors may change in future.) */ {SP_ATTR_CONNECTOR_TYPE, "inkscape:connector-type"}, @@ -421,9 +422,6 @@ static SPStyleProp const props[] = { /* CSS & SVG Properites */ - /* SVG 2 Attributes promoted to properties */ - {SP_ATTR_D, "d"}, - /* Paint */ {SP_PROP_COLOR, "color"}, {SP_PROP_OPACITY, "opacity"}, @@ -554,7 +552,6 @@ static SPStyleProp const props[] = { /* LivePathEffect */ {SP_PROP_PATH_EFFECT, "effect"}, - }; #define n_attrs (sizeof(props) / sizeof(props[0])) diff --git a/src/attributes.h b/src/attributes.h index cecf2673b..a2c1c30f5 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -20,9 +20,9 @@ unsigned char const *sp_attribute_name(unsigned int id); /** * True iff k is a property in SVG, i.e. something that can be written either in a style attribute - * or as its own XML attribute. This must be kept in sync with SPAttributeEnum. + * or as its own XML attribute. */ -#define SP_ATTRIBUTE_IS_CSS(k) (((k) >= SP_ATTR_D) && ((k) <= SP_PROP_PATH_EFFECT)) +#define SP_ATTRIBUTE_IS_CSS(k) (((k) >= SP_PROP_INKSCAPE_FONT_SPEC) && ((k) <= SP_PROP_TEXT_RENDERING)) /* * Do not change order of attributes and properties. Attribute and @@ -146,7 +146,7 @@ enum SPAttributeEnum { SP_ATTR_X, SP_ATTR_Y, /* SPPath */ - // SP_ATTR_D, Promoted to property in SVG 2 + SP_ATTR_D, SP_ATTR_INKSCAPE_ORIGINAL_D, SP_ATTR_CONNECTOR_TYPE, SP_ATTR_CONNECTOR_CURVATURE, @@ -428,12 +428,7 @@ enum SPAttributeEnum { SP_ATTR_TEXT_EXCLUDE, SP_ATTR_LAYOUT_OPTIONS, - /* CSS & SVG Properties KEEP ORDER! - * If first or last property changed, macro at top must be changed! - */ - - /* SVG 2 Attributes promoted to properties */ - SP_ATTR_D, + /* CSS & SVG Properties KEEP ORDER */ /* Paint */ SP_PROP_COLOR, diff --git a/src/object/sp-path.cpp b/src/object/sp-path.cpp index b4e9f7559..a0c7f098d 100644 --- a/src/object/sp-path.cpp +++ b/src/object/sp-path.cpp @@ -21,32 +21,29 @@ #include <glibmm/i18n.h> -#include <2geom/curves.h> +#include "live_effects/effect.h" +#include "live_effects/lpeobject.h" +#include "live_effects/lpeobject-reference.h" +#include "sp-lpe-item.h" -#include "attributes.h" -#include "desktop-style.h" -#include "desktop.h" #include "display/curve.h" -#include "document.h" -#include "inkscape.h" -#include "style.h" - +#include <2geom/curves.h> #include "helper/geom-curves.h" -#include "live_effects/effect.h" -#include "live_effects/lpeobject-reference.h" -#include "live_effects/lpeobject.h" +#include "svg/svg.h" +#include "xml/repr.h" +#include "attributes.h" -#include "sp-guide.h" -#include "sp-lpe-item.h" #include "sp-path.h" +#include "sp-guide.h" -#include "svg/svg.h" +#include "document.h" +#include "desktop.h" +#include "desktop-style.h" #include "ui/tools/tool-base.h" - -#include "xml/repr.h" -#include "xml/sp-css-attr.h" +#include "inkscape.h" +#include "style.h" #define noPATH_VERBOSE @@ -112,18 +109,13 @@ void SPPath::convert_to_guides() const { sp_guide_pt_pairs_to_guides(this->document, pts); } -SPPath::SPPath() - : SPShape() - , connEndPair(this) - , d_source( SP_STYLE_SRC_UNSET ) -{ +SPPath::SPPath() : SPShape(), connEndPair(this) { } SPPath::~SPPath() { } void SPPath::build(SPDocument *document, Inkscape::XML::Node *repr) { - /* Are these calls actually necessary? */ this->readAttr( "marker" ); this->readAttr( "marker-start" ); @@ -172,6 +164,7 @@ void SPPath::build(SPDocument *document, Inkscape::XML::Node *repr) { /* d is a required attribute */ char const *d = this->getAttribute("d", NULL); + if (d == NULL) { // First see if calculating the path effect will generate "d": this->update_patheffect(true); @@ -180,11 +173,8 @@ void SPPath::build(SPDocument *document, Inkscape::XML::Node *repr) { // I guess that didn't work, now we have nothing useful to write ("") if (d == NULL) { this->setKeyValue( sp_attribute_lookup("d"), ""); - } else { - d_source = SP_STYLE_SRC_ATTRIBUTE; } } - } void SPPath::release() { @@ -285,46 +275,10 @@ g_message("sp_path_write writes 'd' attribute"); } void SPPath::update(SPCtx *ctx, guint flags) { - if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { 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 ); - - } else { - // Do nothing... don't overwrite 'd' from attribute - } - } - } - SPShape::update(ctx, flags); this->connEndPair.update(); @@ -417,6 +371,7 @@ g_message("sp_path_update_patheffect writes 'd' attribute"); } } + /** * Adds a original_curve to the path. If owner is specified, a reference * will be made, otherwise the curve will be copied into the path. diff --git a/src/object/sp-path.h b/src/object/sp-path.h index 0530a396a..572fd648d 100644 --- a/src/object/sp-path.h +++ b/src/object/sp-path.h @@ -18,7 +18,6 @@ #include "sp-shape.h" #include "sp-conn-end-pair.h" -#include "style-internal.h" // For SPStyleSrc class SPCurve; @@ -48,22 +47,19 @@ 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 diff --git a/src/style.cpp b/src/style.cpp index b3bbcbe45..3298cb0c9 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -97,10 +97,6 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) : // font-family // font-specification - - // SVG 2 attributes promoted to properties. (When geometry properties are added, move after font.) - d( "d" ), // SPIString Not inherited! - // Font related properties and 'font' shorthand font_style( "font-style", enum_font_style, SP_CSS_FONT_STYLE_NORMAL ), font_variant( "font-variant", enum_font_variant, SP_CSS_FONT_VARIANT_NORMAL ), @@ -286,9 +282,6 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) : // This might be too resource hungary... but for now it possible to loop over properties - // SVG 2: Attributes promoted to properties - _properties.push_back( &d ); - // 'color' must be before 'fill', 'stroke', 'text-decoration-color', ... _properties.push_back( &color ); @@ -709,9 +702,6 @@ SPStyle::readIfUnset( gint id, gchar const *val, SPStyleSrc const &source ) { g_return_if_fail(val != NULL); switch (id) { - case SP_ATTR_D: - d.readIfUnset( val, source ); - break; case SP_PROP_INKSCAPE_FONT_SPEC: font_specification.readIfUnset( val, source ); break; diff --git a/src/style.h b/src/style.h index 2556ba2b1..1b6ee2f47 100644 --- a/src/style.h +++ b/src/style.h @@ -91,11 +91,6 @@ public: /* ----------------------- THE PROPERTIES ------------------------- */ /* Match order in style.cpp. */ - /* SVG 2 attributes promoted to properties. */ - - /** Path data */ - SPIString d; - /* Font ---------------------------- */ /** Font style */ |
