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