[Libreoffice-commits] .: 7 commits - sc/qa test/inc test/Library_subsequenttest.mk test/Package_inc.mk test/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Sat Feb 18 15:39:05 PST 2012


 dev/null                                       |binary
 sc/qa/extras/scdatapilottableobj.cxx           |   13 ++
 sc/qa/extras/scnamedrangeobj.cxx               |   48 ++++++++---
 sc/qa/extras/scnamedrangesobj.cxx              |    2 
 sc/qa/extras/testdocuments/ScNamedRangeObj.ods |binary
 sc/qa/unoapi/knownissues.xcl                   |    4 
 test/Library_subsequenttest.mk                 |    1 
 test/Package_inc.mk                            |    1 
 test/inc/test/sheet/xcellrangereferrer.hxx     |   52 +++++++++++
 test/inc/test/sheet/xdatapilottable2.hxx       |    7 +
 test/source/sheet/xcellrangereferrer.cxx       |   56 ++++++++++++
 test/source/sheet/xdatapilottable2.cxx         |  109 +++++++++++++++++++++++--
 12 files changed, 271 insertions(+), 22 deletions(-)

New commits:
commit 4681bacef161d3a44e01b928035d9f30717527ae
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Feb 18 23:36:07 2012 +0100

    adapt ScDataPilotTableObj test to XDataPilotTable2 changes

diff --git a/sc/qa/extras/scdatapilottableobj.cxx b/sc/qa/extras/scdatapilottableobj.cxx
index 6fedec0..18a26d0 100644
--- a/sc/qa/extras/scdatapilottableobj.cxx
+++ b/sc/qa/extras/scdatapilottableobj.cxx
@@ -40,7 +40,7 @@
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 13
+#define NUMBER_OF_TESTS 16
 
 class ScDataPilotTableObj : public UnoApiTest, apitest::XDataPilotDescriptor, apitest::XDataPilotTable,
                                 apitest::XNamed, apitest::XDataPilotTable2
@@ -52,6 +52,7 @@ public:
     virtual void tearDown();
     virtual uno::Reference< uno::XInterface > init();
     virtual uno::Reference< uno::XInterface > initDP2();
+    virtual uno::Reference< uno::XInterface > getSheets();
 
     CPPUNIT_TEST_SUITE(ScDataPilotTableObj);
     CPPUNIT_TEST(testRefresh);
@@ -68,6 +69,9 @@ public:
     CPPUNIT_TEST(testGetName);
     CPPUNIT_TEST(testSetName);
     CPPUNIT_TEST(testGetDrillDownData);
+    CPPUNIT_TEST(testInsertDrillDownSheet);
+    CPPUNIT_TEST(testGetPositionData);
+    CPPUNIT_TEST(testGetOutputRangeByType);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -114,6 +118,13 @@ uno::Reference< uno::XInterface > ScDataPilotTableObj::init()
     return xDPTable;
 }
 
