LibreOffice Module test (master) 1
sheetfilterdescriptor.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 */
9
12
13#include <com/sun/star/beans/XPropertySet.hpp>
14#include <com/sun/star/table/CellAddress.hpp>
15#include <com/sun/star/table/TableOrientation.hpp>
16#include <com/sun/star/uno/Any.hxx>
17#include <com/sun/star/uno/Reference.hxx>
18
19#include <cppunit/TestAssert.h>
20
21using namespace com::sun::star;
22using namespace com::sun::star::uno;
23
24namespace apitest
25{
27{
28 uno::Reference<beans::XPropertySet> xSheetFilterDescriptor(init(), UNO_QUERY_THROW);
29 OUString propName;
30 uno::Any aNewValue;
31
32 propName = "IsCaseSensitive";
33 bool bIsCaseSensitiveGet = false;
34 bool bIsCaseSensitiveSet = false;
35 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsCaseSensitive",
36 xSheetFilterDescriptor->getPropertyValue(propName)
37 >>= bIsCaseSensitiveGet);
38
39 aNewValue <<= !bIsCaseSensitiveGet;
40 xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
41 CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bIsCaseSensitiveSet);
42 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue IsCaseSensitive",
43 !bIsCaseSensitiveGet, bIsCaseSensitiveSet);
44
45 propName = "SkipDuplicates";
46 bool bSkipDuplicatesGet = false;
47 bool bSkipDuplicatesSet = false;
48 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SkipDuplicates",
49 xSheetFilterDescriptor->getPropertyValue(propName)
50 >>= bSkipDuplicatesGet);
51
52 aNewValue <<= !bSkipDuplicatesGet;
53 xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
54 CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bSkipDuplicatesSet);
55 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue SkipDuplicates", !bSkipDuplicatesGet,
56 bSkipDuplicatesSet);
57
58 propName = "UseRegularExpressions";
59 bool bUseRegularExpressionsGet = false;
60 bool bUseRegularExpressionsSet = false;
61 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue UseRegularExpressions",
62 xSheetFilterDescriptor->getPropertyValue(propName)
63 >>= bUseRegularExpressionsGet);
64
65 aNewValue <<= !bUseRegularExpressionsGet;
66 xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
67 CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName)
68 >>= bUseRegularExpressionsSet);
69 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue UseRegularExpressions",
70 !bUseRegularExpressionsGet, bUseRegularExpressionsSet);
71
72 propName = "SaveOutputPosition";
73 bool bSaveOutputPositionGet = false;
74 bool bSaveOutputPositionSet = false;
75 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SaveOutputPosition",
76 xSheetFilterDescriptor->getPropertyValue(propName)
77 >>= bSaveOutputPositionGet);
78
79 aNewValue <<= !bSaveOutputPositionGet;
80 xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
81 CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bSaveOutputPositionSet);
82 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue SaveOutputPosition",
83 !bSaveOutputPositionGet, bSaveOutputPositionSet);
84
85 propName = "Orientation";
86 table::TableOrientation aOrientationGet;
87 table::TableOrientation aOrientationSet;
88 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Orientation",
89 xSheetFilterDescriptor->getPropertyValue(propName) >>= aOrientationGet);
90
91 aNewValue <<= table::TableOrientation_COLUMNS;
92 xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
93 CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= aOrientationSet);
94 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Orientation",
95 table::TableOrientation_COLUMNS, aOrientationSet);
96
97 propName = "ContainsHeader";
98 bool bContainsHeaderGet = false;
99 bool bContainsHeaderSet = false;
100 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ContainsHeader",
101 xSheetFilterDescriptor->getPropertyValue(propName)
102 >>= bContainsHeaderGet);
103
104 aNewValue <<= !bContainsHeaderGet;
105 xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
106 CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bContainsHeaderSet);
107 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ContainsHeader", !bContainsHeaderGet,
108 bContainsHeaderSet);
109
110 propName = "CopyOutputData";
111 bool bCopyOutputDataGet = false;
112 bool bCopyOutputDataSet = false;
113 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue CopyOutputData",
114 xSheetFilterDescriptor->getPropertyValue(propName)
115 >>= bCopyOutputDataGet);
116
117 aNewValue <<= !bCopyOutputDataGet;
118 xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
119 CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bCopyOutputDataSet);
120 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue CopyOutputData", !bCopyOutputDataGet,
121 bCopyOutputDataSet);
122
123 propName = "OutputPosition";
124 table::CellAddress aCellAddressGet;
125 table::CellAddress aCellAddressSet;
126 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue OutputPosition",
127 xSheetFilterDescriptor->getPropertyValue(propName) >>= aCellAddressGet);
128
129 aCellAddressGet = table::CellAddress(0, 42, 42);
130 aNewValue <<= aCellAddressGet;
131 xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
132 CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= aCellAddressSet);
133 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue OutputPosition", aCellAddressGet,
134 aCellAddressSet);
135
136 propName = "MaxFieldCount";
137 sal_Int32 nMaxFieldCountGet = 0;
138 sal_Int32 nMaxFieldCountSet = 0;
139 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue MaxFieldCount",
140 xSheetFilterDescriptor->getPropertyValue(propName)
141 >>= nMaxFieldCountGet);
142
143 aNewValue <<= nMaxFieldCountGet + 42;
144 xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
145 CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= nMaxFieldCountSet);
146 CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue MaxFieldCount", nMaxFieldCountGet,
147 nMaxFieldCountSet);
148}
149}
150
151/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > init()=0