1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.chart;
25 
26 import lib.MultiPropertyTest;
27 import lib.Status;
28 import lib.StatusException;
29 
30 import com.sun.star.beans.XPropertySet;
31 import com.sun.star.chart.XChartDocument;
32 import com.sun.star.chart.XDiagram;
33 import com.sun.star.uno.UnoRuntime;
34 
35 /**
36 * Testing <code>com.sun.star.chart.Chart3DBarProperties</code>
37 * service properties:
38 * <ul>
39 *  <li><code> SolidType</code></li>
40 * </ul> <p>
41 * This test needs the following object relations :
42 * <ul>
43 *  <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
44 *   to have reference to chart document </li>
45 *  <li> <code>'BAR'</code> (of type <code>XDiagram</code>):
46 *   relation that use as parameter for method setDiagram of chart document </li>
47 * <ul> <p>
48 * @see com.sun.star.chart.Chart3DBarProperties
49 * @see com.sun.star.chart.XChartDocument
50 * @see com.sun.star.chart.XDiagram
51 */
52 public class _Chart3DBarProperties extends MultiPropertyTest {
53 
54     /**
55     * Retrieves object relations and prepares a chart document.
56     * @throws StatusException if one of relations not found.
57     */
before()58     protected void before() {
59         log.println("Setting Diagram type to BarDiagram");
60         XChartDocument doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
61         if (doc == null) throw new StatusException(Status.failed
62             ("Relation 'CHARTDOC' not found"));
63 
64         XDiagram bar = (XDiagram) tEnv.getObjRelation("BAR");
65         if (bar == null) throw new StatusException(Status.failed
66             ("Relation 'BAR' not found"));
67 
68         doc.setDiagram(bar);
69         log.println("Change Diagram to 3D");
70         oObj = (XPropertySet)
71             UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
72         try {
73             oObj.setPropertyValue("Dim3D", new Boolean(true));
74         } catch(com.sun.star.lang.WrappedTargetException e) {
75             log.println("Couldn't change Diagram to 3D");
76             e.printStackTrace(log);
77             throw new StatusException("Couldn't change Diagram to 3D", e);
78         } catch(com.sun.star.lang.IllegalArgumentException 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.beans.PropertyVetoException 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.UnknownPropertyException 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         }
91     }
92 
93     /**
94     * Sets the diagram back to 2D as 2D rendering is much faster for the following tests.
95     */
after()96     protected void after() {
97         log.println("Setting Diagram back to 2D");
98         XChartDocument doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
99         if (doc == null) throw new StatusException(Status.failed
100             ("Relation 'CHARTDOC' not found"));
101 
102         log.println("Change Diagram to 3D");
103         oObj = (XPropertySet)
104             UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
105         try {
106             oObj.setPropertyValue("Dim3D", new Boolean(false));
107         } catch(com.sun.star.lang.WrappedTargetException e) {
108             log.println("Couldn't change Diagram back to 2D");
109             e.printStackTrace(log);
110             throw new StatusException("Couldn't change Diagram back to 2D", e);
111         } catch(com.sun.star.lang.IllegalArgumentException 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.beans.PropertyVetoException 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.UnknownPropertyException 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         }
124     }
125 
126 }  // finish class _Chart3DBarProperties
127 
128 
129