fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / test / source / sheet / xdatapilotdescriptor.cxx
blobba5b89f602471a9af5509a735b10813b64795602
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/xdatapilotdescriptor.hxx"
12 #include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
13 #include <com/sun/star/table/CellRangeAddress.hpp>
14 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
15 #include <com/sun/star/beans/XPropertySet.hpp>
17 #include "cppunit/extensions/HelperMacros.h"
19 #include <rtl/ustring.hxx>
21 using namespace css;
22 using namespace css::uno;
24 namespace apitest {
26 std::vector< OUString > XDataPilotDescriptor::maFieldNames;
28 void XDataPilotDescriptor::testTag()
30 OUString aTag("DataPilotDescriptor_Tag");
31 uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
32 xDescr->setTag(aTag);
33 OUString aNewTag = xDescr->getTag();
34 CPPUNIT_ASSERT( aTag == aNewTag );
37 void XDataPilotDescriptor::testSourceRange()
39 uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
40 table::CellRangeAddress aOldAddress = xDescr->getSourceRange();
42 table::CellRangeAddress aAddress;
43 aAddress.Sheet = 1;
44 aAddress.StartColumn = 1;
45 aAddress.StartRow = 1;
46 aAddress.EndColumn = 5;
47 aAddress.EndRow = 5;
48 xDescr->setSourceRange(aAddress);
50 table::CellRangeAddress aReturn;
51 aReturn = xDescr->getSourceRange();
53 CPPUNIT_ASSERT(aAddress.Sheet == aReturn.Sheet);
54 CPPUNIT_ASSERT(aAddress.StartColumn == aReturn.StartColumn);
55 CPPUNIT_ASSERT(aAddress.StartRow == aReturn.StartRow);
56 CPPUNIT_ASSERT(aAddress.EndColumn == aReturn.EndColumn);
57 CPPUNIT_ASSERT(aAddress.EndRow == aReturn.EndRow);
59 //restore old settings
60 xDescr->setSourceRange(aOldAddress);
63 void XDataPilotDescriptor::testGetFilterDescriptor()
65 uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
66 uno::Reference< sheet::XSheetFilterDescriptor > xSheetFilterDescr = xDescr->getFilterDescriptor();
67 CPPUNIT_ASSERT(xSheetFilterDescr.is());
70 void XDataPilotDescriptor::testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > xDescr)
72 //this method should only be called once but needs to be called before any of the other tests
73 static bool bCalled = false;
74 if (bCalled)
75 return;
76 else
77 bCalled = true;
79 uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataPilotFields(), UNO_QUERY_THROW);
80 CPPUNIT_ASSERT( xIndex.is());
82 sal_Int32 nCount = xIndex->getCount();
84 OUString aOrientation("Orientation");
85 for (sal_Int32 i = 0; i < nCount && i < 5; ++i)
87 uno::Reference< container::XNamed > xNamed( xIndex->getByIndex( i ), UNO_QUERY_THROW);
88 CPPUNIT_ASSERT(xNamed.is());
89 OUString aName = xNamed->getName();
90 maFieldNames.push_back(aName);
91 CPPUNIT_ASSERT( aName != "Data" );
93 uno::Reference< beans::XPropertySet > xPropSet( xNamed, UNO_QUERY_THROW);
94 CPPUNIT_ASSERT( xPropSet.is() );
96 switch ( i % 5 )
98 case 0:
100 uno::Any aAny;
101 aAny<<= sheet::DataPilotFieldOrientation_COLUMN;
102 xPropSet->setPropertyValue(aOrientation, aAny);
104 break;
105 case 1:
107 uno::Any aAny;
108 aAny<<= sheet::DataPilotFieldOrientation_ROW;
109 xPropSet->setPropertyValue(aOrientation, aAny);
111 break;
112 case 2:
114 uno::Any aAny;
115 aAny<<= sheet::DataPilotFieldOrientation_DATA;
116 xPropSet->setPropertyValue(aOrientation, aAny);
118 break;
119 case 3:
121 uno::Any aAny;
122 aAny<<= sheet::DataPilotFieldOrientation_HIDDEN;
123 xPropSet->setPropertyValue(aOrientation, aAny);
125 break;
126 case 4:
128 uno::Any aAny;
129 aAny<<= sheet::DataPilotFieldOrientation_PAGE;
130 xPropSet->setPropertyValue(aOrientation, aAny);
132 break;
137 void XDataPilotDescriptor::testGetDataPilotFields()
139 uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
140 testGetDataPilotFields_Impl( xDescr );
143 void XDataPilotDescriptor::testGetColumnFields()
145 uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(),UNO_QUERY_THROW);
146 testGetDataPilotFields_Impl( xDescr );
147 uno::Reference< container::XIndexAccess > xIndex(xDescr->getColumnFields(), UNO_QUERY_THROW);
149 checkName( xIndex, 0 );
152 void XDataPilotDescriptor::testGetRowFields()
154 uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(),UNO_QUERY_THROW);
155 testGetDataPilotFields_Impl( xDescr );
156 uno::Reference< container::XIndexAccess > xIndex(xDescr->getRowFields(), UNO_QUERY_THROW);
158 //checkName( xIndex, 1 );
161 void XDataPilotDescriptor::testGetPageFields()
163 uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
164 testGetDataPilotFields_Impl( xDescr );
165 uno::Reference< container::XIndexAccess > xIndex(xDescr->getPageFields(), UNO_QUERY_THROW);
167 checkName( xIndex, 4 );
170 void XDataPilotDescriptor::testGetDataFields()
172 uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(),UNO_QUERY_THROW);
173 testGetDataPilotFields_Impl( xDescr );
174 uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataFields(), UNO_QUERY_THROW);
176 checkName( xIndex, 2 );
179 void XDataPilotDescriptor::testGetHiddenFields()
181 std::cout << "testGetHiddenFields" <<std::endl;
182 uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(),UNO_QUERY_THROW);
183 testGetDataPilotFields_Impl( xDescr );
184 uno::Reference< container::XIndexAccess > xIndex(xDescr->getHiddenFields(), UNO_QUERY_THROW);
186 checkName( xIndex, 3 );
189 void XDataPilotDescriptor::checkName( uno::Reference< container::XIndexAccess > xIndex, sal_Int32 nIndex )
191 CPPUNIT_ASSERT(xIndex.is());
192 CPPUNIT_ASSERT(maFieldNames.size() >= static_cast<size_t>(nIndex));
194 for (sal_Int32 i = 0; i < xIndex->getCount(); ++i)
196 uno::Reference< container::XNamed > xNamed( xIndex->getByIndex(i), UNO_QUERY_THROW);
197 std::cout << "Expected: " << maFieldNames[nIndex] << " Got: " << xNamed->getName() << std::endl;
198 CPPUNIT_ASSERT( xNamed->getName() == maFieldNames[nIndex] );
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */