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.text; 29 30 import com.sun.star.beans.PropertyValue; 31 import java.util.Enumeration; 32 import java.util.Hashtable; 33 import lib.StatusException; 34 import lib.TestParameters; 35 import share.LogWriter; 36 37 38 /** 39 * Testing <code>com.sun.star.text.NumberingLevel</code><p> 40 * This service is currently konwn as property value of 41 * com.sun.star.text.ParagraphProperties.NumberingRules 42 * This test checks only for completnes of implemented properties. 43 * service properties : 44 * <ul> 45 * <li><code> Adjust</code></li> 46 * <li><code> ParentNumbering</code></li> 47 * <li><code> Prefix</code></li> 48 * <li><code> Suffix</code></li> 49 * <li><code> CharStyleName</code></li> 50 * <li><code> BulletId</code></li> 51 * <li><code> BulletChar</code></li> 52 * <li><code> BulletFontName</code></li> 53 * <li><code> BulletFont</code></li> 54 * <li><code> GraphicURL</code></li> 55 * <li><code> GraphicBitmap</code></li> 56 * <li><code> GraphicSize</code></li> 57 * <li><code> VertOrient</code></li> 58 * <li><code> StartWith</code></li> 59 * <li><code> LeftMargin</code></li> 60 * <li><code> SymbolTextDistance</code></li> 61 * <li><code> FirstLineOffset</code></li> 62 * <li><code> NumberingType</code></li> 63 * <li><code> HeadingStyleName</code></li> 64 * <li><code> BulletColor</code></li> 65 * <li><code> BulletRelSize</code></li> 66 * </ul> <p> 67 * 68 * @see com.sun.star.text.NumberingLevel 69 * @see com.sun.star.test.ParagraphProperties 70 * @see ifc.text._ParagraphProperties 71 */ 72 public class _NumberingLevel { 73 74 private static TestParameters tParam = null; 75 private static Hashtable NumberingLevel = new Hashtable(); 76 private static PropertyValue[] PropertyArray = null; 77 private static LogWriter log = null; 78 79 80 /** 81 * returns an instance of _NumberingLevel 82 * @param log the log writer 83 * @param tParam the test parameters 84 * @param propertyValues a PropertyValue[] which should contain all properties of com.sun.star.text.NumberingLevel 85 */ 86 public _NumberingLevel(LogWriter log, TestParameters tParam, PropertyValue[] propertyValues){ 87 88 this.tParam = tParam; 89 this.PropertyArray = propertyValues; 90 91 this.log = log; 92 93 //key = PropertyName, value = Ooptional 94 NumberingLevel.put("Adjust", new Boolean(false)); 95 NumberingLevel.put("ParentNumbering", new Boolean(true)); 96 NumberingLevel.put("Prefix", new Boolean(false)); 97 NumberingLevel.put("Suffix", new Boolean(false)); 98 NumberingLevel.put("CharStyleName", new Boolean(true)); 99 NumberingLevel.put("BulletId", new Boolean(true)); 100 NumberingLevel.put("BulletChar", new Boolean(false)); 101 NumberingLevel.put("BulletFontName", new Boolean(false)); 102 NumberingLevel.put("BulletFont", new Boolean(true)); 103 NumberingLevel.put("GraphicURL", new Boolean(false)); 104 NumberingLevel.put("GraphicBitmap", new Boolean(true)); 105 NumberingLevel.put("GraphicSize", new Boolean(true)); 106 NumberingLevel.put("VertOrient", new Boolean(true)); 107 NumberingLevel.put("StartWith", new Boolean(true)); 108 NumberingLevel.put("LeftMargin", new Boolean(false)); 109 NumberingLevel.put("SymbolTextDistance", new Boolean(true)); 110 NumberingLevel.put("FirstLineOffset", new Boolean(false)); 111 NumberingLevel.put("NumberingType", new Boolean(false)); 112 NumberingLevel.put("HeadingStyleName", new Boolean(false)); 113 NumberingLevel.put("BulletColor", new Boolean(true)); 114 NumberingLevel.put("BulletRelSize", new Boolean(true)); 115 116 } 117 118 /** 119 * This methods checks the PropertyValue for completnes. If one or more properties 120 * are missing the return value is FALSE, else TRUE 121 * @return returns TRUE if PropertyValue[] is complete, else FALSE 122 */ 123 public boolean testPropertieArray(){ 124 125 boolean status = true; 126 try{ 127 128 // iterate over the given property array and remove it from the must list 129 for (int i = 0; i < PropertyArray.length; i++){ 130 String propertyName=PropertyArray[i].Name; 131 132 if ( NumberingLevel.containsKey(propertyName) ) { 133 NumberingLevel.remove(propertyName); 134 } else { 135 status = false; 136 if ( status ) { 137 log.println("FAILED: com.sun.star.text.NumberingLevel -> " + 138 "found not described property:"); 139 } 140 141 status = false; 142 log.println("-> '" + propertyName + "'"); 143 } 144 145 } 146 147 // get rest of properties and check if they are optional 148 if (! NumberingLevel.isEmpty()){ 149 for (Enumeration e = NumberingLevel.keys() ; e.hasMoreElements() ;) { 150 String property = (String) e.nextElement(); 151 152 // if some elements are not optional -> failed 153 if ( ! ((Boolean)NumberingLevel.get(property)).booleanValue() ){ 154 155 if ( status ) { 156 log.println("FAILED: com.sun.star.text.NumberingLevel -> " + 157 "could not find not optional property:"); 158 } 159 160 status = false; 161 log.println("-> '" + property + "'"); 162 } 163 } 164 } 165 166 }catch( Exception e ){ 167 throw new StatusException("ERROR: could not test all properties of com.sun.star.text.NumberingLevel",e); 168 } 169 170 return status; 171 } 172 173 174 } // finish class _NumberingLevel 175