[Libreoffice-commits] .: 3 commits - sc/CppunitTest_sc_namedrangeobj.mk sc/qa

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Thu Dec 15 19:32:00 PST 2011


 sc/CppunitTest_sc_namedrangeobj.mk        |    3 
 sc/qa/extras/testdocuments/rangenames.ods |binary
 sc/qa/extras/xnamedrange.cxx              |  201 ++++++++++++++++++++++
 sc/qa/extras/xnamedranges.cxx             |  259 +++++++++++++++++++++++++++++
 sc/qa/extras/xrangename.cxx               |  265 ------------------------------
 sc/qa/unoapi/sc.sce                       |    4 
 6 files changed, 464 insertions(+), 268 deletions(-)

New commits:
commit d75042329e7dd9bcc6d355ca19f556f144e93492
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Thu Dec 15 15:56:57 2011 +0100

    c++ subsequent tests XRangeName and XRangeNames
    
    renaming previous test to XRangeNames
    new test for XRangeName

diff --git a/sc/CppunitTest_sc_namedrangeobj.mk b/sc/CppunitTest_sc_namedrangeobj.mk
index de25f26..cb01294 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 7a743d7..1b101fd 100644
Binary files a/sc/qa/extras/testdocuments/rangenames.ods and b/sc/qa/extras/testdocuments/rangenames.ods differ
diff --git a/sc/qa/extras/xnamedrange.cxx b/sc/qa/extras/xnamedrange.cxx
new file mode 100644
index 0000000..616c835
--- /dev/null
+++ b/sc/qa/extras/xnamedrange.cxx
@@ -0,0 +1,201 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Laurent Godard lgodard.libre at laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/unoapi_test.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/Border.hpp>
+#include <com/sun/star/sheet/NamedRangeFlag.hpp>
+
+#include <rtl/oustringostreaminserter.hxx>
+
+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 3fc1a17..a1eea8a 100644
--- a/sc/qa/extras/xnamedranges.cxx
+++ b/sc/qa/extras/xnamedranges.cxx
@@ -46,7 +46,7 @@
 
 #include <rtl/oustringostreaminserter.hxx>
 
-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: */
commit f8d90723faf9fb6bd59000c252e477bc0d3ce77e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Dec 16 04:19:25 2011 +0100

    disable scs' subsequenttests that use binfilter formats

diff --git a/sc/qa/unoapi/sc.sce b/sc/qa/unoapi/sc.sce
index 3e4dfcb..b35fdd0 100644
--- a/sc/qa/unoapi/sc.sce
+++ b/sc/qa/unoapi/sc.sce
@@ -37,8 +37,8 @@
 -o sc.ScChartObj
 -o sc.ScChartsObj
 -o sc.ScConsolidationDescriptor
--o sc.ScDDELinkObj
--o sc.ScDDELinksObj
+# fdo43376 -o sc.ScDDELinkObj
+# fdo43376 -o sc.ScDDELinksObj
 -o sc.ScDataPilotFieldGroupItemObj
 -o sc.ScDataPilotFieldGroupObj
 -o sc.ScDataPilotFieldGroupsObj
commit d4b0b023d9c84d56321e20a18694233ddf74c561
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Wed Dec 14 16:50:54 2011 +0100

    sc test xrangename - code cleaning and minor bug aNr2

