summaryrefslogtreecommitdiff
path: root/lotuswordpro
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2022-07-15 22:46:03 +0200
committerBartosz Kosiorek <gang65@poczta.onet.pl>2022-07-21 09:11:31 +0200
commita0bcd1d187a4e56a9fa600462842004545b6be9c (patch)
tree147169997a66bf755c5311fef5c489ea85b42306 /lotuswordpro
parentd449da36086409e3cc440036193c4fc8a10a37a1 (diff)
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 <gang65@poczta.onet.pl>
Diffstat (limited to 'lotuswordpro')
-rw-r--r--lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwpbin0 -> 21316 bytes
-rw-r--r--lotuswordpro/qa/cppunit/import_test.cxx102
-rw-r--r--lotuswordpro/source/filter/lwpbulletstylemgr.cxx20
3 files changed, 114 insertions, 8 deletions
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
--- /dev/null
+++ b/lotuswordpro/qa/cppunit/data/tdf33787-ordered-bullets.lwp
Binary files 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());
}