sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithDrawing.docx |binary sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithInline.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 22 ++++++++++++ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 7 +++ 4 files changed, 29 insertions(+)
New commits: commit 2cc661a28db182d52d11f26cf8acf3cead7ab1d8 Author: Justin Luth <[email protected]> AuthorDate: Mon Jan 26 10:21:04 2026 -0500 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Jan 27 09:41:04 2026 +0100 tdf#165359 writerfilter: import graphic into richText, not plainText MS Word complains that documents are corrupt if a <w:text/> w:sdt (plainText content control) contains a picture. make CppunitTest_sw_ooxmlexport25 \ CPPUNIT_TEST_NAME=testTdf165359_SdtWithInline make CppunitTest_sw_ooxmlexport25 \ CPPUNIT_TEST_NAME=testTdf165359_SdtWithDrawing Change-Id: Ic1533a71fbaaaa4e28e7e00976f5c8f747cf2d6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198049 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198054 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithDrawing.docx b/sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithDrawing.docx new file mode 100644 index 000000000000..31a37c5e8f2f Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithDrawing.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithInline.docx b/sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithInline.docx new file mode 100644 index 000000000000..87d4ddac6770 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithInline.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index 5ad2011bbb5e..cb16ac8a1e34 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -121,6 +121,28 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf170438_dropdown) assertXPath(pXmlDoc, "//w:listItem[1]", "value", u""); // value may be empty } +CPPUNIT_TEST_FIXTURE(Test, testTdf165359_SdtWithInline) +{ + createSwDoc("tdf165359_SdtWithInline.docx"); + + save(TestFilter::DOCX); + + xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); + // MS Word reports document as corrupt if a picture is inside of a plainText content control + assertXPath(pXmlDoc, "//w:sdtPr/w:text", 0); +} + +CPPUNIT_TEST_FIXTURE(Test, testTdf165359_SdtWithDrawing) +{ + createSwDoc("tdf165359_SdtWithDrawing.docx"); + + save(TestFilter::DOCX); + + xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); + // MS Word reports document as corrupt if a picture is inside of a plainText content control + assertXPath(pXmlDoc, "//w:sdtPr/w:text", 0); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf170389_manyTabstops) { createSwDoc("tdf170389_manyTabstops.odt"); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 3d5111cd0361..b8518b794fb2 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -9523,6 +9523,13 @@ void DomainMapper_Impl::ImportGraphic(const writerfilter::Reference<Properties> } } + if (m_pSdtHelper->getControlType() == SdtControlType::plainText + && (m_StreamStateStack.top().bSdt || GetSdtStarts().size())) + { + // plainText controls cannot contain pictures or shapes + m_pSdtHelper->setControlType(SdtControlType::richText); + } + // Update the shape properties if it is embedded object. if (m_StreamStateStack.top().xEmbedded.is())
