summaryrefslogtreecommitdiffstats
path: root/test/source/sheet/spreadsheetdocumentsettings.cxx
blob: a1eec4d0de28dc6bd9c57a9de8fc350acd54e451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <test/unoapi_property_testers.hxx>
#include <test/sheet/spreadsheetdocumentsettings.hxx>

#include <com/sun/star/awt/XDevice.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
#include <com/sun/star/util/Date.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>

#include <cppunit/TestAssert.h>

using namespace com::sun::star;
using namespace com::sun::star::uno;

namespace apitest
{
void SpreadsheetDocumentSettings::testSpreadsheetDocumentSettingsProperties()
{
    uno::Reference<beans::XPropertySet> xSpreadsheetDocumentSettings(init(), UNO_QUERY_THROW);
    OUString propName;
    uno::Any aNewValue;

    propName = "IsIterationEnabled";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "IterationCount";
    testLongProperty(xSpreadsheetDocumentSettings, propName);

    propName = "IterationEpsilon";
    testDoubleProperty(xSpreadsheetDocumentSettings, propName);

    propName = "StandardDecimals";
    testShortProperty(xSpreadsheetDocumentSettings, propName);

    propName = "NullDate";
    util::Date aNullDateGet;
    util::Date aNullDateSet;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: NullDate",
                           xSpreadsheetDocumentSettings->getPropertyValue(propName)
                           >>= aNullDateGet);

    aNewValue <<= util::Date(1, 1, 2000);
    xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= aNullDateSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: NullDate", sal_Int16(2000),
                                 aNullDateSet.Year);

    propName = "DefaultTabStop";
    testShortProperty(xSpreadsheetDocumentSettings, propName);

    propName = "IgnoreCase";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "CalcAsShown";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "MatchWholeCell";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "SpellOnline";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "LookUpLabels";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "RegularExpressions";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "ForbiddenCharacters";
    uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersGet;
    uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersSet;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ForbiddenCharacters",
                           xSpreadsheetDocumentSettings->getPropertyValue(propName)
                           >>= xForbiddenCharactersGet);

    lang::Locale aForbiddenCharactersLocale;
    aForbiddenCharactersLocale.Language = "ru";
    aForbiddenCharactersLocale.Country = "RU";

    uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersNew;
    aNewValue <<= xForbiddenCharactersNew;
    xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
                   >>= xForbiddenCharactersSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE(
        "Able to set PropertyValue: ForbiddenCharacters",
        xForbiddenCharactersGet->hasForbiddenCharacters(aForbiddenCharactersLocale),
        xForbiddenCharactersSet->hasForbiddenCharacters(aForbiddenCharactersLocale));

    propName = "HasDrawPages";
    testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);

    propName = "CharLocale";
    lang::Locale aCharLocaleGet;
    lang::Locale aCharLocaleSet;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocale",
                           xSpreadsheetDocumentSettings->getPropertyValue(propName)
                           >>= aCharLocaleGet);

    lang::Locale aCharLocaleNew;
    aCharLocaleNew.Language = "en";
    aCharLocaleNew.Country = "CA";
    aNewValue <<= aCharLocaleNew;
    xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= aCharLocaleSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocale", aCharLocaleNew.Country,
                                 aCharLocaleSet.Country);

    propName = "CharLocaleAsian";
    lang::Locale aCharLocaleAsianGet;
    lang::Locale aCharLocaleAsianSet;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocaleAsian",
                           xSpreadsheetDocumentSettings->getPropertyValue(propName)
                           >>= aCharLocaleAsianGet);

    lang::Locale aCharLocaleAsianNew;
    aCharLocaleAsianNew.Language = "en";
    aCharLocaleAsianNew.Country = "CA";
    aNewValue <<= aCharLocaleAsianNew;
    xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
                   >>= aCharLocaleAsianSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocaleAsian",
                                 aCharLocaleAsianNew.Country, aCharLocaleAsianSet.Country);

    propName = "CharLocaleComplex";
    lang::Locale aCharLocaleComplexGet;
    lang::Locale aCharLocaleComplexSet;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocaleComplex",
                           xSpreadsheetDocumentSettings->getPropertyValue(propName)
                           >>= aCharLocaleComplexGet);

    lang::Locale aCharLocaleComplexNew;
    aCharLocaleComplexNew.Language = "en";
    aCharLocaleComplexNew.Country = "CA";
    aNewValue <<= aCharLocaleComplexNew;
    xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
                   >>= aCharLocaleComplexSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocaleComplex",
                                 aCharLocaleComplexNew.Country, aCharLocaleComplexSet.Country);

    propName = "IsLoaded";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "IsUndoEnabled";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "IsAdjustHeightEnabled";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "IsExecuteLinkEnabled";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "ReferenceDevice";
    uno::Reference<awt::XDevice> xDeviceGet;
    uno::Reference<awt::XDevice> xDeviceSet;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ReferenceDevice",
                           xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= xDeviceGet);

    uno::Reference<awt::XDevice> xDeviceNew;
    aNewValue <<= xDeviceNew;
    xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= xDeviceSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue: ReferenceDevice",
                                 xDeviceSet->getInfo().Width, xDeviceGet->getInfo().Width);

    propName = "RecordChanges";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);

    propName = "IsRecordChangesProtected";
    testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);

    propName = "Wildcards";
    testBooleanProperty(xSpreadsheetDocumentSettings, propName);
}
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */