2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import java
.util
.HashMap
;
22 import java
.util
.Iterator
;
25 import lib
.StatusException
;
26 import lib
.TestParameters
;
27 import share
.LogWriter
;
29 import com
.sun
.star
.beans
.PropertyValue
;
33 * Testing <code>com.sun.star.text.NumberingLevel</code><p>
34 * This service is currently known as property value of
35 * com.sun.star.text.ParagraphProperties.NumberingRules
36 * This test checks only for completeness of implemented properties.
37 * service properties :
39 * <li><code> Adjust</code></li>
40 * <li><code> ParentNumbering</code></li>
41 * <li><code> Prefix</code></li>
42 * <li><code> Suffix</code></li>
43 * <li><code> CharStyleName</code></li>
44 * <li><code> BulletId</code></li>
45 * <li><code> BulletChar</code></li>
46 * <li><code> BulletFontName</code></li>
47 * <li><code> BulletFont</code></li>
48 * <li><code> GraphicURL</code></li>
49 * <li><code> GraphicBitmap</code></li>
50 * <li><code> GraphicSize</code></li>
51 * <li><code> VertOrient</code></li>
52 * <li><code> StartWith</code></li>
53 * <li><code> LeftMargin</code></li>
54 * <li><code> SymbolTextDistance</code></li>
55 * <li><code> FirstLineOffset</code></li>
56 * <li><code> NumberingType</code></li>
57 * <li><code> HeadingStyleName</code></li>
58 * <li><code> BulletColor</code></li>
59 * <li><code> BulletRelSize</code></li>
62 * @see com.sun.star.text.NumberingLevel
63 * @see com.sun.star.test.ParagraphProperties
64 * @see ifc.style._ParagraphProperties
66 public class _NumberingLevel
{
68 private HashMap
<String
, Boolean
> NumberingLevel
= new HashMap
<String
,Boolean
>();
69 private PropertyValue
[] PropertyArray
= null;
70 private LogWriter log
= null;
74 * returns an instance of _NumberingLevel
75 * @param log the log writer
76 * @param tParam the test parameters
77 * @param propertyValues a PropertyValue[] which should contain all properties of com.sun.star.text.NumberingLevel
79 public _NumberingLevel(LogWriter log
, TestParameters tParam
, PropertyValue
[] propertyValues
){
81 this.PropertyArray
= propertyValues
;
85 //key = PropertyName, value = Ooptional
86 NumberingLevel
.put("Adjust", Boolean
.FALSE
);
87 NumberingLevel
.put("ParentNumbering", Boolean
.TRUE
);
88 NumberingLevel
.put("Prefix", Boolean
.FALSE
);
89 NumberingLevel
.put("Suffix", Boolean
.FALSE
);
90 NumberingLevel
.put("CharStyleName", Boolean
.TRUE
);
91 NumberingLevel
.put("BulletId", Boolean
.TRUE
);
92 NumberingLevel
.put("BulletChar", Boolean
.FALSE
);
93 NumberingLevel
.put("BulletFontName", Boolean
.FALSE
);
94 NumberingLevel
.put("BulletFont", Boolean
.TRUE
);
95 NumberingLevel
.put("GraphicURL", Boolean
.FALSE
);
96 NumberingLevel
.put("GraphicBitmap", Boolean
.TRUE
);
97 NumberingLevel
.put("GraphicSize", Boolean
.TRUE
);
98 NumberingLevel
.put("VertOrient", Boolean
.TRUE
);
99 NumberingLevel
.put("StartWith", Boolean
.TRUE
);
100 NumberingLevel
.put("LeftMargin", Boolean
.FALSE
);
101 NumberingLevel
.put("SymbolTextDistance", Boolean
.TRUE
);
102 NumberingLevel
.put("FirstLineOffset", Boolean
.FALSE
);
103 NumberingLevel
.put("NumberingType", Boolean
.FALSE
);
104 NumberingLevel
.put("HeadingStyleName", Boolean
.FALSE
);
105 NumberingLevel
.put("BulletColor", Boolean
.TRUE
);
106 NumberingLevel
.put("BulletRelSize", Boolean
.TRUE
);
111 * This method checks the PropertyValue for completeness. If one or more properties
112 * are missing the return value is FALSE, else TRUE
113 * @return returns TRUE if PropertyValue[] is complete, else FALSE
115 public boolean testPropertyArray(){
117 boolean status
= true;
120 // iterate over the given property array and remove it from the must list
121 for (int i
= 0; i
< PropertyArray
.length
; i
++){
122 String propertyName
=PropertyArray
[i
].Name
;
124 if ( NumberingLevel
.containsKey(propertyName
) ) {
125 NumberingLevel
.remove(propertyName
);
128 log
.println("FAILED: com.sun.star.text.NumberingLevel -> " +
129 "found not described property:");
133 log
.println("-> '" + propertyName
+ "'");
138 // get rest of properties and check if they are optional
139 if (! NumberingLevel
.isEmpty()){
140 for (Map
.Entry
<String
,Boolean
> e
: NumberingLevel
.entrySet()) {
141 // if some elements are not optional -> failed
142 if (!e
.getValue().booleanValue()) {
145 log
.println("FAILED: com.sun.star.text.NumberingLevel -> " +
146 "could not find not optional property:");
150 log
.println("-> '" + e
.getKey() + "'");
155 }catch( Exception e
){
156 throw new StatusException("ERROR: could not test all properties of com.sun.star.text.NumberingLevel",e
);
163 } // finish class _NumberingLevel