summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/inc/test/sheet/xdatapilottable2.hxx7
-rw-r--r--test/source/sheet/xdatapilottable2.cxx109
2 files changed, 110 insertions, 6 deletions
diff --git a/test/inc/test/sheet/xdatapilottable2.hxx b/test/inc/test/sheet/xdatapilottable2.hxx
index e81de869c382..7b82bf8340af 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 2aa34b8c4b22..0d93f3a55f43 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: */