2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import com
.sun
.star
.beans
.PropertyValue
;
22 import java
.io
.PrintWriter
;
24 import lib
.StatusException
;
26 import lib
.TestEnvironment
;
27 import lib
.TestParameters
;
28 import util
.SOfficeFactory
;
30 import com
.sun
.star
.lang
.XMultiServiceFactory
;
31 import com
.sun
.star
.text
.XChapterNumberingSupplier
;
32 import com
.sun
.star
.text
.XTextDocument
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.XInterface
;
37 * Test for object, which is a collection of chapter numbering rules of document.
38 * Object implements the following interfaces:
40 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
41 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
42 * <li> <code>com::sun::star::container::XElementAccess</code></li>
43 * <li> <code>com::sun::star::text::NumberingRules</code></li>
45 * This object test <b> is NOT </b> designed to be run in several
46 * threads concurently.
47 * @see com.sun.star.beans.XPropertySet
48 * @see com.sun.star.container.XIndexAccess
49 * @see com.sun.star.container.XElementAccess
50 * @see com.sun.star.text.NumberingRules
51 * @see ifc.beans._XPropertySet
52 * @see ifc.container._XIndexAccess
53 * @see ifc.container._XElementAccess
54 * @see ifc.text._NumberingRules
56 public class SwXChapterNumbering
extends TestCase
{
57 XTextDocument xTextDoc
;
60 * Creates text document.
62 protected void initialize( TestParameters tParam
, PrintWriter log
) {
63 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
65 log
.println( "creating a textdocument" );
66 xTextDoc
= SOF
.createTextDoc( null );
67 } catch ( com
.sun
.star
.uno
.Exception e
) {
68 e
.printStackTrace( log
);
69 throw new StatusException( "Couldn't create document", e
);
74 * Disposes text document.
76 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
77 log
.println( " disposing xTextDoc " );
78 util
.DesktopTools
.closeDoc(xTextDoc
);
82 * Creating a Testenvironment for the interfaces to be tested. Chapter
83 * numbering rules are gotten from text document using interface
84 * <code>XChapterNumberingSupplier</code>.
86 public TestEnvironment
createTestEnvironment(
87 TestParameters tParam
, PrintWriter log
) throws StatusException
{
88 XInterface oObj
= null;
90 XChapterNumberingSupplier oCNSupp
= UnoRuntime
.queryInterface(XChapterNumberingSupplier
.class,xTextDoc
);
91 oObj
= oCNSupp
.getChapterNumberingRules();
93 PropertyValue
[] instance1
= null;
95 instance1
= (PropertyValue
[]) oCNSupp
.getChapterNumberingRules().getByIndex(1);
96 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
98 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
102 //instance1[0].Value = new Short((short)5);
104 TestEnvironment tEnv
= new TestEnvironment( oObj
);
106 tEnv
.addObjRelation("INSTANCE1", instance1
);
110 } // finish method getTestEnvironment
112 } // finish class SwXChapterNumbering