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 28 package ifc.awt; 29 30 import lib.MultiPropertyTest; 31 import util.utils; 32 33 import com.sun.star.lang.XMultiServiceFactory; 34 35 /** 36 * Testing <code>com.sun.star.awt.UnoControlFormattedFieldModel</code> 37 * service properties : 38 * <ul> 39 * <li><code> Align</code></li> 40 * <li><code> BackgroundColor</code></li> 41 * <li><code> Border</code></li> 42 * <li><code> DefaultControl</code></li> 43 * <li><code> EffectiveDefault</code></li> 44 * <li><code> EffectiveMax</code></li> 45 * <li><code> EffectiveMin</code></li> 46 * <li><code> EffectiveValue</code></li> 47 * <li><code> Enabled</code></li> 48 * <li><code> FontDescriptor</code></li> 49 * <li><code> FormatKey</code></li> 50 * <li><code> FormatsSupplier</code></li> 51 * <li><code> MaxTextLen</code></li> 52 * <li><code> Printable</code></li> 53 * <li><code> ReadOnly</code></li> 54 * <li><code> Spin</code></li> 55 * <li><code> StrictFormat</code></li> 56 * <li><code> Tabstop</code></li> 57 * <li><code> Text</code></li> 58 * <li><code> TextColor</code></li> 59 * <li><code> HelpText</code></li> 60 * <li><code> HelpURL</code></li> 61 * </ul> <p> 62 * Properties testing is automated by <code>lib.MultiPropertyTest</code>. 63 * @see com.sun.star.awt.UnoControlFormattedFieldModel 64 */ 65 public class _UnoControlFormattedFieldModel extends MultiPropertyTest { 66 67 /** 68 * Redefined method must return a valid service name, that differs from 69 * name exists. 70 * 71 */ 72 protected PropertyTester ControlTester = new PropertyTester() { 73 protected Object getNewValue(String propName, Object oldValue) { 74 if (util.ValueComparer.equalValue(oldValue, 75 "com.sun.star.form.control.FormattedField")) 76 return "com.sun.star.awt.UnoControlFormattedField"; 77 else 78 return "com.sun.star.form.control.FormattedField"; 79 } 80 }; 81 82 /** 83 * This property must contain a valid service name. 84 */ 85 public void _DefaultControl() { 86 log.println("Testing with custom Property tester") ; 87 testProperty("DefaultControl", ControlTester) ; 88 } 89 90 /** 91 * This property can be VOID, and in case if it is so new 92 * value must defined. 93 */ 94 public void _BorderColor() { 95 testProperty("BorderColor", new PropertyTester() { 96 protected Object getNewValue(String p, Object old) { 97 return utils.isVoid(old) ? new Integer(1234) : null ; 98 } 99 }) ; 100 } 101 102 /** 103 * This property can be void, so if old value is <code> null </code> 104 * new value must be specified. 105 */ 106 public void _TextColor() { 107 testProperty("TextColor", new PropertyTester() { 108 protected Object getNewValue(String p, Object v) { 109 return utils.isVoid(v) ? new Integer(123) : 110 super.getNewValue(p,v) ; 111 } 112 }) ; 113 } 114 115 /** 116 * This property can be void, so if old value is <code> null </code> 117 * new value must be specified. 118 */ 119 public void _TextLineColor() { 120 testProperty("TextLineColor", new PropertyTester() { 121 protected Object getNewValue(String p, Object v) { 122 return utils.isVoid(v) ? new Integer(123) : 123 super.getNewValue(p,v) ; 124 } 125 }) ; 126 } 127 128 /** 129 * This property can be void, so if old value is <code> null </code> 130 * new value must be specified. 131 */ 132 public void _BackgroundColor() { 133 testProperty("BackgroundColor", new PropertyTester() { 134 protected Object getNewValue(String p, Object v) { 135 return utils.isVoid(v) ? new Integer(123) : 136 super.getNewValue(p,v) ; 137 } 138 }) ; 139 } 140 141 /** 142 * This property can be void, so if old value is <code> null </code> 143 * new value must be specified. 144 */ 145 public void _EffectiveDefault() { 146 testProperty("EffectiveDefault", new Double(5.8),new Double(2.3)) ; 147 } 148 149 /** 150 * This property can be void, so if old value is <code> null </code> 151 * new value must be specified. 152 */ 153 public void _EffectiveValue() { 154 testProperty("EffectiveValue", new Double(5.8),new Double(2.3)) ; 155 } 156 157 /** 158 * This property can be void, so if old value is <code> null </code> 159 * new value must be specified. 160 */ 161 public void _EffectiveMax() { 162 testProperty("EffectiveMax", new PropertyTester() { 163 protected Object getNewValue(String p, Object v) { 164 return utils.isVoid(v) ? new Double(123.8) : 165 super.getNewValue(p,v) ; 166 } 167 }) ; 168 } 169 170 /** 171 * This property can be void, so if old value is <code> null </code> 172 * new value must be specified. 173 */ 174 public void _FormatsSupplier() { 175 testProperty("FormatsSupplier", new PropertyTester() { 176 protected Object getNewValue(String p, Object v) { 177 Object newValue = null; 178 try { 179 newValue = ((XMultiServiceFactory)tParam.getMSF()).createInstance( 180 "com.sun.star.util.NumberFormatsSupplier"); 181 } catch (com.sun.star.uno.Exception e) {} 182 return newValue; 183 } 184 }) ; 185 } 186 187 /** 188 * This property can be void, so if old value is <code> null </code> 189 * new value must be specified. 190 */ 191 public void _EffectiveMin() { 192 testProperty("EffectiveMin", new PropertyTester() { 193 protected Object getNewValue(String p, Object v) { 194 return utils.isVoid(v) ? new Double(0.1) : 195 super.getNewValue(p,v) ; 196 } 197 }) ; 198 } 199 200 /** 201 * This property can be void, so if old value is <code> null </code> 202 * new value must be specified. 203 */ 204 public void _FormatKey() { 205 testProperty("FormatKey", new PropertyTester() { 206 protected Object getNewValue(String p, Object v) { 207 return utils.isVoid(v) ? new Integer(0) : 208 super.getNewValue(p,v) ; 209 } 210 }) ; 211 } 212 213 /** 214 * This property can be void, so if old value is <code> null </code> 215 * new value must be specified. 216 */ 217 public void _StrictFromat() { 218 testProperty("StrictFromat", new PropertyTester() { 219 protected Object getNewValue(String p, Object v) { 220 return utils.isVoid(v) ? new Boolean(true) : 221 super.getNewValue(p,v) ; 222 } 223 }) ; 224 } 225 226 /** 227 * This property can be void, so if old value is <code> null </code> 228 * new value must be specified. 229 */ 230 public void _Tabstop() { 231 testProperty("Tabstop", new PropertyTester() { 232 protected Object getNewValue(String p, Object v) { 233 return utils.isVoid(v) ? new Boolean(true) : 234 null ; 235 } 236 }) ; 237 } 238 239 /** 240 * This property can be void, so if old value is <code> null </code> 241 * new value must be specified. 242 */ 243 public void _Text() { 244 testProperty("Text", new PropertyTester() { 245 protected Object getNewValue(String p, Object v) { 246 return utils.isVoid(v) ? "UnoControlFormattedFieldModel" : 247 super.getNewValue(p,v) ; 248 } 249 }) ; 250 } 251 } 252