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