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 complex.dataPilot; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet; 31*cdf0e10cSrcweir import com.sun.star.container.XIndexAccess; 32*cdf0e10cSrcweir import com.sun.star.container.XNamed; 33*cdf0e10cSrcweir import com.sun.star.sheet.DataPilotFieldOrientation; 34*cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotDescriptor; 35*cdf0e10cSrcweir import com.sun.star.table.CellRangeAddress; 36*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 37*cdf0e10cSrcweir // import lib.MultiMethodTest; 38*cdf0e10cSrcweir // import lib.Status; 39*cdf0e10cSrcweir //import lib.StatusException; 40*cdf0e10cSrcweir import lib.TestParameters; 41*cdf0e10cSrcweir // import share.LogWriter; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir /** 44*cdf0e10cSrcweir * Testing <code>com.sun.star.sheet.XDataPilotDescriptor</code> 45*cdf0e10cSrcweir * interface methods : 46*cdf0e10cSrcweir * <ul> 47*cdf0e10cSrcweir * <li><code> getTag()</code></li> 48*cdf0e10cSrcweir * <li><code> setTag()</code></li> 49*cdf0e10cSrcweir * <li><code> getSourceRange()</code></li> 50*cdf0e10cSrcweir * <li><code> setSourceRange()</code></li> 51*cdf0e10cSrcweir * <li><code> getFilterDescriptor()</code></li> 52*cdf0e10cSrcweir * <li><code> getDataPilotFields()</code></li> 53*cdf0e10cSrcweir * <li><code> getColumnFields()</code></li> 54*cdf0e10cSrcweir * <li><code> getRowFields()</code></li> 55*cdf0e10cSrcweir * <li><code> getPageFields()</code></li> 56*cdf0e10cSrcweir * <li><code> getDataFields()</code></li> 57*cdf0e10cSrcweir * <li><code> getHiddenFields()</code></li> 58*cdf0e10cSrcweir * </ul> <p> 59*cdf0e10cSrcweir * This test needs the following object relations : 60*cdf0e10cSrcweir * <ul> 61*cdf0e10cSrcweir * <li> <code>'FIELDSAMOUNT'</code> (of type <code>Integer</code>): 62*cdf0e10cSrcweir * to have number of fields </li> 63*cdf0e10cSrcweir * <ul> <p> 64*cdf0e10cSrcweir * @see com.sun.star.sheet.XDataPilotDescriptor 65*cdf0e10cSrcweir */ 66*cdf0e10cSrcweir public class _XDataPilotDescriptor { 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir public XDataPilotDescriptor oObj = null; 69*cdf0e10cSrcweir CellRangeAddress CRA = new CellRangeAddress((short)1, 0, 0, 5, 5); 70*cdf0e10cSrcweir CellRangeAddress oldCRA = null ; 71*cdf0e10cSrcweir String sTag = new String ("XDataPilotDescriptor_Tag"); 72*cdf0e10cSrcweir String fieldsNames[]; 73*cdf0e10cSrcweir int fieldsAmount = 0; 74*cdf0e10cSrcweir int tEnvFieldsAmount = 0; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir /** 77*cdf0e10cSrcweir * The test parameters 78*cdf0e10cSrcweir */ 79*cdf0e10cSrcweir private TestParameters param = null; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir /** 82*cdf0e10cSrcweir * The log writer 83*cdf0e10cSrcweir */ 84*cdf0e10cSrcweir // private LogWriter log = null; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir /** 87*cdf0e10cSrcweir * Constructor: gets the object to test, a logger and the test parameters 88*cdf0e10cSrcweir * @param xObj The test object 89*cdf0e10cSrcweir * @param param The test parameters 90*cdf0e10cSrcweir */ 91*cdf0e10cSrcweir public _XDataPilotDescriptor(XDataPilotDescriptor xObj/*, 92*cdf0e10cSrcweir LogWriter log*/, TestParameters param) { 93*cdf0e10cSrcweir oObj = xObj; 94*cdf0e10cSrcweir // this.log = log; 95*cdf0e10cSrcweir this.param = param; 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir /** 99*cdf0e10cSrcweir * Retrieves object relations. 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir * @return 102*cdf0e10cSrcweir */ 103*cdf0e10cSrcweir public boolean before() { 104*cdf0e10cSrcweir Integer amount = (Integer)param.get("FIELDSAMOUNT"); 105*cdf0e10cSrcweir if (amount == null) { 106*cdf0e10cSrcweir System.out.println("Relation 'FIELDSAMOUNT' not found"); 107*cdf0e10cSrcweir return false; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir tEnvFieldsAmount = amount.intValue(); 110*cdf0e10cSrcweir return true; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir /** 114*cdf0e10cSrcweir * Test calls the method and compares returned value with value that was set 115*cdf0e10cSrcweir * in method <code>setSourceRange()</code>. <p> 116*cdf0e10cSrcweir * Has <b> OK </b> status if all fields of cell range addresses are equal. <p> 117*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 118*cdf0e10cSrcweir * <ul> 119*cdf0e10cSrcweir * <li> <code> setSourceRange() </code> : to have current source range </li> 120*cdf0e10cSrcweir * </ul> 121*cdf0e10cSrcweir * @return 122*cdf0e10cSrcweir */ 123*cdf0e10cSrcweir public boolean _getSourceRange(){ 124*cdf0e10cSrcweir // requiredMethod("setSourceRange()"); 125*cdf0e10cSrcweir boolean bResult = true; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir CellRangeAddress objRA = oObj.getSourceRange(); 128*cdf0e10cSrcweir bResult &= objRA.Sheet == CRA.Sheet; 129*cdf0e10cSrcweir bResult &= objRA.StartRow == CRA.StartRow; 130*cdf0e10cSrcweir bResult &= objRA.StartColumn == CRA.StartColumn; 131*cdf0e10cSrcweir bResult &= objRA.EndRow == CRA.EndRow; 132*cdf0e10cSrcweir bResult &= objRA.EndColumn == CRA.EndColumn; 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir return bResult; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir /** 138*cdf0e10cSrcweir * Test gets the current source range, stores it and sets new source range.<p> 139*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns. <p> 140*cdf0e10cSrcweir * The following method tests are to be executed before : 141*cdf0e10cSrcweir * <ul> 142*cdf0e10cSrcweir * <li> <code> getColumnFields() </code> </li> 143*cdf0e10cSrcweir * <li> <code> getRowFields() </code> </li> 144*cdf0e10cSrcweir * <li> <code> getDataFields() </code> </li> 145*cdf0e10cSrcweir * <li> <code> getHiddenFields() </code> </li> 146*cdf0e10cSrcweir * <li> <code> getPageFields() </code> </li> 147*cdf0e10cSrcweir * </ul> 148*cdf0e10cSrcweir * @return 149*cdf0e10cSrcweir */ 150*cdf0e10cSrcweir public boolean _setSourceRange(){ 151*cdf0e10cSrcweir /* executeMethod("getColumnFields()") ; 152*cdf0e10cSrcweir executeMethod("getRowFields()") ; 153*cdf0e10cSrcweir executeMethod("getDataFields()") ; 154*cdf0e10cSrcweir executeMethod("getHiddenFields()") ; 155*cdf0e10cSrcweir executeMethod("getPageFields()") ; */ 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir oldCRA = oObj.getSourceRange() ; 158*cdf0e10cSrcweir oObj.setSourceRange(CRA); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir return true; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir /** 164*cdf0e10cSrcweir * Test calls the method and checks returned value with value that was set 165*cdf0e10cSrcweir * by method <code>setTag()</code>. <p> 166*cdf0e10cSrcweir * Has <b> OK </b> status if returned value is equal to value that was set 167*cdf0e10cSrcweir * by method <code>setTag()</code>. <p> 168*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 169*cdf0e10cSrcweir * <ul> 170*cdf0e10cSrcweir * <li> <code> setTag() </code> : to have current tag </li> 171*cdf0e10cSrcweir * </ul> 172*cdf0e10cSrcweir * @return 173*cdf0e10cSrcweir */ 174*cdf0e10cSrcweir public boolean _getTag(){ 175*cdf0e10cSrcweir // requiredMethod("setTag()"); 176*cdf0e10cSrcweir boolean bResult = true; 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir String objTag = oObj.getTag(); 179*cdf0e10cSrcweir bResult &= objTag.equals(sTag); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir return bResult; 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir /** 185*cdf0e10cSrcweir * Test just calls the method. <p> 186*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns. <p> 187*cdf0e10cSrcweir * @return 188*cdf0e10cSrcweir */ 189*cdf0e10cSrcweir public boolean _setTag(){ 190*cdf0e10cSrcweir oObj.setTag(sTag); 191*cdf0e10cSrcweir return true; 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir /** 195*cdf0e10cSrcweir * Test calls the method , checks returned value, compares 196*cdf0e10cSrcweir * number of fields goten from returned value and obtained by object 197*cdf0e10cSrcweir * relation <code>'FIELDSAMOUNT'</code> and set property 198*cdf0e10cSrcweir * <code>Orientation</code> to one of DataPilotFieldOrientation values. <p> 199*cdf0e10cSrcweir * Has <b> OK </b> status if returned value isn't null, number of fields 200*cdf0e10cSrcweir * goten from returned value is less than number of fields obtained by relation 201*cdf0e10cSrcweir * and no exceptions were thrown. <p> 202*cdf0e10cSrcweir * @return 203*cdf0e10cSrcweir */ 204*cdf0e10cSrcweir public boolean _getDataPilotFields(){ 205*cdf0e10cSrcweir boolean bResult = true; 206*cdf0e10cSrcweir XIndexAccess IA = null; 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir IA = oObj.getDataPilotFields(); 209*cdf0e10cSrcweir if (IA == null) { 210*cdf0e10cSrcweir System.out.println("Returned value is null."); 211*cdf0e10cSrcweir return false; 212*cdf0e10cSrcweir } else {System.out.println("getDataPilotFields returned not Null value -- OK");} 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir fieldsAmount = IA.getCount(); 215*cdf0e10cSrcweir if (fieldsAmount < tEnvFieldsAmount) { 216*cdf0e10cSrcweir System.out.println("Number of fields is less than number goten by relation."); 217*cdf0e10cSrcweir return false; 218*cdf0e10cSrcweir } else {System.out.println("count of returned fields -- OK");} 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir fieldsNames = new String[tEnvFieldsAmount]; 221*cdf0e10cSrcweir int i = -1 ; 222*cdf0e10cSrcweir int cnt = 0 ; 223*cdf0e10cSrcweir while (++i < fieldsAmount) { 224*cdf0e10cSrcweir Object field; 225*cdf0e10cSrcweir try { 226*cdf0e10cSrcweir field = IA.getByIndex(i); 227*cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 228*cdf0e10cSrcweir e.printStackTrace(); 229*cdf0e10cSrcweir return false; 230*cdf0e10cSrcweir } catch(com.sun.star.lang.IndexOutOfBoundsException e) { 231*cdf0e10cSrcweir e.printStackTrace(); 232*cdf0e10cSrcweir return false; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir XNamed named = UnoRuntime.queryInterface(XNamed.class, field); 236*cdf0e10cSrcweir String name = named.getName(); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir System.out.println("Field : '" + name + "' ... ") ; 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir if (!name.equals("Data")) { 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir fieldsNames[cnt] = name ; 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir XPropertySet props = 245*cdf0e10cSrcweir UnoRuntime.queryInterface(XPropertySet.class, field); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir try { 248*cdf0e10cSrcweir switch (cnt % 5) { 249*cdf0e10cSrcweir case 0 : 250*cdf0e10cSrcweir props.setPropertyValue("Orientation", 251*cdf0e10cSrcweir DataPilotFieldOrientation.COLUMN); 252*cdf0e10cSrcweir System.out.println(" Column") ; 253*cdf0e10cSrcweir break; 254*cdf0e10cSrcweir case 1 : 255*cdf0e10cSrcweir props.setPropertyValue("Orientation", 256*cdf0e10cSrcweir DataPilotFieldOrientation.ROW); 257*cdf0e10cSrcweir System.out.println(" Row") ; 258*cdf0e10cSrcweir break; 259*cdf0e10cSrcweir case 2 : 260*cdf0e10cSrcweir props.setPropertyValue("Orientation", 261*cdf0e10cSrcweir DataPilotFieldOrientation.DATA); 262*cdf0e10cSrcweir System.out.println(" Data") ; 263*cdf0e10cSrcweir break; 264*cdf0e10cSrcweir case 3 : 265*cdf0e10cSrcweir props.setPropertyValue("Orientation", 266*cdf0e10cSrcweir DataPilotFieldOrientation.HIDDEN); 267*cdf0e10cSrcweir System.out.println(" Hidden") ; 268*cdf0e10cSrcweir break; 269*cdf0e10cSrcweir case 4 : 270*cdf0e10cSrcweir props.setPropertyValue("Orientation", 271*cdf0e10cSrcweir DataPilotFieldOrientation.PAGE); 272*cdf0e10cSrcweir System.out.println(" Page") ; 273*cdf0e10cSrcweir props.setPropertyValue("CurrentPage", "20"); 274*cdf0e10cSrcweir break; 275*cdf0e10cSrcweir } } catch (com.sun.star.lang.WrappedTargetException e) { 276*cdf0e10cSrcweir e.printStackTrace(); 277*cdf0e10cSrcweir return false; 278*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 279*cdf0e10cSrcweir e.printStackTrace(); 280*cdf0e10cSrcweir return false; 281*cdf0e10cSrcweir } catch (com.sun.star.beans.PropertyVetoException e) { 282*cdf0e10cSrcweir e.printStackTrace(); 283*cdf0e10cSrcweir return false; 284*cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException e) { 285*cdf0e10cSrcweir e.printStackTrace(); 286*cdf0e10cSrcweir return false; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir if (++cnt > 4) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir break; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir else 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir return false; 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir return bResult; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir /** 303*cdf0e10cSrcweir * Test calls the method and checks returned collection using the method 304*cdf0e10cSrcweir * <code>CheckNames()</code>. <p> 305*cdf0e10cSrcweir * Has <b> OK </b> status if the method <code>CheckNames()</code> returns true 306*cdf0e10cSrcweir * and no exceptions were thrown. <p> 307*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 308*cdf0e10cSrcweir * <ul> 309*cdf0e10cSrcweir * <li> <code> getDataPilotFields() </code> : to have array of field names </li> 310*cdf0e10cSrcweir * </ul> 311*cdf0e10cSrcweir * @return 312*cdf0e10cSrcweir */ 313*cdf0e10cSrcweir public boolean _getColumnFields(){ 314*cdf0e10cSrcweir // requiredMethod("getDataPilotFields()"); 315*cdf0e10cSrcweir System.out.println("getColumnFields") ; 316*cdf0e10cSrcweir XIndexAccess IA = oObj.getColumnFields(); 317*cdf0e10cSrcweir return CheckNames(IA, 0); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir /** 321*cdf0e10cSrcweir * Test calls the method and checks returned collection using the method 322*cdf0e10cSrcweir * <code>CheckNames()</code>. <p> 323*cdf0e10cSrcweir * Has <b> OK </b> status if the method <code>CheckNames()</code> returned true 324*cdf0e10cSrcweir * and no exceptions were thrown. <p> 325*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 326*cdf0e10cSrcweir * <ul> 327*cdf0e10cSrcweir * <li> <code> getDataPilotFields() </code> : to have array of field names </li> 328*cdf0e10cSrcweir * </ul> 329*cdf0e10cSrcweir * @return 330*cdf0e10cSrcweir */ 331*cdf0e10cSrcweir public boolean _getDataFields(){ 332*cdf0e10cSrcweir // requiredMethod("getDataPilotFields()"); 333*cdf0e10cSrcweir System.out.println("getDataFields") ; 334*cdf0e10cSrcweir XIndexAccess IA = oObj.getDataFields(); 335*cdf0e10cSrcweir return CheckNames(IA, 2); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir /** 339*cdf0e10cSrcweir * Test calls the method and checks returned collection using the method 340*cdf0e10cSrcweir * <code>CheckNames()</code>. <p> 341*cdf0e10cSrcweir * Has <b> OK </b> status if the method <code>CheckNames()</code> returned true 342*cdf0e10cSrcweir * and no exceptions were thrown. <p> 343*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 344*cdf0e10cSrcweir * <ul> 345*cdf0e10cSrcweir * <li> <code> getDataPilotFields() </code> : to have array of field names </li> 346*cdf0e10cSrcweir * </ul> 347*cdf0e10cSrcweir * @return 348*cdf0e10cSrcweir */ 349*cdf0e10cSrcweir public boolean _getHiddenFields(){ 350*cdf0e10cSrcweir // requiredMethod("getDataPilotFields()"); 351*cdf0e10cSrcweir System.out.println("getHiddenFields") ; 352*cdf0e10cSrcweir XIndexAccess IA = oObj.getHiddenFields(); 353*cdf0e10cSrcweir return CheckNames(IA, 3); 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir /** 357*cdf0e10cSrcweir * Test calls the method and checks returned collection using the method 358*cdf0e10cSrcweir * <code>CheckNames()</code>. <p> 359*cdf0e10cSrcweir * Has <b> OK </b> status if the method <code>CheckNames()</code> returned true 360*cdf0e10cSrcweir * and no exceptions were thrown. <p> 361*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 362*cdf0e10cSrcweir * <ul> 363*cdf0e10cSrcweir * <li> <code> getDataPilotFields() </code> : to have array of field names </li> 364*cdf0e10cSrcweir * </ul> 365*cdf0e10cSrcweir * @return 366*cdf0e10cSrcweir */ 367*cdf0e10cSrcweir public boolean _getRowFields(){ 368*cdf0e10cSrcweir // requiredMethod("getDataPilotFields()"); 369*cdf0e10cSrcweir System.out.println("getRowFields") ; 370*cdf0e10cSrcweir XIndexAccess IA = oObj.getRowFields(); 371*cdf0e10cSrcweir boolean bResult = CheckNames(IA, 1); 372*cdf0e10cSrcweir return bResult; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir /** 376*cdf0e10cSrcweir * setting of PageFields isn't supported by StarOffice Calc 377*cdf0e10cSrcweir * Has <b> OK </b> status if the returned IndexAccess 378*cdf0e10cSrcweir * isn't NULL. <p> 379*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 380*cdf0e10cSrcweir * <ul> 381*cdf0e10cSrcweir * <li> <code> getDataPilotFields() </code> : to have array of field names </li> 382*cdf0e10cSrcweir * </ul> 383*cdf0e10cSrcweir * @return 384*cdf0e10cSrcweir */ 385*cdf0e10cSrcweir public boolean _getPageFields(){ 386*cdf0e10cSrcweir // requiredMethod("getDataPilotFields()"); 387*cdf0e10cSrcweir System.out.println("getPageFields") ; 388*cdf0e10cSrcweir XIndexAccess IA = oObj.getPageFields(); 389*cdf0e10cSrcweir boolean bResult = CheckNames(IA, 4); 390*cdf0e10cSrcweir return bResult; 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir /** 394*cdf0e10cSrcweir * Test calls the method and checks returned value. <p> 395*cdf0e10cSrcweir * Has <b> OK </b> status if returned value isn't null 396*cdf0e10cSrcweir * and no exceptions were thrown. <p> 397*cdf0e10cSrcweir * @return 398*cdf0e10cSrcweir */ 399*cdf0e10cSrcweir public boolean _getFilterDescriptor(){ 400*cdf0e10cSrcweir boolean bResult = oObj.getFilterDescriptor() != null; 401*cdf0e10cSrcweir return bResult; 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir /** 405*cdf0e10cSrcweir * Method checks that the field with index <code>rem</code> exists 406*cdf0e10cSrcweir * in the array <code>IA</code>. 407*cdf0e10cSrcweir * @param IA collection of elements that support interface <code>XNamed</code> 408*cdf0e10cSrcweir * @param rem index of field in the array of field names that was stored in 409*cdf0e10cSrcweir * the method <code>getDataPilotFields()</code> 410*cdf0e10cSrcweir * @return true if required field name exists in passed collection; 411*cdf0e10cSrcweir * false otherwise 412*cdf0e10cSrcweir * @see com.sun.star.container.XNamed 413*cdf0e10cSrcweir */ 414*cdf0e10cSrcweir private boolean CheckNames(XIndexAccess IA, int rem) { 415*cdf0e10cSrcweir String name = null; 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir if (IA == null) { 418*cdf0e10cSrcweir System.out.println("Null retruned.") ; 419*cdf0e10cSrcweir return false ; 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir if (fieldsNames[rem] == null) { 423*cdf0e10cSrcweir System.out.println("No fields were set to this orientation - cann't check result") ; 424*cdf0e10cSrcweir return true ; 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir if (IA.getCount() == 0) { 428*cdf0e10cSrcweir System.out.println("No fields found. Must be at least '" 429*cdf0e10cSrcweir + fieldsNames[rem] + "'") ; 430*cdf0e10cSrcweir return false ; 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir try { 434*cdf0e10cSrcweir System.out.println("Fields returned ") ; 435*cdf0e10cSrcweir for (int i = 0; i < IA.getCount(); i++) { 436*cdf0e10cSrcweir Object field = IA.getByIndex(i); 437*cdf0e10cSrcweir XNamed named = UnoRuntime.queryInterface 438*cdf0e10cSrcweir (XNamed.class, field); 439*cdf0e10cSrcweir name = named.getName(); 440*cdf0e10cSrcweir System.out.println(" " + name) ; 441*cdf0e10cSrcweir if (fieldsNames[rem].equals(name)) { 442*cdf0e10cSrcweir System.out.println(" - OK") ; 443*cdf0e10cSrcweir return true ; 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException e) { 447*cdf0e10cSrcweir e.printStackTrace(); 448*cdf0e10cSrcweir return false ; 449*cdf0e10cSrcweir } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 450*cdf0e10cSrcweir e.printStackTrace(); 451*cdf0e10cSrcweir return false ; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir System.out.println(" - FAILED (field " + fieldsNames[rem] + " was not found.") ; 454*cdf0e10cSrcweir return false ; 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir /** 458*cdf0e10cSrcweir * Recreates object(to back old orientations of the fields). 459*cdf0e10cSrcweir * 460*cdf0e10cSrcweir protected void after() { 461*cdf0e10cSrcweir disposeEnvironment(); 462*cdf0e10cSrcweir }*/ 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir 465