sw/qa/extras/ooxmlexport/data/tdf165359_SdtWithInline.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport25.cxx                 |   11 +++++++++++
 sw/source/writerfilter/dmapper/DomainMapper.cxx            |    8 ++++++++
 3 files changed, 19 insertions(+)

New commits:
commit dfa0497c829636d49734fe2b21e7f38883e1c2ef
Author:     Justin Luth <[email protected]>
AuthorDate: Fri Jan 23 20:35:06 2026 -0500
Commit:     Justin Luth <[email protected]>
CommitDate: Sat Jan 24 04:03:21 2026 +0100

    tdf#165359 writerfilter: import pictures 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
    
    Change-Id: I7beeb891eba7f77e58ead23fa79b0e3b3ef2e124
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198029
    Reviewed-by: Justin Luth <[email protected]>
    Tested-by: Jenkins

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 110211a7c2c9..0956f4f67b09 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx
@@ -150,6 +150,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf165478_bottomAligned, 
"tdf165478_bottomAligned.d
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1887), nFlyTop);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf165359_SdtWithInline)
+{
+    createSwDoc("tdf165359_SdtWithInline.docx");
+
+    saveAndReload(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, testTdf170438_dropdown)
 {
     createSwDoc("tdf170438_dropdown.odt");
diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper.cxx
index 2220e51d1d98..b82078c0c309 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx
@@ -3063,6 +3063,14 @@ 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())

Reply via email to