sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 20 ++++++++++++++++---- sw/source/filter/ww8/docxattributeoutput.cxx | 7 +++++-- 2 files changed, 21 insertions(+), 6 deletions(-)
New commits: commit 47df7f0b5c7509b084ee6916a9c98283e54332a2 Author: Aron Budea <[email protected]> AuthorDate: Mon Dec 1 00:27:05 2025 +1030 Commit: Xisco Fauli <[email protected]> CommitDate: Mon Jan 12 08:34:35 2026 +0100 tdf#142693 tdf#169419 sw: Limit page size exported to DOCX Based on what Word can roundtrip, which is 64K twips, even though that size (115 cm) can't be set via the UI. Officially 2.1.220 Part 1 Section 17.6.13 of [MS-OI29500] says 31680 twips, but let's keep to the value that works in practice. Don't adjust size on import, only on export, Writer can handle much larger sizes. 446771fe3e91eb7d154e86b9c6a614374110e9ca was related. Change-Id: I88540e80f4e94fd8fc3703c18d8b151a7bd270e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194843 Tested-by: Jenkins Reviewed-by: Aron Budea <[email protected]> (cherry picked from commit 714c2ee044b31f6974cbedc3f8cb3f80db475afc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197012 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/data/tdf142693_hugePaperSizeImport.docx b/sw/qa/extras/ooxmlexport/data/tdf142693_hugePaperSize.docx similarity index 100% rename from sw/qa/extras/ooxmlexport/data/tdf142693_hugePaperSizeImport.docx rename to sw/qa/extras/ooxmlexport/data/tdf142693_hugePaperSize.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index e88f5cd76fac..6b61b86c6bfa 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -1347,13 +1347,25 @@ DECLARE_OOXMLEXPORT_TEST(testTdf127741, "tdf127741.docx") CPPUNIT_ASSERT(visitedStyleName.equalsIgnoreAsciiCase("Visited Internet Link")); } -CPPUNIT_TEST_FIXTURE(Test, testTdf142693_hugePaperSizeImport) +CPPUNIT_TEST_FIXTURE(Test, testTdf142693_hugePaperSize) { - createSwDoc("tdf142693_hugePaperSizeImport.docx"); + createSwDoc("tdf142693_hugePaperSize.docx"); + + // Verify that original page size is imported as is, since Writer can handle + // large page sizes + uno::Reference<beans::XPropertySet> xPageStyle( + getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Page Width (mm) ", sal_Int32(1594), + getProperty<sal_Int32>(xPageStyle, u"Width"_ustr) / 100); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Page Height (mm)", sal_Int32(1841), + getProperty<sal_Int32>(xPageStyle, u"Height"_ustr) / 100); + save(TestFilter::DOCX); xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); - assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgSz", "w", u"90369"); - assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgSz", "h", u"104372"); + // Verify that exported page size is limited to conform to max page dimensions + // Word can handle in practice, which is about 64k twips (as opposed to 31680 in [MS-OI29500]) + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgSz", "w", u"65500"); + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgSz", "h", u"65500"); } CPPUNIT_TEST_FIXTURE(Test, testTdf127925) diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 2288f8b42310..3317e134824d 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -9412,8 +9412,11 @@ void DocxAttributeOutput::FormatFrameSize( const SwFormatFrameSize& rSize ) if ( m_rExport.m_pCurrentPageDesc->GetLandscape( ) ) attrList->add( FSNS( XML_w, XML_orient ), "landscape" ); - attrList->add( FSNS( XML_w, XML_w ), OString::number( rSize.GetWidth( ) ) ); - attrList->add( FSNS( XML_w, XML_h ), OString::number( rSize.GetHeight( ) ) ); + // Max page dimensions in practice, (2.1.220 Part 1 Section 17.6.13 in [MS-OI29500] says 31680, + // but Word can handle about 64k twips + const tools::Long nMaxSize = 65500; + attrList->add( FSNS( XML_w, XML_w ), OString::number( std::min( nMaxSize, rSize.GetWidth( ) ) ) ); + attrList->add( FSNS( XML_w, XML_h ), OString::number( std::min( nMaxSize, rSize.GetHeight( ) ) ) ); m_pSerializer->singleElementNS( XML_w, XML_pgSz, attrList ); }
