nss: upgrade to release 3.73
[LibreOffice.git] / test / source / sheet / spreadsheetdocumentsettings.cxx
bloba1eec4d0de28dc6bd9c57a9de8fc350acd54e451
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.
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/unoapi_property_testers.hxx>
11 #include <test/sheet/spreadsheetdocumentsettings.hxx>
13 #include <com/sun/star/awt/XDevice.hpp>
14 #include <com/sun/star/beans/XPropertySet.hpp>
15 #include <com/sun/star/lang/Locale.hpp>
16 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
17 #include <com/sun/star/util/Date.hpp>
18 #include <com/sun/star/uno/Any.hxx>
19 #include <com/sun/star/uno/Reference.hxx>
21 #include <cppunit/TestAssert.h>
23 using namespace com::sun::star;
24 using namespace com::sun::star::uno;
26 namespace apitest
28 void SpreadsheetDocumentSettings::testSpreadsheetDocumentSettingsProperties()
30 uno::Reference<beans::XPropertySet> xSpreadsheetDocumentSettings(init(), UNO_QUERY_THROW);
31 OUString propName;
32 uno::Any aNewValue;
34 propName = "IsIterationEnabled";
35 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
37 propName = "IterationCount";
38 testLongProperty(xSpreadsheetDocumentSettings, propName);
40 propName = "IterationEpsilon";
41 testDoubleProperty(xSpreadsheetDocumentSettings, propName);
43 propName = "StandardDecimals";
44 testShortProperty(xSpreadsheetDocumentSettings, propName);
46 propName = "NullDate";
47 util::Date aNullDateGet;
48 util::Date aNullDateSet;
49 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: NullDate",
50 xSpreadsheetDocumentSettings->getPropertyValue(propName)
51 >>= aNullDateGet);
53 aNewValue <<= util::Date(1, 1, 2000);
54 xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
55 CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= aNullDateSet);
56 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: NullDate", sal_Int16(2000),
57 aNullDateSet.Year);
59 propName = "DefaultTabStop";
60 testShortProperty(xSpreadsheetDocumentSettings, propName);
62 propName = "IgnoreCase";
63 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
65 propName = "CalcAsShown";
66 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
68 propName = "MatchWholeCell";
69 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
71 propName = "SpellOnline";
72 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
74 propName = "LookUpLabels";
75 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
77 propName = "RegularExpressions";
78 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
80 propName = "ForbiddenCharacters";
81 uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersGet;
82 uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersSet;
83 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ForbiddenCharacters",
84 xSpreadsheetDocumentSettings->getPropertyValue(propName)
85 >>= xForbiddenCharactersGet);
87 lang::Locale aForbiddenCharactersLocale;
88 aForbiddenCharactersLocale.Language = "ru";
89 aForbiddenCharactersLocale.Country = "RU";
91 uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersNew;
92 aNewValue <<= xForbiddenCharactersNew;
93 xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
94 CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
95 >>= xForbiddenCharactersSet);
96 CPPUNIT_ASSERT_EQUAL_MESSAGE(
97 "Able to set PropertyValue: ForbiddenCharacters",
98 xForbiddenCharactersGet->hasForbiddenCharacters(aForbiddenCharactersLocale),
99 xForbiddenCharactersSet->hasForbiddenCharacters(aForbiddenCharactersLocale));
101 propName = "HasDrawPages";
102 testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);
104 propName = "CharLocale";
105 lang::Locale aCharLocaleGet;
106 lang::Locale aCharLocaleSet;
107 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocale",
108 xSpreadsheetDocumentSettings->getPropertyValue(propName)
109 >>= aCharLocaleGet);
111 lang::Locale aCharLocaleNew;
112 aCharLocaleNew.Language = "en";
113 aCharLocaleNew.Country = "CA";
114 aNewValue <<= aCharLocaleNew;
115 xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
116 CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= aCharLocaleSet);
117 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocale", aCharLocaleNew.Country,
118 aCharLocaleSet.Country);
120 propName = "CharLocaleAsian";
121 lang::Locale aCharLocaleAsianGet;
122 lang::Locale aCharLocaleAsianSet;
123 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocaleAsian",
124 xSpreadsheetDocumentSettings->getPropertyValue(propName)
125 >>= aCharLocaleAsianGet);
127 lang::Locale aCharLocaleAsianNew;
128 aCharLocaleAsianNew.Language = "en";
129 aCharLocaleAsianNew.Country = "CA";
130 aNewValue <<= aCharLocaleAsianNew;
131 xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
132 CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
133 >>= aCharLocaleAsianSet);
134 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocaleAsian",
135 aCharLocaleAsianNew.Country, aCharLocaleAsianSet.Country);
137 propName = "CharLocaleComplex";
138 lang::Locale aCharLocaleComplexGet;
139 lang::Locale aCharLocaleComplexSet;
140 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocaleComplex",
141 xSpreadsheetDocumentSettings->getPropertyValue(propName)
142 >>= aCharLocaleComplexGet);
144 lang::Locale aCharLocaleComplexNew;
145 aCharLocaleComplexNew.Language = "en";
146 aCharLocaleComplexNew.Country = "CA";
147 aNewValue <<= aCharLocaleComplexNew;
148 xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
149 CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
150 >>= aCharLocaleComplexSet);
151 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocaleComplex",
152 aCharLocaleComplexNew.Country, aCharLocaleComplexSet.Country);
154 propName = "IsLoaded";
155 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
157 propName = "IsUndoEnabled";
158 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
160 propName = "IsAdjustHeightEnabled";
161 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
163 propName = "IsExecuteLinkEnabled";
164 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
166 propName = "ReferenceDevice";
167 uno::Reference<awt::XDevice> xDeviceGet;
168 uno::Reference<awt::XDevice> xDeviceSet;
169 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ReferenceDevice",
170 xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= xDeviceGet);
172 uno::Reference<awt::XDevice> xDeviceNew;
173 aNewValue <<= xDeviceNew;
174 xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
175 CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= xDeviceSet);
176 CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue: ReferenceDevice",
177 xDeviceSet->getInfo().Width, xDeviceGet->getInfo().Width);
179 propName = "RecordChanges";
180 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
182 propName = "IsRecordChangesProtected";
183 testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);
185 propName = "Wildcards";
186 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */