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
.uno
.UnoRuntime
;
39 * Testing <code>com.sun.star.chart.ChartAxisYSupplier</code>
40 * service properties :
42 * <li><code> HasYAxis</code></li>
43 * <li><code> HasYAxisDescription</code></li>
44 * <li><code> HasYAxisGrid</code></li>
45 * <li><code> HasYAxisHelpGrid</code></li>
46 * <li><code> HasYAxisTitle</code></li>
48 * This test needs the following object relations :
50 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
51 * to have reference to chart document </li>
53 * @see com.sun.star.chart.ChartAxisYSupplier
55 public class _ChartAxisYSupplier
extends MultiPropertyTest
{
58 * Retrieves object relations and prepares a chart document.
59 * @throws StatusException if one of relations not found.
61 protected void before() {
62 XChartDocument doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
63 if (doc
== null) throw new StatusException(Status
.failed
64 ("Relation 'CHARTDOC' not found"));
67 UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
70 public void _HasYAxis() {
72 log
.println("Property HasYAxis");
73 boolean res
= ((Boolean
)oObj
.getPropertyValue(
74 "HasYAxis")).booleanValue();
76 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
77 // test connected property HasYAxisDescription
78 if (!((Boolean
)oObj
.getPropertyValue(
79 "HasYAxisDescription")).booleanValue())
80 oObj
.setPropertyValue("HasYAxisDescription", Boolean
.TRUE
);
82 oObj
.setPropertyValue("HasYAxis", Boolean
.FALSE
);
83 boolean setVal
= ((Boolean
)oObj
.getPropertyValue(
84 "HasYAxis")).booleanValue();
85 log
.println("Start value: " + setVal
);
86 // description should also be false now
87 setVal
|= ((Boolean
)oObj
.getPropertyValue(
88 "HasYAxisDescription")).booleanValue();
89 log
.println("Connected value axis description: " + setVal
);
91 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
92 setVal
|= !((Boolean
)oObj
.getPropertyValue(
93 "HasYAxis")).booleanValue();
94 log
.println("Changed value: " + !setVal
);
96 // description should be true again
97 setVal
|= !((Boolean
)oObj
.getPropertyValue(
98 "HasYAxisDescription")).booleanValue();
99 log
.println("Changed connected value axis description: "+!setVal
);
101 tRes
.tested("HasYAxis", !setVal
);
102 // leave axis untouched
103 oObj
.setPropertyValue("HasYAxis", new Boolean(res
));
105 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
106 log
.println(e
.getMessage());
107 e
.printStackTrace(log
);
108 tRes
.tested("HasYAxis", false);
110 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
111 log
.println(e
.getMessage());
112 e
.printStackTrace(log
);
113 tRes
.tested("HasYAxis", false);
115 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
116 log
.println(e
.getMessage());
117 e
.printStackTrace(log
);
118 tRes
.tested("HasYAxis", false);
120 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
121 log
.println(e
.getMessage());
122 e
.printStackTrace(log
);
123 tRes
.tested("HasYAxis", false);
127 public void _HasYAxisDescription() {
128 requiredMethod("HasYAxis");
130 log
.println("Property HasYAxisDescription");
131 if (!((Boolean
)oObj
.getPropertyValue("HasYAxis")).booleanValue())
132 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
134 boolean res
= ((Boolean
)oObj
.getPropertyValue(
135 "HasYAxisDescription")).booleanValue();
136 log
.println("Start value: " + res
);
138 oObj
.setPropertyValue("HasYAxisDescription", new Boolean(!res
));
139 boolean setValue
= ((Boolean
)oObj
.getPropertyValue(
140 "HasYAxisDescription")).booleanValue();
141 log
.println("Changed value: " + setValue
);
142 tRes
.tested("HasYAxisDescription", res
!= setValue
);
144 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
145 log
.println(e
.getMessage());
146 e
.printStackTrace(log
);
147 tRes
.tested("HasYAxisDescription", false);
149 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
150 log
.println(e
.getMessage());
151 e
.printStackTrace(log
);
152 tRes
.tested("HasYAxisDescription", false);
154 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
155 log
.println(e
.getMessage());
156 e
.printStackTrace(log
);
157 tRes
.tested("HasYAxisDescription", false);
159 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
160 log
.println(e
.getMessage());
161 e
.printStackTrace(log
);
162 tRes
.tested("HasYAxisDescription", false);
166 } // EOF ChartAxisYSupplier