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 3db40e042e5f13f7414b8c557a9069155a29dc79 Author: Karthik Godha <[email protected]> AuthorDate: Sat Nov 1 10:26:16 2025 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Tue Nov 4 13:26:54 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]> 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 e95c37e3b765..03a893913117 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> @@ -1391,6 +1392,41 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf168567) } } +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 27b3bcf19b4d..beaf665024d4 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -988,6 +988,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())
