LibreOffice Module test (master) 1
spreadsheetdocumentsettings.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/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>
20
21#include <cppunit/TestAssert.h>
22
23using namespace com::sun::star;
24using namespace com::sun::star::uno;
25
26namespace apitest
27{
29{
30 uno::Reference<beans::XPropertySet> xSpreadsheetDocumentSettings(init(), UNO_QUERY_THROW);
31 OUString propName;
32 uno::Any aNewValue;
33
34 propName = "IsIterationEnabled";
35 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
36
37 propName = "IterationCount";
38 testLongProperty(xSpreadsheetDocumentSettings, propName);
39
40 propName = "IterationEpsilon";
41 testDoubleProperty(xSpreadsheetDocumentSettings, propName);
42
43 propName = "StandardDecimals";
44 testShortProperty(xSpreadsheetDocumentSettings, propName);
45
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);
52
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);
58
59 propName = "DefaultTabStop";
60 testShortProperty(xSpreadsheetDocumentSettings, propName);
61
62 propName = "IgnoreCase";
63 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
64
65 propName = "CalcAsShown";
66 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
67
68 propName = "MatchWholeCell";
69 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
70
71 propName = "SpellOnline";
72 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
73
74 propName = "LookUpLabels";
75 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
76
77 propName = "RegularExpressions";
78 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
79
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);
86
87 lang::Locale aForbiddenCharactersLocale;
88 aForbiddenCharactersLocale.Language = "ru";
89 aForbiddenCharactersLocale.Country = "RU";
90
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));
100
101 propName = "HasDrawPages";
102 testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);
103
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);
110
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);
119
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);
126
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);
136
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);
143
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);
153
154 propName = "IsLoaded";
155 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
156
157 propName = "IsUndoEnabled";
158 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
159
160 propName = "IsAdjustHeightEnabled";
161 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
162
163 propName = "IsExecuteLinkEnabled";
164 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
165
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);
171
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);
178
179 propName = "RecordChanges";
180 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
181
182 propName = "IsRecordChangesProtected";
183 testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);
184
185 propName = "Wildcards";
186 testBooleanProperty(xSpreadsheetDocumentSettings, propName);
187}
188}
189
190/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > init()=0
void testLongProperty(uno::Reference< beans::XPropertySet > const &xPropertySet, const OUString &name, const sal_Int32 &nValue)
void testShortProperty(uno::Reference< beans::XPropertySet > const &xPropertySet, const OUString &name, const sal_Int16 &nValue)
void testBooleanProperty(uno::Reference< beans::XPropertySet > const &xPropertySet, const OUString &name)
void testDoubleProperty(uno::Reference< beans::XPropertySet > const &xPropertySet, const OUString &name, const double &dValue)
void testBooleanReadonlyProperty(uno::Reference< beans::XPropertySet > const &xPropertySet, const OUString &name)