1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 package ifc.sheet; 28 29 import lib.MultiPropertyTest; 30 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; 36 37 38 /** 39 * Testing <code>com.sun.star.sheet.SpreadsheetDocumentSettings</code> 40 * service properties : 41 * <ul> 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> 56 * </ul> <p> 57 * Properties testing is automated by <code>lib.MultiPropertyTest</code>. 58 * @see com.sun.star.sheet.SpreadsheetDocumentSettings 59 */ 60 public class _SpreadsheetDocumentSettings extends MultiPropertyTest { 61 /** 62 *This class is destined to custom test of property <code>NullDate</code>. 63 */ 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, 68 date.Year); 69 70 return newDate; 71 } 72 }; 73 74 /** 75 *This class is destined to custom test of property <code>ForbiddenCharacters</code>. 76 */ 77 protected PropertyTester ChrTester = new PropertyTester() { 78 protected Object getNewValue(String propName, Object oldValue) { 79 return new ForbiddenChrTest(); 80 } 81 82 protected boolean compare(Object obj1, Object obj2) { 83 Locale loc = new Locale("ru", "RU", ""); 84 XForbiddenCharacters fc1 = (XForbiddenCharacters) UnoRuntime.queryInterface( 85 XForbiddenCharacters.class, 86 obj1); 87 XForbiddenCharacters fc2 = (XForbiddenCharacters) UnoRuntime.queryInterface( 88 XForbiddenCharacters.class, 89 obj2); 90 boolean has1 = fc1.hasForbiddenCharacters(loc); 91 boolean has2 = fc2.hasForbiddenCharacters(loc); 92 93 return has1 == has2; 94 } 95 }; 96 97 /** 98 * Test property <code>NullDate</code> using custom <code>PropertyTest</code>. 99 */ 100 public void _NullDate() { 101 testProperty("NullDate", DateTester); 102 } 103 104 /** 105 * Test property <code>ForbiddenCharacters</code> using custom <code>PropertyTest</code>. 106 */ 107 public void _ForbiddenCharacters() { 108 testProperty("ForbiddenCharacters", ChrTester); 109 } 110 111 /** 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 117 */ 118 protected class ForbiddenChrTest implements XForbiddenCharacters { 119 protected Locale locale = new Locale("ru", "RU", ""); 120 protected ForbiddenCharacters chrs = new ForbiddenCharacters("q", "w"); 121 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)) { 127 return chrs; 128 } 129 130 throw new com.sun.star.container.NoSuchElementException(); 131 } 132 133 public void setForbiddenCharacters(Locale rLocale, 134 ForbiddenCharacters rForbiddenCharacters) { 135 } 136 137 public void removeForbiddenCharacters(Locale rLocale) { 138 } 139 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)) { 144 return true; 145 } 146 147 return false; 148 } 149 } 150 }