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._sfx; 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.utils; 37 38 import com.sun.star.document.XStandaloneDocumentInfo; 39 import com.sun.star.lang.XMultiServiceFactory; 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.document.StandaloneDocumentInfo</code>. <p> 46 * Object implements the following interfaces : 47 * <ul> 48 * <li> <code>com::sun::star::lang::XComponent</code></li> 49 * <li> <code>com::sun::star::document::DocumentInfo</code></li> 50 * <li> <code>com::sun::star::document::XDocumentInfo</code></li> 51 * <li> <code>com::sun::star::document::XStandaloneDocumentInfo</code></li> 52 * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> 53 * <li> <code>com::sun::star::beans::XPropertySet</code></li> 54 * </ul> <p> 55 * The following files used by this test : 56 * <ul> 57 * <li><b> SfxStandaloneDocInfoObject.sdw </b> : is copied 58 * to SOffice temporary directory and is used to load and 59 * save its info. </li> 60 * </ul> <p> 61 * This object test <b> is NOT </b> designed to be run in several 62 * threads concurently. 63 * 64 * @see com.sun.star.lang.XComponent 65 * @see com.sun.star.document.DocumentInfo 66 * @see com.sun.star.document.XDocumentInfo 67 * @see com.sun.star.document.XStandaloneDocumentInfo 68 * @see com.sun.star.beans.XFastPropertySet 69 * @see com.sun.star.beans.XPropertySet 70 * @see ifc.lang._XComponent 71 * @see ifc.document._DocumentInfo 72 * @see ifc.document._XDocumentInfo 73 * @see ifc.document._XStandaloneDocumentInfo 74 * @see ifc.beans._XFastPropertySet 75 * @see ifc.beans._XPropertySet 76 */ 77 public class StandaloneDocumentInfo extends TestCase { 78 79 String destUrl = null ; 80 81 /** 82 * Copies file 'SfxStandaloneDocInfoObject.sdw' to tempopary 83 * location (overwriting the old file if exists). 84 */ 85 protected void initialize( TestParameters tParam, PrintWriter log ) { 86 String srcUrl = utils.getFullTestURL("SfxStandaloneDocInfoObject.sdw") ; 87 destUrl = utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF()) + 88 "SfxStandaloneDocInfoObject.sdw"; 89 90 utils.doOverwriteFile((XMultiServiceFactory)tParam.getMSF(), srcUrl, destUrl) ; 91 } 92 93 /** 94 * Creating a Testenvironment for the interfaces to be tested. 95 * Creates an instance of the service 96 * <code>com.sun.star.document.StandaloneDocumentInfo</code>. 97 * Object relations created : 98 * <ul> 99 * <li> <code>'DOCURL'</code> for 100 * {@link ifc.document._XStandaloneDocumentInfo} : 101 * the Writer file URL in temporary location. </li> 102 * </ul> 103 */ 104 protected TestEnvironment createTestEnvironment 105 (TestParameters tParam, PrintWriter log) { 106 XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF(); 107 XInterface oObj = null; 108 109 try { 110 oObj = (XInterface)xMSF.createInstance 111 ("com.sun.star.document.StandaloneDocumentInfo"); 112 } catch (com.sun.star.uno.Exception e) { 113 e.printStackTrace(log); 114 throw new StatusException("Unexpected exception", e); 115 } 116 117 String Iname = util.utils.getImplName(oObj); 118 log.println("Implementation Name: "+Iname); 119 TestEnvironment tEnv = new TestEnvironment(oObj); 120 XStandaloneDocumentInfo the_info = (XStandaloneDocumentInfo) 121 UnoRuntime.queryInterface(XStandaloneDocumentInfo.class, oObj); 122 try { 123 the_info.loadFromURL(destUrl); 124 } catch (com.sun.star.io.IOException e) { 125 e.printStackTrace(log); 126 throw new StatusException("Couldn't load document: " + destUrl,e); 127 } 128 tEnv.addObjRelation("DOCURL",destUrl); 129 return tEnv; 130 } 131 132 } // finish class TestCase 133 134