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._sw; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 import util.SOfficeFactory; 33 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 import com.sun.star.view.XViewSettingsSupplier; 39 40 /** 41 * 42 * initial description 43 * @see com.sun.star.beans.XPropertySet 44 * @see com.sun.star.text.ViewSettings 45 * 46 */ 47 public class SwXViewSettings extends TestCase { 48 XTextDocument xTextDoc; 49 initialize( TestParameters tParam, PrintWriter log )50 protected void initialize( TestParameters tParam, PrintWriter log ) { 51 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 52 53 try { 54 log.println( "creating a textdocument" ); 55 xTextDoc = SOF.createTextDoc( null ); 56 } catch ( com.sun.star.uno.Exception e ) { 57 // Some exception occures.FAILED 58 e.printStackTrace( log ); 59 throw new StatusException( "Couldn't create document", e ); 60 } 61 } 62 cleanup( TestParameters tParam, PrintWriter log )63 protected void cleanup( TestParameters tParam, PrintWriter log ) { 64 log.println( " disposing xTextDoc " ); 65 util.DesktopTools.closeDoc(xTextDoc); 66 } 67 68 69 /** 70 * creating a Testenvironment for the interfaces to be tested 71 * 72 * @param tParam class which contains additional test parameters 73 * @param log class to log the test state and result 74 * 75 * @return Status class 76 * 77 * @see TestParameters 78 * @see PrintWriter 79 */ createTestEnvironment(TestParameters tParam, PrintWriter log )80 public synchronized TestEnvironment createTestEnvironment 81 (TestParameters tParam, PrintWriter log ) { 82 83 XInterface oObj = null; 84 85 // creation of testobject here 86 // first we write what we are intend to do to log file 87 log.println( "creating a test environment" ); 88 89 // create testobject here 90 91 oObj = xTextDoc.getCurrentController(); 92 XViewSettingsSupplier oVSSupp = (XViewSettingsSupplier) 93 UnoRuntime.queryInterface(XViewSettingsSupplier.class, oObj); 94 95 oObj = oVSSupp.getViewSettings(); 96 97 log.println( "creating a new environment for ViewSettings object" ); 98 TestEnvironment tEnv = new TestEnvironment( oObj ); 99 100 log.println( "adding TextDocument as mod relation to environment" ); 101 tEnv.addObjRelation("TEXTDOC", xTextDoc); 102 103 return tEnv; 104 } // finish method getTestEnvironment 105 106 107 } // finish class SwXViewSettings 108 109