sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithDrawing.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 13 +++++++++++- sw/source/writerfilter/dmapper/DomainMapper.cxx | 7 ------ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 7 ++++++ 4 files changed, 19 insertions(+), 8 deletions(-)
New commits: commit dc6316b4492d3aa0e7c8a24a8c34086a38bdc14d Author: Justin Luth <[email protected]> AuthorDate: Sat Jan 24 12:28:49 2026 -0500 Commit: Justin Luth <[email protected]> CommitDate: Sat Jan 24 22:58:33 2026 +0100 tdf#165359 writerfilter: import graphic into richText, not plainText This patch replaces the previous one. It is more generic make CppunitTest_sw_ooxmlexport25 \ CPPUNIT_TEST_NAME=testTdf165359_SdtWithDrawing make CppunitTest_sw_ooxmlexport25 \ CPPUNIT_TEST_NAME=testTdf165359_SdtWithInline Change-Id: Ic1533a71fbaaaa4e28e7e00976f5c8f747cf2d6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198049 Tested-by: Jenkins Reviewed-by: Justin Luth <[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/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index 0956f4f67b09..b009516be1d3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -154,7 +154,18 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf165359_SdtWithInline) { createSwDoc("tdf165359_SdtWithInline.docx"); - saveAndReload(TestFilter::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 diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx b/sw/source/writerfilter/dmapper/DomainMapper.cxx index b82078c0c309..d9cc42804897 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx @@ -3064,13 +3064,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) if ( m_pImpl->IsDiscardHeaderFooter() ) break; - if (m_pImpl->m_StreamStateStack.top().bSdt - && m_pImpl->m_pSdtHelper->getControlType() == SdtControlType::plainText) - { - // plainText controls cannot contain pictures or shapes - m_pImpl->m_pSdtHelper->setControlType(SdtControlType::richText); - } - //tdf112342: Break before images as well, if there are page break if (m_pImpl->isBreakDeferred(BreakType::PAGE_BREAK) && nSprmId == NS_ooxml::LN_inline_inline && !m_pImpl->IsInShape()) diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 89b1a2b4da2b..4b904b302746 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -9667,6 +9667,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())
