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: SwXStyleFamilies.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
.container
.XNameAccess
;
42 import com
.sun
.star
.lang
.XMultiServiceFactory
;
43 import com
.sun
.star
.style
.XStyleFamiliesSupplier
;
44 import com
.sun
.star
.text
.XTextDocument
;
45 import com
.sun
.star
.uno
.UnoRuntime
;
49 * Test for object which is represented by service
50 * <code>com.sun.star.style.StyleFamilies</code>. <p>
51 * Object implements the following interfaces :
53 * <li> <code>com::sun::star::container::XNameAccess</code></li>
54 * <li> <code>com::sun::star::container::XElementAccess</code></li>
55 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
57 * This object test <b> is NOT </b> designed to be run in several
58 * threads concurently.
59 * @see com.sun.star.container.XNameAccess
60 * @see com.sun.star.container.XElementAccess
61 * @see com.sun.star.container.XIndexAccess
62 * @see com.sun.star.style.StyleFamilies
63 * @see ifc.container._XNameAccess
64 * @see ifc.container._XElementAccess
65 * @see ifc.container._XIndexAccess
67 public class SwXStyleFamilies
extends TestCase
{
68 XTextDocument xTextDoc
;
71 * Creates text document.
73 protected void initialize( TestParameters tParam
, PrintWriter log
) {
74 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
76 log
.println( "creating a textdocument" );
77 xTextDoc
= SOF
.createTextDoc( null );
78 } catch ( com
.sun
.star
.uno
.Exception e
) {
79 e
.printStackTrace( log
);
80 throw new StatusException( "Couldn't create document", e
);
85 * Disposes text document.
87 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
88 log
.println( " disposing xTextDoc " );
89 util
.DesktopTools
.closeDoc(xTextDoc
);
93 * Creating a Testenvironment for the interfaces to be tested. Style families
94 * are gotten from text document using <code>XStyleFamiliesSupplier</code>
95 * interface and returned as a test component.
97 public synchronized TestEnvironment
createTestEnvironment(
98 TestParameters Param
, PrintWriter log
) throws StatusException
{
101 log
.println( "Creating a test environment" );
102 XTextDocument xArea
= (XTextDocument
)
103 UnoRuntime
.queryInterface(XTextDocument
.class, xTextDoc
);
104 XStyleFamiliesSupplier oSFS
= (XStyleFamiliesSupplier
)
105 UnoRuntime
.queryInterface(XStyleFamiliesSupplier
.class, xArea
);
106 XNameAccess oSF
= oSFS
.getStyleFamilies();
108 TestEnvironment tEnv
= new TestEnvironment(oSF
);
113 } // finish class SwXStyle