sw/source/filter/ww8/docxattributeoutput.cxx |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit ff30cc6a366f1cbaa4f038542d78842cbc90b039
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Oct 31 16:09:17 2025 +0200
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Nov 3 14:22:02 2025 +0100

    mso-test: clamp a:cx and a:cy to >= 0
    
    When loading and then saving the document from ooo83929-3.doc,
    we end up with negative values here, which is not valid.
    
    Use our existing mechanism to enforce correct ordering.
    
    Change-Id: Id584e0bd1d2a2bfcca84b19517f426b0b7c5f510
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193324
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index a74fb5735a12..93a5a378c4af 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5601,8 +5601,9 @@ void DocxAttributeOutput::FlyFrameGraphic( const 
SwGrfNode* pGrfNode, const Size
     m_pSerializer->startElementNS(XML_a, XML_xfrm, xFrameAttributes);
 
     m_pSerializer->singleElementNS(XML_a, XML_off, XML_x, "0", XML_y, "0");
-    OString aWidth( OString::number( TwipsToEMU( aSize.Width() ) ) );
-    OString aHeight( OString::number( TwipsToEMU( aSize.Height() ) ) );
+    // clamp to >=0, negative values are not valid here
+    OString aWidth( OString::number( std::max(sal_Int64(0), TwipsToEMU( 
aSize.Width() )) ) );
+    OString aHeight( OString::number( std::max(sal_Int64(0), TwipsToEMU( 
aSize.Height() )) ) );
     m_pSerializer->singleElementNS(XML_a, XML_ext, XML_cx, aWidth, XML_cy, 
aHeight);
     m_pSerializer->endElementNS( XML_a, XML_xfrm );
     m_pSerializer->startElementNS(XML_a, XML_prstGeom, XML_prst, "rect");

Reply via email to