sw/qa/extras/layout/layout4.cxx | 10 +++++----- sw/source/filter/ww8/docxattributeoutput.cxx | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-)
New commits: commit 3f4d026f7a2fbc6c5341dbfa69052b6ce82c14df Author: [email protected] <[email protected]> AuthorDate: Thu Jan 15 16:58:32 2026 -0500 Commit: Justin Luth <[email protected]> CommitDate: Sat Jan 17 02:08:10 2026 +0100 tdf#170322 docx export: close blockSDT when frame is done If a framePr frame contains (only) a blockSDT, then it was NOT closing the SDT element that it had started, and the popFromTableExportContext guard was resetting m_aParagraphSdt.m_bStartedSdt to false, and thus it was NEVER getting closed, creating invalid XML. make CppunitTest_sw_layoutwriter4 CPPUNIT_TEST_NAME=testTdf159259 Change-Id: I882686474346accc56b95322e39c0a2c4756d21f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197410 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins diff --git a/sw/qa/extras/layout/layout4.cxx b/sw/qa/extras/layout/layout4.cxx index 37a32c3ab533..ebe72e405b53 100644 --- a/sw/qa/extras/layout/layout4.cxx +++ b/sw/qa/extras/layout/layout4.cxx @@ -1122,11 +1122,11 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf159259) CPPUNIT_ASSERT_EQUAL(paraHeight, flyHeight); // tdf#170322: MS Word considers the document corrupt if a plainText control contains a field - // save(TestFilter::DOCX); - // xmlDocUniquePtr pXmlDocument = parseExport(u"word/document.xml"_ustr); - // assertXPath(pXmlDocument, "//w:sdt/w:sdtPr", 1); - // // the sdtPr must be a richText control, not plainText - // assertXPath(pXmlDocument, "//w:sdt/w:sdtPr/w:text", 0); + save(TestFilter::DOCX); + xmlDocUniquePtr pXmlDocument = parseExport(u"word/document.xml"_ustr); + assertXPath(pXmlDocument, "//w:sdt/w:sdtPr", 1); + // the sdtPr must be a richText control, not plainText + assertXPath(pXmlDocument, "//w:sdt/w:sdtPr/w:text", 0); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testLargeTopParaMarginAfterHiddenSection) diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 2d3a4f139f4d..7b823f80e2e9 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1292,7 +1292,10 @@ void DocxAttributeOutput::EndParagraph( const ww8::WW8TableNodeInfoInner::Pointe { DocxTableExportContext aTableExportContext(*this); m_aFramePr.SetFrame(pFrame.get(), !m_xTableWrt ? -1 : m_tableReference.m_nTableDepth); + const bool bOldStartedSdt = m_aParagraphSdt.m_bStartedSdt; m_rExport.SdrExporter().writeOnlyTextOfFrame(pFrame.get()); + if (!bOldStartedSdt && m_aParagraphSdt.m_bStartedSdt) + m_aParagraphSdt.EndSdtBlock(m_pSerializer); m_aFramePr.SetFrame(nullptr); }
