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.table;
25 
26 import lib.MultiPropertyTest;
27 
28 import com.sun.star.container.XNameContainer;
29 import com.sun.star.uno.AnyConverter;
30 import com.sun.star.uno.Type;
31 import com.sun.star.xml.AttributeData;
32 
33 /**
34 * Testing <code>com.sun.star.table.CellProperties</code>
35 * service properties :
36 * <ul>
37 *  <li><code> CellStyle</code></li>
38 *  <li><code> CellBackColor</code></li>
39 *  <li><code> IsCellBackgroundTransparent</code></li>
40 *  <li><code> NumberFormat</code></li>
41 *  <li><code> ShadowFormat</code></li>
42 *  <li><code> HoriJustify</code></li>
43 *  <li><code> VertJustify</code></li>
44 *  <li><code> Orientation</code></li>
45 *  <li><code> CellProtection</code></li>
46 *  <li><code> TableBorder</code></li>
47 *  <li><code> IsTextWrapped</code></li>
48 *  <li><code> RotateAngle</code></li>
49 *  <li><code> RotateReference</code></li>
50 * </ul> <p>
51 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
52 * @see com.sun.star.table.CellProperties
53 */
54 public class _CellProperties extends MultiPropertyTest {
55 
56 
57     /**
58      * This property is tested with custom property tester which
59      * switches between 'Default' and 'Result' style names.
60      */
_CellStyle()61     public void _CellStyle() {
62         testProperty("CellStyle", new PropertyTester() {
63             protected Object getNewValue(String name, Object old) {
64                 return "Default".equals(old) ? "Result" : "Default" ;
65             }
66         }) ;
67     }
68 
_UserDefinedAttributes()69     public void _UserDefinedAttributes() {
70         XNameContainer uda = null;
71         boolean res = false;
72         try {
73             uda = (XNameContainer) AnyConverter.toObject(
74                 new Type(XNameContainer.class),
75                     oObj.getPropertyValue("UserDefinedAttributes"));
76             AttributeData attr = new AttributeData();
77             attr.Namespace = "http://www.sun.com/staroffice/apitest/Cellprop";
78             attr.Type="CDATA";
79             attr.Value="true";
80             uda.insertByName("Cellprop:has-first-alien-attribute",attr);
81             String[] els = uda.getElementNames();
82             oObj.setPropertyValue("UserDefinedAttributes",uda);
83             uda = (XNameContainer) AnyConverter.toObject(
84                 new Type(XNameContainer.class),
85                     oObj.getPropertyValue("UserDefinedAttributes"));
86             els = uda.getElementNames();
87             Object obj = uda.getByName("Cellprop:has-first-alien-attribute");
88             res = true;
89         } catch (com.sun.star.beans.UnknownPropertyException upe) {
90             log.println("Don't know the Property 'UserDefinedAttributes'");
91         } catch (com.sun.star.lang.WrappedTargetException wte) {
92             log.println("WrappedTargetException while getting Property 'UserDefinedAttributes'");
93         } catch (com.sun.star.container.NoSuchElementException nee) {
94             log.println("added Element isn't part of the NameContainer");
95         } catch (com.sun.star.lang.IllegalArgumentException iae) {
96             log.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'");
97         } catch (com.sun.star.beans.PropertyVetoException pve) {
98             log.println("PropertyVetoException while getting Property 'UserDefinedAttributes'");
99         } catch (com.sun.star.container.ElementExistException eee) {
100             log.println("ElementExistException while getting Property 'UserDefinedAttributes'");
101         }
102         tRes.tested("UserDefinedAttributes",res);
103     }
104 
105 } // finish class _CellProperties
106 
107