tdf#95189: docx import: apply list ovverride only once
List overrides should be applied only once on first list with
override appearance in document. Next reference to this list
should not override again and reset list numbering.
Change-Id: I7a24398d5980ca97a74fa8ad09d91ac9adff15ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93894
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf95189.docx b/sw/qa/extras/ooxmlexport/data/tdf95189.docx
new file mode 100644
index 0000000..456276b
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf95189.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 26c8fc24..3f26169d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -695,6 +695,38 @@ DECLARE_OOXMLEXPORT_TEST(testTdf124367, "tdf124367.docx")
.Position);
}
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf95189, "tdf95189.docx")
{
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(2), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("2"), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(3), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(4), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("2"), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("3"), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(6), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(xPara, "ListLabelString"));
}
{
uno::Reference<beans::XPropertySet> xPara(getParagraph(7), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("2"), getProperty<OUString>(xPara, "ListLabelString"));
}
}
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128820, "tdf128820.fodt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3b68ff3..9ff009f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1717,11 +1717,17 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
if (pList->GetCurrentLevel())
{
sal_Int16 nOverrideLevel = pList->GetCurrentLevel()->GetStartOverride();
if (nOverrideLevel != -1)
if (nOverrideLevel != -1 && m_aListOverrideApplied.find(nListId2) == m_aListOverrideApplied.end())
{
// Restart list, it is overridden
// Apply override: we have override instruction for this level
// And this was not done for this list before: we can do this only once on first occurrence
// of list with override
// TODO: Not tested variant with differen levels override in diffent lists.
// Probably m_aListOverrideApplied as a set of overriden listids is not sufficient
// and we need to register level overrides separately.
m_xPreviousParagraph->setPropertyValue("ParaIsNumberingRestart", uno::makeAny(true));
m_xPreviousParagraph->setPropertyValue("NumberingStartValue", uno::makeAny(nOverrideLevel));
m_aListOverrideApplied.insert(nListId2);
}
}
}
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 889dff4..8f46234 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -27,6 +27,7 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <queue>
#include <stack>
#include <set>
#include <unordered_map>
#include <vector>
#include <optional>
@@ -484,6 +485,8 @@ private:
// TableManagers are stacked: one for each stream to avoid any confusion
std::stack< tools::SvRef< DomainMapperTableManager > > m_aTableManagers;
tools::SvRef<DomainMapperTableHandler> m_pTableHandler;
// List of document lists overrides. They are applied only once on first occurrence in document
std::set<sal_Int32> m_aListOverrideApplied;
//each context needs a stack of currently used attributes
std::stack<PropertyMapPtr> m_aPropertyStacks[NUMBER_OF_CONTEXTS];