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