1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 import lib
.MultiPropertyTest
;
31 import com
.sun
.star
.i18n
.ForbiddenCharacters
;
32 import com
.sun
.star
.i18n
.XForbiddenCharacters
;
33 import com
.sun
.star
.lang
.Locale
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
35 import com
.sun
.star
.util
.Date
;
39 * Testing <code>com.sun.star.sheet.SpreadsheetDocumentSettings</code>
40 * service properties :
42 * <li><code> IsIterationEnabled</code></li>
43 * <li><code> IterationCount</code></li>
44 * <li><code> IterationEpsilon</code></li>
45 * <li><code> StandardDecimals</code></li>
46 * <li><code> NullDate</code></li>
47 * <li><code> DefaultTabStop</code></li>
48 * <li><code> IgnoreCase</code></li>
49 * <li><code> CalcAsShown</code></li>
50 * <li><code> MatchWholeCell</code></li>
51 * <li><code> SpellOnline</code></li>
52 * <li><code> LookUpLabels</code></li>
53 * <li><code> RegularExpressions</code></li>
54 * <li><code> ForbiddenCharacters</code></li>
55 * <li><code> HasDrawPages</code></li>
57 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
58 * @see com.sun.star.sheet.SpreadsheetDocumentSettings
60 public class _SpreadsheetDocumentSettings
extends MultiPropertyTest
{
62 *This class is destined to custom test of property <code>NullDate</code>.
64 protected PropertyTester DateTester
= new PropertyTester() {
65 protected Object
getNewValue(String propName
, Object oldValue
) {
66 Date date
= (Date
) oldValue
;
67 Date newDate
= new Date((short) (date
.Day
- 1), date
.Month
,
75 *This class is destined to custom test of property <code>ForbiddenCharacters</code>.
77 protected PropertyTester ChrTester
= new PropertyTester() {
78 protected Object
getNewValue(String propName
, Object oldValue
) {
79 return new ForbiddenChrTest();
82 protected boolean compare(Object obj1
, Object obj2
) {
83 Locale loc
= new Locale("ru", "RU", "");
84 XForbiddenCharacters fc1
= (XForbiddenCharacters
) UnoRuntime
.queryInterface(
85 XForbiddenCharacters
.class,
87 XForbiddenCharacters fc2
= (XForbiddenCharacters
) UnoRuntime
.queryInterface(
88 XForbiddenCharacters
.class,
90 boolean has1
= fc1
.hasForbiddenCharacters(loc
);
91 boolean has2
= fc2
.hasForbiddenCharacters(loc
);
98 * Test property <code>NullDate</code> using custom <code>PropertyTest</code>.
100 public void _NullDate() {
101 testProperty("NullDate", DateTester
);
105 * Test property <code>ForbiddenCharacters</code> using custom <code>PropertyTest</code>.
107 public void _ForbiddenCharacters() {
108 testProperty("ForbiddenCharacters", ChrTester
);
112 * Class implements interface <code>XForbiddenCharacters</code>.
113 * It's destined to custom test of property <code>ForbiddenCharacters</code>.
114 * Feature of the class that it supports forbidden characters
115 * for russian locale.
116 * @see com.sun.star.i18n.XForbiddenCharacters
118 protected class ForbiddenChrTest
implements XForbiddenCharacters
{
119 protected Locale locale
= new Locale("ru", "RU", "");
120 protected ForbiddenCharacters chrs
= new ForbiddenCharacters("q", "w");
122 public ForbiddenCharacters
getForbiddenCharacters(Locale rLocale
)
123 throws com
.sun
.star
.container
.NoSuchElementException
{
124 if (rLocale
.Country
.equals(locale
.Country
) &&
125 rLocale
.Language
.equals(locale
.Language
) &&
126 rLocale
.Variant
.equals(locale
.Variant
)) {
130 throw new com
.sun
.star
.container
.NoSuchElementException();
133 public void setForbiddenCharacters(Locale rLocale
,
134 ForbiddenCharacters rForbiddenCharacters
) {
137 public void removeForbiddenCharacters(Locale rLocale
) {
140 public boolean hasForbiddenCharacters(Locale rLocale
) {
141 if (rLocale
.Country
.equals(locale
.Country
) &&
142 rLocale
.Language
.equals(locale
.Language
) &&
143 rLocale
.Variant
.equals(locale
.Variant
)) {