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: SwXChapterNumbering.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 com
.sun
.star
.beans
.PropertyValue
;
34 import java
.io
.PrintWriter
;
36 import lib
.StatusException
;
38 import lib
.TestEnvironment
;
39 import lib
.TestParameters
;
40 import util
.SOfficeFactory
;
42 import com
.sun
.star
.lang
.XMultiServiceFactory
;
43 import com
.sun
.star
.text
.XChapterNumberingSupplier
;
44 import com
.sun
.star
.text
.XTextDocument
;
45 import com
.sun
.star
.uno
.UnoRuntime
;
46 import com
.sun
.star
.uno
.XInterface
;
49 * Test for object, which is a collection of chapter numbering rules of document.
50 * Object implements the following interfaces:
52 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
53 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
54 * <li> <code>com::sun::star::container::XElementAccess</code></li>
55 * <li> <code>com::sun::star::text::NumberingRules</code></li>
57 * This object test <b> is NOT </b> designed to be run in several
58 * threads concurently.
59 * @see com.sun.star.beans.XPropertySet
60 * @see com.sun.star.container.XIndexAccess
61 * @see com.sun.star.container.XElementAccess
62 * @see com.sun.star.text.NumberingRules
63 * @see ifc.beans._XPropertySet
64 * @see ifc.container._XIndexAccess
65 * @see ifc.container._XElementAccess
66 * @see ifc.text._NumberingRules
68 public class SwXChapterNumbering
extends TestCase
{
69 XTextDocument xTextDoc
;
72 * Creates text document.
74 protected void initialize( TestParameters tParam
, PrintWriter log
) {
75 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
77 log
.println( "creating a textdocument" );
78 xTextDoc
= SOF
.createTextDoc( null );
79 } catch ( com
.sun
.star
.uno
.Exception e
) {
80 e
.printStackTrace( log
);
81 throw new StatusException( "Couldn't create document", e
);
86 * Disposes text document.
88 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
89 log
.println( " disposing xTextDoc " );
90 util
.DesktopTools
.closeDoc(xTextDoc
);
94 * Creating a Testenvironment for the interfaces to be tested. Chapter
95 * numbering rules are gotten from text document using interface
96 * <code>XChapterNumberingSupplier</code>.
98 public TestEnvironment
createTestEnvironment(
99 TestParameters tParam
, PrintWriter log
) throws StatusException
{
100 XInterface oObj
= null;
102 XChapterNumberingSupplier oCNSupp
= (XChapterNumberingSupplier
)
103 UnoRuntime
.queryInterface(XChapterNumberingSupplier
.class,xTextDoc
);
104 oObj
= oCNSupp
.getChapterNumberingRules();
106 PropertyValue
[] instance1
= null;
108 instance1
= (PropertyValue
[]) oCNSupp
.getChapterNumberingRules().getByIndex(1);
109 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
111 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
115 //instance1[0].Value = new Short((short)5);
117 TestEnvironment tEnv
= new TestEnvironment( oObj
);
119 tEnv
.addObjRelation("INSTANCE1", instance1
);
123 } // finish method getTestEnvironment
125 } // finish class SwXChapterNumbering