1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir package ifc.text;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
31*cdf0e10cSrcweir import java.util.Enumeration;
32*cdf0e10cSrcweir import java.util.Hashtable;
33*cdf0e10cSrcweir import lib.StatusException;
34*cdf0e10cSrcweir import lib.TestParameters;
35*cdf0e10cSrcweir import share.LogWriter;
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir /**
39*cdf0e10cSrcweir * Testing <code>com.sun.star.text.NumberingLevel</code><p>
40*cdf0e10cSrcweir * This service is currently konwn as property value of
41*cdf0e10cSrcweir * com.sun.star.text.ParagraphProperties.NumberingRules
42*cdf0e10cSrcweir * This test checks only for completnes of implemented properties.
43*cdf0e10cSrcweir * service properties :
44*cdf0e10cSrcweir * <ul>
45*cdf0e10cSrcweir *  <li><code> Adjust</code></li>
46*cdf0e10cSrcweir *  <li><code> ParentNumbering</code></li>
47*cdf0e10cSrcweir *  <li><code> Prefix</code></li>
48*cdf0e10cSrcweir *  <li><code> Suffix</code></li>
49*cdf0e10cSrcweir *  <li><code> CharStyleName</code></li>
50*cdf0e10cSrcweir *  <li><code> BulletId</code></li>
51*cdf0e10cSrcweir *  <li><code> BulletChar</code></li>
52*cdf0e10cSrcweir *  <li><code> BulletFontName</code></li>
53*cdf0e10cSrcweir *  <li><code> BulletFont</code></li>
54*cdf0e10cSrcweir *  <li><code> GraphicURL</code></li>
55*cdf0e10cSrcweir *  <li><code> GraphicBitmap</code></li>
56*cdf0e10cSrcweir *  <li><code> GraphicSize</code></li>
57*cdf0e10cSrcweir *  <li><code> VertOrient</code></li>
58*cdf0e10cSrcweir *  <li><code> StartWith</code></li>
59*cdf0e10cSrcweir *  <li><code> LeftMargin</code></li>
60*cdf0e10cSrcweir *  <li><code> SymbolTextDistance</code></li>
61*cdf0e10cSrcweir *  <li><code> FirstLineOffset</code></li>
62*cdf0e10cSrcweir *  <li><code> NumberingType</code></li>
63*cdf0e10cSrcweir *  <li><code> HeadingStyleName</code></li>
64*cdf0e10cSrcweir *  <li><code> BulletColor</code></li>
65*cdf0e10cSrcweir *  <li><code> BulletRelSize</code></li>
66*cdf0e10cSrcweir * </ul> <p>
67*cdf0e10cSrcweir *
68*cdf0e10cSrcweir * @see com.sun.star.text.NumberingLevel
69*cdf0e10cSrcweir * @see com.sun.star.test.ParagraphProperties
70*cdf0e10cSrcweir * @see ifc.text._ParagraphProperties
71*cdf0e10cSrcweir */
72*cdf0e10cSrcweir public class _NumberingLevel {
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     private static TestParameters tParam = null;
75*cdf0e10cSrcweir     private static Hashtable NumberingLevel = new Hashtable();
76*cdf0e10cSrcweir     private static PropertyValue[] PropertyArray = null;
77*cdf0e10cSrcweir     private static LogWriter log = null;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     /**
81*cdf0e10cSrcweir      * returns an instance of _NumberingLevel
82*cdf0e10cSrcweir      * @param log the log writer
83*cdf0e10cSrcweir      * @param tParam the test parameters
84*cdf0e10cSrcweir      * @param propertyValues a PropertyValue[] which should contain all properties of com.sun.star.text.NumberingLevel
85*cdf0e10cSrcweir      */
86*cdf0e10cSrcweir     public _NumberingLevel(LogWriter log, TestParameters tParam, PropertyValue[] propertyValues){
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir         this.tParam = tParam;
89*cdf0e10cSrcweir         this.PropertyArray = propertyValues;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir         this.log = log;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir         //key = PropertyName, value = Ooptional
94*cdf0e10cSrcweir         NumberingLevel.put("Adjust", new Boolean(false));
95*cdf0e10cSrcweir         NumberingLevel.put("ParentNumbering", new Boolean(true));
96*cdf0e10cSrcweir         NumberingLevel.put("Prefix", new Boolean(false));
97*cdf0e10cSrcweir         NumberingLevel.put("Suffix", new Boolean(false));
98*cdf0e10cSrcweir         NumberingLevel.put("CharStyleName", new Boolean(true));
99*cdf0e10cSrcweir         NumberingLevel.put("BulletId", new Boolean(true));
100*cdf0e10cSrcweir         NumberingLevel.put("BulletChar", new Boolean(false));
101*cdf0e10cSrcweir         NumberingLevel.put("BulletFontName", new Boolean(false));
102*cdf0e10cSrcweir         NumberingLevel.put("BulletFont", new Boolean(true));
103*cdf0e10cSrcweir         NumberingLevel.put("GraphicURL", new Boolean(false));
104*cdf0e10cSrcweir         NumberingLevel.put("GraphicBitmap", new Boolean(true));
105*cdf0e10cSrcweir         NumberingLevel.put("GraphicSize", new Boolean(true));
106*cdf0e10cSrcweir         NumberingLevel.put("VertOrient", new Boolean(true));
107*cdf0e10cSrcweir         NumberingLevel.put("StartWith", new Boolean(true));
108*cdf0e10cSrcweir         NumberingLevel.put("LeftMargin", new Boolean(false));
109*cdf0e10cSrcweir         NumberingLevel.put("SymbolTextDistance", new Boolean(true));
110*cdf0e10cSrcweir         NumberingLevel.put("FirstLineOffset", new Boolean(false));
111*cdf0e10cSrcweir         NumberingLevel.put("NumberingType", new Boolean(false));
112*cdf0e10cSrcweir         NumberingLevel.put("HeadingStyleName", new Boolean(false));
113*cdf0e10cSrcweir         NumberingLevel.put("BulletColor", new Boolean(true));
114*cdf0e10cSrcweir         NumberingLevel.put("BulletRelSize", new Boolean(true));
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     /**
119*cdf0e10cSrcweir      * This methods checks the PropertyValue for completnes. If one or more properties
120*cdf0e10cSrcweir      * are missing the return value is FALSE, else TRUE
121*cdf0e10cSrcweir      * @return returns TRUE if PropertyValue[] is complete, else FALSE
122*cdf0e10cSrcweir      */
123*cdf0e10cSrcweir     public boolean testPropertieArray(){
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir         boolean status = true;
126*cdf0e10cSrcweir         try{
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir             // iterate over the given property array and remove it from the must list
129*cdf0e10cSrcweir             for (int i = 0; i < PropertyArray.length; i++){
130*cdf0e10cSrcweir                 String propertyName=PropertyArray[i].Name;
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir                 if ( NumberingLevel.containsKey(propertyName) ) {
133*cdf0e10cSrcweir                     NumberingLevel.remove(propertyName);
134*cdf0e10cSrcweir                 } else {
135*cdf0e10cSrcweir                     status = false;
136*cdf0e10cSrcweir                         if ( status ) {
137*cdf0e10cSrcweir                             log.println("FAILED: com.sun.star.text.NumberingLevel -> " +
138*cdf0e10cSrcweir                                         "found not described property:");
139*cdf0e10cSrcweir                         }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir                         status = false;
142*cdf0e10cSrcweir                         log.println("-> '" + propertyName + "'");
143*cdf0e10cSrcweir                 }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir             }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir             // get rest of properties and check if they are optional
148*cdf0e10cSrcweir             if (! NumberingLevel.isEmpty()){
149*cdf0e10cSrcweir                 for (Enumeration e = NumberingLevel.keys() ; e.hasMoreElements() ;) {
150*cdf0e10cSrcweir                     String property = (String) e.nextElement();
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir                     // if some elements are not optional -> failed
153*cdf0e10cSrcweir                     if ( ! ((Boolean)NumberingLevel.get(property)).booleanValue() ){
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir                         if ( status ) {
156*cdf0e10cSrcweir                             log.println("FAILED: com.sun.star.text.NumberingLevel -> " +
157*cdf0e10cSrcweir                                         "could not find not optional property:");
158*cdf0e10cSrcweir                         }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir                         status = false;
161*cdf0e10cSrcweir                         log.println("-> '" + property + "'");
162*cdf0e10cSrcweir                     }
163*cdf0e10cSrcweir                 }
164*cdf0e10cSrcweir             }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir         }catch( Exception e ){
167*cdf0e10cSrcweir             throw new StatusException("ERROR: could not test all properties of com.sun.star.text.NumberingLevel",e);
168*cdf0e10cSrcweir         }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         return status;
171*cdf0e10cSrcweir     }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir }  // finish class _NumberingLevel
175