bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXLineNumberingProperties.java
blobff07a8cfc46e308343b7e8093dd06b3d01f9d36d
1 /*
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 .
19 package mod._sw;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
28 import util.dbg;
30 import com.sun.star.beans.XPropertySet;
31 import com.sun.star.lang.XMultiServiceFactory;
32 import com.sun.star.text.ControlCharacter;
33 import com.sun.star.text.XLineNumberingProperties;
34 import com.sun.star.text.XText;
35 import com.sun.star.text.XTextCursor;
36 import com.sun.star.text.XTextDocument;
37 import com.sun.star.uno.UnoRuntime;
39 /**
40 * Test for object which is represented by service
41 * <code>com.sun.star.text.LineNumberingProperties</code>. <p>
42 * Object implements the following interfaces :
43 * <ul>
44 * <li> <code>com::sun::star::text::LineNumberingProperties</code></li>
45 * </ul> <p>
46 * This object test <b> is NOT </b> designed to be run in several
47 * threads concurently.
48 * @see com.sun.star.text.LineNumberingProperties
49 * @see ifc.text._LineNumberingProperties
51 public class SwXLineNumberingProperties extends TestCase {
52 XTextDocument xTextDoc;
54 /**
55 * Creates text document.
57 protected void initialize( TestParameters tParam, PrintWriter log ) {
58 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
59 try {
60 log.println( "creating a textdocument" );
61 xTextDoc = SOF.createTextDoc( null );
62 } catch ( com.sun.star.uno.Exception e ) {
63 e.printStackTrace( log );
64 throw new StatusException( "Couldn't create document", e );
68 /**
69 * Disposes text document.
71 protected void cleanup( TestParameters tParam, PrintWriter log ) {
72 log.println( " disposing xTextDoc " );
73 util.DesktopTools.closeDoc(xTextDoc);
77 /**
78 * Creating a Testenvironment for the interfaces to be tested. After inserting
79 * string and control character to the text document, line numbering
80 * properties are gotten using <code>XLineNumberingProperties</code> interface.
82 public TestEnvironment createTestEnvironment(
83 TestParameters tParam, PrintWriter log ) throws StatusException {
85 // insert some Text
86 XText oText = xTextDoc.getText();
87 XTextCursor oCursor = oText.createTextCursor();
88 try {
89 for (int i=0; i<5; i++) {
90 oText.insertString(oCursor, "The quick brown fox jumps "+
91 "over the lazy Dog", false);
92 oText.insertControlCharacter(oCursor,
93 ControlCharacter.PARAGRAPH_BREAK, false );
95 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
96 e.printStackTrace(log);
97 log.println("Exception occurred: " + e);
100 XLineNumberingProperties oLNP = UnoRuntime.queryInterface(XLineNumberingProperties.class,xTextDoc);
101 XPropertySet lineNumProps = oLNP.getLineNumberingProperties();
102 dbg.printPropertiesNames(lineNumProps);
103 TestEnvironment tEnv = new TestEnvironment(lineNumProps);
104 return tEnv;
106 } // finish method getTestEnvironment
108 } // finish class SwXLineNumberingProperties