oox/source/export/drawingml.cxx |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 496ad75786a460c3bbf248f1c436daeb996192cc
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Nov 18 10:49:50 2025 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Nov 19 20:55:01 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
    (cherry picked from commit 0fa14f38a6538b57e18ee44873cdcc31a78cea5c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194219
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3c76f4c06617..93a3bf81b1cd 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2019,14 +2019,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())) );
+            }
     }
 }
 

Reply via email to