[Libreoffice-commits] core.git: filter/source

Xisco Fauli anistenis at gmail.com
Thu Nov 26 04:18:35 PST 2015


 filter/source/svg/units.cxx |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit fa17cfd7e006c73f1360a5a974f38d9875f347c5
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Wed Nov 25 20:03:19 2015 +0100

    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 at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/svg/units.cxx b/filter/source/svg/units.cxx
index d0165b1..691305e 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


More information about the Libreoffice-commits mailing list