summaryrefslogtreecommitdiff
path: root/sw/qa/extras/rtfimport
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-04-27 22:36:12 +0200
commit7459b9ecb54a298f02d19089620149718f8d8d48 (patch)
tree8e26f751e26b4e4f7ca53d36d6c94603d096650c /sw/qa/extras/rtfimport
parent4ba179eb9208185406207522e39626327c7d74c3 (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>
Diffstat (limited to 'sw/qa/extras/rtfimport')
-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 f9d4e3cbdb6e..08d7d647c167 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)