1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _CellProperties.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiPropertyTest
;
35 import com
.sun
.star
.container
.XNameContainer
;
36 import com
.sun
.star
.uno
.AnyConverter
;
37 import com
.sun
.star
.uno
.Type
;
38 import com
.sun
.star
.xml
.AttributeData
;
41 * Testing <code>com.sun.star.table.CellProperties</code>
42 * service properties :
44 * <li><code> CellStyle</code></li>
45 * <li><code> CellBackColor</code></li>
46 * <li><code> IsCellBackgroundTransparent</code></li>
47 * <li><code> NumberFormat</code></li>
48 * <li><code> ShadowFormat</code></li>
49 * <li><code> HoriJustify</code></li>
50 * <li><code> VertJustify</code></li>
51 * <li><code> Orientation</code></li>
52 * <li><code> CellProtection</code></li>
53 * <li><code> TableBorder</code></li>
54 * <li><code> IsTextWrapped</code></li>
55 * <li><code> RotateAngle</code></li>
56 * <li><code> RotateReference</code></li>
58 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
59 * @see com.sun.star.table.CellProperties
61 public class _CellProperties
extends MultiPropertyTest
{
65 * This property is tested with custom property tester which
66 * switches between 'Default' and 'Result' style names.
68 public void _CellStyle() {
69 testProperty("CellStyle", new PropertyTester() {
70 protected Object
getNewValue(String name
, Object old
) {
71 return "Default".equals(old
) ?
"Result" : "Default" ;
76 public void _UserDefinedAttributes() {
77 XNameContainer uda
= null;
80 uda
= (XNameContainer
) AnyConverter
.toObject(
81 new Type(XNameContainer
.class),
82 oObj
.getPropertyValue("UserDefinedAttributes"));
83 AttributeData attr
= new AttributeData();
84 attr
.Namespace
= "http://www.sun.com/staroffice/apitest/Cellprop";
87 uda
.insertByName("Cellprop:has-first-alien-attribute",attr
);
88 String
[] els
= uda
.getElementNames();
89 oObj
.setPropertyValue("UserDefinedAttributes",uda
);
90 uda
= (XNameContainer
) AnyConverter
.toObject(
91 new Type(XNameContainer
.class),
92 oObj
.getPropertyValue("UserDefinedAttributes"));
93 els
= uda
.getElementNames();
94 Object obj
= uda
.getByName("Cellprop:has-first-alien-attribute");
96 } catch (com
.sun
.star
.beans
.UnknownPropertyException upe
) {
97 log
.println("Don't know the Property 'UserDefinedAttributes'");
98 } catch (com
.sun
.star
.lang
.WrappedTargetException wte
) {
99 log
.println("WrappedTargetException while getting Property 'UserDefinedAttributes'");
100 } catch (com
.sun
.star
.container
.NoSuchElementException nee
) {
101 log
.println("added Element isn't part of the NameContainer");
102 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
103 log
.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'");
104 } catch (com
.sun
.star
.beans
.PropertyVetoException pve
) {
105 log
.println("PropertyVetoException while getting Property 'UserDefinedAttributes'");
106 } catch (com
.sun
.star
.container
.ElementExistException eee
) {
107 log
.println("ElementExistException while getting Property 'UserDefinedAttributes'");
109 tRes
.tested("UserDefinedAttributes",res
);
112 } // finish class _CellProperties