1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import lib
.MultiPropertyTest
;
32 import lib
.StatusException
;
34 import com
.sun
.star
.beans
.XPropertySet
;
35 import com
.sun
.star
.chart
.XChartDocument
;
36 import com
.sun
.star
.chart
.XDiagram
;
37 import com
.sun
.star
.uno
.UnoRuntime
;
40 * Testing <code>com.sun.star.chart.ChartAxisZSupplier</code>
41 * service properties :
43 * <li><code> HasZAxis</code></li>
44 * <li><code> HasZAxisDescription</code></li>
45 * <li><code> HasZAxisGrid</code></li>
46 * <li><code> HasZAxisHelpGrid</code></li>
47 * <li><code> HasZAxisTitle</code></li>
49 * This test needs the following object relations :
51 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
52 * to have reference to chart document </li>
53 * <li> <code>'BAR'</code> (of type <code>XDiagram</code>):
54 * relation that use as parameter for method setDiagram of chart document</li>
56 * @see com.sun.star.chart.ChartAxisZSupplier
58 public class _ChartAxisZSupplier
extends MultiPropertyTest
{
61 * Retrieves object relations and prepares a chart document.
62 * @throws StatusException if one of relations not found.
64 protected void before() {
65 log
.println("Setting Diagram type to BarDiagram");
66 XChartDocument doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
67 if (doc
== null) throw new StatusException(Status
.failed
68 ("Relation 'CHARTDOC' not found"));
70 XDiagram bar
= (XDiagram
) tEnv
.getObjRelation("BAR");
71 if (bar
== null) throw new StatusException(Status
.failed
72 ("Relation 'BAR' not found"));
75 log
.println("Set it to 3D");
77 UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
79 oObj
.setPropertyValue("Dim3D", new Boolean(true));
80 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
81 log
.println("Exception while set property value");
82 e
.printStackTrace(log
);
83 throw new StatusException("Exception while set property value", e
);
84 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
85 log
.println("Exception while set property value");
86 e
.printStackTrace(log
);
87 throw new StatusException("Exception while set property value", e
);
88 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
89 log
.println("Exception while set property value");
90 e
.printStackTrace(log
);
91 throw new StatusException("Exception while set property value", e
);
92 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
93 log
.println("Exception while set property value");
94 e
.printStackTrace(log
);
95 throw new StatusException("Exception while set property value", e
);
99 public void _HasZAxis() {
101 log
.println("Property HasZAxis");
102 boolean res
= ((Boolean
)oObj
.getPropertyValue(
103 "HasZAxis")).booleanValue();
105 oObj
.setPropertyValue("HasZAxis", Boolean
.TRUE
);
106 // test connected property HasZAxisDescription
107 if (!((Boolean
)oObj
.getPropertyValue(
108 "HasZAxisDescription")).booleanValue())
109 oObj
.setPropertyValue("HasZAxisDescription", Boolean
.TRUE
);
111 oObj
.setPropertyValue("HasZAxis", Boolean
.FALSE
);
112 boolean setVal
= ((Boolean
)oObj
.getPropertyValue(
113 "HasZAxis")).booleanValue();
114 log
.println("Start value: " + setVal
);
115 // description should also be false now
116 setVal
|= ((Boolean
)oObj
.getPropertyValue(
117 "HasZAxisDescription")).booleanValue();
118 log
.println("Connected value axis description: " + setVal
);
120 oObj
.setPropertyValue("HasZAxis", Boolean
.TRUE
);
121 setVal
|= !((Boolean
)oObj
.getPropertyValue(
122 "HasZAxis")).booleanValue();
123 log
.println("Changed value: " + !setVal
);
125 // description should be true again
126 setVal
|= !((Boolean
)oObj
.getPropertyValue(
127 "HasZAxisDescription")).booleanValue();
128 log
.println("Changed connected value axis description: " + !setVal
);
130 tRes
.tested("HasZAxis", !setVal
);
131 // leave axis untouched
132 oObj
.setPropertyValue("HasZAxis", new Boolean(res
));
134 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
135 log
.println(e
.getMessage());
136 e
.printStackTrace(log
);
137 tRes
.tested("HasZAxis", false);
139 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
140 log
.println(e
.getMessage());
141 e
.printStackTrace(log
);
142 tRes
.tested("HasZAxis", false);
144 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
145 log
.println(e
.getMessage());
146 e
.printStackTrace(log
);
147 tRes
.tested("HasZAxis", false);
149 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
150 log
.println(e
.getMessage());
151 e
.printStackTrace(log
);
152 tRes
.tested("HasZAxis", false);
156 public void _HasZAxisDescription() {
157 requiredMethod("HasZAxis");
159 log
.println("Property HasZAxisDescription");
160 if (!((Boolean
)oObj
.getPropertyValue("HasZAxis")).booleanValue())
161 oObj
.setPropertyValue("HasZAxis", Boolean
.TRUE
);
163 boolean res
= ((Boolean
)oObj
.getPropertyValue(
164 "HasZAxisDescription")).booleanValue();
165 log
.println("Start value: " + res
);
167 oObj
.setPropertyValue("HasZAxisDescription", new Boolean(!res
));
168 boolean setValue
= ((Boolean
)oObj
.getPropertyValue(
169 "HasZAxisDescription")).booleanValue();
170 log
.println("Changed value: " + setValue
);
171 tRes
.tested("HasZAxisDescription", res
!= setValue
);
173 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
174 log
.println(e
.getMessage());
175 e
.printStackTrace(log
);
176 tRes
.tested("HasZAxisDescription", false);
178 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
179 log
.println(e
.getMessage());
180 e
.printStackTrace(log
);
181 tRes
.tested("HasZAxisDescription", false);
183 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
184 log
.println(e
.getMessage());
185 e
.printStackTrace(log
);
186 tRes
.tested("HasZAxisDescription", false);
188 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
189 log
.println(e
.getMessage());
190 e
.printStackTrace(log
);
191 tRes
.tested("HasZAxisDescription", false);
197 * Forces environment recreation.
199 protected void after() {
200 disposeEnvironment();
203 } // EOF ChartAxisZSupplier