[Libreoffice-commits] core.git: sw/qa
Mark Hung
marklh9 at gmail.com
Wed Jul 11 15:44:43 UTC 2018
sw/qa/extras/inc/swmodeltestbase.hxx | 30 ++++++++++++++++
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 48 ++++----------------------
sw/qa/extras/rtfexport/rtfexport.cxx | 57 +++++--------------------------
sw/qa/extras/ww8export/ww8export.cxx | 34 ++----------------
4 files changed, 53 insertions(+), 116 deletions(-)
New commits:
commit d0acd56420625133a2e5622f44932e439b2cf95d
Author: Mark Hung <marklh9 at gmail.com>
Date: Sat Jul 7 23:05:51 2018 +0800
sw/qa: CjkNumberedListTestHelper -> getNumberingTypeOfParagraph
Move CjkNumberedListTestHelper to swmodeltestbase.hxx to get
rid of copy-pasted code, and rename it to getNumberingTypeOfParagraph.
Change-Id: I36f14be30bcd9a9d22d1d5071220a13c02602a22
Reviewed-on: https://gerrit.libreoffice.org/57137
Tested-by: Jenkins
Reviewed-by: Mark Hung <marklh9 at gmail.com>
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 19090189510c..3bcc7116b091 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -579,6 +579,36 @@ protected:
return xParagraph;
}
+ sal_Int16 getNumberingTypeOfParagraph(int nPara)
+ {
+ sal_Int16 nNumberingType = -1;
+ uno::Reference<text::XTextRange> xPara(getParagraph(nPara));
+ uno::Reference< beans::XPropertySet > properties( xPara, uno::UNO_QUERY);
+ bool isNumber = false;
+ properties->getPropertyValue("NumberingIsNumber") >>= isNumber;
+ if (isNumber)
+ {
+ uno::Reference<container::XIndexAccess> xLevels( properties->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+ sal_Int16 nNumberingLevel = -1;
+ properties->getPropertyValue("NumberingLevel") >>= nNumberingLevel;
+ if (nNumberingLevel >= 0 && nNumberingLevel < xLevels->getCount())
+ {
+ uno::Sequence< beans::PropertyValue > aPropertyValue;
+ xLevels->getByIndex(nNumberingLevel) >>= aPropertyValue;
+ for( int j = 0 ; j< aPropertyValue.getLength() ; ++j)
+ {
+ beans::PropertyValue aProp= aPropertyValue[j];
+ if (aProp.Name == "NumberingType")
+ {
+ nNumberingType = aProp.Value.get<sal_Int16>();
+ break;
+ }
+ }
+ }
+ }
+ return nNumberingType;
+ }
+
uno::Reference<text::XTextRange> getParagraphOfText(int number, uno::Reference<text::XText> const & xText, const OUString& content = OUString()) const
{
uno::Reference<text::XTextRange> const xParagraph(getParagraphOrTable(number, xText), uno::UNO_QUERY_THROW);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 732a938c8094..a1e2a5194904 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -54,30 +54,6 @@ protected:
return std::find(vWhitelist.begin(), vWhitelist.end(), filename) != vWhitelist.end();
}
-protected:
- bool CjkNumberedListTestHelper(sal_Int16 &nValue)
- {
- bool isNumber = false;
- uno::Reference<text::XTextRange> xPara(getParagraph(1));
- uno::Reference< beans::XPropertySet > properties( xPara, uno::UNO_QUERY);
- properties->getPropertyValue("NumberingIsNumber") >>= isNumber;
- if (!isNumber)
- return false;
- uno::Reference<container::XIndexAccess> xLevels( properties->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- uno::Sequence< beans::PropertyValue > aPropertyValue;
- xLevels->getByIndex(0) >>= aPropertyValue;
- for( int j = 0 ; j< aPropertyValue.getLength() ; ++j)
- {
- beans::PropertyValue aProp= aPropertyValue[j];
- if (aProp.Name == "NumberingType")
- {
- nValue = aProp.Value.get<sal_Int16>();
- return true;
- }
- }
- return false;
-
- }
};
DECLARE_OOXMLEXPORT_TEST(testfdo81381, "fdo81381.docx")
@@ -635,57 +611,49 @@ DECLARE_OOXMLEXPORT_TEST(testTableRtl, "table-rtl.docx")
DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist30, "cjklist30.docx")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat);
}
DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist31, "cjklist31.docx")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat);
}
DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist34, "cjklist34.docx")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat);
}
DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist35, "cjklist35.docx")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_LOWER_ZH, numFormat);
}
DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist44, "cjklist44.docx")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_HANGUL_KO, numFormat);
}
DECLARE_OOXMLEXPORT_TEST(testOoxmlTextNumberList, "text_number_list.docx")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::TEXT_NUMBER, numFormat);
}
DECLARE_OOXMLEXPORT_TEST(testOoxmlTextCardinalList, "text_cardinal_list.docx")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::TEXT_CARDINAL, numFormat);
}
DECLARE_OOXMLEXPORT_TEST(testOoxmlTextOrdinalList, "text_ordinal_list.docx")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::TEXT_ORDINAL, numFormat);
}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 06de83bd27f7..5ebaa354112b 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -55,30 +55,6 @@ public:
&& std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end());
}
- bool CjkNumberedListTestHelper(sal_Int16& rValue)
- {
- bool isNumber = false;
- uno::Reference<text::XTextRange> xPara(getParagraph(1));
- uno::Reference<beans::XPropertySet> properties(xPara, uno::UNO_QUERY);
- properties->getPropertyValue("NumberingIsNumber") >>= isNumber;
- if (!isNumber)
- return false;
- uno::Reference<container::XIndexAccess> xLevels(
- properties->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> aPropertyValue;
- xLevels->getByIndex(0) >>= aPropertyValue;
- for (int j = 0; j < aPropertyValue.getLength(); ++j)
- {
- beans::PropertyValue aProp = aPropertyValue[j];
- if (aProp.Name == "NumberingType")
- {
- rValue = aProp.Value.get<sal_Int16>();
- return true;
- }
- }
- return false;
- }
-
virtual void postLoad(const char* pFilename) override
{
if (OString(pFilename) == "tdf90421.fodt")
@@ -904,78 +880,67 @@ DECLARE_RTFEXPORT_TEST(testFdo82858, "fdo82858.docx")
DECLARE_RTFEXPORT_TEST(testCjklist12, "cjklist12.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_HALFWIDTH_JA, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist13, "cjklist13.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_HALFWIDTH_JA, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist16, "cjklist16.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_TRADITIONAL_JA, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist20, "cjklist20.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_FULLWIDTH_JA, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist21, "cjklist21.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_FULLWIDTH_JA, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist24, "cjklist24.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_SYLLABLE_KO, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist25, "cjklist25.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_JAMO_KO, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist30, "cjklist30.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist31, "cjklist31.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist34, "cjklist34.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat);
}
DECLARE_RTFEXPORT_TEST(testCjklist38, "cjklist38.rtf")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH, numFormat);
}
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 295f39b7dc11..5e46c38ea337 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -94,28 +94,6 @@ public:
return (OString(filename).endsWith(".doc") && std::find(aBlacklist.begin(), aBlacklist.end(), filename) == aBlacklist.end());
}
protected:
- bool CjkNumberedListTestHelper(sal_Int16 &nValue)
- {
- bool isNumber = false;
- uno::Reference<text::XTextRange> xPara(getParagraph(1));
- uno::Reference< beans::XPropertySet > properties( xPara, uno::UNO_QUERY);
- properties->getPropertyValue("NumberingIsNumber") >>= isNumber;
- if (!isNumber)
- return false;
- uno::Reference<container::XIndexAccess> xLevels( properties->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- uno::Sequence< beans::PropertyValue > aPropertyValue;
- xLevels->getByIndex(0) >>= aPropertyValue;
- for( int j = 0 ; j< aPropertyValue.getLength() ; ++j)
- {
- beans::PropertyValue aProp= aPropertyValue[j];
- if (aProp.Name == "NumberingType")
- {
- nValue = aProp.Value.get<sal_Int16>();
- return true;
- }
- }
- return false;
- }
virtual void postLoad(const char* pFilename) override
{
@@ -1129,29 +1107,25 @@ DECLARE_WW8EXPORT_TEST(testBnc636128, "bnc636128.doc")
DECLARE_WW8EXPORT_TEST(testWw8Cjklist30, "cjklist30.doc")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat);
}
DECLARE_WW8EXPORT_TEST(testWw8Cjklist31, "cjklist31.doc")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat);
}
DECLARE_WW8EXPORT_TEST(testWw8Cjklist34, "cjklist34.doc")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat);
}
DECLARE_WW8EXPORT_TEST(testWw8Cjklist35, "cjklist35.doc")
{
- sal_Int16 numFormat;
- CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_LOWER_ZH, numFormat);
}
More information about the Libreoffice-commits
mailing list