sw/qa/extras/ooxmlimport/data/tdf169173.docx         |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx            |   36 +++++++++++++++++++
 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx |    7 +++
 3 files changed, 43 insertions(+)

New commits:
commit d5ee7dba9c826ef7c55760cf1bb27fdde176f972
Author:     Karthik Godha <[email protected]>
AuthorDate: Sat Nov 1 10:26:16 2025 +0530
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Nov 10 21:50:02 2025 +0100

    tdf#169173 Fix import of dropdown SDTs in a table
    
    When we have nested run-level SDTs in the document, dropdown SDTs are
    not imported properly.
    
    Change-Id: I5aaa3f2c7900c6920da1acbb83690251d24233a5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193289
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit 3db40e042e5f13f7414b8c557a9069155a29dc79)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193749
    Tested-by: Jenkins
    (cherry picked from commit b9c04b6e94bf9c320a91bd1528cfb3932b2b2728)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193770
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sw/qa/extras/ooxmlimport/data/tdf169173.docx 
b/sw/qa/extras/ooxmlimport/data/tdf169173.docx
new file mode 100644
index 000000000000..810e7c3f5633
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf169173.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 3fe6676dc57b..5d3a9e461fc6 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/style/BreakType.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/text/XTextField.hpp>
 #include <com/sun/star/table/XCellRange.hpp>
 
 #include <comphelper/propertysequence.hxx>
@@ -1379,6 +1380,41 @@ CPPUNIT_TEST_FIXTURE(Test, testInvalidRefNumPara)
     createSwDoc("__RefNumPara__.docx");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf169173)
+{
+    createSwDoc("tdf169173.docx");
+
+    // Access the first table in the doc
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xTables(xTablesSupplier->getTextTables(),
+                                                    uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+    uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY);
+
+    // Get the last row first coloumn in the table
+    uno::Reference<text::XText> xCell(
+        xCellRange->getCellByPosition(0, xTable->getRows()->getCount() - 1), 
uno::UNO_QUERY);
+
+    uno::Reference<container::XEnumerationAccess> xParaAccess(xCell, 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xParagraphs = 
xParaAccess->createEnumeration();
+
+    uno::Reference<container::XEnumerationAccess> 
xParagraph(xParagraphs->nextElement(),
+                                                             uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xPortions = 
xParagraph->createEnumeration();
+
+    uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), 
uno::UNO_QUERY);
+
+    // Block level SDTs are imported as ComboBox
+    OUString aPortionType;
+    xTextPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType;
+    CPPUNIT_ASSERT_EQUAL(u"TextField"_ustr, aPortionType);
+    uno::Reference<text::XTextField> xField;
+    xTextPortion->getPropertyValue(u"TextField"_ustr) >>= xField;
+    uno::Reference<lang::XServiceInfo> xServiceInfo(xField, uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xServiceInfo.is());
+    
CPPUNIT_ASSERT(xServiceInfo->supportsService(u"com.sun.star.text.textfield.DropDown"_ustr));
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 } // end of anonymous namespace
diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
index 53d4418e8168..8abec3397c69 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -990,6 +990,13 @@ void DomainMapper_Impl::SetParaSectpr(bool bParaSectpr)
 
 void DomainMapper_Impl::SetSdt(bool bSdt)
 {
+    // Empty run level SDTs before starting a block level SDT
+    if (bSdt)
+    {
+        while (!m_xSdtStarts.empty())
+            m_xSdtStarts.pop();
+    }
+
     m_StreamStateStack.top().bSdt = bSdt;
 
     if (m_StreamStateStack.top().bSdt && !m_aTextAppendStack.empty())

Reply via email to