fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / test / source / sheet / xdatabaserange.cxx
blobd1e5a5a72554219cf549c1746a060ca2ee860d5a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <test/sheet/xdatabaserange.hxx>
12 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
13 #include <com/sun/star/sheet/XSpreadsheet.hpp>
14 #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
15 #include <com/sun/star/beans/PropertyValue.hpp>
16 #include <com/sun/star/sheet/XDatabaseRange.hpp>
17 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
18 #include <com/sun/star/table/CellRangeAddress.hpp>
19 #include <com/sun/star/util/XCloseable.hpp>
20 #include <com/sun/star/beans/XPropertySet.hpp>
21 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
22 #include <com/sun/star/table/XCell.hpp>
23 #include <com/sun/star/table/XTableRows.hpp>
24 #include <com/sun/star/table/XColumnRowRange.hpp>
26 #include <rtl/ustring.hxx>
27 #include "cppunit/extensions/HelperMacros.h"
28 #include <iostream>
30 using namespace css;
31 using namespace css::uno;
33 namespace apitest {
35 /**
36 * tests setDataArea and getDataArea
38 void XDatabaseRange::testDataArea()
40 uno::Reference< sheet::XDatabaseRange > xDBRange(init(OUString("DataArea")), UNO_QUERY_THROW);
42 table::CellRangeAddress aCellAddress;
43 aCellAddress.Sheet = 0;
44 aCellAddress.StartColumn = 1;
45 aCellAddress.EndColumn = 4;
46 aCellAddress.StartRow = 2;
47 aCellAddress.EndRow = 5;
48 xDBRange->setDataArea(aCellAddress);
49 table::CellRangeAddress aValue;
50 aValue = xDBRange->getDataArea();
51 CPPUNIT_ASSERT( aCellAddress.Sheet == aValue.Sheet );
52 CPPUNIT_ASSERT( aCellAddress.StartRow == aValue.StartRow );
53 CPPUNIT_ASSERT( aCellAddress.EndRow == aValue.EndRow );
54 CPPUNIT_ASSERT( aCellAddress.StartColumn == aValue.StartColumn );
55 CPPUNIT_ASSERT( aCellAddress.EndColumn == aValue.EndColumn );
58 void XDatabaseRange::testGetSubtotalDescriptor()
60 uno::Reference< sheet::XDatabaseRange > xDBRange(init(OUString("SubtotalDescriptor")), UNO_QUERY_THROW);
61 uno::Reference< sheet::XSubTotalDescriptor> xSubtotalDescr = xDBRange->getSubTotalDescriptor();
62 CPPUNIT_ASSERT(xSubtotalDescr.is());
65 void XDatabaseRange::testGetSortDescriptor()
67 uno::Reference< sheet::XDatabaseRange > xDBRange(init(OUString("SortDescriptor")), UNO_QUERY_THROW);
68 uno::Sequence< beans::PropertyValue > xSortDescr = xDBRange->getSortDescriptor();
69 for (sal_Int32 i = 0; i < xSortDescr.getLength(); ++i)
71 beans::PropertyValue xProp = xSortDescr[i];
72 //std::cout << "Prop " << i << " Name: " << OUString(xProp.Name) << std::endl;
74 if (xProp.Name == "IsSortColumns")
76 bool bIsSortColumns = true;
77 xProp.Value >>= bIsSortColumns;
78 CPPUNIT_ASSERT(bIsSortColumns);
80 else if (xProp.Name == "ContainsHeader")
82 bool bContainsHeader = true;
83 xProp.Value >>= bContainsHeader;
84 CPPUNIT_ASSERT(bContainsHeader);
86 else if (xProp.Name == "MaxFieldCount")
88 sal_Int32 nMaxFieldCount = 0;
89 xProp.Value >>= nMaxFieldCount;
90 std::cout << "Value: " << nMaxFieldCount << std::endl;
93 else if (xProp.Name == "SortFields")
97 else if (xProp.Name == "BindFormatsToContent")
99 bool bBindFormatsToContent = false;
100 xProp.Value >>= bBindFormatsToContent;
101 CPPUNIT_ASSERT(bBindFormatsToContent);
103 else if (xProp.Name == "CopyOutputData")
105 bool bCopyOutputData = true;
106 xProp.Value >>= bCopyOutputData;
107 CPPUNIT_ASSERT(!bCopyOutputData);
109 else if (xProp.Name == "OutputPosition")
113 else if (xProp.Name == "IsUserListEnabled")
115 bool bIsUserListEnabled = true;
116 xProp.Value >>= bIsUserListEnabled;
117 CPPUNIT_ASSERT(!bIsUserListEnabled);
120 else if (xProp.Name == "UserListIndex")
122 sal_Int32 nUserListIndex = 1;
123 xProp.Value >>= nUserListIndex;
124 CPPUNIT_ASSERT(nUserListIndex == 0);
129 void XDatabaseRange::testGetFilterDescriptor()
131 uno::Reference< sheet::XDatabaseRange > xDBRange( init(OUString("FilterDescriptor")), UNO_QUERY_THROW);
132 uno::Reference< uno::XInterface > xFilterDescr( xDBRange->getFilterDescriptor(), UNO_QUERY_THROW);
133 CPPUNIT_ASSERT(xFilterDescr.is());
136 void XDatabaseRange::testGetImportDescriptor()
138 uno::Reference< sheet::XDatabaseRange > xDBRange( init(OUString("ImportDescriptor")), UNO_QUERY_THROW);
139 uno::Sequence< beans::PropertyValue > xImportDescr = xDBRange->getImportDescriptor();
140 (void) xImportDescr;
143 void XDatabaseRange::testRefresh()
145 uno::Reference< sheet::XDatabaseRange > xDBRange( init(OUString("Refresh")), UNO_QUERY_THROW);
147 const sal_Int32 nCol = 0;
148 OUString aHidden("IsVisible");
149 uno::Reference< sheet::XCellRangeReferrer > xCellRangeReferrer(xDBRange, UNO_QUERY_THROW);
150 uno::Reference< table::XCellRange > xCellRange = xCellRangeReferrer->getReferredCells();
152 for (sal_Int32 i = 1; i < 5; ++i)
154 uno::Reference< table::XCell > xCell = xCellRange->getCellByPosition(nCol, i);
155 xCell->setValue(0);
158 for (sal_Int32 i = 2; i < 5; ++i)
160 uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
161 uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
162 uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
163 uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
164 Any aAny = xPropRow->getPropertyValue( aHidden );
166 CPPUNIT_ASSERT(aAny.get<bool>());
169 xDBRange->refresh();
170 std::cout << "after refresh" << std::endl;
172 for (sal_Int32 i = 1; i < 5; ++i)
174 uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
175 uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
176 uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
177 uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
178 Any aAny = xPropRow->getPropertyValue( aHidden );
180 CPPUNIT_ASSERT(!aAny.get<bool>());
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */