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 com.sun.star.container.XIndexAccess; 33 import com.sun.star.lang.XMultiServiceFactory; 34 import com.sun.star.uno.AnyConverter; 35 import com.sun.star.uno.Type; 36 import com.sun.star.uno.UnoRuntime; 37 import com.sun.star.uno.XInterface; 38 39 /** 40 * Test for object which is represented by service 41 * <code>com.sun.star.sheet.TableAutoFormatField</code>. 42 * In StarCalc application there is a collection of autoformats 43 * for tables (you can select a predefined format for a 44 * table or create your own). Each autoformat has a number 45 * of fields with definitions of font parameters, number 46 * formats etc. for different parts of a table (column and 47 * row names, footers, data). This object represents the 48 * field of the same kind. <p> 49 * Object implements the following interfaces : 50 * <ul> 51 * <li> <code>com::sun::star::sheet::TableAutoFormatField</code></li> 52 * <li> <code>com::sun::star::beans::XPropertySet</code></li> 53 * </ul> 54 * This object test <b> is NOT </b> designed to be run in several 55 * threads concurently. 56 * @see com.sun.star.sheet.TableAutoFormatField 57 * @see com.sun.star.beans.XPropertySet 58 * @see ifc.sheet._TableAutoFormatField 59 * @see ifc.beans._XPropertySet 60 */ 61 public class ScAutoFormatFieldObj extends TestCase { 62 63 /** 64 * Creating a Testenvironment for the interfaces to be tested. 65 * Using SOffice ServiceManager an instance of 66 * <code>com.sun.star.sheet.TableAutoFormatField</code> service 67 * is created. From this collection one Format is retrieved 68 * and then from this format one of its compound fields is 69 * retrieved. 70 */ createTestEnvironment( TestParameters Param, PrintWriter log )71 public synchronized TestEnvironment createTestEnvironment 72 ( TestParameters Param, PrintWriter log ) throws StatusException { 73 74 XInterface oObj = null; 75 76 try { 77 78 log.println ("create Object ...") ; 79 // creation of testobject here 80 XInterface formats = (XInterface)((XMultiServiceFactory)Param.getMSF()).createInstance 81 ("com.sun.star.sheet.TableAutoFormats"); 82 XIndexAccess formatsIndex = (XIndexAccess)UnoRuntime.queryInterface 83 (XIndexAccess.class, formats); 84 XInterface format = (XInterface) AnyConverter.toObject( 85 new Type(XInterface.class),formatsIndex.getByIndex(0)); 86 XIndexAccess formatIndex = (XIndexAccess) UnoRuntime.queryInterface 87 (XIndexAccess.class, format); 88 oObj = (XInterface) AnyConverter.toObject( 89 new Type(XInterface.class),formatIndex.getByIndex(0)); 90 91 } catch (com.sun.star.uno.Exception e) { 92 log.println ("Exception occurred while creating test Object.") ; 93 e.printStackTrace(log) ; 94 } 95 96 TestEnvironment tEnv = new TestEnvironment(oObj) ; 97 98 return tEnv; 99 } 100 101 } // finish class ScAutoFormatFieldObj 102 103