12#include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
13#include <com/sun/star/beans/PropertyValue.hpp>
14#include <com/sun/star/sheet/XDatabaseRange.hpp>
15#include <com/sun/star/table/CellRangeAddress.hpp>
16#include <com/sun/star/beans/XPropertySet.hpp>
17#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
18#include <com/sun/star/table/XCell.hpp>
19#include <com/sun/star/table/XTableRows.hpp>
20#include <com/sun/star/table/XColumnRowRange.hpp>
22#include <rtl/ustring.hxx>
23#include <cppunit/TestAssert.h>
27using namespace css::uno;
36 uno::Reference<sheet::XDatabaseRange> xDBRange(
init(
"DataArea"), UNO_QUERY_THROW);
38 table::CellRangeAddress aCellAddress;
39 aCellAddress.Sheet = 0;
40 aCellAddress.StartColumn = 1;
41 aCellAddress.EndColumn = 4;
42 aCellAddress.StartRow = 2;
43 aCellAddress.EndRow = 5;
44 xDBRange->setDataArea(aCellAddress);
45 table::CellRangeAddress aValue = xDBRange->getDataArea();
46 CPPUNIT_ASSERT_EQUAL(aCellAddress.Sheet, aValue.Sheet);
47 CPPUNIT_ASSERT_EQUAL(aCellAddress.StartRow, aValue.StartRow);
48 CPPUNIT_ASSERT_EQUAL(aCellAddress.EndRow, aValue.EndRow);
49 CPPUNIT_ASSERT_EQUAL(aCellAddress.StartColumn, aValue.StartColumn);
50 CPPUNIT_ASSERT_EQUAL(aCellAddress.EndColumn, aValue.EndColumn);
55 uno::Reference<sheet::XDatabaseRange> xDBRange(
init(
"SubtotalDescriptor"), UNO_QUERY_THROW);
56 uno::Reference<sheet::XSubTotalDescriptor> xSubtotalDescr = xDBRange->getSubTotalDescriptor();
57 CPPUNIT_ASSERT(xSubtotalDescr.is());
62 uno::Reference<sheet::XDatabaseRange> xDBRange(
init(
"SortDescriptor"), UNO_QUERY_THROW);
63 const uno::Sequence<beans::PropertyValue> xSortDescr = xDBRange->getSortDescriptor();
64 for (
const beans::PropertyValue& aProp : xSortDescr)
68 if (aProp.Name ==
"IsSortColumns")
70 bool bIsSortColumns =
true;
71 aProp.Value >>= bIsSortColumns;
72 CPPUNIT_ASSERT(!bIsSortColumns);
74 else if (aProp.Name ==
"ContainsHeader")
76 bool bContainsHeader =
true;
77 aProp.Value >>= bContainsHeader;
78 CPPUNIT_ASSERT(bContainsHeader);
80 else if (aProp.Name ==
"MaxFieldCount")
82 sal_Int32 nMaxFieldCount = 0;
83 aProp.Value >>= nMaxFieldCount;
84 std::cout <<
"Value: " << nMaxFieldCount << std::endl;
86 else if (aProp.Name ==
"SortFields")
89 else if (aProp.Name ==
"BindFormatsToContent")
91 bool bBindFormatsToContent =
false;
92 aProp.Value >>= bBindFormatsToContent;
93 CPPUNIT_ASSERT(bBindFormatsToContent);
95 else if (aProp.Name ==
"CopyOutputData")
97 bool bCopyOutputData =
true;
98 aProp.Value >>= bCopyOutputData;
99 CPPUNIT_ASSERT(!bCopyOutputData);
101 else if (aProp.Name ==
"OutputPosition")
104 else if (aProp.Name ==
"IsUserListEnabled")
106 bool bIsUserListEnabled =
true;
107 aProp.Value >>= bIsUserListEnabled;
108 CPPUNIT_ASSERT(!bIsUserListEnabled);
110 else if (aProp.Name ==
"UserListIndex")
112 sal_Int32 nUserListIndex = 1;
113 aProp.Value >>= nUserListIndex;
114 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nUserListIndex);
121 uno::Reference<sheet::XDatabaseRange> xDBRange(
init(
"FilterDescriptor"), UNO_QUERY_THROW);
122 uno::Reference<uno::XInterface> xFilterDescr(xDBRange->getFilterDescriptor(), UNO_QUERY_THROW);
127 uno::Reference<sheet::XDatabaseRange> xDBRange(
init(
"ImportDescriptor"), UNO_QUERY_THROW);
128 (void)xDBRange->getImportDescriptor();
133 uno::Reference<sheet::XDatabaseRange> xDBRange(
init(
"Refresh"), UNO_QUERY_THROW);
135 const sal_Int32 nCol = 0;
136 OUString aHidden(
"IsVisible");
137 uno::Reference<sheet::XCellRangeReferrer> xCellRangeReferrer(xDBRange, UNO_QUERY_THROW);
138 uno::Reference<table::XCellRange> xCellRange = xCellRangeReferrer->getReferredCells();
140 for (sal_Int32
i = 1;
i < 5; ++
i)
142 uno::Reference<table::XCell> xCell = xCellRange->getCellByPosition(nCol,
i);
146 for (sal_Int32
i = 2;
i < 5; ++
i)
148 uno::Reference<table::XColumnRowRange> xColRowRange(xCellRange, UNO_QUERY_THROW);
149 uno::Reference<table::XTableRows> xRows = xColRowRange->getRows();
150 uno::Reference<table::XCellRange> xRow(xRows->getByIndex(
i), UNO_QUERY_THROW);
151 uno::Reference<beans::XPropertySet> xPropRow(xRow, UNO_QUERY_THROW);
152 Any aAny = xPropRow->getPropertyValue(aHidden);
154 CPPUNIT_ASSERT(aAny.get<
bool>());
158 std::cout <<
"after refresh" << std::endl;
160 for (sal_Int32
i = 1;
i < 5; ++
i)
162 uno::Reference<table::XColumnRowRange> xColRowRange(xCellRange, UNO_QUERY_THROW);
163 uno::Reference<table::XTableRows> xRows = xColRowRange->getRows();
164 uno::Reference<table::XCellRange> xRow(xRows->getByIndex(
i), UNO_QUERY_THROW);
165 uno::Reference<beans::XPropertySet> xPropRow(xRow, UNO_QUERY_THROW);
166 Any aAny = xPropRow->getPropertyValue(aHidden);
168 CPPUNIT_ASSERT(!aAny.get<
bool>());
void testGetSubtotalDescriptor()
virtual css::uno::Reference< css::uno::XInterface > init(const OUString &rDBName)=0
void testGetSortDescriptor()
void testDataArea()
tests setDataArea and getDataArea
void testGetImportDescriptor()
void testGetFilterDescriptor()