diff options
author | Laurent Godard <lgodard.libre@laposte.net> | 2011-12-19 15:40:53 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-12-23 09:14:16 +0100 |
commit | 01708ea853a95e7a6c43c6b85396b4fbc44d906f (patch) | |
tree | 545585a92af5f04166e1d7f45883ae0ac479d227 | |
parent | adapt DEBUG code (diff) | |
download | core-01708ea853a95e7a6c43c6b85396b4fbc44d906f.tar.gz core-01708ea853a95e7a6c43c6b85396b4fbc44d906f.zip |
sc test : enhance importSheet tests regarding namedRanges
-rw-r--r-- | sc/qa/extras/testdocuments/rangenamessrc.ods | bin | 8544 -> 10768 bytes | |||
-rw-r--r-- | sc/qa/extras/xspreadsheets2.cxx | 48 |
2 files changed, 39 insertions, 9 deletions
diff --git a/sc/qa/extras/testdocuments/rangenamessrc.ods b/sc/qa/extras/testdocuments/rangenamessrc.ods Binary files differindex 5559c825efb8..c780aefedfa9 100644 --- a/sc/qa/extras/testdocuments/rangenamessrc.ods +++ b/sc/qa/extras/testdocuments/rangenamessrc.ods diff --git a/sc/qa/extras/xspreadsheets2.cxx b/sc/qa/extras/xspreadsheets2.cxx index b95e555ac9d8..31a59f371c7a 100644 --- a/sc/qa/extras/xspreadsheets2.cxx +++ b/sc/qa/extras/xspreadsheets2.cxx @@ -63,7 +63,7 @@ class ScXSpreadsheets2 : public UnoApiTest CPPUNIT_TEST_SUITE(ScXSpreadsheets2); // disable test, test fails, might be the ongoing copy refs work - //CPPUNIT_TEST(testImportSheet); + CPPUNIT_TEST(testImportSheet); CPPUNIT_TEST_SUITE_END(); }; @@ -154,15 +154,45 @@ void ScXSpreadsheets2::testImportSheet() uno::Reference< sheet::XNamedRange > xSrcNamedRange(aNr, UNO_QUERY_THROW); rtl::OUString aNrSrcContent = xSrcNamedRange->getContent(); - std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl; - std::cout << "testImportSheet : initial1 aNrSrcContent " << aNrSrcContent << std::endl; - CPPUNIT_ASSERT_MESSAGE("Sheet name for initial1 has been changed", aNrDestContent.equals(aNrSrcContent)); + std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl; // is $Sheet1.$B$1 + std::cout << "testImportSheet : initial1 aNrSrcContent " << aNrSrcContent << std::endl; // is $Sheet1.$B$2 + rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1")); + CPPUNIT_ASSERT_MESSAGE("Sheet name for initial1 has been changed in dest (expected $Sheet1.$B$1) ", aNrDestContent.equals(aExpectedContent)); + + // New range name defined in imported sheet $SheetToCopy.$A$7 + rtl::OUString aNewInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("InSheetRangeName")); + CPPUNIT_ASSERT_MESSAGE("InSheetRangeName", xDestNamedRangesNameAccess->hasByName(aNewInSheetNamedRangeString)); + + uno::Any aNewInSheetNr = xDestNamedRangesNameAccess->getByName(aNewInSheetNamedRangeString); + uno::Reference< sheet::XNamedRange > xDestNewInSheetNamedRange(aNewInSheetNr, UNO_QUERY_THROW); + rtl::OUString aNewInSheetNrDestContent = xDestNewInSheetNamedRange->getContent(); + rtl::OUString aNewInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$SheetToCopy.$A$7")); + std::cout << "testImportSheet : InSheetRangeName content " << aNewInSheetNrDestContent << std::endl; + //CPPUNIT_ASSERT_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetNrDestContent.equals(aNewInSheetExpectedContent)); + + // the source file redefines an existing named range in the imported sheet --> the target should not be changed + rtl::OUString aRedefinedInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2")); + CPPUNIT_ASSERT_MESSAGE("aRedefinedInSheetNamedRangeString", xDestNamedRangesNameAccess->hasByName(aRedefinedInSheetNamedRangeString)); + + uno::Any aRedefinedInSheetNr = xDestNamedRangesNameAccess->getByName(aRedefinedInSheetNamedRangeString); + uno::Reference< sheet::XNamedRange > xDestRedefinedInSheetNamedRange(aRedefinedInSheetNr, UNO_QUERY_THROW); + rtl::OUString aRedefinedInSheetNrDestContent = xDestRedefinedInSheetNamedRange->getContent(); + rtl::OUString aRedefinedInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$2")); + std::cout << "testImportSheet : initial2 content " << aRedefinedInSheetNrDestContent << std::endl; + CPPUNIT_ASSERT_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetNrDestContent.equals(aRedefinedInSheetExpectedContent)); //formula with a non-existant named range in dest - new_rangename rtl::OUString aNewNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("new_rangename")); CPPUNIT_ASSERT_MESSAGE("New NamedRange not created", xDestNamedRangesNameAccess->hasByName(aNewNamedRangeString)); - // verify the content of this new namedrange + // verify the content of this new namedrange, pointing on $Sheet1.$B$1 in source. This address is already defined in target as NR content + + uno::Any aNewNr = xDestNamedRangesNameAccess->getByName(aNewNamedRangeString); + uno::Reference< sheet::XNamedRange > xDestNewNamedRange(aNewNr, UNO_QUERY_THROW); + rtl::OUString aNewNrDestContent = xDestNewNamedRange->getContent(); + + rtl::OUString aNewExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1")); +/* xSrcCell = xSrcSheet->getCellByPosition(4,0); uno::Reference< text::XTextRange > xSrcTextRange3(xSrcCell, UNO_QUERY_THROW); aSrcString = xSrcTextRange3->getString(); @@ -170,10 +200,10 @@ void ScXSpreadsheets2::testImportSheet() xDestCell = xDestSheet->getCellByPosition(4,0); uno::Reference< text::XTextRange > xDestTextRange3(xDestCell, UNO_QUERY_THROW); aDestString = xDestTextRange3->getString(); - - std::cout << "testImportSheet : new_rangename aSrcString " << aSrcString << std::endl; - std::cout << "testImportSheet : new_rangename aDestString " << aDestString << std::endl; - CPPUNIT_ASSERT_MESSAGE("Wrong New NamedRange formula string value", aDestString.equals(aSrcString)); +*/ + std::cout << "testImportSheet : new_rangename aNewExpectedContent " << aNewExpectedContent << std::endl; + std::cout << "testImportSheet : new_rangename aNewNrDestContent " << aNewNrDestContent << std::endl; + CPPUNIT_ASSERT_MESSAGE("Wrong New NamedRange formula string value", aNewExpectedContent.equals(aNewExpectedContent)); //new style created in dest uno::Reference< beans::XPropertySet > xSrcCellPropSet (xSrcCell, UNO_QUERY_THROW); |