1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 package ifc.chart;
29 
30 import lib.MultiPropertyTest;
31 import lib.StatusException;
32 import util.ValueChanger;
33 
34 /**
35 * Testing <code>com.sun.star.chart.ChartAxis</code>
36 * service properties:
37 * <ul>
38 *  <li><code> ArrangeOrder</code></li>
39 *  <li><code> AutoMax</code></li>
40 *  <li><code> AutoMin</code></li>
41 *  <li><code> AutoOrigin</code></li>
42 *  <li><code> AutoStepHelp</code></li>
43 *  <li><code> AutoStepMain</code></li>
44 *  <li><code> DisplayLabels</code></li>
45 *  <li><code> GapWidth</code></li>
46 *  <li><code> HelpMarks</code></li>
47 *  <li><code> Logarithmic</code></li>
48 *  <li><code> Marks</code></li>
49 *  <li><code> Max</code></li>
50 *  <li><code> Min</code></li>
51 *  <li><code> NumberFormat</code></li>
52 *  <li><code> Origin</code></li>
53 *  <li><code> Overlap</code></li>
54 *  <li><code> StepHelp</code></li>
55 *  <li><code> StepMain</code></li>
56 *  <li><code> TextBreak</code></li>
57 *  <li><code> TextRotation</code></li>
58 *  <li><code> TextCanOverlap</code></li>
59 * </ul> <p>
60 * @see com.sun.star.chart.ChartAxis
61 */
62 public class _ChartAxis extends MultiPropertyTest {
63 
64     /**
65     * Tests property 'Max'.
66     * Property 'AutoOrigin' sets to true and property 'AutoMax'
67     * sets to false before test.
68     */
69     public void _Max() {
70         try {
71             //if AutoOrigin isn't true then this property works only when
72             //current Origin is less then new value of Max
73             oObj.setPropertyValue("AutoOrigin", new Boolean(true));
74             oObj.setPropertyValue("AutoMax",new Boolean(false));
75         } catch(com.sun.star.lang.WrappedTargetException e) {
76             log.println("Couldn't set property value");
77             e.printStackTrace(log);
78             throw new StatusException("Couldn't set property value", e);
79         } catch(com.sun.star.lang.IllegalArgumentException e) {
80             log.println("Couldn't set property value");
81             e.printStackTrace(log);
82             throw new StatusException("Couldn't set property value", e);
83         } catch(com.sun.star.beans.PropertyVetoException e) {
84             log.println("Couldn't set property value");
85             e.printStackTrace(log);
86             throw new StatusException("Couldn't set property value", e);
87         } catch(com.sun.star.beans.UnknownPropertyException e) {
88             log.println("Couldn't set property value");
89             e.printStackTrace(log);
90             throw new StatusException("Couldn't set property value", e);
91         }
92 
93         testProperty("Max");
94     }
95 
96     /**
97     * Tests property 'Min'.
98     * Property 'AutoOrigin' sets to true and property 'AutoMin'
99     * sets to false before test.
100     */
101     public void _Min() {
102         try {
103             //if AutoOrigin isn't true then this property works only when
104             //current Origin is greater then new value of Min
105             oObj.setPropertyValue("AutoOrigin", new Boolean(true));
106             oObj.setPropertyValue("AutoMin", new Boolean(false));
107         } catch(com.sun.star.lang.WrappedTargetException e) {
108             log.println("Couldn't set property value");
109             e.printStackTrace(log);
110             throw new StatusException("Couldn't set property value", e);
111         } catch(com.sun.star.lang.IllegalArgumentException e) {
112             log.println("Couldn't set property value");
113             e.printStackTrace(log);
114             throw new StatusException("Couldn't set property value", e);
115         } catch(com.sun.star.beans.PropertyVetoException e) {
116             log.println("Couldn't set property value");
117             e.printStackTrace(log);
118             throw new StatusException("Couldn't set property value", e);
119         } catch(com.sun.star.beans.UnknownPropertyException e) {
120             log.println("Couldn't set property value");
121             e.printStackTrace(log);
122             throw new StatusException("Couldn't set property value", e);
123         }
124 
125         testProperty("Min");
126     }
127 
128     /**
129     * Tests property 'Origin'.
130     * Property 'Logarithmic' sets to false before test.
131     */
132     public void _Origin() {
133         try {
134             oObj.setPropertyValue("Logarithmic",new Boolean(false));
135         } catch(com.sun.star.lang.WrappedTargetException e) {
136             log.println("Couldn't set property value");
137             e.printStackTrace(log);
138             throw new StatusException("Couldn't set property value", e);
139         } catch(com.sun.star.lang.IllegalArgumentException e) {
140             log.println("Couldn't set property value");
141             e.printStackTrace(log);
142             throw new StatusException("Couldn't set property value", e);
143         } catch(com.sun.star.beans.PropertyVetoException e) {
144             log.println("Couldn't set property value");
145             e.printStackTrace(log);
146             throw new StatusException("Couldn't set property value", e);
147         } catch(com.sun.star.beans.UnknownPropertyException e) {
148             log.println("Couldn't set property value");
149             e.printStackTrace(log);
150             throw new StatusException("Couldn't set property value", e);
151         }
152 
153         testProperty("Origin");
154     }
155 
156     protected PropertyTester StepMainTester = new PropertyTester() {
157         protected Object getNewValue(String propName, Object oldValue)
158                 throws java.lang.IllegalArgumentException {
159             Double ValueToSet = (Double) ValueChanger.changePValue(oldValue);
160             double stm = ValueToSet.doubleValue();
161             stm = stm / 5;
162             return new Double(stm);
163         }
164     };
165 
166     /**
167     * Tests property 'StepMain'.
168     * Property 'Logarithmic' and 'AutoStepMain' sets
169     * to false before test.
170     */
171     public void _StepMain() {
172         try {
173             oObj.setPropertyValue("AutoStepMain", new Boolean(false));
174             oObj.setPropertyValue("Logarithmic",new Boolean(false));
175         } catch(com.sun.star.lang.WrappedTargetException e) {
176             log.println("Couldn't set property value");
177             e.printStackTrace(log);
178             throw new StatusException("Couldn't set property value", e);
179         } catch(com.sun.star.lang.IllegalArgumentException e) {
180             log.println("Couldn't set property value");
181             e.printStackTrace(log);
182             throw new StatusException("Couldn't set property value", e);
183         } catch(com.sun.star.beans.PropertyVetoException e) {
184             log.println("Couldn't set property value");
185             e.printStackTrace(log);
186             throw new StatusException("Couldn't set property value", e);
187         } catch(com.sun.star.beans.UnknownPropertyException e) {
188             log.println("Couldn't set property value");
189             e.printStackTrace(log);
190             throw new StatusException("Couldn't set property value", e);
191         }
192 
193         testProperty("StepMain", StepMainTester);
194     }
195 }  // finish class _ChartAxis
196 
197