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 23 24 package mod._sfx; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 33 import com.sun.star.frame.XStorable; 34 import com.sun.star.lang.XMultiServiceFactory; 35 import com.sun.star.text.XTextDocument; 36 import com.sun.star.uno.UnoRuntime; 37 import com.sun.star.uno.XInterface; 38 39 /** 40 * Test for object which is represented by service 41 * <code>com.sun.star.frame.DocumentTemplates</code>. <p> 42 * 43 * Object implements the following interfaces : 44 * <ul> 45 * <li> <code>com::sun::star::frame::XDocumentTemplates</code></li> 46 * </ul> <p> 47 * 48 */ 49 public class DocumentTemplates extends TestCase { 50 51 XTextDocument xTextDoc; 52 initialize( TestParameters tParam, PrintWriter log )53 protected void initialize( TestParameters tParam, PrintWriter log ) { 54 String aURL=util.utils.getFullTestURL("report2.stw"); 55 xTextDoc = util.WriterTools.loadTextDoc((XMultiServiceFactory)tParam.getMSF(),aURL); 56 } 57 cleanup( TestParameters tParam, PrintWriter log )58 protected void cleanup( TestParameters tParam, PrintWriter log ) { 59 log.println( " disposing xTextDoc " ); 60 xTextDoc.dispose(); 61 } 62 63 /** 64 * Creating a Testenvironment for the interfaces to be tested. 65 * Creates an instance of the service 66 * <code>com.sun.star.frame.DocumentTemplates</code>. 67 */ createTestEnvironment(TestParameters tParam, PrintWriter log)68 protected TestEnvironment createTestEnvironment 69 (TestParameters tParam, PrintWriter log) { 70 71 XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF(); 72 XInterface oObj = null; 73 XStorable store = null; 74 75 try { 76 oObj = (XInterface)xMSF.createInstance 77 ("com.sun.star.frame.DocumentTemplates"); 78 store = (XStorable) UnoRuntime.queryInterface 79 (XStorable.class,xTextDoc); 80 } catch (com.sun.star.uno.Exception e) { 81 e.printStackTrace(log); 82 throw new StatusException("Unexpected exception", e); 83 } 84 85 String Iname = util.utils.getImplName(oObj); 86 log.println("Implementation Name: "+Iname); 87 TestEnvironment tEnv = new TestEnvironment(oObj); 88 tEnv.addObjRelation("Store",store); 89 return tEnv; 90 } 91 92 } // finish class TestCase 93 94