1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.sheet;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldAutoShowInfo;
27cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldLayoutInfo;
28cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldReference;
29cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldSortInfo;
30cdf0e10cSrcweir import lib.MultiPropertyTest;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir /**
33cdf0e10cSrcweir * Testing <code>com.sun.star.sheet.DataPilotField</code>
34cdf0e10cSrcweir * service properties :
35cdf0e10cSrcweir * <ul>
36cdf0e10cSrcweir *  <li><code> Orientation</code></li>
37cdf0e10cSrcweir *  <li><code> Function</code></li>
38cdf0e10cSrcweir * </ul> <p>
39cdf0e10cSrcweir * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
40cdf0e10cSrcweir * @see com.sun.star.sheet.DataPilotField
41cdf0e10cSrcweir */
42cdf0e10cSrcweir public class _DataPilotField extends MultiPropertyTest {
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     /**
45cdf0e10cSrcweir      *This class is destined to custom test of property <code>SortInfo</code>.
46cdf0e10cSrcweir      */
47cdf0e10cSrcweir     protected PropertyTester SortInfoTester = new PropertyTester() {
48cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
49cdf0e10cSrcweir             DataPilotFieldSortInfo sortInfo = new DataPilotFieldSortInfo();
50cdf0e10cSrcweir 	    sortInfo.Mode = com.sun.star.sheet.DataPilotFieldSortMode.MANUAL;
51cdf0e10cSrcweir             sortInfo.IsAscending = false;
52cdf0e10cSrcweir             sortInfo.Field = "COL1";
53cdf0e10cSrcweir             log.println("Having Value and returning a new one");
54cdf0e10cSrcweir             return sortInfo.equals(oldValue) ? null : sortInfo;
55cdf0e10cSrcweir         }
56cdf0e10cSrcweir     };
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     /**
59cdf0e10cSrcweir      * Test property <code>SortInfo</code> using custom <code>PropertyTest</code>.
60cdf0e10cSrcweir      */
_SortInfo()61cdf0e10cSrcweir     public void _SortInfo() {
62cdf0e10cSrcweir         testProperty("SortInfo", SortInfoTester);
63cdf0e10cSrcweir     }
64cdf0e10cSrcweir 
_HasSortInfo()65cdf0e10cSrcweir     public void _HasSortInfo() {
66cdf0e10cSrcweir         requiredMethod("SortInfo");
67cdf0e10cSrcweir         testProperty("HasSortInfo");
68cdf0e10cSrcweir     }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     /**
71cdf0e10cSrcweir      *This class is destined to custom test of property <code>LayoutInfo</code>.
72cdf0e10cSrcweir      */
73cdf0e10cSrcweir     protected PropertyTester LayoutInfoTester = new PropertyTester() {
74cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
75cdf0e10cSrcweir             DataPilotFieldLayoutInfo layoutInfo = new DataPilotFieldLayoutInfo();
76cdf0e10cSrcweir             layoutInfo.LayoutMode = com.sun.star.sheet.DataPilotFieldLayoutMode.OUTLINE_SUBTOTALS_BOTTOM;
77cdf0e10cSrcweir             layoutInfo.AddEmptyLines = true;
78cdf0e10cSrcweir             log.println("Having Value and returning a new one");
79cdf0e10cSrcweir             return layoutInfo.equals(oldValue) ? null : layoutInfo;
80cdf0e10cSrcweir         }
81cdf0e10cSrcweir     };
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     /**
84cdf0e10cSrcweir      * Test property <code>LayoutInfo</code> using custom <code>PropertyTest</code>.
85cdf0e10cSrcweir      */
_LayoutInfo()86cdf0e10cSrcweir     public void _LayoutInfo() {
87cdf0e10cSrcweir         testProperty("LayoutInfo", LayoutInfoTester);
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir 
_HasLayoutInfo()90cdf0e10cSrcweir     public void _HasLayoutInfo() {
91cdf0e10cSrcweir         requiredMethod("LayoutInfo");
92cdf0e10cSrcweir         testProperty("HasLayoutInfo");
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     /**
96cdf0e10cSrcweir      *This class is destined to custom test of property <code>AutoShowInfo</code>.
97cdf0e10cSrcweir      */
98cdf0e10cSrcweir     protected PropertyTester AutoShowInfoTester = new PropertyTester() {
99cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
100cdf0e10cSrcweir             DataPilotFieldAutoShowInfo AutoShowInfo = new DataPilotFieldAutoShowInfo();
101cdf0e10cSrcweir             AutoShowInfo.DataField = "Col1";
102cdf0e10cSrcweir             AutoShowInfo.IsEnabled = true;
103cdf0e10cSrcweir             log.println("Having Value and returning a new one");
104cdf0e10cSrcweir             return AutoShowInfo.equals(oldValue) ? null : AutoShowInfo;
105cdf0e10cSrcweir         }
106cdf0e10cSrcweir     };
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     /**
109cdf0e10cSrcweir      * Test property <code>AutoShowInfo</code> using custom <code>PropertyTest</code>.
110cdf0e10cSrcweir      */
_AutoShowInfo()111cdf0e10cSrcweir     public void _AutoShowInfo() {
112cdf0e10cSrcweir         testProperty("AutoShowInfo", AutoShowInfoTester);
113cdf0e10cSrcweir     }
114cdf0e10cSrcweir 
_HasAutoShowInfo()115cdf0e10cSrcweir     public void _HasAutoShowInfo() {
116cdf0e10cSrcweir         requiredMethod("AutoShowInfo");
117cdf0e10cSrcweir         testProperty("HasAutoShowInfo");
118cdf0e10cSrcweir     }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     /**
121cdf0e10cSrcweir      *This class is destined to custom test of property <code>Reference</code>.
122cdf0e10cSrcweir      */
123cdf0e10cSrcweir     protected PropertyTester ReferenceTester = new PropertyTester() {
124cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
125cdf0e10cSrcweir             DataPilotFieldReference Reference = new DataPilotFieldReference();
126cdf0e10cSrcweir             Reference.ReferenceField="Col1";
127cdf0e10cSrcweir             Reference.ReferenceItemType = com.sun.star.sheet.DataPilotFieldReferenceItemType.NAMED;
128cdf0e10cSrcweir             log.println("Having Value and returning a new one");
129cdf0e10cSrcweir             return Reference.equals(oldValue) ? null : Reference;
130cdf0e10cSrcweir         }
131cdf0e10cSrcweir     };
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     /**
134cdf0e10cSrcweir      * Test property <code>Reference</code> using custom <code>PropertyTest</code>.
135cdf0e10cSrcweir      */
_Reference()136cdf0e10cSrcweir     public void _Reference() {
137cdf0e10cSrcweir         testProperty("Reference", ReferenceTester);
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir 
_HasReference()140cdf0e10cSrcweir     public void _HasReference() {
141cdf0e10cSrcweir         requiredMethod("Reference");
142cdf0e10cSrcweir         testProperty("HasReference");
143cdf0e10cSrcweir     }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     /*
146cdf0e10cSrcweir      * this property can only set a true value to false, fo ungrouping purposes
147cdf0e10cSrcweir      */
_IsGroupField()148cdf0e10cSrcweir     public void _IsGroupField() {
149cdf0e10cSrcweir         boolean result = true;
150cdf0e10cSrcweir         try {
151cdf0e10cSrcweir             Boolean propValue = (Boolean) oObj.getPropertyValue ("IsGroupField");
152cdf0e10cSrcweir             if (propValue.booleanValue ()) {
153cdf0e10cSrcweir                 oObj.setPropertyValue ("IsGroupField", Boolean.FALSE);
154cdf0e10cSrcweir                 Boolean propV = (Boolean) oObj.getPropertyValue ("IsGroupField");
155cdf0e10cSrcweir                 result = !propV.booleanValue ();
156cdf0e10cSrcweir             }
157cdf0e10cSrcweir         } catch (Exception e) {
158cdf0e10cSrcweir             log.println ("Exception while getting Property 'IsGroupField'"+e);
159cdf0e10cSrcweir             result = false;
160cdf0e10cSrcweir         }
161cdf0e10cSrcweir         tRes.tested ("IsGroupField",result);
162cdf0e10cSrcweir     }
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 
166