diff options
author | Xisco Fauli <anistenis@gmail.com> | 2015-11-25 20:03:19 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-11-26 12:18:05 +0000 |
commit | fa17cfd7e006c73f1360a5a974f38d9875f347c5 (patch) | |
tree | 33d6fc00781d448c9a4dde65eb1005f309376589 /filter | |
parent | 4424daa225e73d291a3fd64d369cdda5857f3d51 (diff) |
tdf#96046 SVG: Parse 'em' and 'ex' units correctly
the problem is that real_p parses the 'e' in 'em' and 'ex' as the exponential
operator instead of as a str.
Change it to parse sequencies like: (11) (1.1) (1,1) (.1) (,1) (1.) (1,)
but now the parser returns a std::string so we need to convert it to double,
and make sure the commas are converted to dots too.
Change-Id: I913be7975e7db1be4773f528fd0d586db67c9461
Reviewed-on: https://gerrit.libreoffice.org/20181
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/svg/units.cxx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/filter/source/svg/units.cxx b/filter/source/svg/units.cxx index d0165b174898..691305e5bf80 100644 --- a/filter/source/svg/units.cxx +++ b/filter/source/svg/units.cxx @@ -71,12 +71,12 @@ double convLength( const OUString& sValue, const State& rState, char dir ) OString aUTF8 = OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ); - double nVal=0.0; + std::string sVal; SvgUnit eUnit=SVG_LENGTH_UNIT_PX; const bool bRes = parse(aUTF8.getStr(), // Begin grammar ( - real_p[assign_a(nVal)] + (*digit_p >> *((str_p(".") | str_p(",")) >> *digit_p))[assign_a(sVal)] >> ( str_p("cm") [assign_a(eUnit,SVG_LENGTH_UNIT_CM)] | str_p("em") [assign_a(eUnit,SVG_LENGTH_UNIT_EM)] | str_p("ex") [assign_a(eUnit,SVG_LENGTH_UNIT_EX)] @@ -95,7 +95,9 @@ double convLength( const OUString& sValue, const State& rState, char dir ) if( !bRes ) return 0.0; - return convLength(nVal,eUnit,rState,dir); + OUString oVal = OUString::createFromAscii(sVal.c_str()).replaceAll(",","."); + + return convLength(oVal.toDouble(),eUnit,rState,dir); } } // namespace svgi |