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._sd; 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.document.XLinkTargetSupplier; 39 import com.sun.star.lang.XComponent; 40 import com.sun.star.lang.XMultiServiceFactory; 41 import com.sun.star.uno.UnoRuntime; 42 import com.sun.star.uno.XInterface; 43 44 /** 45 * Test for object which is represented by service 46 * <code>com.sun.star.document.LinkTargets</code>. <p> 47 * Object implements the following interfaces : 48 * <ul> 49 * <li> <code>com::sun::star::container::XNameAccess</code></li> 50 * <li> <code>com::sun::star::container::XElementAccess</code></li> 51 * </ul> 52 * @see com.sun.star.document.LinkTargets 53 * @see com.sun.star.container.XNameAccess 54 * @see com.sun.star.container.XElementAccess 55 * @see ifc.container._XNameAccess 56 * @see ifc.container._XElementAccess 57 */ 58 public class SdDocLinkTargets extends TestCase { 59 XComponent xDrawDoc; 60 61 /** 62 * Creates Drawing document. 63 */ 64 protected void initialize(TestParameters Param, PrintWriter log) { 65 // get a soffice factory object 66 SOfficeFactory SOF = SOfficeFactory.getFactory( 67 (XMultiServiceFactory)Param.getMSF()); 68 69 try { 70 log.println( "creating a draw document" ); 71 xDrawDoc = SOF.createDrawDoc(null); 72 } catch (com.sun.star.uno.Exception e) { 73 // Some exception occures.FAILED 74 e.printStackTrace( log ); 75 throw new StatusException( "Couldn't create document", e ); 76 } 77 } 78 79 /** 80 * Disposes Drawing document. 81 */ 82 protected void cleanup( TestParameters Param, PrintWriter log) { 83 log.println("disposing xDrawDoc"); 84 util.DesktopTools.closeDoc(xDrawDoc);; 85 } 86 87 /** 88 * Creating a Testenvironment for the interfaces to be tested. 89 * Retrieves the possible links to childrens of the drawing document using 90 * the interface <code>XLinkTargetSupplier</code>. The retrieved collection 91 * is the instance of the service <code>com.sun.star.document.LinkTargets</code>. 92 * @see com.sun.star.document.XLinkTargetSupplier 93 * @see com.sun.star.document.LinkTargets 94 */ 95 public TestEnvironment createTestEnvironment( 96 TestParameters Param, PrintWriter log) throws StatusException { 97 98 // get the Links here 99 log.println( "getting Links" ); 100 XLinkTargetSupplier oLTS = (XLinkTargetSupplier) 101 UnoRuntime.queryInterface(XLinkTargetSupplier.class,xDrawDoc); 102 XInterface oObj = oLTS.getLinks(); 103 104 log.println( "creating a new environment for drawpage object" ); 105 TestEnvironment tEnv = new TestEnvironment( oObj ); 106 107 return tEnv; 108 } // finish method createTestEnvironment 109 110 } // finish class SdDocLinkTargets 111 112