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.LineDiagram</code>
32 * service properties :
34 * <li><code> SymbolType</code></li>
35 * <li><code> SymbolSize</code></li>
36 * <li><code> SymbolBitmapURL</code></li>
37 * <li><code> Lines</code></li>
38 * <li><code> SplineType</code></li>
40 * The following predefined files needed to complete the test:
42 * <li> <code>space-metal.jpg</code> :
43 * for test of property 'SymbolBitmapURL' </li>
44 * <li> <code>crazy-blue.jpg</code> :
45 * for test of property 'SymbolBitmapURL' </li>
47 * This test needs the following object relations :
49 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
50 * to have reference to chart document </li>
51 * <li> <code>'LINE'</code> (of type <code>XDiagram</code>):
52 * relation that use as parameter for method setDiagram of chart document </li>
54 * @see com.sun.star.chart.LineDiagram
56 public class _LineDiagram
extends MultiPropertyTest
{
58 XChartDocument doc
= null;
59 XDiagram oldDiagram
= null;
62 * Retrieves object relations.
63 * @throws StatusException If one of relations not found.
66 protected void before() {
67 log
.println("Setting Diagram type to LineDiagram");
68 doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
69 if (doc
== null) throw new StatusException(Status
.failed
70 ("Relation 'CHARTDOC' not found"));
72 XDiagram Line
= (XDiagram
) tEnv
.getObjRelation("LINE");
73 if (Line
== null) throw new StatusException(Status
.failed
74 ("Relation 'LINE' not found"));
76 oldDiagram
= doc
.getDiagram();
78 oObj
= UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
82 * Sets the old diagram for a chart document.
85 protected void after() {
86 doc
.setDiagram(oldDiagram
);
89 protected PropertyTester SymbolTester
= new PropertyTester() {
91 protected Object
getNewValue(String propName
, Object oldValue
)
92 throws java
.lang
.IllegalArgumentException
{
94 int a
= com
.sun
.star
.chart
.ChartSymbolType
.AUTO
;
95 int b
= com
.sun
.star
.chart
.ChartSymbolType
.NONE
;
96 if ( ((Integer
) oldValue
).intValue() == a
)
97 return Integer
.valueOf(b
); else
98 return Integer
.valueOf(a
);
102 protected PropertyTester SplineTester
= new PropertyTester() {
104 protected Object
getNewValue(String propName
, Object oldValue
)
105 throws java
.lang
.IllegalArgumentException
{
109 if ( ((Integer
) oldValue
).intValue() == a
)
110 return Integer
.valueOf(b
); else
111 return Integer
.valueOf(a
);
116 * Tests property 'SymbolType'.
118 public void _SymbolType() {
119 log
.println("Testing with custom Property tester") ;
120 testProperty("SymbolType", SymbolTester
) ;
122 oObj
.setPropertyValue("SymbolType",Integer
.valueOf(-2));
123 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
124 log
.println("Exception while set property value");
125 e
.printStackTrace(log
);
126 throw new StatusException("Exception while set property value", e
);
127 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
128 log
.println("Exception while set property value");
129 e
.printStackTrace(log
);
130 throw new StatusException("Exception while set property value", e
);
131 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
132 log
.println("Exception while set property value");
133 e
.printStackTrace(log
);
134 throw new StatusException("Exception while set property value", e
);
135 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
136 log
.println("Exception while set property value");
137 e
.printStackTrace(log
);
138 throw new StatusException("Exception while set property value", e
);
143 * Tests property 'SplineType'.
145 public void _SplineType() {
146 log
.println("Testing with custom Property tester") ;
147 testProperty("SplineType", SplineTester
) ;
151 * Tests property 'SymbolBitmapURL'.
153 public void _SymbolBitmapURL() {
154 log
.println("Testing with custom Property tester") ;
156 oObj
.setPropertyValue("SymbolType",
157 Integer
.valueOf(com
.sun
.star
.chart
.ChartSymbolType
.BITMAPURL
));
158 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
159 log
.println("Exception while set property value");
160 e
.printStackTrace(log
);
161 throw new StatusException("Exception while set property value", e
);
162 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
163 log
.println("Exception while set property value");
164 e
.printStackTrace(log
);
165 throw new StatusException("Exception while set property value", e
);
166 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
167 log
.println("Exception while set property value");
168 e
.printStackTrace(log
);
169 throw new StatusException("Exception while set property value", e
);
170 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
171 log
.println("Exception while set property value");
172 e
.printStackTrace(log
);
173 throw new StatusException("Exception while set property value", e
);
177 oObj
.setPropertyValue(
179 util
.utils
.getFullTestURL("space-metal.jpg") );
180 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
181 log
.println("Exception while set property value");
182 e
.printStackTrace(log
);
183 throw new StatusException("Exception while set property value", e
);
184 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
185 log
.println("Exception while set property value");
186 e
.printStackTrace(log
);
187 throw new StatusException("Exception while set property value", e
);
188 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
189 log
.println("Exception while set property value");
190 e
.printStackTrace(log
);
191 throw new StatusException("Exception while set property value", e
);
192 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
193 log
.println("Exception while set property value");
194 e
.printStackTrace(log
);
195 throw new StatusException("Exception while set property value", e
);