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: ScStyleFamiliesObj.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
.XComponent
;
43 import com
.sun
.star
.lang
.XMultiServiceFactory
;
44 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
45 import com
.sun
.star
.style
.XStyleFamiliesSupplier
;
46 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 * @see com.sun.star.style.StyleFamilies
58 * @see com.sun.star.container.XNameAccess
59 * @see com.sun.star.container.XElementAccess
60 * @see com.sun.star.container.XIndexAccess
61 * @see ifc.container._XNameAccess
62 * @see ifc.container._XElementAccess
63 * @see ifc.container._XIndexAccess
65 public class ScStyleFamiliesObj
extends TestCase
{
66 static XSpreadsheetDocument xSpreadsheetDoc
= null;
69 * Creates Spreadsheet document.
71 protected void initialize( TestParameters tParam
, PrintWriter log
) {
72 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
75 log
.println( "creating a Spreadsheet document" );
76 xSpreadsheetDoc
= SOF
.createCalcDoc(null);
77 } catch ( com
.sun
.star
.uno
.Exception e
) {
78 // Some exception occures.FAILED
79 e
.printStackTrace( log
);
80 throw new StatusException( "Couldn't create document", e
);
85 * Disposes Spreadsheet document.
87 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
88 log
.println( " disposing xSheetDoc " );
89 XComponent oComp
= (XComponent
)
90 UnoRuntime
.queryInterface (XComponent
.class, xSpreadsheetDoc
) ;
91 util
.DesktopTools
.closeDoc(oComp
);
95 * Creating a Testenvironment for the interfaces to be tested.
96 * Retrieves the collection of style families from the document
97 * using the interface <code>XStyleFamiliesSupplier</code>.
98 * This collection is the instance of the service
99 * <code>com.sun.star.style.StyleFamilies</code>.
100 * @see com.sun.star.style.StyleFamilies
101 * @see com.sun.star.style.XStyleFamiliesSupplier
103 public TestEnvironment
createTestEnvironment(
104 TestParameters tParam
, PrintWriter log
) throws StatusException
{
106 // creation of testobject here
107 // first we write what we are intend to do to log file
108 log
.println( "creating a test environment" );
110 XNameAccess oStyleFamilies
=null;
111 // create testobject here
112 log
.println("getting style families");
113 XStyleFamiliesSupplier oStyleFamiliesSupplier
=(XStyleFamiliesSupplier
)
114 UnoRuntime
.queryInterface(
115 XStyleFamiliesSupplier
.class, xSpreadsheetDoc
);
117 oStyleFamilies
= oStyleFamiliesSupplier
.getStyleFamilies();
119 TestEnvironment tEnv
= new TestEnvironment(oStyleFamilies
);
122 } // finish method getTestEnvironment
123 } // finish class ScStyleFamiliesObj