From d75042329e7dd9bcc6d355ca19f556f144e93492 Mon Sep 17 00:00:00 2001 From: Laurent Godard Date: Thu, 15 Dec 2011 15:56:57 +0100 Subject: [PATCH] c++ subsequent tests XRangeName and XRangeNames renaming previous test to XRangeNames new test for XRangeName --- sc/CppunitTest_sc_namedrangeobj.mk | 1 + sc/qa/extras/testdocuments/rangenames.ods | Bin 10047 -> 9347 bytes sc/qa/extras/xnamedrange.cxx | 201 ++++++++++++++++++++++ sc/qa/extras/xnamedranges.cxx | 4 +- 4 files changed, 203 insertions(+), 3 deletions(-) create mode 100644 sc/qa/extras/xnamedrange.cxx diff --git a/sc/CppunitTest_sc_namedrangeobj.mk b/sc/CppunitTest_sc_namedrangeobj.mk index de25f26dfe16..cb01294b9156 100644 --- a/sc/CppunitTest_sc_namedrangeobj.mk +++ b/sc/CppunitTest_sc_namedrangeobj.mk @@ -32,6 +32,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sc_namedrangeobj)) $(eval $(call gb_CppunitTest_add_exception_objects,sc_namedrangeobj, \ sc/qa/extras/xnamedranges \ + sc/qa/extras/xnamedrange \ )) $(eval $(call gb_CppunitTest_add_linked_libs,sc_namedrangeobj, \ diff --git a/sc/qa/extras/testdocuments/rangenames.ods b/sc/qa/extras/testdocuments/rangenames.ods index 7a743d76ddabf467c498c3446d9cb947892a8f84..1b101fde24be1aa27ccb0341b4c2c6d46a1e1d1b 100644 GIT binary patch delta 5650 zcmZ8l1yo(TwmrBNJEatNch>^N-JL>#7I!PO*v5+#FYZopcXy{y91aI}r&zI1d+)pN zzMnlZX7 zSD_ZKTIP`cXe(S4`;m3A^O*he*zzBOI_2WwW zQtz8h$amM~G+SkJ{hon0Ot=F-X9D~Q5;pztHSox~f=Lu8?6KDs|`E`c1o2 zwY}T{s9lmtSq%@)<*3yAC+Ffdd^6`aEOB@8g|=Jri_k-R?RLftuGksU33m=fueDSp zCE!Si0+13BYS&)jgV7yGU<1T?1U4CKzQ>YWcm}}_HmGn%Tl_LZ+8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Pr(Z5#7za*A2X;ucO3iQCbSO~uv@Et_UIK?l2pp!wIe>I zeat(_US#8j>aC=&BR@EmJt>H3g@NODMRr-qR8!w|N(hOpY?QH*sS(m;4s=(L;~pk^Z-Kd(BVAmAl{EV7m2OV8ZUyf(bRJynaWHv90n`B@E z9SWx|YE5?~Mb!4XU1&5flf`Z1PXlSHzEaz36kf4FFu#5cNNKZ8O}USE&#%E{XWDoSkBfAz8V z1UFoIbQ2^xOCz3)?_6*30H#GiE1Ae<(et62q(dpIr{s3TAYgxc*~L-s{6VbAm+(n; zZ&&(3H#PLVN0bN8^0BQK4&C)|EeTH>H0`j@#gZ2>wJ1*uB2 zV&qtr#(;@gZ0=xIO@O#VDew@ly{x9EbX;S9*pj8iC!5@j`;`iA1o3e=8E1mqRQ&`!_4 zAy*K;N_jMvfW*B@TvQZY7Vj@3Hx9WYeO;n=F*KL!U$}x7Pcf~M9A@j~=#D8WnR?eORvo18`+jL-cC9n^OZ2!4 zd@d4ZyvfjyMq_PCkDs_G5$ERr83mOL^fz=yD1v{XV#FR3E#ftp^Vhw-1FZGS1I)At zK_>QJ?VE9LroYDXn3Vq0r|`E)t@Boh9dsgJaK + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace ScNamedRangeObj { + +class ScXNamedRange : public UnoApiTest +{ + uno::Reference< sheet::XSpreadsheetDocument> init(); + uno::Reference< sheet::XNamedRange> getTestedNamedRange(const rtl::OUString&); + + // XNamedRange + void testGetContent(); + void testSetContent(); + void testGetType(); + void testSetType(); + void testGetReferencePosition(); + void testSetReferencePosition(); + + CPPUNIT_TEST_SUITE(ScXNamedRange); + CPPUNIT_TEST(testGetContent); + CPPUNIT_TEST(testSetContent); + CPPUNIT_TEST(testGetType); + CPPUNIT_TEST(testSetType); + CPPUNIT_TEST(testGetReferencePosition); + CPPUNIT_TEST(testSetReferencePosition); + CPPUNIT_TEST_SUITE_END(); +}; + + +void ScXNamedRange::testGetContent() +{ + rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); + uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); + + rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1")); + CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 on GetContent", xNamedRange->getContent().equals(aExpectedContent)); +} + +void ScXNamedRange::testSetContent() +{ + rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); + uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); + + rtl::OUString aExpectedContent; + + // test a cell + aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D1")); + xNamedRange->setContent(aExpectedContent); + CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cell", xNamedRange->getContent().equals(aExpectedContent)); + + // test a cellrange + aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D1:D10")); + xNamedRange->setContent(aExpectedContent); + CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cellrange", xNamedRange->getContent().equals(aExpectedContent)); + + // test a formula + aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=D10")); + xNamedRange->setContent(aExpectedContent); + aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D10")); + CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a formula", xNamedRange->getContent().equals(aExpectedContent)); + +} + +void ScXNamedRange::testGetType() +{ + rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); + uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); + CPPUNIT_ASSERT_MESSAGE("Wrong expected Type", xNamedRange->getType() == 0); +} + +void ScXNamedRange::testSetType() +{ + rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); + uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); + + sal_Int32 nType = ::sheet::NamedRangeFlag::ROW_HEADER;; + xNamedRange->setType(nType); + CPPUNIT_ASSERT_MESSAGE("Wrong expected Type ROW_HEADER after setting it", xNamedRange->getType() == nType); + + nType = ::sheet::NamedRangeFlag::COLUMN_HEADER; + xNamedRange->setType(nType); + CPPUNIT_ASSERT_MESSAGE("Wrong expected Type COLUMN_HEADER after setting it", xNamedRange->getType() == nType); + + nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA; + xNamedRange->setType(nType); + CPPUNIT_ASSERT_MESSAGE("Wrong expected Type FILTER_CRITERIA after setting it", xNamedRange->getType() == nType); + + nType = ::sheet::NamedRangeFlag::PRINT_AREA; + xNamedRange->setType(nType); + CPPUNIT_ASSERT_MESSAGE("Wrong expected Type PRINT_AREA after setting it", xNamedRange->getType() == nType); + + nType = 0; + xNamedRange->setType(nType); + CPPUNIT_ASSERT_MESSAGE("Wrong expected Type 0 after setting it", xNamedRange->getType() == nType); +} + +void ScXNamedRange::testGetReferencePosition() +{ + rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2")); + uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); + + table::CellAddress xCellAddress = xNamedRange->getReferencePosition(); + // the expeted address is on B1, as it was the active cell when intial2 created + CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", xCellAddress.Sheet == 0); + CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", xCellAddress.Column == 1); + CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", xCellAddress.Row == 0); +} + +void ScXNamedRange::testSetReferencePosition() +{ + rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); + uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); + + table::CellAddress aBaseAddress = table::CellAddress(1,2,3); + + xNamedRange->setReferencePosition(aBaseAddress); + + table::CellAddress xCellAddress = xNamedRange->getReferencePosition(); + CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position after setting it", xCellAddress.Sheet == 1); + CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position after setting it", xCellAddress.Column == 2); + CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position after setting it", xCellAddress.Row == 3); +} + +uno::Reference< sheet::XSpreadsheetDocument> ScXNamedRange::init() +{ + rtl::OUString aFileURL; + const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")); + createFileURL(aFileBase, aFileURL); + static uno::Reference< lang::XComponent > xComponent; + if( !xComponent.is()) + xComponent = loadFromDesktop(aFileURL); + uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDoc.is()); + + return xDoc; +} + +uno::Reference< sheet::XNamedRange> ScXNamedRange::getTestedNamedRange(const rtl::OUString& aTestedNamedRangeString) +{ + uno::Reference< sheet::XSpreadsheetDocument> xDoc = init(); + uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW); + rtl::OUString aNamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); + uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW); + + uno::Reference< sheet::XNamedRange > xNamedRange(xNamedRangesNameAccess->getByName(aTestedNamedRangeString), UNO_QUERY_THROW); + + return xNamedRange; +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScXNamedRange); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/xnamedranges.cxx b/sc/qa/extras/xnamedranges.cxx index 3fc1a17b5a46..a1eea8a905a8 100644 --- a/sc/qa/extras/xnamedranges.cxx +++ b/sc/qa/extras/xnamedranges.cxx @@ -46,7 +46,7 @@ #include -namespace ScNamedRangeObj { +namespace ScNamedRangesObj { class ScXNamedRanges : public UnoApiTest { @@ -254,8 +254,6 @@ uno::Reference< sheet::XSpreadsheetDocument> ScXNamedRanges::init() CPPUNIT_TEST_SUITE_REGISTRATION(ScXNamedRanges); -CPPUNIT_PLUGIN_IMPLEMENT(); - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */