diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-08-16 11:37:27 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-08-16 15:06:13 +0200 |
commit | 7ad44f3dd271a591529b048212c4391d8b38ed9d (patch) | |
tree | 1233a1b2e5be288aafd9a7db19999af711990d99 /sw | |
parent | 0aa2b700aae306674d768356875998f5b8f14f0f (diff) |
crashtesting: fix DOCX export of forum-mso-de-99522.docx
Export of this document to DOCX wrote not-well-formed XML output,
resulting in an assertion failure in debug builds.
writerfilter/ maps a selection of <w:sdt> tags to Writer content
controls (a safe subset), and leaves the rest unchanged, which means we
continue to map those to grab-bags. The trouble is that a combination of
content controls and grab-bags leads to bad output on export, as we
start the <w:sdt> element twice, but only close it once.
Fix the problem by extending writerfilter/ code to not do any grab-bags
for the richText type, we already did that in the past for dropDowns.
In the long run, we should never do grab-bagging for any <w:sdt>
elements that we map to Writer content controls.
Change-Id: I27a0b814efd667cc0477d8f492f7f956c938c854
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138351
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/content-control-grab-bag.docx | bin | 0 -> 30547 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 12 |
2 files changed, 12 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/content-control-grab-bag.docx b/sw/qa/extras/ooxmlexport/data/content-control-grab-bag.docx Binary files differnew file mode 100644 index 000000000000..33c01f08fd25 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/content-control-grab-bag.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index 43a7c2a67ce4..688b393a2d29 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -871,6 +871,18 @@ DECLARE_OOXMLEXPORT_TEST( testSdtDatePicker, "test_sdt_datepicker.docx" ) CPPUNIT_ASSERT_EQUAL(OUString("008000"), sColor); } +CPPUNIT_TEST_FIXTURE(Test, testContentControlGrabBag) +{ + // Given a document with a <w:sdt> tag: + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "content-control-grab-bag.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: + save("Office Open XML Text", maTempFile); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf104823) { // Test how we can roundtrip sdt plain text with databindings support |