oox/source/export/drawingml.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
New commits: commit 0fa14f38a6538b57e18ee44873cdcc31a78cea5c Author: Noel Grandin <[email protected]> AuthorDate: Tue Nov 18 10:49:50 2025 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Wed Nov 19 17:44:51 2025 +0100 mso-test: invalid attribute values in srcRect found by converting tdf97212-1.odp to pptx and running officeotron on the output we end up with markup like: <a:srcRect l="INF" t="NaN" r="NaN" b="INF"/> Change-Id: I1780cd7b668351b6ced3cd52d557b4a57f959b60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194153 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> (cherry picked from commit bf8db30c20f4c599a53879c0564042b6c4dcb4b6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194200 Tested-by: Jenkins diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 7c15777a5999..0649ddeb0232 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2014,14 +2014,15 @@ void DrawingML::WriteGraphicCropProperties(uno::Reference<beans::XPropertySet> c if (rMapMode.GetMapUnit() == MapUnit::MapPixel) aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize, MapMode(MapUnit::Map100thMM)); - if ( (0 != aGraphicCropStruct.Left) || (0 != aGraphicCropStruct.Top) || (0 != aGraphicCropStruct.Right) || (0 != aGraphicCropStruct.Bottom) ) - { - mpFS->singleElementNS( XML_a, XML_srcRect, - XML_l, OString::number(rtl::math::round(aGraphicCropStruct.Left * 100000.0 / aOriginalSize.Width())), - XML_t, OString::number(rtl::math::round(aGraphicCropStruct.Top * 100000.0 / aOriginalSize.Height())), - XML_r, OString::number(rtl::math::round(aGraphicCropStruct.Right * 100000.0 / aOriginalSize.Width())), - XML_b, OString::number(rtl::math::round(aGraphicCropStruct.Bottom * 100000.0 / aOriginalSize.Height())) ); - } + if (aOriginalSize.Width() != 0 && aOriginalSize.Height() != 0) + if ( (0 != aGraphicCropStruct.Left) || (0 != aGraphicCropStruct.Top) || (0 != aGraphicCropStruct.Right) || (0 != aGraphicCropStruct.Bottom) ) + { + mpFS->singleElementNS( XML_a, XML_srcRect, + XML_l, OString::number(rtl::math::round(aGraphicCropStruct.Left * 100000.0 / aOriginalSize.Width())), + XML_t, OString::number(rtl::math::round(aGraphicCropStruct.Top * 100000.0 / aOriginalSize.Height())), + XML_r, OString::number(rtl::math::round(aGraphicCropStruct.Right * 100000.0 / aOriginalSize.Width())), + XML_b, OString::number(rtl::math::round(aGraphicCropStruct.Bottom * 100000.0 / aOriginalSize.Height())) ); + } } }
