merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _DataPilotField.java
blobae3066e9d15446934a3e4ce5f30ec7c9973134aa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _DataPilotField.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.sheet;
33 import com.sun.star.sheet.DataPilotFieldAutoShowInfo;
34 import com.sun.star.sheet.DataPilotFieldLayoutInfo;
35 import com.sun.star.sheet.DataPilotFieldReference;
36 import com.sun.star.sheet.DataPilotFieldSortInfo;
37 import lib.MultiPropertyTest;
39 /**
40 * Testing <code>com.sun.star.sheet.DataPilotField</code>
41 * service properties :
42 * <ul>
43 * <li><code> Orientation</code></li>
44 * <li><code> Function</code></li>
45 * </ul> <p>
46 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
47 * @see com.sun.star.sheet.DataPilotField
49 public class _DataPilotField extends MultiPropertyTest {
51 /**
52 *This class is destined to custom test of property <code>SortInfo</code>.
54 protected PropertyTester SortInfoTester = new PropertyTester() {
55 protected Object getNewValue(String propName, Object oldValue) {
56 DataPilotFieldSortInfo sortInfo = new DataPilotFieldSortInfo();
57 sortInfo.Mode = com.sun.star.sheet.DataPilotFieldSortMode.MANUAL;
58 sortInfo.IsAscending = false;
59 sortInfo.Field = "COL1";
60 log.println("Having Value and returning a new one");
61 return sortInfo.equals(oldValue) ? null : sortInfo;
65 /**
66 * Test property <code>SortInfo</code> using custom <code>PropertyTest</code>.
68 public void _SortInfo() {
69 testProperty("SortInfo", SortInfoTester);
72 public void _HasSortInfo() {
73 requiredMethod("SortInfo");
74 testProperty("HasSortInfo");
77 /**
78 *This class is destined to custom test of property <code>LayoutInfo</code>.
80 protected PropertyTester LayoutInfoTester = new PropertyTester() {
81 protected Object getNewValue(String propName, Object oldValue) {
82 DataPilotFieldLayoutInfo layoutInfo = new DataPilotFieldLayoutInfo();
83 layoutInfo.LayoutMode = com.sun.star.sheet.DataPilotFieldLayoutMode.OUTLINE_SUBTOTALS_BOTTOM;
84 layoutInfo.AddEmptyLines = true;
85 log.println("Having Value and returning a new one");
86 return layoutInfo.equals(oldValue) ? null : layoutInfo;
90 /**
91 * Test property <code>LayoutInfo</code> using custom <code>PropertyTest</code>.
93 public void _LayoutInfo() {
94 testProperty("LayoutInfo", LayoutInfoTester);
97 public void _HasLayoutInfo() {
98 requiredMethod("LayoutInfo");
99 testProperty("HasLayoutInfo");
103 *This class is destined to custom test of property <code>AutoShowInfo</code>.
105 protected PropertyTester AutoShowInfoTester = new PropertyTester() {
106 protected Object getNewValue(String propName, Object oldValue) {
107 DataPilotFieldAutoShowInfo AutoShowInfo = new DataPilotFieldAutoShowInfo();
108 AutoShowInfo.DataField = "Col1";
109 AutoShowInfo.IsEnabled = true;
110 log.println("Having Value and returning a new one");
111 return AutoShowInfo.equals(oldValue) ? null : AutoShowInfo;
116 * Test property <code>AutoShowInfo</code> using custom <code>PropertyTest</code>.
118 public void _AutoShowInfo() {
119 testProperty("AutoShowInfo", AutoShowInfoTester);
122 public void _HasAutoShowInfo() {
123 requiredMethod("AutoShowInfo");
124 testProperty("HasAutoShowInfo");
128 *This class is destined to custom test of property <code>Reference</code>.
130 protected PropertyTester ReferenceTester = new PropertyTester() {
131 protected Object getNewValue(String propName, Object oldValue) {
132 DataPilotFieldReference Reference = new DataPilotFieldReference();
133 Reference.ReferenceField="Col1";
134 Reference.ReferenceItemType = com.sun.star.sheet.DataPilotFieldReferenceItemType.NAMED;
135 log.println("Having Value and returning a new one");
136 return Reference.equals(oldValue) ? null : Reference;
141 * Test property <code>Reference</code> using custom <code>PropertyTest</code>.
143 public void _Reference() {
144 testProperty("Reference", ReferenceTester);
147 public void _HasReference() {
148 requiredMethod("Reference");
149 testProperty("HasReference");
153 * this property can only set a true value to false, fo ungrouping purposes
155 public void _IsGroupField() {
156 boolean result = true;
157 try {
158 Boolean propValue = (Boolean) oObj.getPropertyValue ("IsGroupField");
159 if (propValue.booleanValue ()) {
160 oObj.setPropertyValue ("IsGroupField", Boolean.FALSE);
161 Boolean propV = (Boolean) oObj.getPropertyValue ("IsGroupField");
162 result = !propV.booleanValue ();
164 } catch (Exception e) {
165 log.println ("Exception while getting Property 'IsGroupField'"+e);
166 result = false;
168 tRes.tested ("IsGroupField",result);