summaryrefslogtreecommitdiff
path: root/sw/qa/extras/rtfimport/rtfimport.cxx
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2020-04-13 11:06:29 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-05-05 22:22:37 +0200
commit10e99b6ad18a8575351e1a9a6b129b6a6e1f0586 (patch)
treeea0c3b4d6528911535c7339fb921810272ecf1b8 /sw/qa/extras/rtfimport/rtfimport.cxx
parent76beaebdb4e45149576e3946895d77bd3054fe50 (diff)
tdf#116883: sw: support for lists level format string
Multilevel lists are more flexible in case of DOCX. There is supported custom format for any level in DOCX unlike in LO and ODT where we are limited only with prefix and suffix for hardcoded list levels separated by dot. At the same time DOCX can have lists not only "1.2.3.4", but "1/2/3/4" or even "1!2>3)4" and such format can vary on each list level. Here is basic implementation for list format as a core feature for all documents and old way (prefix-suffix + ".") is left as fallback. Practically its usage is currently implemented only in DOCX import/export. Some RTF/OOXML unittests were redesigned: since we are not creating prefix/suffix for these formats conditions should be checked in a different way. Change-Id: I1ec58bcc5874d4fa19aee6a1f42bf1671d853b14 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92106 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93125 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Change-Id: Ia8f066913a2565559d81f3caabeba24b29c09052 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93456
Diffstat (limited to 'sw/qa/extras/rtfimport/rtfimport.cxx')
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx156
1 files changed, 62 insertions, 94 deletions
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index a652b354dbe7..3fe90033be59 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -141,21 +141,52 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf108943)
CPPUNIT_TEST_FIXTURE(Test, testFdo46662)
{
load(mpTestDocumentPath, "fdo46662.rtf");
- uno::Reference<beans::XPropertySet> xPropertySet(
- getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xLevels(
- xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> aProps;
- xLevels->getByIndex(1) >>= aProps; // 2nd level
- for (int i = 0; i < aProps.getLength(); ++i)
+ OUString listStyle;
+
{
- const beans::PropertyValue& rProp = aProps[i];
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0),
+ getProperty<sal_Int16>(xPara, "NumberingLevel"));
+ CPPUNIT_ASSERT(xPara->getPropertyValue("NumberingStyleName") >>= listStyle);
+ CPPUNIT_ASSERT(listStyle.startsWith("WWNum"));
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(xPara, "ListLabelString"));
+ }
+
+ {
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1),
+ getProperty<sal_Int16>(xPara, "NumberingLevel"));
+ CPPUNIT_ASSERT(xPara->getPropertyValue("NumberingStyleName") >>= listStyle);
+ CPPUNIT_ASSERT(listStyle.startsWith("WWNum"));
+ CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty<OUString>(xPara, "ListLabelString"));
+ }
+
+ {
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(3), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2),
+ getProperty<sal_Int16>(xPara, "NumberingLevel"));
+ CPPUNIT_ASSERT(xPara->getPropertyValue("NumberingStyleName") >>= listStyle);
+ CPPUNIT_ASSERT(listStyle.startsWith("WWNum"));
+ CPPUNIT_ASSERT_EQUAL(OUString("1.1.1"), getProperty<OUString>(xPara, "ListLabelString"));
+ }
+
+ {
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(4), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(3),
+ getProperty<sal_Int16>(xPara, "NumberingLevel"));
+ CPPUNIT_ASSERT(xPara->getPropertyValue("NumberingStyleName") >>= listStyle);
+ CPPUNIT_ASSERT(listStyle.startsWith("WWNum"));
+ CPPUNIT_ASSERT_EQUAL(OUString("1.1.1.1"), getProperty<OUString>(xPara, "ListLabelString"));
+ }
- if (rProp.Name == "ParentNumbering")
- CPPUNIT_ASSERT_EQUAL(sal_Int16(2), rProp.Value.get<sal_Int16>());
- else if (rProp.Name == "Suffix")
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<OUString>().getLength());
+ {
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0),
+ getProperty<sal_Int16>(xPara, "NumberingLevel"));
+ CPPUNIT_ASSERT(xPara->getPropertyValue("NumberingStyleName") >>= listStyle);
+ CPPUNIT_ASSERT(listStyle.startsWith("WWNum"));
+ CPPUNIT_ASSERT_EQUAL(OUString("2"), getProperty<OUString>(xPara, "ListLabelString"));
}
}
@@ -1037,25 +1068,12 @@ CPPUNIT_TEST_FIXTURE(Test, testCp950listleveltext1)
{
load(mpTestDocumentPath, "cp950listleveltext1.rtf");
// suffix with Chinese only ( most common case generated by MSO2010 TC)
- const sal_Unicode aExpectedSuffix[1]
- = { 0x3001 }; // This is a dot that is generally used as suffix of Chinese list number
- uno::Reference<beans::XPropertySet> xPropertySet(
- getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xLevels(
- xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> aProps;
- xLevels->getByIndex(0) >>= aProps; // 1st level
-
- OUString aSuffix;
- for (int i = 0; i < aProps.getLength(); ++i)
- {
- const beans::PropertyValue& rProp = aProps[i];
+ // This is a dot that is generally used as suffix of Chinese list number
+ const sal_Unicode aExpectedNumbering[] = { 0x4e00, 0x3001 };
- if (rProp.Name == "Suffix")
- aSuffix = rProp.Value.get<OUString>();
- }
- // Suffix was '\0' instead of ' '.
- CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix, SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering, SAL_N_ELEMENTS(aExpectedNumbering)),
+ getProperty<OUString>(xPara, "ListLabelString"));
}
// This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
@@ -1063,85 +1081,35 @@ CPPUNIT_TEST_FIXTURE(Test, testCp950listleveltext2)
{
load(mpTestDocumentPath, "cp950listleveltext2.rtf");
// Prefix and suffix with Chinese only ( tweaked from default in MSO2010 TC)
- const sal_Unicode aExpectedPrefix[2] = { 0x524d, 0x7f6e };
- const sal_Unicode aExpectedSuffix[3] = { 0x3001, 0x5f8c, 0x7f6e };
+ const sal_Unicode aExpectedNumbering[] = { 0x524d, 0x7f6e, 0x7532, 0x3001, 0x5f8c, 0x7f6e };
- uno::Reference<beans::XPropertySet> xPropertySet(
- getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xLevels(
- xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> aProps;
- xLevels->getByIndex(0) >>= aProps; // 1st level
-
- OUString aSuffix, aPrefix;
- for (int i = 0; i < aProps.getLength(); ++i)
- {
- const beans::PropertyValue& rProp = aProps[i];
-
- if (rProp.Name == "Suffix")
- aSuffix = rProp.Value.get<OUString>();
- if (rProp.Name == "Prefix")
- aPrefix = rProp.Value.get<OUString>();
- }
- // Suffix was '\0' instead of ' '.
- CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix, SAL_N_ELEMENTS(aExpectedPrefix)), aPrefix);
- CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix, SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering, SAL_N_ELEMENTS(aExpectedNumbering)),
+ getProperty<OUString>(xPara, "ListLabelString"));
}
// This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 )
CPPUNIT_TEST_FIXTURE(Test, testCp950listleveltext3)
{
load(mpTestDocumentPath, "cp950listleveltext3.rtf");
- // Prefix and suffix that mix Chinese and English ( tweaked from default in MSO2010 TC)
- const sal_Unicode aExpectedPrefix[4] = { 0x524d, 0x0061, 0x7f6e, 0x0062 };
- const sal_Unicode aExpectedSuffix[6] = { 0x3001, 0x0063, 0x5f8c, 0x0064, 0x7f6e, 0x0065 };
+ // Numbering is a mix Chinese and English ( tweaked from default in MSO2010 TC)
+ const sal_Unicode aExpectedNumbering[] = { 0x524d, 0x0061, 0x7f6e, 0x0062, 0x7532, 0x3001,
+ 0x0063, 0x5f8c, 0x0064, 0x7f6e, 0x0065 };
- uno::Reference<beans::XPropertySet> xPropertySet(
- getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xLevels(
- xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> aProps;
- xLevels->getByIndex(0) >>= aProps; // 1st level
-
- OUString aSuffix, aPrefix;
- for (int i = 0; i < aProps.getLength(); ++i)
- {
- const beans::PropertyValue& rProp = aProps[i];
-
- if (rProp.Name == "Suffix")
- aSuffix = rProp.Value.get<OUString>();
- if (rProp.Name == "Prefix")
- aPrefix = rProp.Value.get<OUString>();
- }
- // Suffix was '\0' instead of ' '.
- CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix, SAL_N_ELEMENTS(aExpectedPrefix)), aPrefix);
- CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix, SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering, SAL_N_ELEMENTS(aExpectedNumbering)),
+ getProperty<OUString>(xPara, "ListLabelString"));
}
CPPUNIT_TEST_FIXTURE(Test, testChtOutlineNumberingRtf)
{
load(mpTestDocumentPath, "chtoutline.rtf");
- const sal_Unicode aExpectedPrefix[2] = { 0x7b2c, 0x0020 };
- const sal_Unicode aExpectedSuffix[2] = { 0x0020, 0x7ae0 };
- uno::Reference<text::XChapterNumberingSupplier> xChapterNumberingSupplier(mxComponent,
- uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xLevels(
- xChapterNumberingSupplier->getChapterNumberingRules());
- uno::Sequence<beans::PropertyValue> aProps;
- xLevels->getByIndex(0) >>= aProps; // 1st level
- OUString aSuffix, aPrefix;
- for (int i = 0; i < aProps.getLength(); ++i)
- {
- const beans::PropertyValue& rProp = aProps[i];
+ const sal_Unicode aExpectedNumbering[] = { 0x7b2c, ' ', '1', ' ', 0x7ae0 };
- if (rProp.Name == "Suffix")
- aSuffix = rProp.Value.get<OUString>();
- if (rProp.Name == "Prefix")
- aPrefix = rProp.Value.get<OUString>();
- }
- CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix, SAL_N_ELEMENTS(aExpectedPrefix)), aPrefix);
- CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix, SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(aExpectedNumbering, SAL_N_ELEMENTS(aExpectedNumbering)),
+ getProperty<OUString>(xPara, "ListLabelString"));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf90046)