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.sheet;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldAutoShowInfo;
31*cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldLayoutInfo;
32*cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldReference;
33*cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldSortInfo;
34*cdf0e10cSrcweir import lib.MultiPropertyTest;
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir /**
37*cdf0e10cSrcweir * Testing <code>com.sun.star.sheet.DataPilotField</code>
38*cdf0e10cSrcweir * service properties :
39*cdf0e10cSrcweir * <ul>
40*cdf0e10cSrcweir *  <li><code> Orientation</code></li>
41*cdf0e10cSrcweir *  <li><code> Function</code></li>
42*cdf0e10cSrcweir * </ul> <p>
43*cdf0e10cSrcweir * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
44*cdf0e10cSrcweir * @see com.sun.star.sheet.DataPilotField
45*cdf0e10cSrcweir */
46*cdf0e10cSrcweir public class _DataPilotField extends MultiPropertyTest {
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir     /**
49*cdf0e10cSrcweir      *This class is destined to custom test of property <code>SortInfo</code>.
50*cdf0e10cSrcweir      */
51*cdf0e10cSrcweir     protected PropertyTester SortInfoTester = new PropertyTester() {
52*cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
53*cdf0e10cSrcweir             DataPilotFieldSortInfo sortInfo = new DataPilotFieldSortInfo();
54*cdf0e10cSrcweir 	    sortInfo.Mode = com.sun.star.sheet.DataPilotFieldSortMode.MANUAL;
55*cdf0e10cSrcweir             sortInfo.IsAscending = false;
56*cdf0e10cSrcweir             sortInfo.Field = "COL1";
57*cdf0e10cSrcweir             log.println("Having Value and returning a new one");
58*cdf0e10cSrcweir             return sortInfo.equals(oldValue) ? null : sortInfo;
59*cdf0e10cSrcweir         }
60*cdf0e10cSrcweir     };
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     /**
63*cdf0e10cSrcweir      * Test property <code>SortInfo</code> using custom <code>PropertyTest</code>.
64*cdf0e10cSrcweir      */
65*cdf0e10cSrcweir     public void _SortInfo() {
66*cdf0e10cSrcweir         testProperty("SortInfo", SortInfoTester);
67*cdf0e10cSrcweir     }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     public void _HasSortInfo() {
70*cdf0e10cSrcweir         requiredMethod("SortInfo");
71*cdf0e10cSrcweir         testProperty("HasSortInfo");
72*cdf0e10cSrcweir     }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     /**
75*cdf0e10cSrcweir      *This class is destined to custom test of property <code>LayoutInfo</code>.
76*cdf0e10cSrcweir      */
77*cdf0e10cSrcweir     protected PropertyTester LayoutInfoTester = new PropertyTester() {
78*cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
79*cdf0e10cSrcweir             DataPilotFieldLayoutInfo layoutInfo = new DataPilotFieldLayoutInfo();
80*cdf0e10cSrcweir             layoutInfo.LayoutMode = com.sun.star.sheet.DataPilotFieldLayoutMode.OUTLINE_SUBTOTALS_BOTTOM;
81*cdf0e10cSrcweir             layoutInfo.AddEmptyLines = true;
82*cdf0e10cSrcweir             log.println("Having Value and returning a new one");
83*cdf0e10cSrcweir             return layoutInfo.equals(oldValue) ? null : layoutInfo;
84*cdf0e10cSrcweir         }
85*cdf0e10cSrcweir     };
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     /**
88*cdf0e10cSrcweir      * Test property <code>LayoutInfo</code> using custom <code>PropertyTest</code>.
89*cdf0e10cSrcweir      */
90*cdf0e10cSrcweir     public void _LayoutInfo() {
91*cdf0e10cSrcweir         testProperty("LayoutInfo", LayoutInfoTester);
92*cdf0e10cSrcweir     }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     public void _HasLayoutInfo() {
95*cdf0e10cSrcweir         requiredMethod("LayoutInfo");
96*cdf0e10cSrcweir         testProperty("HasLayoutInfo");
97*cdf0e10cSrcweir     }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     /**
100*cdf0e10cSrcweir      *This class is destined to custom test of property <code>AutoShowInfo</code>.
101*cdf0e10cSrcweir      */
102*cdf0e10cSrcweir     protected PropertyTester AutoShowInfoTester = new PropertyTester() {
103*cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
104*cdf0e10cSrcweir             DataPilotFieldAutoShowInfo AutoShowInfo = new DataPilotFieldAutoShowInfo();
105*cdf0e10cSrcweir             AutoShowInfo.DataField = "Col1";
106*cdf0e10cSrcweir             AutoShowInfo.IsEnabled = true;
107*cdf0e10cSrcweir             log.println("Having Value and returning a new one");
108*cdf0e10cSrcweir             return AutoShowInfo.equals(oldValue) ? null : AutoShowInfo;
109*cdf0e10cSrcweir         }
110*cdf0e10cSrcweir     };
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     /**
113*cdf0e10cSrcweir      * Test property <code>AutoShowInfo</code> using custom <code>PropertyTest</code>.
114*cdf0e10cSrcweir      */
115*cdf0e10cSrcweir     public void _AutoShowInfo() {
116*cdf0e10cSrcweir         testProperty("AutoShowInfo", AutoShowInfoTester);
117*cdf0e10cSrcweir     }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     public void _HasAutoShowInfo() {
120*cdf0e10cSrcweir         requiredMethod("AutoShowInfo");
121*cdf0e10cSrcweir         testProperty("HasAutoShowInfo");
122*cdf0e10cSrcweir     }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     /**
125*cdf0e10cSrcweir      *This class is destined to custom test of property <code>Reference</code>.
126*cdf0e10cSrcweir      */
127*cdf0e10cSrcweir     protected PropertyTester ReferenceTester = new PropertyTester() {
128*cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
129*cdf0e10cSrcweir             DataPilotFieldReference Reference = new DataPilotFieldReference();
130*cdf0e10cSrcweir             Reference.ReferenceField="Col1";
131*cdf0e10cSrcweir             Reference.ReferenceItemType = com.sun.star.sheet.DataPilotFieldReferenceItemType.NAMED;
132*cdf0e10cSrcweir             log.println("Having Value and returning a new one");
133*cdf0e10cSrcweir             return Reference.equals(oldValue) ? null : Reference;
134*cdf0e10cSrcweir         }
135*cdf0e10cSrcweir     };
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     /**
138*cdf0e10cSrcweir      * Test property <code>Reference</code> using custom <code>PropertyTest</code>.
139*cdf0e10cSrcweir      */
140*cdf0e10cSrcweir     public void _Reference() {
141*cdf0e10cSrcweir         testProperty("Reference", ReferenceTester);
142*cdf0e10cSrcweir     }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     public void _HasReference() {
145*cdf0e10cSrcweir         requiredMethod("Reference");
146*cdf0e10cSrcweir         testProperty("HasReference");
147*cdf0e10cSrcweir     }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     /*
150*cdf0e10cSrcweir      * this property can only set a true value to false, fo ungrouping purposes
151*cdf0e10cSrcweir      */
152*cdf0e10cSrcweir     public void _IsGroupField() {
153*cdf0e10cSrcweir         boolean result = true;
154*cdf0e10cSrcweir         try {
155*cdf0e10cSrcweir             Boolean propValue = (Boolean) oObj.getPropertyValue ("IsGroupField");
156*cdf0e10cSrcweir             if (propValue.booleanValue ()) {
157*cdf0e10cSrcweir                 oObj.setPropertyValue ("IsGroupField", Boolean.FALSE);
158*cdf0e10cSrcweir                 Boolean propV = (Boolean) oObj.getPropertyValue ("IsGroupField");
159*cdf0e10cSrcweir                 result = !propV.booleanValue ();
160*cdf0e10cSrcweir             }
161*cdf0e10cSrcweir         } catch (Exception e) {
162*cdf0e10cSrcweir             log.println ("Exception while getting Property 'IsGroupField'"+e);
163*cdf0e10cSrcweir             result = false;
164*cdf0e10cSrcweir         }
165*cdf0e10cSrcweir         tRes.tested ("IsGroupField",result);
166*cdf0e10cSrcweir     }
167*cdf0e10cSrcweir }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 
170