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: SwXLineNumberingProperties.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
;
42 import com
.sun
.star
.beans
.XPropertySet
;
43 import com
.sun
.star
.lang
.XMultiServiceFactory
;
44 import com
.sun
.star
.text
.ControlCharacter
;
45 import com
.sun
.star
.text
.XLineNumberingProperties
;
46 import com
.sun
.star
.text
.XText
;
47 import com
.sun
.star
.text
.XTextCursor
;
48 import com
.sun
.star
.text
.XTextDocument
;
49 import com
.sun
.star
.uno
.UnoRuntime
;
52 * Test for object which is represented by service
53 * <code>com.sun.star.text.LineNumberingProperties</code>. <p>
54 * Object implements the following interfaces :
56 * <li> <code>com::sun::star::text::LineNumberingProperties</code></li>
58 * This object test <b> is NOT </b> designed to be run in several
59 * threads concurently.
60 * @see com.sun.star.text.LineNumberingProperties
61 * @see ifc.text._LineNumberingProperties
63 public class SwXLineNumberingProperties
extends TestCase
{
64 XTextDocument xTextDoc
;
67 * Creates text document.
69 protected void initialize( TestParameters tParam
, PrintWriter log
) {
70 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
72 log
.println( "creating a textdocument" );
73 xTextDoc
= SOF
.createTextDoc( null );
74 } catch ( com
.sun
.star
.uno
.Exception e
) {
75 e
.printStackTrace( log
);
76 throw new StatusException( "Couldn't create document", e
);
81 * Disposes text document.
83 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
84 log
.println( " disposing xTextDoc " );
85 util
.DesktopTools
.closeDoc(xTextDoc
);
90 * Creating a Testenvironment for the interfaces to be tested. After inserting
91 * string and control character to the text document, line numbering
92 * properties are gotten using <code>XLineNumberingProperties</code> interface.
94 public TestEnvironment
createTestEnvironment(
95 TestParameters tParam
, PrintWriter log
) throws StatusException
{
98 XText oText
= xTextDoc
.getText();
99 XTextCursor oCursor
= oText
.createTextCursor();
101 for (int i
=0; i
<5; i
++) {
102 oText
.insertString(oCursor
, "The quick brown fox jumps "+
103 "over the lazy Dog", false);
104 oText
.insertControlCharacter(oCursor
,
105 ControlCharacter
.PARAGRAPH_BREAK
, false );
107 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
108 e
.printStackTrace(log
);
109 log
.println("Exception occured: " + e
);
112 XLineNumberingProperties oLNP
= (XLineNumberingProperties
)
113 UnoRuntime
.queryInterface(XLineNumberingProperties
.class,xTextDoc
);
114 XPropertySet lineNumProps
= oLNP
.getLineNumberingProperties();
115 dbg
.printPropertiesNames(lineNumProps
);
116 TestEnvironment tEnv
= new TestEnvironment(lineNumProps
);
119 } // finish method getTestEnvironment
121 } // finish class SwXLineNumberingProperties