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.Chart3DBarProperties</code>
43 * <li><code> SolidType</code></li>
45 * This test needs the following object relations :
47 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
48 * to have reference to chart document </li>
49 * <li> <code>'BAR'</code> (of type <code>XDiagram</code>):
50 * relation that use as parameter for method setDiagram of chart document </li>
52 * @see com.sun.star.chart.Chart3DBarProperties
53 * @see com.sun.star.chart.XChartDocument
54 * @see com.sun.star.chart.XDiagram
56 public class _Chart3DBarProperties
extends MultiPropertyTest
{
59 * Retrieves object relations and prepares a chart document.
60 * @throws StatusException if one of relations not found.
62 protected void before() {
63 log
.println("Setting Diagram type to BarDiagram");
64 XChartDocument doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
65 if (doc
== null) throw new StatusException(Status
.failed
66 ("Relation 'CHARTDOC' not found"));
68 XDiagram bar
= (XDiagram
) tEnv
.getObjRelation("BAR");
69 if (bar
== null) throw new StatusException(Status
.failed
70 ("Relation 'BAR' not found"));
73 log
.println("Change Diagram to 3D");
75 UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
77 oObj
.setPropertyValue("Dim3D", new Boolean(true));
78 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
79 log
.println("Couldn't change Diagram to 3D");
80 e
.printStackTrace(log
);
81 throw new StatusException("Couldn't change Diagram to 3D", e
);
82 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
83 log
.println("Couldn't change Diagram to 3D");
84 e
.printStackTrace(log
);
85 throw new StatusException("Couldn't change Diagram to 3D", e
);
86 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
87 log
.println("Couldn't change Diagram to 3D");
88 e
.printStackTrace(log
);
89 throw new StatusException("Couldn't change Diagram to 3D", e
);
90 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
91 log
.println("Couldn't change Diagram to 3D");
92 e
.printStackTrace(log
);
93 throw new StatusException("Couldn't change Diagram to 3D", e
);
98 * Sets the diagram back to 2D as 2D rendering is much faster for the following tests.
100 protected void after() {
101 log
.println("Setting Diagram back to 2D");
102 XChartDocument doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
103 if (doc
== null) throw new StatusException(Status
.failed
104 ("Relation 'CHARTDOC' not found"));
106 log
.println("Change Diagram to 3D");
107 oObj
= (XPropertySet
)
108 UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
110 oObj
.setPropertyValue("Dim3D", new Boolean(false));
111 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
112 log
.println("Couldn't change Diagram back to 2D");
113 e
.printStackTrace(log
);
114 throw new StatusException("Couldn't change Diagram back to 2D", e
);
115 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
116 log
.println("Couldn't change Diagram back to 2D");
117 e
.printStackTrace(log
);
118 throw new StatusException("Couldn't change Diagram back to 2D", e
);
119 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
120 log
.println("Couldn't change Diagram back to 2D");
121 e
.printStackTrace(log
);
122 throw new StatusException("Couldn't change Diagram back to 2D", e
);
123 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
124 log
.println("Couldn't change Diagram back to 2D");
125 e
.printStackTrace(log
);
126 throw new StatusException("Couldn't change Diagram back to 2D", e
);
130 } // finish class _Chart3DBarProperties