sw/qa/extras/ooxmlexport/data/inline-sdt-header.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx           |    6 ++++++
 sw/source/filter/ww8/docxattributeoutput.cxx         |    3 +++
 sw/source/filter/ww8/docxattributeoutput.hxx         |    1 +
 4 files changed, 10 insertions(+)

New commits:
commit e1aad6d8fcb17fe893e9270ff42378aed450faa3
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Aug 31 11:17:43 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Sep 5 14:16:27 2022 +0200

    crashtesting: fix DOCX export of forum-mso-de-102317.docx
    
    This went wrong in b2bc4ea8ddae6b01f344469d988e21fed3143c42 (DOCX
    import: handle SDT around citation field, 2014-07-16), the problem is
    that a run/inline SDT is pending, but we wrote a header stream in the
    meantime, so the invariant that Start/EndParagraph() in
    DocxAttributeOutput is called in pairs doesn't help, which results in
    not-well-formed XML, which is an assertion failure in debug build.
    
    Fix the problem similar to 5f3af56b2c0ef6c628a7cfe5ce6e86f8e1765f5f (sw:
    refactoring for docx sdt blocks output, 2021-11-16), which already did
    the same for paragraph/block SDTs.
    
    Change-Id: I5e7273b839bb5c1f841c0fab9b68b4ca239cca18
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139089
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 8431cde61432893dd5ba75d8244457306a9f177b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139420
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/inline-sdt-header.docx 
b/sw/qa/extras/ooxmlexport/data/inline-sdt-header.docx
new file mode 100644
index 000000000000..0a6009c2cd1b
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/inline-sdt-header.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index e47e72667310..a2d5f2cca2b2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -56,6 +56,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf150197_predefinedNumbering)
     CPPUNIT_ASSERT_EQUAL(OUString("1."), 
getProperty<OUString>(getParagraph(1), "ListLabelString"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testInlineSdtHeader)
+{
+    // Without the accompanying fix in place, this test would have failed with 
an assertion failure,
+    // we produced not-well-formed XML on save.
+    loadAndSave("inline-sdt-header.docx");
+}
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1014f69ed64b..94d1f19294d0 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6806,6 +6806,8 @@ void 
DocxAttributeOutput::pushToTableExportContext(DocxTableExportContext& rCont
 
     rContext.m_bStartedParaSdt = m_aParagraphSdt.m_bStartedSdt;
     m_aParagraphSdt.m_bStartedSdt = false;
+    rContext.m_bStartedRunSdt = m_aRunSdt.m_bStartedSdt;
+    m_aRunSdt.m_bStartedSdt = false;
 }
 
 void DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext 
const & rContext)
@@ -6814,6 +6816,7 @@ void 
DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext const
     m_tableReference->m_bTableCellOpen = rContext.m_bTableCellOpen;
     m_tableReference->m_nTableDepth = rContext.m_nTableDepth;
     m_aParagraphSdt.m_bStartedSdt = rContext.m_bStartedParaSdt;
+    m_aRunSdt.m_bStartedSdt = rContext.m_bStartedRunSdt;
 }
 
 void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape)
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 6dc6ea3cffb9..09dcc375a3b9 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -1102,6 +1102,7 @@ struct DocxTableExportContext
     ww8::WW8TableInfo::Pointer_t m_pTableInfo;
     bool m_bTableCellOpen;
     bool m_bStartedParaSdt;
+    bool m_bStartedRunSdt;
     sal_uInt32 m_nTableDepth;
     DocxTableExportContext(DocxAttributeOutput& rOutput) : m_rOutput(rOutput) 
{ m_rOutput.pushToTableExportContext(*this); }
     ~DocxTableExportContext() { m_rOutput.popFromTableExportContext(*this); }

Reply via email to