1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package ifc.text; 25 26 import com.sun.star.beans.PropertyValue; 27 import java.util.Enumeration; 28 import java.util.Hashtable; 29 import lib.StatusException; 30 import lib.TestParameters; 31 import share.LogWriter; 32 33 34 /** 35 * Testing <code>com.sun.star.text.NumberingLevel</code><p> 36 * This service is currently konwn as property value of 37 * com.sun.star.text.ParagraphProperties.NumberingRules 38 * This test checks only for completnes of implemented properties. 39 * service properties : 40 * <ul> 41 * <li><code> Adjust</code></li> 42 * <li><code> ParentNumbering</code></li> 43 * <li><code> Prefix</code></li> 44 * <li><code> Suffix</code></li> 45 * <li><code> CharStyleName</code></li> 46 * <li><code> BulletId</code></li> 47 * <li><code> BulletChar</code></li> 48 * <li><code> BulletFontName</code></li> 49 * <li><code> BulletFont</code></li> 50 * <li><code> GraphicURL</code></li> 51 * <li><code> GraphicBitmap</code></li> 52 * <li><code> GraphicSize</code></li> 53 * <li><code> VertOrient</code></li> 54 * <li><code> StartWith</code></li> 55 * <li><code> LeftMargin</code></li> 56 * <li><code> SymbolTextDistance</code></li> 57 * <li><code> FirstLineOffset</code></li> 58 * <li><code> NumberingType</code></li> 59 * <li><code> HeadingStyleName</code></li> 60 * <li><code> BulletColor</code></li> 61 * <li><code> BulletRelSize</code></li> 62 * </ul> <p> 63 * 64 * @see com.sun.star.text.NumberingLevel 65 * @see com.sun.star.test.ParagraphProperties 66 * @see ifc.style._ParagraphProperties 67 */ 68 public class _NumberingLevel { 69 70 private static TestParameters tParam = null; 71 private static Hashtable NumberingLevel = new Hashtable(); 72 private static PropertyValue[] PropertyArray = null; 73 private static LogWriter log = null; 74 75 76 /** 77 * returns an instance of _NumberingLevel 78 * @param log the log writer 79 * @param tParam the test parameters 80 * @param propertyValues a PropertyValue[] which should contain all properties of com.sun.star.text.NumberingLevel 81 */ _NumberingLevel(LogWriter log, TestParameters tParam, PropertyValue[] propertyValues)82 public _NumberingLevel(LogWriter log, TestParameters tParam, PropertyValue[] propertyValues){ 83 84 this.tParam = tParam; 85 this.PropertyArray = propertyValues; 86 87 this.log = log; 88 89 //key = PropertyName, value = Ooptional 90 NumberingLevel.put("Adjust", new Boolean(false)); 91 NumberingLevel.put("ParentNumbering", new Boolean(true)); 92 NumberingLevel.put("Prefix", new Boolean(false)); 93 NumberingLevel.put("Suffix", new Boolean(false)); 94 NumberingLevel.put("CharStyleName", new Boolean(true)); 95 NumberingLevel.put("BulletId", new Boolean(true)); 96 NumberingLevel.put("BulletChar", new Boolean(false)); 97 NumberingLevel.put("BulletFontName", new Boolean(false)); 98 NumberingLevel.put("BulletFont", new Boolean(true)); 99 NumberingLevel.put("GraphicURL", new Boolean(false)); 100 NumberingLevel.put("GraphicBitmap", new Boolean(true)); 101 NumberingLevel.put("GraphicSize", new Boolean(true)); 102 NumberingLevel.put("VertOrient", new Boolean(true)); 103 NumberingLevel.put("StartWith", new Boolean(true)); 104 NumberingLevel.put("LeftMargin", new Boolean(false)); 105 NumberingLevel.put("SymbolTextDistance", new Boolean(true)); 106 NumberingLevel.put("FirstLineOffset", new Boolean(false)); 107 NumberingLevel.put("NumberingType", new Boolean(false)); 108 NumberingLevel.put("HeadingStyleName", new Boolean(false)); 109 NumberingLevel.put("BulletColor", new Boolean(true)); 110 NumberingLevel.put("BulletRelSize", new Boolean(true)); 111 112 } 113 114 /** 115 * This methods checks the PropertyValue for completnes. If one or more properties 116 * are missing the return value is FALSE, else TRUE 117 * @return returns TRUE if PropertyValue[] is complete, else FALSE 118 */ testPropertieArray()119 public boolean testPropertieArray(){ 120 121 boolean status = true; 122 try{ 123 124 // iterate over the given property array and remove it from the must list 125 for (int i = 0; i < PropertyArray.length; i++){ 126 String propertyName=PropertyArray[i].Name; 127 128 if ( NumberingLevel.containsKey(propertyName) ) { 129 NumberingLevel.remove(propertyName); 130 } else { 131 status = false; 132 if ( status ) { 133 log.println("FAILED: com.sun.star.text.NumberingLevel -> " + 134 "found not described property:"); 135 } 136 137 status = false; 138 log.println("-> '" + propertyName + "'"); 139 } 140 141 } 142 143 // get rest of properties and check if they are optional 144 if (! NumberingLevel.isEmpty()){ 145 for (Enumeration e = NumberingLevel.keys() ; e.hasMoreElements() ;) { 146 String property = (String) e.nextElement(); 147 148 // if some elements are not optional -> failed 149 if ( ! ((Boolean)NumberingLevel.get(property)).booleanValue() ){ 150 151 if ( status ) { 152 log.println("FAILED: com.sun.star.text.NumberingLevel -> " + 153 "could not find not optional property:"); 154 } 155 156 status = false; 157 log.println("-> '" + property + "'"); 158 } 159 } 160 } 161 162 }catch( Exception e ){ 163 throw new StatusException("ERROR: could not test all properties of com.sun.star.text.NumberingLevel",e); 164 } 165 166 return status; 167 } 168 169 170 } // finish class _NumberingLevel 171