1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DocumentProperties.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.SOfficeFactory
;
41 import com
.sun
.star
.document
.XDocumentInfoSupplier
;
42 import com
.sun
.star
.lang
.XMultiServiceFactory
;
43 import com
.sun
.star
.text
.XTextDocument
;
44 import com
.sun
.star
.uno
.UnoRuntime
;
45 import com
.sun
.star
.uno
.XInterface
;
48 * Test for object which is represented by service
49 * <code>com.sun.star.document.DocumentInfo</code>. <p>
50 * Object implements the following interfaces :
52 * <li><code>com::sun::star::beans::XFastPropertySet</code></li>
53 * <li><code>com::sun::star::beans::XPropertySet</code></li>
54 * <li><code>com::sun::star::document::XDocumentInfo</code></li>
55 * <li><code>com::sun::star::document::XStandaloneDocumentInfo</code></li>
56 * <li><code>com::sun::star::lang::XComponent</code></li>
58 * @see com.sun.star.beans.XFastPropertySet
59 * @see com.sun.star.beans.XPropertySet
60 * @see com.sun.star.document.XDocumentInfo
61 * @see com.sun.star.document.XStandaloneDocumentInfo
62 * @see com.sun.star.lang.XComponent
63 * @see ifc.beans._XFastPropertySet
64 * @see ifc.beans._XPropertySet
65 * @see ifc.document._XDocumentInfo
66 * @see ifc.document._XStandaloneDocumentInfo
67 * @see ifc.lang._XComponent
69 public class DocumentProperties
extends TestCase
{
71 XTextDocument xTextDoc
;
74 * Disposes the document, if exists, created in
75 * <code>createTestEnvironment</code> method.
77 protected void cleanup( TestParameters Param
, PrintWriter log
) {
79 log
.println("disposing xTextDoc");
81 if (xTextDoc
!= null) {
87 * Creates a text document.
88 * Obtains the property <code>'DocumentInfo'</code> of the created document.
90 public TestEnvironment
createTestEnvironment( TestParameters Param
,
91 PrintWriter log
) throws StatusException
{
93 XInterface oObj
= null;
95 log
.println( "creating a test environment" );
97 if (xTextDoc
!= null) xTextDoc
.dispose();
99 // get a soffice factory object
100 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF());
103 log
.println( "creating a text document" );
104 xTextDoc
= SOF
.createTextDoc(null);
105 } catch ( com
.sun
.star
.uno
.Exception e
) {
106 // Some exception occures.FAILED
107 e
.printStackTrace( log
);
108 throw new StatusException( "Couldn't create document", e
);
113 XDocumentInfoSupplier xdis
= (XDocumentInfoSupplier
)
114 UnoRuntime
.queryInterface(XDocumentInfoSupplier
.class, xTextDoc
);
115 //oObj = (XInterface)UnoRuntime.queryInterface(XInterface.class, docInfo);
116 oObj
= xdis
.getDocumentInfo();
117 TestEnvironment tEnv
= new TestEnvironment( oObj
);
120 } // finish method getTestEnvironment
123 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
126 private void shortWait() {
129 } catch (InterruptedException e
) {
130 log
.println("While waiting :" + e
) ;