diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-06-10 14:20:18 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-08-05 00:31:06 +0000 |
| commit | 7aaeaacc08de60fd324646afe69f4dbed93f89d4 (patch) | |
| tree | 13c87e946659151021e553dc3b752c3dbcd2f4a2 /src/style-internal.cpp | |
| parent | Fix one symbolic icon bug (diff) | |
| download | inkscape-7aaeaacc08de60fd324646afe69f4dbed93f89d4.tar.gz inkscape-7aaeaacc08de60fd324646afe69f4dbed93f89d4.zip | |
Allow inkscape handle units and percent in dasharray and dashoffset. Add pref optional to scale dashes on stroke scale
Diffstat (limited to 'src/style-internal.cpp')
| -rw-r--r-- | src/style-internal.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/style-internal.cpp b/src/style-internal.cpp index 429353493..4ed59e82e 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -2034,20 +2034,17 @@ SPIDashArray::read( gchar const *str ) { return; } - // std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("[,\\s]+", str ); + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("[,\\s]+", str ); - gchar *e = nullptr; bool LineSolid = true; - while (e != str && *str != '\0') { - /* TODO: Should allow <length> rather than just a unitless (px) number. */ - double number = g_ascii_strtod(str, (char **) &e); - values.push_back( number ); - if (number > 0.00000001) + for (auto token:tokens) { + SVGLength svglength; + double value = atof(token.c_str()); + if(value > 0.00000001) { LineSolid = false; - if (e != str) { - str = e; } - while (str && *str && !(isalnum(*str) || *str=='.')) str += 1; + svglength.read(token.c_str()); + values.push_back(svglength); } if (LineSolid) { @@ -2074,7 +2071,7 @@ SPIDashArray::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase if (i) { os << ", "; } - os << this->values[i]; + os << this->values[i].write().c_str(); } os << important_str(); os << ";"; @@ -2088,7 +2085,9 @@ SPIDashArray::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase void SPIDashArray::cascade( const SPIBase* const parent ) { if( const SPIDashArray* p = dynamic_cast<const SPIDashArray*>(parent) ) { - if( !set || inherit ) values = p->values; // Always inherits + if( !set || inherit ) { + values = p->values; // Always inherits + } } else { std::cerr << "SPIDashArray::cascade(): Incorrect parent type" << std::endl; } @@ -2112,10 +2111,13 @@ SPIDashArray::merge( const SPIBase* const parent ) { bool SPIDashArray::operator==(const SPIBase& rhs) { if( const SPIDashArray* r = dynamic_cast<const SPIDashArray*>(&rhs) ) { - return values == r->values && SPIBase::operator==(rhs); - } else { - return false; + for (int i = 0;i < values.size(); i++) { + if (values[i] != r->values[i]) { + return false; + } + } } + return SPIBase::operator==(rhs); } |
