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