2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiPropertyTest
;
23 import lib
.StatusException
;
25 import com
.sun
.star
.beans
.XPropertySet
;
26 import com
.sun
.star
.chart
.XChartDocument
;
27 import com
.sun
.star
.chart
.XDiagram
;
28 import com
.sun
.star
.uno
.UnoRuntime
;
31 * Testing <code>com.sun.star.chart.ChartTwoAxisXSupplier</code>
32 * service properties :
34 * <li><code> HasSecondaryXAxis</code></li>
35 * <li><code> HasSecondaryXAxisDescription</code></li>
37 * This test needs the following object relations :
39 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
40 * to have reference to chart document </li>
41 * <li> <code>'BAR'</code> (of type <code>XDiagram</code>):
42 * relation that use as parameter for method setDiagram of chart document </li>
44 * @see com.sun.star.chart.ChartTwoAxisXSupplier
46 public class _ChartTwoAxisXSupplier
extends MultiPropertyTest
{
48 XChartDocument doc
= null;
49 XDiagram oldDiagram
= null;
52 * Retrieves object relations and prepares a chart document.
53 * @throws StatusException if one of relations not found.
56 protected void before() {
57 log
.println("Setting Diagram type to BarDiagram");
58 doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
59 if (doc
== null) throw new StatusException(Status
.failed
60 ("Relation 'CHARTDOC' not found"));
62 XDiagram bar
= (XDiagram
) tEnv
.getObjRelation("BAR");
63 if (bar
== null) throw new StatusException(Status
.failed
64 ("Relation 'BAR' not found"));
66 oldDiagram
= doc
.getDiagram();
69 log
.println("Set it to 3D");
70 oObj
= UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
72 oObj
.setPropertyValue("Dim3D", Boolean
.TRUE
);
73 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
74 log
.println("Exception while set property value");
75 e
.printStackTrace(log
);
76 throw new StatusException("Exception while set property value", e
);
77 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
78 log
.println("Exception while set property value");
79 e
.printStackTrace(log
);
80 throw new StatusException("Exception while set property value", e
);
81 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
82 log
.println("Exception while set property value");
83 e
.printStackTrace(log
);
84 throw new StatusException("Exception while set property value", e
);
85 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
86 log
.println("Exception while set property value");
87 e
.printStackTrace(log
);
88 throw new StatusException("Exception while set property value", e
);
93 * Sets the old diagram for a chart document.
96 protected void after() {
97 doc
.setDiagram(oldDiagram
);
99 } // EOF ChartTwoAxisXSupplier