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