diff --git a/sc/CppunitTest_sc_namedrangeobj.mk b/sc/CppunitTest_sc_namedrangeobj.mk
index 87619a7..de25f26 100644
--- a/sc/CppunitTest_sc_namedrangeobj.mk
+++ b/sc/CppunitTest_sc_namedrangeobj.mk
@@ -31,7 +31,7 @@
 $(eval $(call gb_CppunitTest_CppunitTest,sc_namedrangeobj))
 
 $(eval $(call gb_CppunitTest_add_exception_objects,sc_namedrangeobj, \
-    sc/qa/extras/xrangename \
+    sc/qa/extras/xnamedranges \
 ))
 
 $(eval $(call gb_CppunitTest_add_linked_libs,sc_namedrangeobj, \
diff --git a/sc/qa/extras/xnamedranges.cxx b/sc/qa/extras/xnamedranges.cxx
new file mode 100644
index 0000000..3fc1a17
--- /dev/null
+++ b/sc/qa/extras/xnamedranges.cxx
@@ -0,0 +1,261 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Laurent Godard lgodard.libre at laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/unoapi_test.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/Border.hpp>
+#include <com/sun/star/sheet/NamedRangeFlag.hpp>
+
+#include <rtl/oustringostreaminserter.hxx>
+
+namespace ScNamedRangeObj {
+
+class ScXNamedRanges : public UnoApiTest
+{
+    uno::Reference< sheet::XSpreadsheetDocument> init();
+
+    // XNamedRanges
+    void testAddNewByName();
+    void testAddNewFromTitles();
+    void testRemoveByName();
+    void testOutputList();
+
+    CPPUNIT_TEST_SUITE(ScXNamedRanges);
+    CPPUNIT_TEST(testAddNewByName);
+    CPPUNIT_TEST(testAddNewFromTitles);
+    //fix first warning in ExceptionsTestCaseDecorator
+    //CPPUNIT_TEST_EXCEPTION(testRemoveByName, uno::RuntimeException);
+    CPPUNIT_TEST(testOutputList);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+
+void ScXNamedRanges::testAddNewByName()
+{
+    uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
+    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
+
+    uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
+    rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
+    uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
+    uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
+
+    table::CellAddress aBaseAddress = table::CellAddress(0,0,0);
+
+    sal_Int32 nType = 0;
+    rtl::OUString aContent1(RTL_CONSTASCII_USTRINGPARAM("D1"));
+    rtl::OUString aName1(RTL_CONSTASCII_USTRINGPARAM("type_0"));
+    xNamedRanges->addNewByName(aName1, aContent1, aBaseAddress, nType);
+    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type 0 - Normal case", xNamedRanges->hasByName(aName1));
+
+    nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
+    rtl::OUString aContent2(RTL_CONSTASCII_USTRINGPARAM("D2"));
+    rtl::OUString aName2(RTL_CONSTASCII_USTRINGPARAM("type_COLUMN_HEADER"));
+    xNamedRanges->addNewByName(aName2, aContent2, aBaseAddress, nType);
+    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type COLUMN_HEADER", xNamedRanges->hasByName(aName2));
+
+    nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
+    rtl::OUString aContent3(RTL_CONSTASCII_USTRINGPARAM("D3"));
+    rtl::OUString aName3(RTL_CONSTASCII_USTRINGPARAM("type_FILTER_CRITERIA"));
+    xNamedRanges->addNewByName(aName3, aContent3, aBaseAddress, nType);
+    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type FILTER_CRITERIA", xNamedRanges->hasByName(aName3));
+
+    nType = ::sheet::NamedRangeFlag::PRINT_AREA;
+    rtl::OUString aContent4(RTL_CONSTASCII_USTRINGPARAM("D4"));
+    rtl::OUString aName4(RTL_CONSTASCII_USTRINGPARAM("type_PRINT_AREA"));
+    xNamedRanges->addNewByName(aName4, aContent4, aBaseAddress, nType);
+    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type PRINT_AREA", xNamedRanges->hasByName(aName4));
+
+    nType = ::sheet::NamedRangeFlag::ROW_HEADER;
+    rtl::OUString aContent5(RTL_CONSTASCII_USTRINGPARAM("D5"));
+    rtl::OUString aName5(RTL_CONSTASCII_USTRINGPARAM("type_ROW_HEADERA"));
+    xNamedRanges->addNewByName(aName5, aContent5, aBaseAddress, nType);
+    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type ROW_HEADER", xNamedRanges->hasByName(aName5));
+
+}
+
+void ScXNamedRanges::testAddNewFromTitles()
+{
+
+    uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
+    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
+
+    uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
+    rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
+    uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
+    uno::Reference< container::XIndexAccess > xNamedRangesIndex(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
+    uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
+
+    table::CellRangeAddress aCellRangeAddress = table::CellRangeAddress(1,0,0,3,3);
+
+    rtl::OUString aString;
+    uno::Reference< table::XCell > xCell;
+
+    xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_TOP);
+
+    for (sal_Int32 i = 1; i < 4; i++)
+    {
+        // verify namedrange exists
+        xCell = xSheet->getCellByPosition(i,0);
+        uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
+        aString = xTextRange->getString();
+        std::cout << "verify " << aString << std::endl;
+        CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
+
+        // verify it points on the right cell
+        uno::Any aNr = xNamedRangesNameAccess->getByName(aString);
+        uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW);
+
+        uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW);
+        uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
+        table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
+
+        CPPUNIT_ASSERT(cellRangeAddress.EndColumn == i && cellRangeAddress.StartColumn == i);
+        CPPUNIT_ASSERT(cellRangeAddress.StartRow == 1);
+        CPPUNIT_ASSERT(cellRangeAddress.EndRow == 3);
+        CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
+    }
+
+    xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_LEFT);
+
+    for (sal_Int32 i = 1; i < 4; i++)
+    {
+        // verify namedrange exists
+        xCell = xSheet->getCellByPosition(0,i);
+        uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
+        aString = xTextRange->getString();
+        std::cout << "verify " << aString << std::endl;
+        CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
+
+        // verify it points on the right cell
+        uno::Any aNr= xNamedRangesNameAccess->getByName(aString);
+        uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW);
+
+        uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW);
+        uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
+        table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
+
+        CPPUNIT_ASSERT(cellRangeAddress.EndRow == i && cellRangeAddress.StartRow == i);
+        CPPUNIT_ASSERT(cellRangeAddress.StartColumn == 1);
+        CPPUNIT_ASSERT(cellRangeAddress.EndColumn == 3);
+        CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
+    }
+}
+
+void ScXNamedRanges::testRemoveByName()
+{
+    uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
+    uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
+    rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
+    uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
+    uno::Reference< container::XIndexAccess > xIndex(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
+
+    rtl::OUString aNr1(RTL_CONSTASCII_USTRINGPARAM("initial1"));
+    bool bHasIt = xNamedRanges->hasByName(aNr1);
+    CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 des not exits, can't remove it", bHasIt);
+
+    if (bHasIt)
+    {
+        // remove existing
+        sal_Int32 nInitialCount = xIndex->getCount();
+        xNamedRanges->removeByName(aNr1);
+        sal_Int32 nNewCount = xIndex->getCount();
+        CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 not removed", nNewCount == nInitialCount - 1);
+        CPPUNIT_ASSERT_MESSAGE("Wrong NamedRange removed, initial1 still present", !xNamedRanges->hasByName(aNr1));
+        // try to remove non existing
+        rtl::OUString aNr2(RTL_CONSTASCII_USTRINGPARAM("dummyNonExistingNamedRange"));
+        xNamedRanges->removeByName(aNr2);// an exception should be raised here
+    }
+}
+
+void ScXNamedRanges::testOutputList()
+{
+
+    uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
+    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
+
+    table::CellAddress xCellAddress = table::CellAddress (0,2,0);
+
+    uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
+    rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
+    uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
+    uno::Reference< container::XIndexAccess > xNamedRangesIndex(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
+    sal_Int32 nElementsCount = xNamedRangesIndex->getCount();
+
+    xNamedRanges->outputList(xCellAddress);
+
+    rtl::OUString aString;
+    uno::Reference< table::XCell > xCell;
+
+    for (sal_Int32 i = 0; i < nElementsCount; i++)
+    {
+        xCell = xSheet->getCellByPosition(2,i);
+        uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
+        aString = xTextRange->getString();
+        std::cout << "verify " << aString << std::endl;
+        CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
+    }
+}
+
+uno::Reference< sheet::XSpreadsheetDocument> ScXNamedRanges::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;
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScXNamedRanges);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/xrangename.cxx b/sc/qa/extras/xrangename.cxx
deleted file mode 100644
index 2a61145..0000000
--- a/sc/qa/extras/xrangename.cxx
+++ /dev/null
@@ -1,265 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2011 Laurent Godard lgodard.libre at laposte.net (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#include <com/sun/star/table/XCellRange.hpp>
-#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
-#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
-#include <com/sun/star/sheet/XNamedRanges.hpp>
-#include <com/sun/star/sheet/XNamedRange.hpp>
-#include <com/sun/star/table/XCell.hpp>
-#include <com/sun/star/text/XTextRange.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-
-#include <com/sun/star/table/CellAddress.hpp>
-#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <com/sun/star/sheet/Border.hpp>
-#include <com/sun/star/sheet/NamedRangeFlag.hpp>
-
-#include <rtl/oustringostreaminserter.hxx>
-
-namespace ScNamedRangeObj {
-
-class ScXNamedRange : public UnoApiTest
-{
-    uno::Reference< sheet::XSpreadsheetDocument> init();
-
-    // XNamedRanges
-    void testAddNewByName();
-    void testAddNewFromTitles();
-    void testRemoveByName();
-    void testOutputList();
-
-    CPPUNIT_TEST_SUITE(ScXNamedRange);
-    CPPUNIT_TEST(testAddNewByName);
-    CPPUNIT_TEST(testAddNewFromTitles);
-    //fix first warning in ExceptionsTestCaseDecorator
-    //CPPUNIT_TEST_EXCEPTION(testRemoveByName, uno::RuntimeException);
-    CPPUNIT_TEST(testOutputList);
-    CPPUNIT_TEST_SUITE_END();
-};
-
-
-void ScXNamedRange::testAddNewByName()
-{
-    uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
-    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
-    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
-
-    uno::Reference< beans::XPropertySet > propSet (xDoc, UNO_QUERY_THROW);
-    rtl::OUString namedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
-    uno::Reference< sheet::XNamedRanges > xNamedRanges(propSet->getPropertyValue(namedRangesString), UNO_QUERY_THROW);
-    uno::Reference< container::XNameAccess > xNamedRangesNameAccess(propSet->getPropertyValue(namedRangesString), UNO_QUERY_THROW);
-
-    table::CellAddress xBaseAddress = table::CellAddress(0,0,0);
-
-    sal_Int32 nType = 0;
-    rtl::OUString content1(RTL_CONSTASCII_USTRINGPARAM("D1"));
-    rtl::OUString name1(RTL_CONSTASCII_USTRINGPARAM("type_0"));
-    xNamedRanges->addNewByName(name1, content1, xBaseAddress, nType);
-    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type 0 - Normal case", xNamedRanges->hasByName(name1));
-
-    nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
-    rtl::OUString content2(RTL_CONSTASCII_USTRINGPARAM("D2"));
-    rtl::OUString name2(RTL_CONSTASCII_USTRINGPARAM("type_COLUMN_HEADER"));
-    xNamedRanges->addNewByName(name2, content2, xBaseAddress, nType);
-    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type COLUMN_HEADER", xNamedRanges->hasByName(name2));
-
-    nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
-    rtl::OUString content3(RTL_CONSTASCII_USTRINGPARAM("D3"));
-    rtl::OUString name3(RTL_CONSTASCII_USTRINGPARAM("type_FILTER_CRITERIA"));
-    xNamedRanges->addNewByName(name3, content3, xBaseAddress, nType);
-    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type FILTER_CRITERIA", xNamedRanges->hasByName(name3));
-
-    nType = ::sheet::NamedRangeFlag::PRINT_AREA;
-    rtl::OUString content4(RTL_CONSTASCII_USTRINGPARAM("D4"));
-    rtl::OUString name4(RTL_CONSTASCII_USTRINGPARAM("type_PRINT_AREA"));
-    xNamedRanges->addNewByName(name4, content4, xBaseAddress, nType);
-    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type PRINT_AREA", xNamedRanges->hasByName(name4));
-
-    nType = ::sheet::NamedRangeFlag::ROW_HEADER;
-    rtl::OUString content5(RTL_CONSTASCII_USTRINGPARAM("D5"));
-    rtl::OUString name5(RTL_CONSTASCII_USTRINGPARAM("type_ROW_HEADERA"));
-    xNamedRanges->addNewByName(name5, content5, xBaseAddress, nType);
-    CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type ROW_HEADER", xNamedRanges->hasByName(name5));
-
-}
-
-void ScXNamedRange::testAddNewFromTitles()
-{
-
-    uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
-    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
-    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
-
-    uno::Reference< beans::XPropertySet > propSet (xDoc, UNO_QUERY_THROW);
-    rtl::OUString namedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
-    uno::Reference< sheet::XNamedRanges > xNamedRanges(propSet->getPropertyValue(namedRangesString), UNO_QUERY_THROW);
-    uno::Reference< container::XIndexAccess > xNamedRangesIndex(propSet->getPropertyValue(namedRangesString), UNO_QUERY_THROW);
-    uno::Reference< container::XNameAccess > xNamedRangesNameAccess(propSet->getPropertyValue(namedRangesString), UNO_QUERY_THROW);
-
-    table::CellRangeAddress xCellRangeAddress = table::CellRangeAddress(1,0,0,3,3);
-
-    rtl::OUString aString;
-    uno::Reference< table::XCell > xCell;
-
-    xNamedRanges->addNewFromTitles(xCellRangeAddress, sheet::Border_TOP);
-
-    for (sal_Int32 i = 1; i < 4; i++)
-    {
-        // verify namedrange exists
-        xCell = xSheet->getCellByPosition(i,0);
-        uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
-        aString = xTextRange->getString();
-        std::cout << "verify " << aString << std::endl;
-        CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
-
-        // verify it points on the right cell
-        uno::Any aNr = xNamedRangesNameAccess->getByName(aString);
-        uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW);
-
-        uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW);
-        uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
-        table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
-
-        CPPUNIT_ASSERT(cellRangeAddress.EndColumn == i && cellRangeAddress.StartColumn == i);
-        CPPUNIT_ASSERT(cellRangeAddress.StartRow == 1);
-        CPPUNIT_ASSERT(cellRangeAddress.EndRow == 3);
-        CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
-    }
-
-    xNamedRanges->addNewFromTitles(xCellRangeAddress, sheet::Border_LEFT);
-
-    for (sal_Int32 i = 1; i < 4; i++)
-    {
-        // verify namedrange exists
-        xCell = xSheet->getCellByPosition(0,i);
-        uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
-        aString = xTextRange->getString();
-        std::cout << "verify " << aString << std::endl;
-        CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
-
-        // verify it points on the right cell
-        uno::Any aNr= xNamedRangesNameAccess->getByName(aString);
-        uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW);
-
-        uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW);
-        uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
-        table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
-
-        CPPUNIT_ASSERT(cellRangeAddress.EndRow == i && cellRangeAddress.StartRow == i);
-        CPPUNIT_ASSERT(cellRangeAddress.StartColumn == 1);
-        CPPUNIT_ASSERT(cellRangeAddress.EndColumn == 3);
-        CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
-    }
-}
-
-void ScXNamedRange::testRemoveByName()
-{
-    uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
-    uno::Reference< beans::XPropertySet > propSet (xDoc, UNO_QUERY_THROW);
-    rtl::OUString namedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
-    uno::Reference< sheet::XNamedRanges > xNamedRanges(propSet->getPropertyValue(namedRangesString), UNO_QUERY_THROW);
-    uno::Reference< container::XIndexAccess > xIndex(propSet->getPropertyValue(namedRangesString), UNO_QUERY_THROW);
-
-    rtl::OUString aNr1(RTL_CONSTASCII_USTRINGPARAM("initial1"));
-    bool bHasIt = xNamedRanges->hasByName(aNr1);
-    CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 des not exits, can't remove it", bHasIt);
-
-    if (bHasIt)
-    {
-        // remove existing
-        sal_Int32 nInitialCount = xIndex->getCount();
-        xNamedRanges->removeByName(aNr1);
-        sal_Int32 nNewCount = xIndex->getCount();
-        CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 not removed", nNewCount == nInitialCount - 1);
-        bool bHasItAgain = xNamedRanges->hasByName(aNr1);
-        CPPUNIT_ASSERT_MESSAGE("Wrong NamedRange removed, initial1 still present", !bHasItAgain);
-
-        rtl::OUString nr2(RTL_CONSTASCII_USTRINGPARAM("dummyNamedRange"));
-        xNamedRanges->removeByName(aNr1);
-        // should throw an exception
-    }
-}
-
-void ScXNamedRange::testOutputList()
-{
-
-    uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
-    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
-    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
-
-    table::CellAddress xCellAddress = table::CellAddress (0,2,0);
-
-    uno::Reference< beans::XPropertySet > propSet (xDoc, UNO_QUERY_THROW);
-    rtl::OUString namedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
-    uno::Reference< sheet::XNamedRanges > xNamedRanges(propSet->getPropertyValue(namedRangesString), UNO_QUERY_THROW);
-    uno::Reference< container::XIndexAccess > xNamedRangesIndex(propSet->getPropertyValue(namedRangesString), UNO_QUERY_THROW);
-    sal_Int32 nElementsCount = xNamedRangesIndex->getCount();
-
-    xNamedRanges->outputList(xCellAddress);
-
-    rtl::OUString aString;
-    uno::Reference< table::XCell > xCell;
-
-    for (sal_Int32 i = 0; i < nElementsCount; i++)
-    {
-        xCell = xSheet->getCellByPosition(2,i);
-        uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
-        aString = xTextRange->getString();
-        std::cout << "verify " << aString << std::endl;
-        CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
-    }
-}
-
-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;
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScXNamedRange);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list