2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import lib
.MultiPropertyTest
;
22 import com
.sun
.star
.i18n
.ForbiddenCharacters
;
23 import com
.sun
.star
.i18n
.XForbiddenCharacters
;
24 import com
.sun
.star
.lang
.Locale
;
25 import com
.sun
.star
.uno
.UnoRuntime
;
26 import com
.sun
.star
.util
.Date
;
30 * Testing <code>com.sun.star.sheet.SpreadsheetDocumentSettings</code>
31 * service properties :
33 * <li><code> IsIterationEnabled</code></li>
34 * <li><code> IterationCount</code></li>
35 * <li><code> IterationEpsilon</code></li>
36 * <li><code> StandardDecimals</code></li>
37 * <li><code> NullDate</code></li>
38 * <li><code> DefaultTabStop</code></li>
39 * <li><code> IgnoreCase</code></li>
40 * <li><code> CalcAsShown</code></li>
41 * <li><code> MatchWholeCell</code></li>
42 * <li><code> SpellOnline</code></li>
43 * <li><code> LookUpLabels</code></li>
44 * <li><code> RegularExpressions</code></li>
45 * <li><code> ForbiddenCharacters</code></li>
46 * <li><code> HasDrawPages</code></li>
48 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
49 * @see com.sun.star.sheet.SpreadsheetDocumentSettings
51 public class _SpreadsheetDocumentSettings
extends MultiPropertyTest
{
53 *This class is destined to custom test of property <code>NullDate</code>.
55 protected PropertyTester DateTester
= new PropertyTester() {
57 protected Object
getNewValue(String propName
, Object oldValue
) {
58 Date date
= (Date
) oldValue
;
59 Date newDate
= new Date((short) (date
.Day
- 1), date
.Month
,
67 *This class is destined to custom test of property <code>ForbiddenCharacters</code>.
69 protected PropertyTester ChrTester
= new PropertyTester() {
71 protected Object
getNewValue(String propName
, Object oldValue
) {
72 return new ForbiddenChrTest();
76 protected boolean compare(Object obj1
, Object obj2
) {
77 Locale loc
= new Locale("ru", "RU", "");
78 XForbiddenCharacters fc1
= UnoRuntime
.queryInterface(
79 XForbiddenCharacters
.class,
81 XForbiddenCharacters fc2
= UnoRuntime
.queryInterface(
82 XForbiddenCharacters
.class,
84 boolean has1
= fc1
.hasForbiddenCharacters(loc
);
85 boolean has2
= fc2
.hasForbiddenCharacters(loc
);
92 * Test property <code>NullDate</code> using custom <code>PropertyTest</code>.
94 public void _NullDate() {
95 testProperty("NullDate", DateTester
);
99 * Test property <code>ForbiddenCharacters</code> using custom <code>PropertyTest</code>.
101 public void _ForbiddenCharacters() {
102 testProperty("ForbiddenCharacters", ChrTester
);
106 * Class implements interface <code>XForbiddenCharacters</code>.
107 * It's destined to custom test of property <code>ForbiddenCharacters</code>.
108 * Feature of the class that it supports forbidden characters
109 * for russian locale.
110 * @see com.sun.star.i18n.XForbiddenCharacters
112 protected class ForbiddenChrTest
implements XForbiddenCharacters
{
113 protected Locale locale
= new Locale("ru", "RU", "");
114 protected ForbiddenCharacters chrs
= new ForbiddenCharacters("q", "w");
116 public ForbiddenCharacters
getForbiddenCharacters(Locale rLocale
)
117 throws com
.sun
.star
.container
.NoSuchElementException
{
118 if (rLocale
.Country
.equals(locale
.Country
) &&
119 rLocale
.Language
.equals(locale
.Language
) &&
120 rLocale
.Variant
.equals(locale
.Variant
)) {
124 throw new com
.sun
.star
.container
.NoSuchElementException();
127 public void setForbiddenCharacters(Locale rLocale
,
128 ForbiddenCharacters rForbiddenCharacters
) {
131 public void removeForbiddenCharacters(Locale rLocale
) {
134 public boolean hasForbiddenCharacters(Locale rLocale
) {
135 if (rLocale
.Country
.equals(locale
.Country
) &&
136 rLocale
.Language
.equals(locale
.Language
) &&
137 rLocale
.Variant
.equals(locale
.Variant
)) {