1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <test/sheet/globalsheetsettings.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/uno/Any.hxx>
14 #include <com/sun/star/uno/Reference.hxx>
16 #include <cppunit/TestAssert.h>
18 using namespace com::sun::star
;
19 using namespace com::sun::star::uno
;
23 void GlobalSheetSettings::testGlobalSheetSettingsProperties()
25 uno::Reference
<beans::XPropertySet
> xGlobalSheetSettings(init(), UNO_QUERY_THROW
);
29 propName
= "MoveSelection";
30 bool aMoveSelection
= false;
31 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aMoveSelection
);
32 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue MoveSelection", aMoveSelection
);
35 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
36 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aMoveSelection
);
37 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue MoveSelection", !aMoveSelection
);
39 propName
= "MoveDirection";
40 sal_Int16 aMoveDirection
= 42;
41 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aMoveDirection
);
42 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue MoveDirection", sal_Int16(0),
45 aNewValue
<<= sal_Int16(1);
46 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
47 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aMoveDirection
);
48 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue MoveDirection", sal_Int16(1),
51 propName
= "EnterEdit";
52 bool aEnterEdit
= true;
53 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aEnterEdit
);
54 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnterEdit", !aEnterEdit
);
57 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
58 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aEnterEdit
);
59 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnterEdit", aEnterEdit
);
61 propName
= "ExtendFormat";
62 bool aExtendFormat
= true;
63 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aExtendFormat
);
64 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ExtendFormat", !aExtendFormat
);
67 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
68 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aExtendFormat
);
69 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ExtendFormat", aExtendFormat
);
71 propName
= "RangeFinder";
72 bool aRangeFinder
= false;
73 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aRangeFinder
);
74 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue RangeFinder", aRangeFinder
);
77 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
78 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aRangeFinder
);
79 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue RangeFinder", !aRangeFinder
);
81 propName
= "ExpandReferences";
82 bool aExpandReferences
= true;
83 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aExpandReferences
);
84 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ExpandReferences", !aExpandReferences
);
87 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
88 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aExpandReferences
);
89 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ExpandReferences", aExpandReferences
);
91 propName
= "MarkHeader";
92 bool aMarkHeader
= false;
93 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aMarkHeader
);
94 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue MarkHeader", aMarkHeader
);
97 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
98 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aMarkHeader
);
99 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue MarkHeader", !aMarkHeader
);
101 propName
= "UseTabCol";
102 bool aUseTabCol
= true;
103 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aUseTabCol
);
104 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue UseTabCol", !aUseTabCol
);
107 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
108 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aUseTabCol
);
109 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue UseTabCol", aUseTabCol
);
112 sal_Int16 aMetric
= 42;
113 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aMetric
);
114 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue Metric", sal_Int16(8), aMetric
);
116 aNewValue
<<= sal_Int16(1);
117 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
118 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aMetric
);
119 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Metric", sal_Int16(1), aMetric
);
122 sal_Int16 aScale
= 42;
123 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aScale
);
124 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue Scale", sal_Int16(100), aScale
);
126 aNewValue
<<= sal_Int16(-1);
127 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
128 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aScale
);
129 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Scale", sal_Int16(-1), aScale
);
131 propName
= "DoAutoComplete";
132 bool aDoAutoComplete
= false;
133 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aDoAutoComplete
);
134 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue DoAutoComplete", aDoAutoComplete
);
137 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
138 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aDoAutoComplete
);
139 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue DoAutoComplete", !aDoAutoComplete
);
141 propName
= "StatusBarFunction";
142 sal_Int16 aStatusBarFunction
= 42;
143 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aStatusBarFunction
);
144 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue StatusBarFunction", sal_Int16(514),
147 aNewValue
<<= sal_Int16(1);
148 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
149 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aStatusBarFunction
);
150 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue StatusBarFunction", sal_Int16(1),
153 propName
= "UserLists";
154 uno::Sequence
<OUString
> aSeq(6);
155 aSeq
[0] = "Sun,Mon,Tue,Wed,Thu,Fri,Sat";
156 aSeq
[1] = "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday";
157 aSeq
[2] = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec";
159 = "January,February,March,April,May,June,July,August,September,October,November,December";
160 aSeq
[4] = "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Shabbat";
161 aSeq
[5] = "Nissan,Iyar,Sivan,Tammuz,Av,Elul,Tishri,Heshvan,Kislev,Tevet,Shevat,Adar,Adar B";
163 uno::Sequence
<OUString
> aUserLists
;
164 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aUserLists
);
165 for (auto i
= 0; i
< aUserLists
.getLength(); i
++)
167 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue UserLists[" + std::to_string(i
)
169 aSeq
[i
], aUserLists
[i
]);
172 aNewValue
<<= uno::Sequence
<OUString
>();
173 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
174 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aUserLists
);
175 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue UserLists", !aUserLists
.hasElements());
177 propName
= "LinkUpdateMode";
178 sal_Int16 aLinkUpdateMode
= 42;
179 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aLinkUpdateMode
);
180 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue LinkUpdateMode", sal_Int16(2),
183 aNewValue
<<= sal_Int16(1);
184 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
185 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aLinkUpdateMode
);
186 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue LinkUpdateMode", sal_Int16(1),
189 propName
= "PrintAllSheets";
190 bool aPrintAllSheets
= true;
191 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aPrintAllSheets
);
192 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue PrintAllSheets", !aPrintAllSheets
);
195 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
196 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aPrintAllSheets
);
197 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue PrintAllSheets", aPrintAllSheets
);
199 propName
= "PrintEmptyPages";
200 bool aPrintEmptyPages
= true;
201 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aPrintEmptyPages
);
202 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue PrintEmptyPages", !aPrintEmptyPages
);
205 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
206 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aPrintEmptyPages
);
207 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue PrintEmptyPages", aPrintEmptyPages
);
209 propName
= "UsePrinterMetrics";
210 bool aUsePrinterMetrics
= true;
211 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aUsePrinterMetrics
);
212 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue UsePrinterMetrics", !aUsePrinterMetrics
);
215 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
216 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aUsePrinterMetrics
);
217 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue UsePrinterMetrics", aUsePrinterMetrics
);
219 propName
= "ReplaceCellsWarning";
220 bool aReplaceCellsWarning
= false;
221 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aReplaceCellsWarning
);
222 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ReplaceCellsWarning", aReplaceCellsWarning
);
225 xGlobalSheetSettings
->setPropertyValue(propName
, aNewValue
);
226 CPPUNIT_ASSERT(xGlobalSheetSettings
->getPropertyValue(propName
) >>= aReplaceCellsWarning
);
227 CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ReplaceCellsWarning",
228 !aReplaceCellsWarning
);
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */