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: _ChartAxisYSupplier.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 lib
.StatusException
;
37 import com
.sun
.star
.beans
.XPropertySet
;
38 import com
.sun
.star
.chart
.XChartDocument
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
42 * Testing <code>com.sun.star.chart.ChartAxisYSupplier</code>
43 * service properties :
45 * <li><code> HasYAxis</code></li>
46 * <li><code> HasYAxisDescription</code></li>
47 * <li><code> HasYAxisGrid</code></li>
48 * <li><code> HasYAxisHelpGrid</code></li>
49 * <li><code> HasYAxisTitle</code></li>
51 * This test needs the following object relations :
53 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
54 * to have reference to chart document </li>
56 * @see com.sun.star.chart.ChartAxisYSupplier
58 public class _ChartAxisYSupplier
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 XChartDocument doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
66 if (doc
== null) throw new StatusException(Status
.failed
67 ("Relation 'CHARTDOC' not found"));
70 UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
73 public void _HasYAxis() {
75 log
.println("Property HasYAxis");
76 boolean res
= ((Boolean
)oObj
.getPropertyValue(
77 "HasYAxis")).booleanValue();
79 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
80 // test connected property HasYAxisDescription
81 if (!((Boolean
)oObj
.getPropertyValue(
82 "HasYAxisDescription")).booleanValue())
83 oObj
.setPropertyValue("HasYAxisDescription", Boolean
.TRUE
);
85 oObj
.setPropertyValue("HasYAxis", Boolean
.FALSE
);
86 boolean setVal
= ((Boolean
)oObj
.getPropertyValue(
87 "HasYAxis")).booleanValue();
88 log
.println("Start value: " + setVal
);
89 // description should also be false now
90 setVal
|= ((Boolean
)oObj
.getPropertyValue(
91 "HasYAxisDescription")).booleanValue();
92 log
.println("Connected value axis description: " + setVal
);
94 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
95 setVal
|= !((Boolean
)oObj
.getPropertyValue(
96 "HasYAxis")).booleanValue();
97 log
.println("Changed value: " + !setVal
);
99 // description should be true again
100 setVal
|= !((Boolean
)oObj
.getPropertyValue(
101 "HasYAxisDescription")).booleanValue();
102 log
.println("Changed connected value axis description: "+!setVal
);
104 tRes
.tested("HasYAxis", !setVal
);
105 // leave axis untouched
106 oObj
.setPropertyValue("HasYAxis", new Boolean(res
));
108 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
109 log
.println(e
.getMessage());
110 e
.printStackTrace(log
);
111 tRes
.tested("HasYAxis", false);
113 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
114 log
.println(e
.getMessage());
115 e
.printStackTrace(log
);
116 tRes
.tested("HasYAxis", false);
118 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
119 log
.println(e
.getMessage());
120 e
.printStackTrace(log
);
121 tRes
.tested("HasYAxis", false);
123 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
124 log
.println(e
.getMessage());
125 e
.printStackTrace(log
);
126 tRes
.tested("HasYAxis", false);
130 public void _HasYAxisDescription() {
131 requiredMethod("HasYAxis");
133 log
.println("Property HasYAxisDescription");
134 if (!((Boolean
)oObj
.getPropertyValue("HasYAxis")).booleanValue())
135 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
137 boolean res
= ((Boolean
)oObj
.getPropertyValue(
138 "HasYAxisDescription")).booleanValue();
139 log
.println("Start value: " + res
);
141 oObj
.setPropertyValue("HasYAxisDescription", new Boolean(!res
));
142 boolean setValue
= ((Boolean
)oObj
.getPropertyValue(
143 "HasYAxisDescription")).booleanValue();
144 log
.println("Changed value: " + setValue
);
145 tRes
.tested("HasYAxisDescription", res
!= setValue
);
147 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
148 log
.println(e
.getMessage());
149 e
.printStackTrace(log
);
150 tRes
.tested("HasYAxisDescription", false);
152 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
153 log
.println(e
.getMessage());
154 e
.printStackTrace(log
);
155 tRes
.tested("HasYAxisDescription", false);
157 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
158 log
.println(e
.getMessage());
159 e
.printStackTrace(log
);
160 tRes
.tested("HasYAxisDescription", false);
162 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
163 log
.println(e
.getMessage());
164 e
.printStackTrace(log
);
165 tRes
.tested("HasYAxisDescription", false);
169 } // EOF ChartAxisYSupplier