lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp |binary
 lotuswordpro/qa/cppunit/import_test.cxx                   |  102 ++++++++++++++
 lotuswordpro/source/filter/lwpbulletstylemgr.cxx          |   20 +-
 3 files changed, 114 insertions(+), 8 deletions(-)

New commits:
commit 55a360860e9c5c608326656a7cf56a0b86f2f7c7
Author:     Bartosz Kosiorek <gan...@poczta.onet.pl>
AuthorDate: Fri Jul 15 22:46:03 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jul 26 14:58:04 2022 +0200

    tdf33787 lotuswordpro: fix increments of ordered bullets
    
    With previous implementation there was an bug which causing missing
    incrementing ordered bullets. For example:
    
            A. Lettered bullet uppercase 1 (A. )
            A. Lettered bullet uppercase 2 (B. )
            A. Lettered bullet uppercase 3 (C. )
    
    This patch is fixing that, and increments is working correctly:
    
            A. Lettered bullet uppercase 1 (A. )
            B. Lettered bullet uppercase 2 (B. )
            C. Lettered bullet uppercase 3 (C. )
    
    It is also make sure that nested and skipped bullets are working correctly:
    
            1) Numbered bullet w/ bracket one (1) )
               Skipped bullet
            2) Numbered bullet w/ bracket two (2) )
                a) Lettered bullet w/ bracket lowercase 1 (a) )
                b) Lettered bullet w/ bracket lowercase 2 (b) )
    
    Change-Id: I1d1ad9ee549039077b418756efefb10bacfa1ddd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137112
    Tested-by: Jenkins
    Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl>
    (cherry picked from commit a0bcd1d187a4e56a9fa600462842004545b6be9c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137423
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp 
b/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp
new file mode 100644
index 000000000000..12febcd60d55
Binary files /dev/null and 
b/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp differ
diff --git a/lotuswordpro/qa/cppunit/import_test.cxx 
b/lotuswordpro/qa/cppunit/import_test.cxx
index fe2128f72ab5..7411a16ab8bd 100644
--- a/lotuswordpro/qa/cppunit/import_test.cxx
+++ b/lotuswordpro/qa/cppunit/import_test.cxx
@@ -53,6 +53,108 @@ void LotusWordProTest::tearDown()
 
 constexpr OUStringLiteral DATA_DIRECTORY = u"/lotuswordpro/qa/cppunit/data/";
 
+CPPUNIT_TEST_FIXTURE(LotusWordProTest, testtdf33787OrderedBullets)
+{
+    // Test if ordered bullets are incrementing correclty:
+    //         A. Lettered bullet uppercase 1 (A.)
+    //         B. Lettered bullet uppercase 2 (B.)
+    //         C. Lettered bullet uppercase 3 (C.)
+    // It is also make sure that nested and skipped bullets are working 
correctly:
+    //         1) Numbered bullet w/ bracket one (1))
+    //            Skipped bullet
+    //         2) Numbered bullet w/ bracket two (2))
+    //             a) Lettered bullet w/ bracket lowercase 1 (a))
+    //             b) Lettered bullet w/ bracket lowercase 2 (b))
+    OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"tdf33787-ordered-bullets.lwp";
+    getComponent() = loadFromDesktop(aURL);
+    uno::Reference<text::XTextDocument> textDocument(getComponent(), 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> 
xParaEnumAccess(textDocument->getText(),
+                                                                  
uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xParaEnum = 
xParaEnumAccess->createEnumeration();
+
+    uno::Reference<beans::XPropertySet> xPara(xParaEnum->nextElement(), 
uno::UNO_QUERY);
+    OUString aListLabelString;
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Make sure the list start from 1.
+    CPPUNIT_ASSERT_EQUAL(OUString("1."), aListLabelString);
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Without the accompanying fix in place, this test would have failed, the 
list label was "1.".
+    CPPUNIT_ASSERT_EQUAL(OUString("2."), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Without the accompanying fix in place, this test would have failed, the 
list label was "1.".
+    CPPUNIT_ASSERT_EQUAL(OUString("3."), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Make sure the list start from i.
+    CPPUNIT_ASSERT_EQUAL(OUString("i."), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Without the accompanying fix in place, this test would have failed, the 
list label was "i.".
+    CPPUNIT_ASSERT_EQUAL(OUString("ii."), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Without the accompanying fix in place, this test would have failed, the 
list label was "i.".
+    CPPUNIT_ASSERT_EQUAL(OUString("iii."), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Make sure the list start from I.
+    CPPUNIT_ASSERT_EQUAL(OUString("I."), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Without the accompanying fix in place, this test would have failed, the 
list label was "I.".
+    CPPUNIT_ASSERT_EQUAL(OUString("II."), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Without the accompanying fix in place, this test would have failed, the 
list label was "I.".
+    CPPUNIT_ASSERT_EQUAL(OUString("III."), aListLabelString);
+
+    for (int i = 0; i < 7; ++i)
+        xParaEnum->nextElement();
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Without the accompanying fix in place, this test would have failed, the 
list label was "A.".
+    CPPUNIT_ASSERT_EQUAL(OUString("C."), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Make sure the nested list (with indendation) starts from 1).
+    CPPUNIT_ASSERT_EQUAL(OUString("1)"), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Make sure skipped element has no prefix
+    CPPUNIT_ASSERT_EQUAL(OUString(""), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Make sure the value after Skip is incremented properly
+    // Without the accompanying fix in place, this test would have failed, the 
list label was "1)".
+    CPPUNIT_ASSERT_EQUAL(OUString("2)"), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Next nested list
+    CPPUNIT_ASSERT_EQUAL(OUString("a)"), aListLabelString);
+
+    xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPara->getPropertyValue("ListLabelString") >>= aListLabelString;
+    // Without the accompanying fix in place, this test would have failed, the 
list label was "a)".
+    CPPUNIT_ASSERT_EQUAL(OUString("b)"), aListLabelString);
+}
+
 CPPUNIT_TEST_FIXTURE(LotusWordProTest, testTdf129993)
 {
     OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"tdf129993.lwp";
diff --git a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx 
b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
index 6f5c9711d5b4..edb6910714cc 100644
--- a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
+++ b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
@@ -243,7 +243,7 @@ rtl::Reference<XFContentContainer> 
LwpBulletStyleMgr::AddBulletList(
         XFContentContainer* pCont, bool bIsOrdered,
         const OUString& rStyleName, sal_Int16 nLevel, bool bIsBulletSkiped)
 {
-    assert(nLevel>0);
+    assert(nLevel > 0);
 
     m_bIsBulletSkipped = bIsBulletSkiped;
 
@@ -253,7 +253,7 @@ rtl::Reference<XFContentContainer> 
LwpBulletStyleMgr::AddBulletList(
     rtl::Reference<XFList> prevList;
     XFListItem* theItem;
     XFListItem* InnerItem = nullptr;
-    for (sal_Int8 nC = nLevel-1; nC >= 0; nC--)
+    for (sal_Int8 nC = nLevel - 1; nC >= 0; nC--)
     {
         rtl::Reference<XFList> theList(new XFList);
         theItem = new XFListItem();
@@ -269,7 +269,7 @@ rtl::Reference<XFContentContainer> 
LwpBulletStyleMgr::AddBulletList(
             theList->SetOrdered(false);
         }
 
-        if (nC == nLevel-1)
+        if (nC == nLevel - 1)
         {
             theList->SetContinueNumber(bContinue);
         }
@@ -277,22 +277,26 @@ rtl::Reference<XFContentContainer> 
LwpBulletStyleMgr::AddBulletList(
         if (nC == 0 && pCont)
         {
             theList->SetStyleName(rStyleName);
+            theList->SetContinueNumber(bContinue);
             pCont->Add(theList.get());
         }
 
-        if ((nC == nLevel-1) && bIsBulletSkiped)
+        if ((nC == 0) && bIsBulletSkiped)
         {
-            theItem->SetIsHeader();
-
             theList->SetContinueNumber(true);
         }
 
-        if(nC == nLevel-1)
+        if ((nC == nLevel - 1) && bIsBulletSkiped)
+        {
+            theItem->SetIsHeader();
+        }
+
+        if (nC == nLevel - 1)
         {
             InnerItem = theItem;
         }
 
-        if(prevList)
+        if (prevList)
         {
             theItem->Add(prevList.get());
         }

Reply via email to