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._fwk; 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.document.XDocumentInfoSupplier; 39 import com.sun.star.lang.XMultiServiceFactory; 40 import com.sun.star.text.XTextDocument; 41 import com.sun.star.uno.UnoRuntime; 42 import com.sun.star.uno.XInterface; 43 44 /** 45 * Test for object which is represented by service 46 * <code>com.sun.star.document.DocumentInfo</code>. <p> 47 * Object implements the following interfaces : 48 * <ul> 49 * <li><code>com::sun::star::beans::XFastPropertySet</code></li> 50 * <li><code>com::sun::star::beans::XPropertySet</code></li> 51 * <li><code>com::sun::star::document::XDocumentInfo</code></li> 52 * <li><code>com::sun::star::document::XStandaloneDocumentInfo</code></li> 53 * <li><code>com::sun::star::lang::XComponent</code></li> 54 * </ul><p> 55 * @see com.sun.star.beans.XFastPropertySet 56 * @see com.sun.star.beans.XPropertySet 57 * @see com.sun.star.document.XDocumentInfo 58 * @see com.sun.star.document.XStandaloneDocumentInfo 59 * @see com.sun.star.lang.XComponent 60 * @see ifc.beans._XFastPropertySet 61 * @see ifc.beans._XPropertySet 62 * @see ifc.document._XDocumentInfo 63 * @see ifc.document._XStandaloneDocumentInfo 64 * @see ifc.lang._XComponent 65 */ 66 public class DocumentProperties extends TestCase { 67 68 XTextDocument xTextDoc; 69 70 /** 71 * Disposes the document, if exists, created in 72 * <code>createTestEnvironment</code> method. 73 */ 74 protected void cleanup( TestParameters Param, PrintWriter log) { 75 76 log.println("disposing xTextDoc"); 77 78 if (xTextDoc != null) { 79 xTextDoc.dispose(); 80 } 81 } 82 83 /** 84 * Creates a text document. 85 * Obtains the property <code>'DocumentInfo'</code> of the created document. 86 */ 87 public TestEnvironment createTestEnvironment( TestParameters Param, 88 PrintWriter log ) throws StatusException { 89 90 XInterface oObj = null; 91 92 log.println( "creating a test environment" ); 93 94 if (xTextDoc != null) xTextDoc.dispose(); 95 96 // get a soffice factory object 97 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); 98 99 try { 100 log.println( "creating a text document" ); 101 xTextDoc = SOF.createTextDoc(null); 102 } catch ( com.sun.star.uno.Exception e ) { 103 // Some exception occures.FAILED 104 e.printStackTrace( log ); 105 throw new StatusException( "Couldn't create document", e ); 106 } 107 108 shortWait(); 109 110 XDocumentInfoSupplier xdis = (XDocumentInfoSupplier) 111 UnoRuntime.queryInterface(XDocumentInfoSupplier.class, xTextDoc); 112 //oObj = (XInterface)UnoRuntime.queryInterface(XInterface.class, docInfo); 113 oObj = xdis.getDocumentInfo(); 114 TestEnvironment tEnv = new TestEnvironment( oObj ); 115 116 return tEnv; 117 } // finish method getTestEnvironment 118 119 /** 120 * Sleeps for 0.5 sec. to allow StarOffice to react on <code> 121 * reset</code> call. 122 */ 123 private void shortWait() { 124 try { 125 Thread.sleep(500) ; 126 } catch (InterruptedException e) { 127 log.println("While waiting :" + e) ; 128 } 129 } 130 } 131