+uno::Reference< uno::XInterface > ScDataPilotTableObj::getSheets()
+{
+    uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
+    uno::Reference< uno::XInterface > xSheets = xDoc->getSheets();
+    return xSheets;
+}
+
 uno::Reference< uno::XInterface > ScDataPilotTableObj::initDP2()
 {
     rtl::OUString aFileURL;
commit 7e14aa7af070418f5694277eb1614f6f12c60d74
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Feb 18 18:26:04 2012 +0100

    complete the XDataPilotTable2 tests

diff --git a/test/inc/test/sheet/xdatapilottable2.hxx b/test/inc/test/sheet/xdatapilottable2.hxx
index e81de86..7b82bf8 100644
--- a/test/inc/test/sheet/xdatapilottable2.hxx
+++ b/test/inc/test/sheet/xdatapilottable2.hxx
@@ -30,6 +30,8 @@
 #include <com/sun/star/table/CellRangeAddress.hpp>
 #include <com/sun/star/table/CellAddress.hpp>
 #include <com/sun/star/sheet/XDataPilotTable2.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/uno/Sequence.h>
 
 #include "test/testdllapi.hxx"
 
@@ -47,13 +49,16 @@ public:
     void testGetPositionData();
     void testGetDrillDownData();
     void testGetOutputRangeByType();
-    void testInsertDrillData();
+    void testInsertDrillDownSheet();
 
     virtual uno::Reference< uno::XInterface > initDP2() = 0;
+    virtual uno::Reference< uno::XInterface > getSheets() = 0;
 
 protected:
 
 private:
+    bool checkDrillDownSheetContent(uno::Reference< sheet::XSpreadsheet >, uno::Sequence< uno::Sequence < uno::Any > > aData);
+
     void getOutputRanges(uno::Reference< sheet::XDataPilotTable2 >);
     void buildDataFields(uno::Reference< sheet::XDataPilotTable2 >);
     void buildResultCells(uno::Reference< sheet::XDataPilotTable2 >);
diff --git a/test/source/sheet/xdatapilottable2.cxx b/test/source/sheet/xdatapilottable2.cxx
index 2aa34b8..0d93f3a 100644
--- a/test/source/sheet/xdatapilottable2.cxx
+++ b/test/source/sheet/xdatapilottable2.cxx
@@ -34,6 +34,10 @@
 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
 #include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
 #include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/table/XCellCursor.hpp>
+#include <com/sun/star/sheet/XCellRangeData.hpp>
 #include <com/sun/star/sheet/DataResult.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include "cppunit/extensions/HelperMacros.h"
@@ -45,6 +49,24 @@ namespace apitest {
 void XDataPilotTable2::testGetPositionData()
 {
     uno::Reference< sheet::XDataPilotTable2 > xDPTable(initDP2(), UNO_QUERY_THROW);
+    getOutputRanges(xDPTable);
+    table::CellAddress aAddr;
+
+    aAddr.Sheet = maRangeTable.Sheet;
+    for (sal_Int32 x = maRangeTable.StartColumn; x <= maRangeTable.EndColumn; ++x)
+    {
+        for (sal_Int32 y = maRangeTable.StartRow; y <= maRangeTable.EndRow; ++y)
+        {
+            aAddr.Column = x;
+            aAddr.Row = y;
+
+            sheet::DataPilotTablePositionData aPosData = xDPTable->getPositionData(aAddr);
+            if (aPosData.PositionType == sheet::DataPilotTablePositionType::NOT_IN_TABLE)
+            {
+                CPPUNIT_ASSERT(false);
+            }
+        }
+    }
 }
 
 void XDataPilotTable2::testGetDrillDownData()
@@ -90,6 +112,7 @@ void XDataPilotTable2::testGetDrillDownData()
 void XDataPilotTable2::testGetOutputRangeByType()
 {
     uno::Reference< sheet::XDataPilotTable2 > xDPTable(initDP2(), UNO_QUERY_THROW);
+    getOutputRanges(xDPTable);
 
     // check for wrong arguments
     bool bCaught = false;
@@ -126,20 +149,56 @@ void XDataPilotTable2::testGetOutputRangeByType()
 
     //result range must be smaller than the table range, and must share the same lower-right corner
     CPPUNIT_ASSERT( maRangeResult.Sheet == maRangeTable.Sheet );
-    CPPUNIT_ASSERT( maRangeResult.StartColumn < maRangeTable.StartColumn );
-    CPPUNIT_ASSERT( maRangeResult.StartRow < maRangeTable.StartRow );
+    CPPUNIT_ASSERT( maRangeResult.StartColumn >= maRangeTable.StartColumn );
+    CPPUNIT_ASSERT( maRangeResult.StartRow >= maRangeTable.StartRow );
     CPPUNIT_ASSERT( maRangeResult.EndRow == maRangeTable.EndRow );
     CPPUNIT_ASSERT( maRangeResult.EndColumn == maRangeTable.EndColumn );
 
 }
 
-/*
-void XDataPilotTable2::testInsertDrillDownData()
+void XDataPilotTable2::testInsertDrillDownSheet()
 {
     uno::Reference< sheet::XDataPilotTable2 > xDPTable(initDP2(), UNO_QUERY_THROW);
+    sal_Int32 nCellCount = maResultCells.size();
+
+    uno::Reference< sheet::XSpreadsheets > xSheets(getSheets(), UNO_QUERY_THROW);
+    uno::Reference< container::XIndexAccess > xIA(xSheets, UNO_QUERY_THROW);
+    sal_Int32 nSheetCount = xIA->getCount();
+
+    for (sal_Int32 i = 0; i < nCellCount; ++i)
+    {
+        table::CellAddress aAddr = maResultCells[i];
+        uno::Sequence< uno::Sequence< Any > > aData = xDPTable->getDrillDownData(aAddr);
+        xDPTable->insertDrillDownSheet(aAddr);
+
+        sal_Int32 nNewSheetCount= xIA->getCount();
+        if (nNewSheetCount == nSheetCount + 1)
+        {
+            CPPUNIT_ASSERT(aData.getLength() >= 2);
+            uno::Reference< sheet::XSpreadsheet > xSheet(xIA->getByIndex(aAddr.Sheet),UNO_QUERY_THROW);
+            CPPUNIT_ASSERT(xSheet.is());
+
+            checkDrillDownSheetContent(xSheet, aData);
+
+            uno::Reference< container::XNamed > xNamed(xSheet, UNO_QUERY_THROW);
+            rtl::OUString aName = xNamed->getName();
+            xSheets->removeByName(aName);
+        }
+        else if (nNewSheetCount == nSheetCount)
+        {
+            if (aData.getLength() > 1)
+            {
+                CPPUNIT_ASSERT(false);
+            }
+        }
+        else
+        {
+            CPPUNIT_ASSERT(false);
+        }
 
+    }
 }
-*/
+
 void XDataPilotTable2::buildResultCells( uno::Reference< sheet::XDataPilotTable2 > xDPTable)
 {
     getOutputRanges(xDPTable);
@@ -190,6 +249,46 @@ void XDataPilotTable2::buildDataFields( uno::Reference< sheet::XDataPilotTable2
     }
 }
 
+namespace {
+
+table::CellAddress getLastUsedCellAddress( uno::Reference< sheet::XSpreadsheet > xSheet, sal_Int32 nCol, sal_Int32 nRow )
+{
+    uno::Reference< sheet::XSheetCellRange > xSheetRange( xSheet->getCellRangeByPosition(nCol, nRow, nCol, nRow), UNO_QUERY_THROW);
+    uno::Reference< sheet::XSheetCellCursor > xCursor = xSheet->createCursorByRange(xSheetRange);
+    uno::Reference< table::XCellCursor > xCellCursor(xCursor, UNO_QUERY_THROW);
+    xCellCursor->gotoEnd();
+
+    uno::Reference< sheet::XCellAddressable > xCellAddr(xCursor->getCellByPosition(0, 0), UNO_QUERY_THROW);
+    return xCellAddr->getCellAddress();
+}
+
+}
+
+bool XDataPilotTable2::checkDrillDownSheetContent(uno::Reference< sheet::XSpreadsheet > xSheet, uno::Sequence< uno::Sequence< Any > > aData)
+{
+    table::CellAddress aLastCell = getLastUsedCellAddress(xSheet, 0, 0);
+    CPPUNIT_ASSERT(aData.getLength() > 0);
+    CPPUNIT_ASSERT(aLastCell.Row);
+    CPPUNIT_ASSERT(aLastCell.Column);
+
+    CPPUNIT_ASSERT_EQUAL(aData.getLength(), aLastCell.Row + 1);
+    CPPUNIT_ASSERT_EQUAL(aData[0].getLength(), aLastCell.Column + 1);
+
+    uno::Reference< table::XCellRange > xCellRange = xSheet->getCellRangeByPosition(0, 0, aLastCell.Column, aLastCell.Row);
+    uno::Reference< sheet::XCellRangeData > xCellRangeData(xCellRangeData, UNO_QUERY_THROW);
+
+    uno::Sequence< uno::Sequence< Any > > aSheetData = xCellRangeData->getDataArray();
+    for (sal_Int32 x = 0; x < aSheetData.getLength(); ++x)
+    {
+        for(sal_Int32 y = 0; y < aSheetData[x].getLength(); ++y)
+        {
+            Any& aCell1 = aSheetData[x][y];
+            Any& aCell2 = aData[x][y];
+            CPPUNIT_ASSERT(aCell1 == aCell2);
+        }
+    }
+    return true;
 }
 
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 05d0fe1ac42a9f3ee596961e1ca60d3edb0806c9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Feb 18 04:51:21 2012 +0100

    remove ScNamedRangeObj from java based tests

diff --git a/sc/qa/unoapi/knownissues.xcl b/sc/qa/unoapi/knownissues.xcl
index c522490..8c2ad89 100644
--- a/sc/qa/unoapi/knownissues.xcl
+++ b/sc/qa/unoapi/knownissues.xcl
@@ -225,6 +225,8 @@ sc.ScDataPilotTableObj::com::sun::star::sheet::XDataPilotDescriptor
 sc.ScDataPilotTableObj::com::sun::star::container::XNamed
 sc.ScDataPilotTableObj::com::sun::star::sheet::XDataPilotTable
 sc.ScNamedRangeObj::com::sun::star::sheet::XNamedRange
+sc.ScNamedRangeObj::com::sun::star::container::XNamed
+sc.ScNamedRangeObj::com::sun::star::sheet::XCellRangeReferrer
 sc.ScNamedRangesObj::com::sun::star::sheet::XNamedRanges
 sc.ScTableSheetObj::com::sun::star::util::XSearchable
 sc.ScTableSheetObj::com::sun::star::util::XReplaceable
commit 8910f2b8a457af9d29e6ed236924b7a6522f067c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Feb 18 04:49:32 2012 +0100

    add XCellRangeReferrer test to ScRangeNameObj
    
    now ScRangeNameObj is fully tested by c++ tests

diff --git a/sc/qa/extras/scnamedrangeobj.cxx b/sc/qa/extras/scnamedrangeobj.cxx
index 69785c7..cdc1f49 100644
--- a/sc/qa/extras/scnamedrangeobj.cxx
+++ b/sc/qa/extras/scnamedrangeobj.cxx
@@ -26,9 +26,10 @@
  * instead of those above.
  */
 
+#include <test/unoapi_test.hxx>
 #include <test/sheet/xnamedrange.hxx>
 #include <test/container/xnamed.hxx>
-#include <test/unoapi_test.hxx>
+#include <test/sheet/xcellrangereferrer.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
@@ -37,9 +38,9 @@
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 8
+#define NUMBER_OF_TESTS 9
 
-class ScNamedRangeObj : public UnoApiTest, apitest::XNamedRange, apitest::XNamed
+class ScNamedRangeObj : public UnoApiTest, apitest::XNamedRange, apitest::XNamed, apitest::XCellRangeReferrer
 {
 public:
     ScNamedRangeObj();
@@ -59,6 +60,7 @@ public:
     CPPUNIT_TEST(testSetReferencePosition);
     CPPUNIT_TEST(testSetName);
     CPPUNIT_TEST(testGetName);
+    CPPUNIT_TEST(testGetReferredCells);
     CPPUNIT_TEST_SUITE_END();
 private:
     uno::Reference< sheet::XNamedRanges > init_impl();
@@ -71,7 +73,8 @@ sal_Int32 ScNamedRangeObj::nTest = 0;
 uno::Reference< lang::XComponent > ScNamedRangeObj::mxComponent;
 
 ScNamedRangeObj::ScNamedRangeObj():
-        apitest::XNamed(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedRange")))
+        apitest::XNamed(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedRange"))),
+        apitest::XCellRangeReferrer(table::CellRangeAddress(0,1,7,1,7))
 {
 
 }
commit 903a19b0c3eb9428445bc115d37f700cec8c3265
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Feb 18 04:31:06 2012 +0100

    add test for XCellRangeReferrer

diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 53cc8e4..cd540d6 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -70,6 +70,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
     test/source/sheet/cellproperties \
     test/source/sheet/datapilotfield \
     test/source/sheet/xcellrangedata \
+    test/source/sheet/xcellrangereferrer \
     test/source/sheet/xcellrangesquery \
     test/source/sheet/xdatabaserange \
     test/source/sheet/xdatapilotdescriptor \
diff --git a/test/Package_inc.mk b/test/Package_inc.mk
index 768c6a8..1dcc10e 100644
--- a/test/Package_inc.mk
+++ b/test/Package_inc.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_Package_add_file,test_inc,inc/test/container/xnamecontainer.hxx
 $(eval $(call gb_Package_add_file,test_inc,inc/test/container/xnamereplace.hxx,test/container/xnamereplace.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/cellproperties.hxx,test/sheet/cellproperties.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xcellrangedata.hxx,test/sheet/xcellrangedata.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xcellrangereferrer.hxx,test/sheet/xcellrangereferrer.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilottable.hxx,test/sheet/xdatapilottable.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilottable2.hxx,test/sheet/xdatapilottable2.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilotfieldgrouping.hxx,test/sheet/xdatapilotfieldgrouping.hxx))
diff --git a/test/inc/test/sheet/xcellrangereferrer.hxx b/test/inc/test/sheet/xcellrangereferrer.hxx
new file mode 100644
index 0000000..b799993
--- /dev/null
+++ b/test/inc/test/sheet/xcellrangereferrer.hxx
@@ -0,0 +1,52 @@
+/* -*- 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) 2012 Markus Mohrhard <markus.mohrhard at googlemail.com> (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 <com/sun/star/table/CellRangeAddress.hpp>
+#include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XCellRangeReferrer
+{
+public:
+    XCellRangeReferrer( table::CellRangeAddress aCellRange ):
+                maCellRange( aCellRange ) {}
+
+    virtual uno::Reference< uno::XInterface > init() = 0;
+
+    void testGetReferredCells();
+
+private:
+    table::CellRangeAddress maCellRange;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xcellrangereferrer.cxx b/test/source/sheet/xcellrangereferrer.cxx
new file mode 100644
index 0000000..c0dbf79
--- /dev/null
+++ b/test/source/sheet/xcellrangereferrer.cxx
@@ -0,0 +1,56 @@
+/* -*- 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) 2012 Markus Mohrhard <markus.mohrhard at googlemail.com> (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/sheet/xcellrangereferrer.hxx>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include "cppunit/extensions/HelperMacros.h"
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XCellRangeReferrer::testGetReferredCells()
+{
+    uno::Reference< sheet::XCellRangeReferrer > xReferrer(init(), UNO_QUERY_THROW);
+    uno::Reference< table::XCellRange > xReferredRange = xReferrer->getReferredCells();
+
+    uno::Reference< sheet::XCellRangeAddressable > xAdressable( xReferredRange, UNO_QUERY_THROW );
+    table::CellRangeAddress aCellRange = xAdressable->getRangeAddress();
+
+    CPPUNIT_ASSERT_EQUAL( aCellRange.Sheet, maCellRange.Sheet );
+    CPPUNIT_ASSERT_EQUAL( aCellRange.StartRow, maCellRange.StartRow );
+    CPPUNIT_ASSERT_EQUAL( aCellRange.EndRow, maCellRange.EndRow );
+    CPPUNIT_ASSERT_EQUAL( aCellRange.StartColumn, maCellRange.StartColumn );
+    CPPUNIT_ASSERT_EQUAL( aCellRange.EndColumn, maCellRange.EndColumn );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit bbfddc1b3b673fe2bd25c2c382ca95cd8f6f28a8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Feb 18 04:10:03 2012 +0100

    add XNamed test to ScNamedRange

diff --git a/sc/qa/extras/scnamedrangeobj.cxx b/sc/qa/extras/scnamedrangeobj.cxx
index 2d72402..69785c7 100644
--- a/sc/qa/extras/scnamedrangeobj.cxx
+++ b/sc/qa/extras/scnamedrangeobj.cxx
@@ -27,19 +27,23 @@
  */
 
 #include <test/sheet/xnamedrange.hxx>
+#include <test/container/xnamed.hxx>
 #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/sheet/XNamedRanges.hpp>
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 6
+#define NUMBER_OF_TESTS 8
 
-class ScNamedRangeObj : public UnoApiTest, apitest::XNamedRange
+class ScNamedRangeObj : public UnoApiTest, apitest::XNamedRange, apitest::XNamed
 {
 public:
+    ScNamedRangeObj();
+
     virtual void setUp();
     virtual void tearDown();
 
@@ -53,8 +57,12 @@ public:
     CPPUNIT_TEST(testSetType);
     CPPUNIT_TEST(testGetReferencePosition);
     CPPUNIT_TEST(testSetReferencePosition);
+    CPPUNIT_TEST(testSetName);
+    CPPUNIT_TEST(testGetName);
     CPPUNIT_TEST_SUITE_END();
 private:
+    uno::Reference< sheet::XNamedRanges > init_impl();
+
     static sal_Int32 nTest;
     static uno::Reference< lang::XComponent > mxComponent;
 };
@@ -62,29 +70,40 @@ private:
 sal_Int32 ScNamedRangeObj::nTest = 0;
 uno::Reference< lang::XComponent > ScNamedRangeObj::mxComponent;
 
-uno::Reference< sheet::XNamedRange> ScNamedRangeObj::getNamedRange(const rtl::OUString& rRangeName)
+ScNamedRangeObj::ScNamedRangeObj():
+        apitest::XNamed(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedRange")))
 {
-    uno::Reference< container::XNameAccess > xNamedAccess(init(), UNO_QUERY_THROW);
-    uno::Reference< sheet::XNamedRange > xNamedRange(xNamedAccess->getByName(rRangeName), UNO_QUERY_THROW);
-    CPPUNIT_ASSERT(xNamedRange.is());
 
-    return xNamedRange;
 }
 
-uno::Reference< uno::XInterface > ScNamedRangeObj::init()
+uno::Reference< sheet::XNamedRanges > ScNamedRangeObj::init_impl()
 {
     rtl::OUString aFileURL;
-    createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")), aFileURL);
+    createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScNamedRangeObj.ods")), aFileURL);
     if(!mxComponent.is())
         mxComponent = loadFromDesktop(aFileURL);
     CPPUNIT_ASSERT(mxComponent.is());
 
     uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);
     rtl::OUString aNamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
-    uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW);
-    CPPUNIT_ASSERT(xNamedRangesNameAccess.is());
+    uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW);
+    CPPUNIT_ASSERT(xNamedRanges.is());
 
-    return xNamedRangesNameAccess;
+    return xNamedRanges;
+}
+
+uno::Reference< sheet::XNamedRange> ScNamedRangeObj::getNamedRange(const rtl::OUString& rRangeName)
+{
+    uno::Reference< container::XNameAccess > xNamedAccess(init_impl(), UNO_QUERY_THROW);
+    uno::Reference< sheet::XNamedRange > xNamedRange(xNamedAccess->getByName(rRangeName), UNO_QUERY_THROW);
+    CPPUNIT_ASSERT(xNamedRange.is());
+
+    return xNamedRange;
+}
+
+uno::Reference< uno::XInterface > ScNamedRangeObj::init()
+{
+    return getNamedRange(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedRange")));
 }
 
 void ScNamedRangeObj::setUp()
diff --git a/sc/qa/extras/scnamedrangesobj.cxx b/sc/qa/extras/scnamedrangesobj.cxx
index f6d2322..7a44bf1 100644
--- a/sc/qa/extras/scnamedrangesobj.cxx
+++ b/sc/qa/extras/scnamedrangesobj.cxx
@@ -63,7 +63,7 @@ uno::Reference< lang::XComponent > ScNamedRangesObj::mxComponent;
 uno::Reference< uno::XInterface > ScNamedRangesObj::init(sal_Int32 nSheet)
 {
     rtl::OUString aFileURL;
-    createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")), aFileURL);
+    createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScNamedRangeObj.ods")), aFileURL);
     if(!mxComponent.is())
         mxComponent = loadFromDesktop(aFileURL);
     CPPUNIT_ASSERT(mxComponent.is());
diff --git a/sc/qa/extras/testdocuments/ScNamedRangeObj.ods b/sc/qa/extras/testdocuments/ScNamedRangeObj.ods
new file mode 100644
index 0000000..39a53b2
Binary files /dev/null and b/sc/qa/extras/testdocuments/ScNamedRangeObj.ods differ
diff --git a/sc/qa/extras/testdocuments/rangenames.ods b/sc/qa/extras/testdocuments/rangenames.ods
deleted file mode 100644
index 1b101fd..0000000
Binary files a/sc/qa/extras/testdocuments/rangenames.ods and /dev/null differ
commit 7541a20151eb14fe23d793f4700bfbd3c3497aec
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Feb 17 02:09:38 2012 +0100

    remove some more tests from the java based tests

diff --git a/sc/qa/unoapi/knownissues.xcl b/sc/qa/unoapi/knownissues.xcl
index 33bed84..c522490 100644
--- a/sc/qa/unoapi/knownissues.xcl
+++ b/sc/qa/unoapi/knownissues.xcl
@@ -200,7 +200,6 @@ sc.ScCellCursorObj::com::sun::star::sheet::XCellRangesQuery
 sc.ScCellObj::com::sun::star::table::CellProperties
 sc.ScCellObj::com::sun::star::style::CharacterProperties
 sc.ScCellObj::com::sun::star::beans::XPropertySet
-sc.ScCellRangeObj::com::sun::star::table::CellProperties
 sc.ScCellRangesObj::com::sun::star::table::CellProperties
 sc.ScCellRangesObj::com::sun::star::beans::XPropertySet
 
@@ -217,6 +216,7 @@ sc.ScCellRangeObj::com::sun::star::table::CellProperties
 sc.ScCellRangeObj::com::sun::star::util::XSearchable
 sc.ScCellRangeObj::com::sun::star::sheet::XCellRangesQuery
 sc.ScCellRangeObj::com::sun::star::util::XReplaceable
+sc.ScCellRangeObj::com::sun::star::sheet::XCellRangeData
 sc.ScDataPilotFieldObj::com::sun::star::sheet::XDataPilotFieldGrouping
 sc.ScDataPilotFieldObj::com::sun::star::sheet::DataPilotField
 sc.ScDataPilotFieldObj::com::sun::star::sheet::DataPilotField


More information about the Libreoffice-commits mailing list