[Libreoffice-commits] core.git: sw/qa writerfilter/source

Vasily Melenchuk (via logerrit) logerrit at kemper.freedesktop.org
Mon May 11 08:41:22 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf95189.docx       |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx        |   32 ++++++++++++++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   10 +++++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    3 ++
 4 files changed, 43 insertions(+), 2 deletions(-)

New commits:
commit 628cde6409eb471024a6aca5a8262b00f448c8cf
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Sat May 9 22:31:48 2020 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Mon May 11 10:40:36 2020 +0200

    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 at 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 000000000000..456276b20d0c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf95189.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 26c8fc248298..3f26169dfffe 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 3b68ff3f582b..9ff009f0d4d1 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 889dff41c855..8f46234a44ba 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];


More information about the Libreoffice-commits mailing list