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._sw; 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 util.SOfficeFactory; 37 38 import com.sun.star.container.XNameAccess; 39 import com.sun.star.lang.XMultiServiceFactory; 40 import com.sun.star.style.XStyleFamiliesSupplier; 41 import com.sun.star.text.XTextDocument; 42 import com.sun.star.uno.UnoRuntime; 43 44 45 /** 46 * Test for object which is represented by service 47 * <code>com.sun.star.style.StyleFamilies</code>. <p> 48 * Object implements the following interfaces : 49 * <ul> 50 * <li> <code>com::sun::star::container::XNameAccess</code></li> 51 * <li> <code>com::sun::star::container::XElementAccess</code></li> 52 * <li> <code>com::sun::star::container::XIndexAccess</code></li> 53 * </ul> <p> 54 * This object test <b> is NOT </b> designed to be run in several 55 * threads concurently. 56 * @see com.sun.star.container.XNameAccess 57 * @see com.sun.star.container.XElementAccess 58 * @see com.sun.star.container.XIndexAccess 59 * @see com.sun.star.style.StyleFamilies 60 * @see ifc.container._XNameAccess 61 * @see ifc.container._XElementAccess 62 * @see ifc.container._XIndexAccess 63 */ 64 public class SwXStyleFamilies extends TestCase { 65 XTextDocument xTextDoc; 66 67 /** 68 * Creates text document. 69 */ 70 protected void initialize( TestParameters tParam, PrintWriter log ) { 71 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 72 try { 73 log.println( "creating a textdocument" ); 74 xTextDoc = SOF.createTextDoc( null ); 75 } catch ( com.sun.star.uno.Exception e ) { 76 e.printStackTrace( log ); 77 throw new StatusException( "Couldn't create document", e ); 78 } 79 } 80 81 /** 82 * Disposes text document. 83 */ 84 protected void cleanup( TestParameters tParam, PrintWriter log ) { 85 log.println( " disposing xTextDoc " ); 86 util.DesktopTools.closeDoc(xTextDoc); 87 } 88 89 /** 90 * Creating a Testenvironment for the interfaces to be tested. Style families 91 * are gotten from text document using <code>XStyleFamiliesSupplier</code> 92 * interface and returned as a test component. 93 */ 94 public synchronized TestEnvironment createTestEnvironment( 95 TestParameters Param, PrintWriter log ) throws StatusException { 96 97 98 log.println( "Creating a test environment" ); 99 XTextDocument xArea = (XTextDocument) 100 UnoRuntime.queryInterface(XTextDocument.class, xTextDoc); 101 XStyleFamiliesSupplier oSFS = (XStyleFamiliesSupplier) 102 UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xArea); 103 XNameAccess oSF = oSFS.getStyleFamilies(); 104 105 TestEnvironment tEnv = new TestEnvironment(oSF); 106 return tEnv; 107 } 108 109 110 } // finish class SwXStyle 111 112