diff options
author | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2020-05-09 22:31:48 +0300 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-05-13 10:58:58 +0200 |
commit | 8ccb18b7e35a4b8f733ecd2b6d12e075410d0468 (patch) | |
tree | 98ba7d0e4d44023b3a215d4882b19ee5c0541878 | |
parent | cf842260e9e0dceb4d7b3d5f7125b9730fe263d9 (diff) |
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>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94031
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf95189.docx | bin | 0 -> 27705 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 32 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 10 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 |
4 files changed, 43 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf95189.docx b/sw/qa/extras/ooxmlexport/data/tdf95189.docx Binary files differnew file mode 100644 index 000000000000..456276b20d0c --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf95189.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 375c6d874021..37248db1500c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -258,6 +258,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") { // Import of exported DOCX failed because of wrong namespase used for wsp element diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 658c99c9a5e1..a59e9cc6d1d2 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1677,11 +1677,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(nListId) == m_aListOverrideApplied.end()) { - // Restart list, it is overriden + // 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(nListId); } } } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 483f8f92715c..cce1178214bc 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -30,6 +30,7 @@ #include <queue> #include <stack> #include <tuple> +#include <set> #include <unordered_map> #include <vector> #include <boost/optional.hpp> @@ -486,6 +487,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]; |