sw/qa/extras/ooxmlexport/data/content-control-shape.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx            |   12 ++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx             |    5 -----
 3 files changed, 12 insertions(+), 5 deletions(-)

New commits:
commit 223a43537559efc96b4b5bca32d93211ed849ae5
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Aug 22 14:37:56 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Aug 22 16:49:00 2022 +0200

    crashtesting: fix DOCX export of tdf135569-1.docx
    
    This went wrong in commit 9700c1b2170ad04453a361ed5647937833ac3c18 (sw
    content controls, plain text: add DOCX import, 2022-07-25), which
    conditionally disabled the DOCX export of content control starts.
    
    The trouble is that the matching content control end is still written
    unconditionally, leading to a not-well-formed XML output.
    
    Reading the commit message, the motivation for the conditional start was
    testSdtAndShapeOverlapping in CppunitTest_sw_ooxmlexport7, but it seems
    that is no longer necessary since we try it harder to not pollute the
    doc model with never-read grab-bags in commit
    7ad44f3dd271a591529b048212c4391d8b38ed9d (crashtesting: fix DOCX export
    of forum-mso-de-99522.docx, 2022-08-16).
    
    Fix the problem by just reverting the problematic hunk, seeing it's no
    longer needed for the testSdtAndShapeOverlapping scenario and it causes
    a problem here.
    
    Change-Id: I5cc94ee00dfdf55de1fffe1c28242388549862ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138685
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/content-control-shape.docx 
b/sw/qa/extras/ooxmlexport/data/content-control-shape.docx
new file mode 100644
index 000000000000..ab5be6cb694a
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/content-control-shape.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 688b393a2d29..073918d31c48 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -883,6 +883,18 @@ CPPUNIT_TEST_FIXTURE(Test, testContentControlGrabBag)
     save("Office Open XML Text", maTempFile);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testContentControlShape)
+{
+    // Given a document with a <w:sdt> tag:
+    OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"content-control-shape.docx";
+    loadURL(aURL, nullptr);
+
+    // When exporting that document back to DOCX:
+    // Then make sure that completes without an assertion failure, which would 
mean not-well-formed
+    // output was produced, since the <w:sdt> was conditional but the </w:sdt> 
was unconditional:
+    save("Office Open XML Text", maTempFile);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf104823)
 {
     // Test how we can roundtrip sdt plain text with databindings support
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index a74692579a1f..096e7cd8a694 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2346,11 +2346,6 @@ void DocxAttributeOutput::WriteContentControlStart()
         return;
     }
 
-    if (m_bAnchorLinkedToNode)
-    {
-        return;
-    }
-
     m_pSerializer->startElementNS(XML_w, XML_sdt);
     m_pSerializer->startElementNS(XML_w, XML_sdtPr);
     if (!m_pContentControl->GetPlaceholderDocPart().isEmpty())

Reply via email to