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