Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _SpreadsheetDocumentSettings.java
blobe3e7ffc5da6f65ed86d77f186f8b33b5348142e6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _SpreadsheetDocumentSettings.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package ifc.sheet;
32 import lib.MultiPropertyTest;
34 import com.sun.star.i18n.ForbiddenCharacters;
35 import com.sun.star.i18n.XForbiddenCharacters;
36 import com.sun.star.lang.Locale;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.util.Date;
41 /**
42 * Testing <code>com.sun.star.sheet.SpreadsheetDocumentSettings</code>
43 * service properties :
44 * <ul>
45 * <li><code> IsIterationEnabled</code></li>
46 * <li><code> IterationCount</code></li>
47 * <li><code> IterationEpsilon</code></li>
48 * <li><code> StandardDecimals</code></li>
49 * <li><code> NullDate</code></li>
50 * <li><code> DefaultTabStop</code></li>
51 * <li><code> IgnoreCase</code></li>
52 * <li><code> CalcAsShown</code></li>
53 * <li><code> MatchWholeCell</code></li>
54 * <li><code> SpellOnline</code></li>
55 * <li><code> LookUpLabels</code></li>
56 * <li><code> RegularExpressions</code></li>
57 * <li><code> ForbiddenCharacters</code></li>
58 * <li><code> HasDrawPages</code></li>
59 * </ul> <p>
60 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
61 * @see com.sun.star.sheet.SpreadsheetDocumentSettings
63 public class _SpreadsheetDocumentSettings extends MultiPropertyTest {
64 /**
65 *This class is destined to custom test of property <code>NullDate</code>.
67 protected PropertyTester DateTester = new PropertyTester() {
68 protected Object getNewValue(String propName, Object oldValue) {
69 Date date = (Date) oldValue;
70 Date newDate = new Date((short) (date.Day - 1), date.Month,
71 date.Year);
73 return newDate;
77 /**
78 *This class is destined to custom test of property <code>ForbiddenCharacters</code>.
80 protected PropertyTester ChrTester = new PropertyTester() {
81 protected Object getNewValue(String propName, Object oldValue) {
82 return new ForbiddenChrTest();
85 protected boolean compare(Object obj1, Object obj2) {
86 Locale loc = new Locale("ru", "RU", "");
87 XForbiddenCharacters fc1 = (XForbiddenCharacters) UnoRuntime.queryInterface(
88 XForbiddenCharacters.class,
89 obj1);
90 XForbiddenCharacters fc2 = (XForbiddenCharacters) UnoRuntime.queryInterface(
91 XForbiddenCharacters.class,
92 obj2);
93 boolean has1 = fc1.hasForbiddenCharacters(loc);
94 boolean has2 = fc2.hasForbiddenCharacters(loc);
96 return has1 == has2;
101 * Test property <code>NullDate</code> using custom <code>PropertyTest</code>.
103 public void _NullDate() {
104 testProperty("NullDate", DateTester);
108 * Test property <code>ForbiddenCharacters</code> using custom <code>PropertyTest</code>.
110 public void _ForbiddenCharacters() {
111 testProperty("ForbiddenCharacters", ChrTester);
115 * Class implements interface <code>XForbiddenCharacters</code>.
116 * It's destined to custom test of property <code>ForbiddenCharacters</code>.
117 * Feature of the class that it supports forbidden characters
118 * for russian locale.
119 * @see com.sun.star.i18n.XForbiddenCharacters
121 protected class ForbiddenChrTest implements XForbiddenCharacters {
122 protected Locale locale = new Locale("ru", "RU", "");
123 protected ForbiddenCharacters chrs = new ForbiddenCharacters("q", "w");
125 public ForbiddenCharacters getForbiddenCharacters(Locale rLocale)
126 throws com.sun.star.container.NoSuchElementException {
127 if (rLocale.Country.equals(locale.Country) &&
128 rLocale.Language.equals(locale.Language) &&
129 rLocale.Variant.equals(locale.Variant)) {
130 return chrs;
133 throw new com.sun.star.container.NoSuchElementException();
136 public void setForbiddenCharacters(Locale rLocale,
137 ForbiddenCharacters rForbiddenCharacters) {
140 public void removeForbiddenCharacters(Locale rLocale) {
143 public boolean hasForbiddenCharacters(Locale rLocale) {
144 if (rLocale.Country.equals(locale.Country) &&
145 rLocale.Language.equals(locale.Language) &&
146 rLocale.Variant.equals(locale.Variant)) {
147 return true;
150 return false;