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.BarDiagram</code>
43 * <li><code>'Vertical'</code></li>
44 * <li><code>'Deep'</code></li>
45 * <li><code>'StackedBarsConnected'</code></li>
46 * <li><code>'NumberOfLines'</code></li>
48 * Properties testing is automated
49 * by <code>lib.MultiPropertyTest</code> except property
50 * <code>'NumberOfLines'</code>. <p>
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>
55 * <li> <code>'BAR'</code> (of type <code>XDiagram</code>):
56 * relation that use as parameter for method setDiagram of chart document </li>
58 * @see com.sun.star.chart.BarDiagram
59 * @see com.sun.star.chart.XChartDocument
60 * @see com.sun.star.chart.XDiagram
61 * @see lib.MultiPropertyTest
63 public class _BarDiagram
extends MultiPropertyTest
{
65 XChartDocument doc
= null;
66 XDiagram oldDiagram
= null;
69 * Retrieves object relations and prepares a chart document.
70 * @throws StatusException if one of relations not found.
72 protected void before() {
73 log
.println("Setting Diagram type to BarDiagram");
74 doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
75 if (doc
== null) throw new StatusException(Status
.failed
76 ("Relation 'CHARTDOC' not found"));
78 XDiagram bar
= (XDiagram
) tEnv
.getObjRelation("BAR");
79 if (bar
== null) throw new StatusException(Status
.failed
80 ("Relation 'BAR' not found"));
82 oldDiagram
= doc
.getDiagram();
85 UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
86 log
.println("Set it to 3D");
88 oObj
.setPropertyValue("Dim3D", new Boolean(true));
89 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
90 log
.println("Exception while set property value");
91 e
.printStackTrace(log
);
92 throw new StatusException("Exception while set property value", e
);
93 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
94 log
.println("Exception while set property value");
95 e
.printStackTrace(log
);
96 throw new StatusException("Exception while set property value", e
);
97 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
98 log
.println("Exception while set property value");
99 e
.printStackTrace(log
);
100 throw new StatusException("Exception while set property value", e
);
101 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
102 log
.println("Exception while set property value");
103 e
.printStackTrace(log
);
104 throw new StatusException("Exception while set property value", e
);
109 * Sets the old diagram for a chart document.
111 protected void after() {
112 doc
.setDiagram(oldDiagram
);
115 protected PropertyTester LineTester
= new PropertyTester() {
116 protected Object
getNewValue(String propName
, Object oldValue
)
117 throws java
.lang
.IllegalArgumentException
{
120 if ( ((Integer
) oldValue
).intValue() == a
)
121 return new Integer(b
); else
122 return new Integer(a
);
127 * Tests property 'NumberOfLines'.
128 * This property tests when diagram in 2D-mode only
129 * except all other properties. This property is currently supported by
130 * two dimensional vertical bar charts only.
132 public void _NumberOfLines() {
133 log
.println("Set it to 2D");
135 oObj
.setPropertyValue("Dim3D", new Boolean(false));
136 oObj
.setPropertyValue("Vertical", new Boolean(false));
137 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
138 log
.println("Exception while set property value");
139 e
.printStackTrace(log
);
140 throw new StatusException("Exception while set property value", e
);
141 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
142 log
.println("Exception while set property value");
143 e
.printStackTrace(log
);
144 throw new StatusException("Exception while set property value", e
);
145 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
146 log
.println("Exception while set property value");
147 e
.printStackTrace(log
);
148 throw new StatusException("Exception while set property value", e
);
149 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
150 log
.println("Exception while set property value");
151 e
.printStackTrace(log
);
152 throw new StatusException("Exception while set property value", e
);
155 log
.println("Testing with custom Property tester") ;
156 testProperty("NumberOfLines", LineTester
) ;