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