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.text.CellProperties</code>
42 * service properties :
44 * <li><code> BackColor</code></li>
45 * <li><code> BackGraphicURL</code></li>
46 * <li><code> BackGraphicFilter</code></li>
47 * <li><code> BackGraphicLocation</code></li>
48 * <li><code> NumberFormat</code></li>
49 * <li><code> BackTransparent</code></li>
50 * <li><code> LeftBorder</code></li>
51 * <li><code> RightBorder</code></li>
52 * <li><code> TopBorder</code></li>
53 * <li><code> BottomBorder</code></li>
54 * <li><code> LeftBorderDistance</code></li>
55 * <li><code> RightBorderDistance</code></li>
56 * <li><code> TopBorderDistance</code></li>
57 * <li><code> BottomBorderDistance</code></li>
58 * <li><code> UserDefinedAttributes</code></li>
59 * <li><code> TextSection</code></li>
60 * <li><code> IsProtected</code></li>
62 * This test needs the following object relations :
64 * <li> <code>'CellProperties.TextSection'</code> (of type
65 * <code>XInterface</code>):
66 * instance of <code>com.sun.star.text.TextSection</code></li>
68 * The following predefined files needed to complete the test:
70 * <li> <code> crazy-blue.jpg </code> : jpeg image used to test
71 * BackGraphicURL()</li>
72 * <li> <code> space-metal.jpg </code> : jpeg image used to test
73 * BackGraphicURL()</li>
75 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
76 * @see com.sun.star.text.CellProperties
78 public class _CellProperties
extends MultiPropertyTest
{
81 * This property can be void, so new value must be specified from
82 * corresponding object relation.
84 public void _TextSection() {
85 log
.println("Testing with custom Property tester") ;
86 testProperty("TextSection", new PropertyTester() {
87 protected Object
getNewValue(String propName
, Object oldValue
) {
88 return tEnv
.getObjRelation("CellProperties.TextSection");
95 * Redefined method returns value, that differs from property value.
97 public void _BackColor() {
98 final Short val1
= new Short( (short) 4 );
99 final Short val2
= new Short( (short) 6 );
100 log
.println("Testing with custom Property tester") ;
101 testProperty("BackColor", new PropertyTester() {
102 protected Object
getNewValue(String propName
, Object oldValue
) {
103 if ( oldValue
.equals(val1
) )
113 * Redefined method returns value, that differs from property value.
115 public void _BackGraphicURL() {
116 log
.println("Testing with custom Property tester") ;
117 testProperty("BackGraphicURL", new PropertyTester() {
118 protected Object
getNewValue(String propName
, Object oldValue
) {
119 if (oldValue
.equals(util
.utils
.getFullTestURL
120 ("space-metal.jpg")))
121 return util
.utils
.getFullTestURL("crazy-blue.jpg");
123 return util
.utils
.getFullTestURL("space-metal.jpg");
130 * Redefined method returns object, that contains changed property value.
132 public void _UserDefinedAttributes() {
133 log
.println("Testing with custom property tester");
134 testProperty("UserDefinedAttributes", new PropertyTester() {
135 protected Object
getNewValue(String propName
, Object oldValue
) {
136 XNameContainer NC
= null;
138 NC
= (XNameContainer
)
139 AnyConverter
.toObject(new Type(XNameContainer
.class),oldValue
);
140 NC
.insertByName("MyAttribute",
141 new AttributeData("","CDATA","Value"));
142 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
143 log
.println("Failed to check 'UserDefinedAttributes'");
144 e
.printStackTrace(log
);
145 } catch ( com
.sun
.star
.lang
.WrappedTargetException e
) {
146 log
.println("Failed to check 'UserDefinedAttributes'");
147 e
.printStackTrace(log
);
148 } catch ( com
.sun
.star
.container
.ElementExistException e
) {
149 log
.println("Failed to check 'UserDefinedAttributes'");
150 e
.printStackTrace(log
);
157 } //finish class _CellProperties