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 URLTester
= new PropertyTester() {
91 protected Object
getNewValue(String propName
, Object oldValue
)
92 throws java
.lang
.IllegalArgumentException
{
93 if (oldValue
.equals(util
.utils
.getFullTestURL("space-metal.jpg")))
94 return util
.utils
.getFullTestURL("crazy-blue.jpg"); else
95 return util
.utils
.getFullTestURL("space-metal.jpg");
99 protected PropertyTester SymbolTester
= new PropertyTester() {
101 protected Object
getNewValue(String propName
, Object oldValue
)
102 throws java
.lang
.IllegalArgumentException
{
104 int a
= com
.sun
.star
.chart
.ChartSymbolType
.AUTO
;
105 int b
= com
.sun
.star
.chart
.ChartSymbolType
.NONE
;
106 if ( ((Integer
) oldValue
).intValue() == a
)
107 return Integer
.valueOf(b
); else
108 return Integer
.valueOf(a
);
112 protected PropertyTester SplineTester
= new PropertyTester() {
114 protected Object
getNewValue(String propName
, Object oldValue
)
115 throws java
.lang
.IllegalArgumentException
{
119 if ( ((Integer
) oldValue
).intValue() == a
)
120 return Integer
.valueOf(b
); else
121 return Integer
.valueOf(a
);
126 * Tests property 'SymbolType'.
128 public void _SymbolType() {
129 log
.println("Testing with custom Property tester") ;
130 testProperty("SymbolType", SymbolTester
) ;
132 oObj
.setPropertyValue("SymbolType",Integer
.valueOf(-2));
133 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
134 log
.println("Exception while set property value");
135 e
.printStackTrace(log
);
136 throw new StatusException("Exception while set property value", e
);
137 } catch(com
.sun
.star
.lang
.IllegalArgumentException 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
.beans
.PropertyVetoException 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
.UnknownPropertyException e
) {
146 log
.println("Exception while set property value");
147 e
.printStackTrace(log
);
148 throw new StatusException("Exception while set property value", e
);
153 * Tests property 'SplineType'.
155 public void _SplineType() {
156 log
.println("Testing with custom Property tester") ;
157 testProperty("SplineType", SplineTester
) ;
161 * Tests property 'SymbolBitmapURL'.
163 public void _SymbolBitmapURL() {
164 log
.println("Testing with custom Property tester") ;
166 oObj
.setPropertyValue("SymbolType",
167 Integer
.valueOf(com
.sun
.star
.chart
.ChartSymbolType
.BITMAPURL
));
168 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
169 log
.println("Exception while set property value");
170 e
.printStackTrace(log
);
171 throw new StatusException("Exception while set property value", e
);
172 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
173 log
.println("Exception while set property value");
174 e
.printStackTrace(log
);
175 throw new StatusException("Exception while set property value", e
);
176 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
177 log
.println("Exception while set property value");
178 e
.printStackTrace(log
);
179 throw new StatusException("Exception while set property value", e
);
180 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
181 log
.println("Exception while set property value");
182 e
.printStackTrace(log
);
183 throw new StatusException("Exception while set property value", e
);
186 testProperty("SymbolBitmapURL", URLTester
) ;