diff options
Diffstat (limited to 'sw/qa/extras/rtfimport')
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 156 |
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) |