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>
This commit is contained in:
committed by
Caolán McNamara
parent
4424daa225
commit
fa17cfd7e0
@@ -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
|
||||
|
Reference in New Issue
Block a user