LibreOffice Module test (master) 1
spreadsheetviewsettings.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
11
12#include <com/sun/star/beans/XPropertySet.hpp>
13#include <com/sun/star/util/Color.hpp>
14#include <com/sun/star/uno/Any.hxx>
15#include <com/sun/star/uno/Reference.hxx>
16
17#include <cppunit/TestAssert.h>
18
19using namespace com::sun::star;
20using namespace com::sun::star::uno;
21
22namespace apitest
23{
25{
26 uno::Reference<beans::XPropertySet> xSpreadsheetViewSettings(init(), UNO_QUERY_THROW);
27 OUString propName;
28 uno::Any aNewValue;
29
30 propName = "ShowFormulas";
31 bool aShowFormulas = true;
32 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowFormulas);
33 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowFormulas", !aShowFormulas);
34
35 aNewValue <<= true;
36 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
37 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowFormulas);
38 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowFormulas", aShowFormulas);
39
40 propName = "ShowZeroValues";
41 bool aShowZeroValues = false;
42 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowZeroValues);
43 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowZeroValues", aShowZeroValues);
44
45 aNewValue <<= false;
46 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
47 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowZeroValues);
48 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowZeroValues", !aShowZeroValues);
49
50 propName = "IsValueHighlightingEnabled";
51 bool aIsValueHighlightingEnabled = true;
52 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName)
53 >>= aIsValueHighlightingEnabled);
54 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsValueHighlightingEnabled",
55 !aIsValueHighlightingEnabled);
56
57 aNewValue <<= true;
58 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
59 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName)
60 >>= aIsValueHighlightingEnabled);
61 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsValueHighlightingEnabled",
62 aIsValueHighlightingEnabled);
63
64 propName = "ShowNotes";
65 bool aShowNotes = false;
66 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowNotes);
67 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowNotes", aShowNotes);
68
69 aNewValue <<= false;
70 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
71 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowNotes);
72 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowNotes", !aShowNotes);
73
74 propName = "HasVerticalScrollBar";
75 bool aHasVerticalScrollBar = false;
76 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasVerticalScrollBar);
77 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasVerticalScrollBar",
78 aHasVerticalScrollBar);
79
80 aNewValue <<= false;
81 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
82 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasVerticalScrollBar);
83 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasVerticalScrollBar",
84 !aHasVerticalScrollBar);
85
86 propName = "HasHorizontalScrollBar";
87 bool aHasHorizontalScrollBar = false;
88 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName)
89 >>= aHasHorizontalScrollBar);
90 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasHorizontalScrollBar",
91 aHasHorizontalScrollBar);
92
93 aNewValue <<= false;
94 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
95 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName)
96 >>= aHasHorizontalScrollBar);
97 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasHorizontalScrollBar",
98 !aHasHorizontalScrollBar);
99
100 propName = "HasSheetTabs";
101 bool aHasSheetTabs = false;
102 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasSheetTabs);
103 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasSheetTabs", aHasSheetTabs);
104
105 aNewValue <<= false;
106 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
107 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasSheetTabs);
108 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasSheetTabs", !aHasSheetTabs);
109
110 propName = "IsOutlineSymbolsSet";
111 bool aIsOutlineSymbolsSet = false;
112 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aIsOutlineSymbolsSet);
113 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsOutlineSymbolsSet", aIsOutlineSymbolsSet);
114
115 aNewValue <<= false;
116 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
117 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aIsOutlineSymbolsSet);
118 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsOutlineSymbolsSet",
119 !aIsOutlineSymbolsSet);
120
121 propName = "HasColumnRowHeaders";
122 bool aHasColumnRowHeaders = false;
123 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasColumnRowHeaders);
124 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasColumnRowHeaders", aHasColumnRowHeaders);
125
126 aNewValue <<= false;
127 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
128 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasColumnRowHeaders);
129 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasColumnRowHeaders",
130 !aHasColumnRowHeaders);
131
132 propName = "ShowGrid";
133 bool aShowGrid = false;
134 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowGrid);
135 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowGrid", aShowGrid);
136
137 aNewValue <<= false;
138 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
139 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowGrid);
140 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowGrid", !aShowGrid);
141
142 propName = "GridColor";
143 util::Color aGridColor;
144 xSpreadsheetViewSettings->getPropertyValue(propName) >>= aGridColor;
145 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue GridColor", sal_Int32(12632256),
146 aGridColor);
147
148 aNewValue <<= sal_Int32(42);
149 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
150 xSpreadsheetViewSettings->getPropertyValue(propName) >>= aGridColor;
151 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue GridColor", sal_Int32(42),
152 aGridColor);
153
154 propName = "ShowHelpLines";
155 bool aShowHelpLines = true;
156 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowHelpLines);
157 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowHelpLines", !aShowHelpLines);
158
159 aNewValue <<= true;
160 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
161 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowHelpLines);
162 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowHelpLines", aShowHelpLines);
163
164 propName = "ShowAnchor";
165 bool aShowAnchor = false;
166 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowAnchor);
167 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowAnchor", aShowAnchor);
168
169 aNewValue <<= false;
170 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
171 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowAnchor);
172 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowAnchor", !aShowAnchor);
173
174 propName = "ShowPageBreaks";
175 bool aShowPageBreaks = false;
176 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowPageBreaks);
177 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowPageBreaks", aShowPageBreaks);
178
179 aNewValue <<= false;
180 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
181 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowPageBreaks);
182 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowPageBreaks", !aShowPageBreaks);
183
184 propName = "ShowObjects";
185 sal_Int16 aShowObjects = 42;
186 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowObjects);
187 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue ShowObjects", sal_Int16(0),
188 aShowObjects);
189
190 aNewValue <<= sal_Int16(1);
191 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
192 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowObjects);
193 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ShowObjects", sal_Int16(1),
194 aShowObjects);
195
196 propName = "ShowCharts";
197 sal_Int16 aShowCharts = 42;
198 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowCharts);
199 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue ShowCharts", sal_Int16(0),
200 aShowCharts);
201
202 aNewValue <<= sal_Int16(1);
203 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
204 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowCharts);
205 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ShowCharts", sal_Int16(1),
206 aShowCharts);
207
208 propName = "ShowDrawing";
209 sal_Int16 aShowDrawing = 42;
210 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowDrawing);
211 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue ShowDrawing", sal_Int16(0),
212 aShowDrawing);
213
214 aNewValue <<= sal_Int16(1);
215 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
216 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowDrawing);
217 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ShowDrawing", sal_Int16(1),
218 aShowDrawing);
219
220 propName = "ZoomType";
221 sal_Int16 aZoomType = 42;
222 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aZoomType);
223 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue ZoomType", sal_Int16(3), aZoomType);
224
225 aNewValue <<= sal_Int16(1);
226 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
227 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aZoomType);
228 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ZoomType", sal_Int16(1), aZoomType);
229
230 propName = "ZoomValue";
231 sal_Int16 aZoomValue = 42;
232 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aZoomValue);
233
234 aNewValue <<= sal_Int16(1);
235 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
236 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aZoomValue);
237 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ZoomValue", sal_Int16(1), aZoomValue);
238
239 propName = "FormulaBarHeight";
240 sal_Int16 aFormulaBarHeight;
241 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aFormulaBarHeight);
242
243 aNewValue <<= sal_Int16(15);
244 xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
245 CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aFormulaBarHeight);
246 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue FormulaBarHeight", sal_Int16(15),
247 aFormulaBarHeight);
248}
249}
250
251/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > init()=0