1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package mod._sc; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 import util.SOfficeFactory; 33 34 import com.sun.star.container.XEnumerationAccess; 35 import com.sun.star.lang.XComponent; 36 import com.sun.star.lang.XMultiServiceFactory; 37 import com.sun.star.sheet.XSpreadsheetDocument; 38 import com.sun.star.sheet.XSpreadsheets; 39 import com.sun.star.uno.UnoRuntime; 40 import com.sun.star.uno.XInterface; 41 42 public class ScIndexEnumeration_SpreadsheetsEnumeration extends TestCase { 43 private static XSpreadsheetDocument xSpreadsheetDoc = null; 44 45 /** 46 * Creates Spreadsheet document. 47 */ initialize( TestParameters Param, PrintWriter log )48 public void initialize( TestParameters Param, PrintWriter log ) { 49 // get a soffice factory object 50 51 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); 52 try { 53 log.println("creating a spreadsheetdocument"); 54 xSpreadsheetDoc = SOF.createCalcDoc(null); 55 } catch (com.sun.star.uno.Exception e) { 56 e.printStackTrace( log ); 57 throw new StatusException( "Couldn't create document ", e ); 58 } 59 } 60 61 /** 62 * Disposes Spreadsheet document. 63 */ cleanup( TestParameters tParam, PrintWriter log )64 protected void cleanup( TestParameters tParam, PrintWriter log ) { 65 log.println("disposing xSpreadsheetDocument"); 66 XComponent oComp = (XComponent) 67 UnoRuntime.queryInterface(XComponent.class, xSpreadsheetDoc); 68 util.DesktopTools.closeDoc(oComp); 69 } 70 createTestEnvironment(TestParameters Param, PrintWriter log)71 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 72 73 log.println("getting sheets"); 74 XSpreadsheets xSpreadsheets = (XSpreadsheets)xSpreadsheetDoc.getSheets(); 75 76 XInterface oObj = (XInterface) 77 UnoRuntime.queryInterface(XInterface.class, xSpreadsheets); 78 79 log.println("creating a new environment for object"); 80 XEnumerationAccess ea = (XEnumerationAccess) 81 UnoRuntime.queryInterface(XEnumerationAccess.class,oObj); 82 83 oObj = ea.createEnumeration(); 84 85 log.println("ImplementationName: "+util.utils.getImplName(oObj)); 86 // creating test environment 87 TestEnvironment tEnv = new TestEnvironment( oObj ); 88 89 tEnv.addObjRelation("ENUM",ea); 90 91 return tEnv; 92 } 93 } 94