1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir package ifc.style;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
26cdf0e10cSrcweir import com.sun.star.beans.UnknownPropertyException;
27cdf0e10cSrcweir import com.sun.star.container.XIndexReplace;
28cdf0e10cSrcweir import com.sun.star.container.XNameContainer;
29cdf0e10cSrcweir import com.sun.star.lang.WrappedTargetException;
30cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
31cdf0e10cSrcweir import com.sun.star.uno.Type;
32cdf0e10cSrcweir import com.sun.star.xml.AttributeData;
33cdf0e10cSrcweir import ifc.text._NumberingLevel;
34cdf0e10cSrcweir import java.util.Enumeration;
35cdf0e10cSrcweir import java.util.Hashtable;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir import lib.MultiPropertyTest;
38cdf0e10cSrcweir import lib.Status;
39cdf0e10cSrcweir import share.LogWriter;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir import util.utils;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 
45cdf0e10cSrcweir /**
46cdf0e10cSrcweir * Testing <code>com.sun.star.style.ParagraphProperties</code>
47cdf0e10cSrcweir * service properties :
48cdf0e10cSrcweir * <ul>
49cdf0e10cSrcweir *  <li><code> ParaAdjust</code></li>
50cdf0e10cSrcweir *  <li><code> ParaLineSpacing</code></li>
51cdf0e10cSrcweir *  <li><code> ParaBackColor</code></li>
52cdf0e10cSrcweir *  <li><code> ParaBackTransparent</code></li>
53cdf0e10cSrcweir *  <li><code> ParaBackGraphicURL</code></li>
54cdf0e10cSrcweir *  <li><code> ParaBackGraphicFilter</code></li>
55cdf0e10cSrcweir *  <li><code> ParaBackGraphicLocation</code></li>
56cdf0e10cSrcweir *  <li><code> ParaLastLineAdjust</code></li>
57cdf0e10cSrcweir *  <li><code> ParaExpandSingleWord</code></li>
58cdf0e10cSrcweir *  <li><code> ParaLeftMargin</code></li>
59cdf0e10cSrcweir *  <li><code> ParaRightMargin</code></li>
60cdf0e10cSrcweir *  <li><code> ParaTopMargin</code></li>
61cdf0e10cSrcweir *  <li><code> ParaBottomMargin</code></li>
62cdf0e10cSrcweir *  <li><code> ParaLineNumberCount</code></li>
63cdf0e10cSrcweir *  <li><code> ParaLineNumberStartValue</code></li>
64cdf0e10cSrcweir *  <li><code> ParaIsHyphenation</code></li>
65cdf0e10cSrcweir *  <li><code> PageDescName</code></li>
66cdf0e10cSrcweir *  <li><code> PageNumberOffset</code></li>
67cdf0e10cSrcweir *  <li><code> ParaRegisterModeActive</code></li>
68cdf0e10cSrcweir *  <li><code> ParaTabStops</code></li>
69cdf0e10cSrcweir *  <li><code> ParaStyleName</code></li>
70cdf0e10cSrcweir *  <li><code> DropCapFormat</code></li>
71cdf0e10cSrcweir *  <li><code> DropCapWholeWord</code></li>
72cdf0e10cSrcweir *  <li><code> ParaKeepTogether</code></li>
73cdf0e10cSrcweir *  <li><code> ParaSplit</code></li>
74cdf0e10cSrcweir *  <li><code> NumberingLevel</code></li>
75cdf0e10cSrcweir *  <li><code> NumberingRules</code></li>
76cdf0e10cSrcweir *  <li><code> NumberingStartValue</code></li>
77cdf0e10cSrcweir *  <li><code> ParaIsNumberingRestart</code></li>
78cdf0e10cSrcweir *  <li><code> NumberingStyleName</code></li>
79cdf0e10cSrcweir *  <li><code> ParaOrphans</code></li>
80cdf0e10cSrcweir *  <li><code> ParaWidows</code></li>
81cdf0e10cSrcweir *  <li><code> ParaShadowFormat</code></li>
82cdf0e10cSrcweir *  <li><code> IsHangingPunctuation</code></li>
83cdf0e10cSrcweir *  <li><code> IsCharacterDistance</code></li>
84cdf0e10cSrcweir *  <li><code> IsForbiddenRules</code></li>
85cdf0e10cSrcweir *  <li><code> LeftBorder</code></li>
86cdf0e10cSrcweir *  <li><code> RightBorder</code></li>
87cdf0e10cSrcweir *  <li><code> TopBorder</code></li>
88cdf0e10cSrcweir *  <li><code> BottomBorder</code></li>
89cdf0e10cSrcweir *  <li><code> BorderDistance</code></li>
90cdf0e10cSrcweir *  <li><code> LeftBorderDistance</code></li>
91cdf0e10cSrcweir *  <li><code> RightBorderDistance</code></li>
92cdf0e10cSrcweir *  <li><code> TopBorderDistance</code></li>
93cdf0e10cSrcweir *  <li><code> BottomBorderDistance</code></li>
94cdf0e10cSrcweir * </ul> <p>
95cdf0e10cSrcweir * This test needs the following object relations :
96cdf0e10cSrcweir * <ul>
97cdf0e10cSrcweir *  <li> <code>'NRULES'</code> : <b>optional</b>
98cdf0e10cSrcweir *   (service <code>com.sun.star.text.NumberingRules</code>):
99cdf0e10cSrcweir *   instance of the service which can be set as 'NumberingRules'
100cdf0e10cSrcweir *   property new value. If the relation doesn't then two
101cdf0e10cSrcweir *   different <code>NumberingRules</code> objects are tried
102cdf0e10cSrcweir *   to be obtained by setting different 'NumberingStyleName'
103cdf0e10cSrcweir *   property styles and getting 'NumberingRules' property values.</li>
104cdf0e10cSrcweir * <ul> <p>
105cdf0e10cSrcweir * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
106cdf0e10cSrcweir * @see com.sun.star.style.ParagraphProperties
107cdf0e10cSrcweir */
108cdf0e10cSrcweir public class _ParagraphProperties extends MultiPropertyTest {
109cdf0e10cSrcweir     /**
110cdf0e10cSrcweir      * Custom tester for numbering style properties. Switches between
111cdf0e10cSrcweir      * 'Numbering 1' and 'Numbering 2' styles.
112cdf0e10cSrcweir      */
113cdf0e10cSrcweir     protected PropertyTester NumberingStyleTester = new PropertyTester() {
114cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue)
115cdf0e10cSrcweir                               throws java.lang.IllegalArgumentException {
116cdf0e10cSrcweir             if ((oldValue != null) && (oldValue.equals("Numbering 1"))) {
117cdf0e10cSrcweir                 return "Numbering 2";
118cdf0e10cSrcweir             } else {
119cdf0e10cSrcweir                 return "Numbering 1";
120cdf0e10cSrcweir             }
121cdf0e10cSrcweir         }
122cdf0e10cSrcweir     };
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     /**
125cdf0e10cSrcweir      * Custom tester for paragraph style properties. Switches between
126cdf0e10cSrcweir      * 'Salutation' and 'Heading' styles.
127cdf0e10cSrcweir      */
128cdf0e10cSrcweir     protected PropertyTester charStyleTester = new PropertyTester() {
129cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
130cdf0e10cSrcweir             if (!utils.isVoid(oldValue) && (oldValue.equals("Example"))) {
131cdf0e10cSrcweir                 return "Emphasis";
132cdf0e10cSrcweir             } else {
133cdf0e10cSrcweir                 return "Example";
134cdf0e10cSrcweir             }
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir     };
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     /**
139cdf0e10cSrcweir      * Custom tester for paragraph style properties. Switches between
140cdf0e10cSrcweir      * 'Salutation' and 'Heading' styles.
141cdf0e10cSrcweir      */
142cdf0e10cSrcweir     protected PropertyTester ParaStyleTester = new PropertyTester() {
143cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
144cdf0e10cSrcweir             if (!utils.isVoid(oldValue) && (oldValue.equals("Heading"))) {
145cdf0e10cSrcweir                 return "Salutation";
146cdf0e10cSrcweir             } else {
147cdf0e10cSrcweir                 return "Heading";
148cdf0e10cSrcweir             }
149cdf0e10cSrcweir         }
150cdf0e10cSrcweir     };
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     /**
153cdf0e10cSrcweir      * Custom tester for PageDescName properties. Switches between
154cdf0e10cSrcweir      * 'HTML' and 'Standard' descriptor names.
155cdf0e10cSrcweir      */
156cdf0e10cSrcweir     protected PropertyTester PageDescTester = new PropertyTester() {
157cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
158cdf0e10cSrcweir             if (!util.utils.isVoid(oldValue) &&
159cdf0e10cSrcweir                     (oldValue.equals("Default"))) {
160cdf0e10cSrcweir                 return "HTML";
161cdf0e10cSrcweir             } else {
162cdf0e10cSrcweir                 return "Default";
163cdf0e10cSrcweir             }
164cdf0e10cSrcweir         }
165cdf0e10cSrcweir     };
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     /**
168cdf0e10cSrcweir      * Custom tester for properties which have <code>short</code> type
169cdf0e10cSrcweir      * and can be void, so if they have void value, the new value must
170cdf0e10cSrcweir      * be specified. Switches between two different values.
171cdf0e10cSrcweir      */
172cdf0e10cSrcweir     protected PropertyTester ShortTester = new PropertyTester() {
173cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
174cdf0e10cSrcweir             if ((oldValue != null) &&
175cdf0e10cSrcweir                     (oldValue.equals(new Short((short) 0)))) {
176cdf0e10cSrcweir                 return new Short((short) 2);
177cdf0e10cSrcweir             } else {
178cdf0e10cSrcweir                 return new Short((short) 0);
179cdf0e10cSrcweir             }
180cdf0e10cSrcweir         }
181cdf0e10cSrcweir     };
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     /**
184cdf0e10cSrcweir      * Custom tester for properties which have <code>boolean</code> type
185cdf0e10cSrcweir      * and can be void, so if they have void value, the new value must
186cdf0e10cSrcweir      * be specified. Switches between true and false.
187cdf0e10cSrcweir      */
188cdf0e10cSrcweir     protected PropertyTester BooleanTester = new PropertyTester() {
189cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
190cdf0e10cSrcweir             if ((oldValue != null) &&
191cdf0e10cSrcweir                     (oldValue.equals(new Boolean((boolean) false)))) {
192cdf0e10cSrcweir                 return new Boolean((boolean) true);
193cdf0e10cSrcweir             } else {
194cdf0e10cSrcweir                 return new Boolean((boolean) false);
195cdf0e10cSrcweir             }
196cdf0e10cSrcweir         }
197cdf0e10cSrcweir     };
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     /**
200cdf0e10cSrcweir      * Custom tester for properties which contains image URLs.
201cdf0e10cSrcweir      * Switches between two JPG images' URLs.
202cdf0e10cSrcweir      */
203cdf0e10cSrcweir     protected PropertyTester URLTester = new PropertyTester() {
204cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
205cdf0e10cSrcweir             if (oldValue.equals(util.utils.getFullTestURL("space-metal.jpg"))) {
206cdf0e10cSrcweir                 return util.utils.getFullTestURL("crazy-blue.jpg");
207cdf0e10cSrcweir             } else {
208cdf0e10cSrcweir                 return util.utils.getFullTestURL("space-metal.jpg");
209cdf0e10cSrcweir             }
210cdf0e10cSrcweir         }
211cdf0e10cSrcweir     };
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     protected PropertyTester rules = null;
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     /**
216cdf0e10cSrcweir      * Creates tester for 'NumberingRules' depending on relation.
217cdf0e10cSrcweir      */
before()218cdf0e10cSrcweir     public void before() {
219cdf0e10cSrcweir         final Object nRules = tEnv.getObjRelation("NRULES");
220cdf0e10cSrcweir 
221cdf0e10cSrcweir         if (nRules != null) {
222cdf0e10cSrcweir             rules = new PropertyTester() {
223cdf0e10cSrcweir                 protected Object getNewValue(String propName, Object oldValue) {
224cdf0e10cSrcweir                     return nRules;
225cdf0e10cSrcweir                 }
226cdf0e10cSrcweir             };
227cdf0e10cSrcweir 
228cdf0e10cSrcweir         } else {
229cdf0e10cSrcweir             Object rules1 = null;
230cdf0e10cSrcweir             Object rules2 = null;
231cdf0e10cSrcweir 
232cdf0e10cSrcweir             try {
233cdf0e10cSrcweir                 oObj.setPropertyValue("NumberingStyleName", "Numbering 1");
234cdf0e10cSrcweir                 rules1 = oObj.getPropertyValue("NumberingRules");
235cdf0e10cSrcweir                 oObj.setPropertyValue("NumberingStyleName", "Numbering 2");
236cdf0e10cSrcweir                 rules2 = oObj.getPropertyValue("NumberingRules");
237cdf0e10cSrcweir             } catch (com.sun.star.lang.WrappedTargetException e) {
238cdf0e10cSrcweir                 log.println("WARNING !!! Exception getting numbering rules :");
239cdf0e10cSrcweir                 e.printStackTrace(log);
240cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException e) {
241cdf0e10cSrcweir                 log.println("WARNING !!! Exception getting numbering rules :");
242cdf0e10cSrcweir                 e.printStackTrace(log);
243cdf0e10cSrcweir             } catch (com.sun.star.beans.PropertyVetoException e) {
244cdf0e10cSrcweir                 log.println("WARNING !!! Exception getting numbering rules :");
245cdf0e10cSrcweir                 e.printStackTrace(log);
246cdf0e10cSrcweir             } catch (com.sun.star.beans.UnknownPropertyException e) {
247cdf0e10cSrcweir                 log.println("Property 'NumberingStyleName' is not supported.");
248cdf0e10cSrcweir             }
249cdf0e10cSrcweir 
250cdf0e10cSrcweir             rules = new PropertyValueSwitcher(rules1, rules2);
251cdf0e10cSrcweir         }
252cdf0e10cSrcweir     }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     /**
255cdf0e10cSrcweir      * Tested with custom property tester.
256cdf0e10cSrcweir      */
_NumberingStyleName()257cdf0e10cSrcweir     public void _NumberingStyleName() {
258cdf0e10cSrcweir         log.println("Testing with custom Property tester");
259cdf0e10cSrcweir         testProperty("NumberingStyleName", NumberingStyleTester);
260cdf0e10cSrcweir     }
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     /**
263cdf0e10cSrcweir      * Tested with custom property tester.
264cdf0e10cSrcweir      */
_DropCapCharStyleName()265cdf0e10cSrcweir     public void _DropCapCharStyleName() {
266cdf0e10cSrcweir         log.println("Testing with custom Property tester");
267cdf0e10cSrcweir         testProperty("DropCapCharStyleName", charStyleTester);
268cdf0e10cSrcweir     }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir     /**
271cdf0e10cSrcweir      * Tested with custom property tester.
272cdf0e10cSrcweir      */
_ParaStyleName()273cdf0e10cSrcweir     public void _ParaStyleName() {
274cdf0e10cSrcweir         log.println("Testing with custom Property tester");
275cdf0e10cSrcweir         testProperty("ParaStyleName", ParaStyleTester);
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     /**
279cdf0e10cSrcweir      * Tested with custom property tester.
280cdf0e10cSrcweir      */
_PageDescName()281cdf0e10cSrcweir     public void _PageDescName() {
282cdf0e10cSrcweir         log.println("Testing with custom Property tester");
283cdf0e10cSrcweir         testProperty("PageDescName", PageDescTester);
284cdf0e10cSrcweir     }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir     /**
287cdf0e10cSrcweir      * Tested with custom property tester. Before testing property
288cdf0e10cSrcweir      * <code>ParaAdjust</code> is setting to value <code>BLOCK</code>
289cdf0e10cSrcweir      * because setting the property <code>ParaLastLineAdjust</code>
290cdf0e10cSrcweir      * makes sense only in this case.
291cdf0e10cSrcweir      */
_ParaLastLineAdjust()292cdf0e10cSrcweir     public void _ParaLastLineAdjust() {
293cdf0e10cSrcweir         log.println("Testing with custom Property tester");
294cdf0e10cSrcweir 
295cdf0e10cSrcweir         try {
296cdf0e10cSrcweir             oObj.setPropertyValue("ParaAdjust",
297cdf0e10cSrcweir                                   com.sun.star.style.ParagraphAdjust.BLOCK);
298cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e) {
299cdf0e10cSrcweir             log.println("Exception occured setting property 'ParagraphAdjust'" + e);
300cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
301cdf0e10cSrcweir             log.println("Exception occured setting property 'ParagraphAdjust'" + e);
302cdf0e10cSrcweir         } catch (com.sun.star.beans.UnknownPropertyException e) {
303cdf0e10cSrcweir             log.println("Exception occured setting property 'ParagraphAdjust'" + e);
304cdf0e10cSrcweir         } catch (com.sun.star.beans.PropertyVetoException e) {
305cdf0e10cSrcweir             log.println("Exception occured setting property 'ParagraphAdjust'" + e);
306cdf0e10cSrcweir         }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir         testProperty("ParaLastLineAdjust", ShortTester);
309cdf0e10cSrcweir     }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     /**
312cdf0e10cSrcweir      * Tested with custom property tester.
313cdf0e10cSrcweir      */
_ParaBackGraphicURL()314cdf0e10cSrcweir     public void _ParaBackGraphicURL() {
315cdf0e10cSrcweir         log.println("Testing with custom Property tester");
316cdf0e10cSrcweir         testProperty("ParaBackGraphicURL", URLTester);
317cdf0e10cSrcweir     }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     /**
320cdf0e10cSrcweir      * Tested with custom property tester. <p>
321cdf0e10cSrcweir      * The following property tests are to be completed successfully before :
322cdf0e10cSrcweir      * <ul>
323cdf0e10cSrcweir      *  <li> <code> NumberingStyleName </code> : a numbering style must
324cdf0e10cSrcweir      *  be set before testing this property </li>
325cdf0e10cSrcweir      * </ul>
326cdf0e10cSrcweir      */
_NumberingLevel()327cdf0e10cSrcweir     public void _NumberingLevel() {
328cdf0e10cSrcweir         requiredMethod("NumberingStyleName");
329cdf0e10cSrcweir         log.println("Testing with custom Property tester");
330cdf0e10cSrcweir         testProperty("NumberingLevel", ShortTester);
331cdf0e10cSrcweir     }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir     /**
334cdf0e10cSrcweir      * Tested with custom property tester. <p>
335cdf0e10cSrcweir      */
_ParaIsConnectBorder()336cdf0e10cSrcweir     public void _ParaIsConnectBorder() {
337cdf0e10cSrcweir 
338cdf0e10cSrcweir         log.println("Testing with custom Property tester");
339cdf0e10cSrcweir         testProperty("ParaIsConnectBorder", BooleanTester);
340cdf0e10cSrcweir     }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir     /**
343cdf0e10cSrcweir      * Tested with custom property tester.
344cdf0e10cSrcweir      */
_ParaVertAlignment()345cdf0e10cSrcweir     public void _ParaVertAlignment() {
346cdf0e10cSrcweir         log.println("Testing with custom Property tester");
347cdf0e10cSrcweir         testProperty("ParaVertAlignment", ShortTester);
348cdf0e10cSrcweir     }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     /**
351cdf0e10cSrcweir      * Tested with com.sun.star.text.NumberingLevel <p>
352cdf0e10cSrcweir      * The value of this property is a com.sun.star.container.XIndexReplace which is represneted by
353cdf0e10cSrcweir      * com.sun.star.text.NumberingLevel.
354cdf0e10cSrcweir      * The following property tests are to be completed successfully before :
355cdf0e10cSrcweir      * <ul>
356cdf0e10cSrcweir      *  <li> <code> NumberingStyleName </code> : a numbering style must
357cdf0e10cSrcweir      *  be set before testing this property </li>
358cdf0e10cSrcweir      * </ul>
359cdf0e10cSrcweir      * @see com.sun.star.text.NumberlingLevel
360cdf0e10cSrcweir      * @see com.sun.star.container.XIndexReplace
361cdf0e10cSrcweir      * @see ifc.text._NumberingLevel
362cdf0e10cSrcweir      */
_NumberingRules()363cdf0e10cSrcweir     public void _NumberingRules() {
364cdf0e10cSrcweir         requiredMethod("NumberingStyleName");
365cdf0e10cSrcweir 
366cdf0e10cSrcweir         XIndexReplace NumberingRules = null;
367cdf0e10cSrcweir         PropertyValue[] propertyValues = null;
368cdf0e10cSrcweir         try {
369cdf0e10cSrcweir             NumberingRules = (XIndexReplace) AnyConverter.toObject(
370cdf0e10cSrcweir                            new Type(XIndexReplace.class), oObj.getPropertyValue("NumberingRules"));
371cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException ex) {
372cdf0e10cSrcweir             Status.failed( "could not get NumberingRuels: "+ ex.toString() );
373cdf0e10cSrcweir             return;
374cdf0e10cSrcweir         } catch (UnknownPropertyException ex) {
375cdf0e10cSrcweir             Status.failed( "could not get NumberingRuels: "+ ex.toString() );
376cdf0e10cSrcweir             return;
377cdf0e10cSrcweir         } catch (WrappedTargetException ex) {
378cdf0e10cSrcweir             Status.failed( "could not get NumberingRuels: "+ ex.toString() );
379cdf0e10cSrcweir             return;
380cdf0e10cSrcweir         }
381cdf0e10cSrcweir         try {
382cdf0e10cSrcweir             propertyValues = (PropertyValue[]) NumberingRules.getByIndex(0);
383cdf0e10cSrcweir 
384cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
385cdf0e10cSrcweir             Status.failed( "could not get NumberlingLevel-Array from NumberingRuels: "+ ex.toString() );
386cdf0e10cSrcweir             return;
387cdf0e10cSrcweir         } catch (WrappedTargetException ex) {
388cdf0e10cSrcweir             Status.failed( "could not get NumberlingLevel-Array from NumberingRuels: "+ ex.toString() );
389cdf0e10cSrcweir             return;
390cdf0e10cSrcweir         }
391cdf0e10cSrcweir 
392cdf0e10cSrcweir         _NumberingLevel numb = new _NumberingLevel((LogWriter)log, tParam, propertyValues);
393cdf0e10cSrcweir 
394cdf0e10cSrcweir         boolean result = numb.testPropertieArray();
395cdf0e10cSrcweir 
396cdf0e10cSrcweir         tRes.tested("NumberingRules", result);
397cdf0e10cSrcweir     }
398cdf0e10cSrcweir 
_ParaUserDefinedAttributes()399cdf0e10cSrcweir     public void _ParaUserDefinedAttributes() {
400cdf0e10cSrcweir         XNameContainer uda = null;
401cdf0e10cSrcweir         boolean res = false;
402cdf0e10cSrcweir 
403cdf0e10cSrcweir         try {
404cdf0e10cSrcweir             try{
405cdf0e10cSrcweir                 uda = (XNameContainer) AnyConverter.toObject(
406cdf0e10cSrcweir                           new Type(XNameContainer.class),
407cdf0e10cSrcweir                           oObj.getPropertyValue("ParaUserDefinedAttributes"));
408cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException e){
409cdf0e10cSrcweir                 log.println("ParaUserDefinedAttributes is empty.");
410cdf0e10cSrcweir                 uda = new _ParagraphProperties.OwnUserDefinedAttributes();
411cdf0e10cSrcweir             }
412cdf0e10cSrcweir             AttributeData attr = new AttributeData();
413cdf0e10cSrcweir             attr.Namespace = "http://www.sun.com/staroffice/apitest/Cellprop";
414cdf0e10cSrcweir             attr.Type = "CDATA";
415cdf0e10cSrcweir             attr.Value = "true";
416cdf0e10cSrcweir             uda.insertByName("Cellprop:has-first-alien-attribute", attr);
417cdf0e10cSrcweir 
418cdf0e10cSrcweir             String[] els = uda.getElementNames();
419cdf0e10cSrcweir             oObj.setPropertyValue("ParaUserDefinedAttributes", uda);
420cdf0e10cSrcweir             uda = (XNameContainer) AnyConverter.toObject(
421cdf0e10cSrcweir                           new Type(XNameContainer.class),
422cdf0e10cSrcweir                           oObj.getPropertyValue("ParaUserDefinedAttributes"));
423cdf0e10cSrcweir             els = uda.getElementNames();
424cdf0e10cSrcweir 
425cdf0e10cSrcweir             Object obj = uda.getByName("Cellprop:has-first-alien-attribute");
426cdf0e10cSrcweir             res = true;
427cdf0e10cSrcweir         } catch (com.sun.star.beans.UnknownPropertyException upe) {
428cdf0e10cSrcweir             if (isOptional("ParaUserDefinedAttributes")) {
429cdf0e10cSrcweir                 log.println("Property is optional and not supported");
430cdf0e10cSrcweir                 res = true;
431cdf0e10cSrcweir             } else {
432cdf0e10cSrcweir                 log.println("Don't know the Property 'ParaUserDefinedAttributes'");
433cdf0e10cSrcweir             }
434cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException wte) {
435cdf0e10cSrcweir             log.println(
436cdf0e10cSrcweir                     "WrappedTargetException while getting Property 'ParaUserDefinedAttributes'");
437cdf0e10cSrcweir         } catch (com.sun.star.container.NoSuchElementException nee) {
438cdf0e10cSrcweir             log.println("added Element isn't part of the NameContainer");
439cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException iae) {
440cdf0e10cSrcweir             log.println(
441cdf0e10cSrcweir                     "IllegalArgumentException while getting Property 'ParaUserDefinedAttributes'");
442cdf0e10cSrcweir         } catch (com.sun.star.beans.PropertyVetoException pve) {
443cdf0e10cSrcweir             log.println(
444cdf0e10cSrcweir                     "PropertyVetoException while getting Property 'ParaUserDefinedAttributes'");
445cdf0e10cSrcweir         } catch (com.sun.star.container.ElementExistException eee) {
446cdf0e10cSrcweir             log.println(
447cdf0e10cSrcweir                     "ElementExistException while getting Property 'ParaUserDefinedAttributes'");
448cdf0e10cSrcweir         }
449cdf0e10cSrcweir 
450cdf0e10cSrcweir         tRes.tested("ParaUserDefinedAttributes", res);
451cdf0e10cSrcweir     }
452cdf0e10cSrcweir 
453cdf0e10cSrcweir     private class OwnUserDefinedAttributes implements XNameContainer{
454cdf0e10cSrcweir         Hashtable members = null;
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 
OwnUserDefinedAttributes()457cdf0e10cSrcweir         public OwnUserDefinedAttributes() {
458cdf0e10cSrcweir             members = new Hashtable();
459cdf0e10cSrcweir         }
460cdf0e10cSrcweir 
getByName(String str)461cdf0e10cSrcweir         public Object getByName(String str) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException {
462cdf0e10cSrcweir             return members.get(str);
463cdf0e10cSrcweir         }
464cdf0e10cSrcweir 
getElementNames()465cdf0e10cSrcweir         public String[] getElementNames() {
466cdf0e10cSrcweir             Enumeration oEnum = members.keys();
467cdf0e10cSrcweir             int count = members.size();
468cdf0e10cSrcweir             String[] res = new String[count];
469cdf0e10cSrcweir             int i=0;
470cdf0e10cSrcweir             while(oEnum.hasMoreElements())
471cdf0e10cSrcweir                 res[i] = (String)oEnum.nextElement();
472cdf0e10cSrcweir             return res;
473cdf0e10cSrcweir         }
474cdf0e10cSrcweir 
getElementType()475cdf0e10cSrcweir         public com.sun.star.uno.Type getElementType() {
476cdf0e10cSrcweir             Enumeration oEnum = members.keys();
477cdf0e10cSrcweir             String key = (String)oEnum.nextElement();
478cdf0e10cSrcweir             Object o = members.get(key);
479cdf0e10cSrcweir             return new Type(o.getClass());
480cdf0e10cSrcweir         }
481cdf0e10cSrcweir 
hasByName(String str)482cdf0e10cSrcweir         public boolean hasByName(String str) {
483cdf0e10cSrcweir             return members.get(str) != null;
484cdf0e10cSrcweir         }
485cdf0e10cSrcweir 
hasElements()486cdf0e10cSrcweir         public boolean hasElements() {
487cdf0e10cSrcweir             return members.size() > 0;
488cdf0e10cSrcweir         }
489cdf0e10cSrcweir 
insertByName(String str, Object obj)490cdf0e10cSrcweir         public void insertByName(String str, Object obj) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.ElementExistException, com.sun.star.lang.WrappedTargetException {
491cdf0e10cSrcweir             members.put(str, obj);
492cdf0e10cSrcweir         }
493cdf0e10cSrcweir 
removeByName(String str)494cdf0e10cSrcweir         public void removeByName(String str) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException {
495cdf0e10cSrcweir             members.remove(str);
496cdf0e10cSrcweir         }
497cdf0e10cSrcweir 
replaceByName(String str, Object obj)498cdf0e10cSrcweir         public void replaceByName(String str, Object obj) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException {
499cdf0e10cSrcweir             members.put(str, obj);
500cdf0e10cSrcweir         }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir     }
503cdf0e10cSrcweir } // finish class _ParagraphProperties
504