oox/source/drawingml/drawingmltypes.cxx | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
New commits: commit cbbb67e05709e89bca60ae241342d6647ea64f79 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Jun 15 15:04:07 2022 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Jun 16 06:45:16 2022 +0200 Correct parsing of ST_Percentage Change-Id: I227b2abd493d3a4ce6f4e4dcd256aa29653fdce0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135886 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/oox/source/drawingml/drawingmltypes.cxx b/oox/source/drawingml/drawingmltypes.cxx index 6ce901ab1ef9..fc2f28d902b7 100644 --- a/oox/source/drawingml/drawingmltypes.cxx +++ b/oox/source/drawingml/drawingmltypes.cxx @@ -23,6 +23,8 @@ #include <com/sun/star/drawing/Hatch.hpp> #include <com/sun/star/style/CaseMap.hpp> #include <com/sun/star/xml/sax/XFastAttributeList.hpp> + +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <sax/tools/converter.hxx> #include <oox/token/tokens.hxx> @@ -374,15 +376,26 @@ const char* GetHatchPattern( const drawing::Hatch& rHatch ) return sPattern; } +namespace +{ +// ISO/IEC-29500 Part 1 ST_Percentage, and [MS-OI29500] 2.1.1324 +sal_Int32 GetST_Percentage(std::u16string_view s) +{ + if (o3tl::ends_with(s, u"%")) + return std::round(o3tl::toDouble(s) * 1000); + return o3tl::toInt32(s); +} +} + /** converts the attributes from a CT_RelativeRect to an IntegerRectangle2D */ IntegerRectangle2D GetRelativeRect( const Reference< XFastAttributeList >& xAttribs ) { IntegerRectangle2D r; - r.X1 = xAttribs->getOptionalValue( XML_l ).toInt32(); - r.Y1 = xAttribs->getOptionalValue( XML_t ).toInt32(); - r.X2 = xAttribs->getOptionalValue( XML_r ).toInt32(); - r.Y2 = xAttribs->getOptionalValue( XML_b ).toInt32(); + r.X1 = GetST_Percentage(xAttribs->getOptionalValue( XML_l )); + r.Y1 = GetST_Percentage(xAttribs->getOptionalValue( XML_t )); + r.X2 = GetST_Percentage(xAttribs->getOptionalValue( XML_r )); + r.Y2 = GetST_Percentage(xAttribs->getOptionalValue( XML_b )); return r; }