bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXTextRange.java
blobca6c9cfa3e0b96d769f00fde8033a25b8ef880f2
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.utils;
30 import com.sun.star.text.XText;
31 import com.sun.star.text.XTextCursor;
32 import com.sun.star.text.XTextDocument;
33 import com.sun.star.uno.XInterface;
35 public class SwXTextRange extends TestCase {
36 XTextDocument xTextDoc;
38 @Override
39 protected void initialize( TestParameters tParam, PrintWriter log ) {
40 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
42 try {
43 log.println( "creating a textdocument" );
44 xTextDoc = SOF.createTextDoc( null );
45 } catch ( com.sun.star.uno.Exception e ) {
46 // Some exception occurs.FAILED
47 e.printStackTrace( log );
48 throw new StatusException( "Couldn't create document", e );
52 @Override
53 protected void cleanup( TestParameters tParam, PrintWriter log ) {
54 log.println( " disposing xTextDoc " );
55 util.DesktopTools.closeDoc(xTextDoc);
58 /**
59 * creating a Testenvironment for the interfaces to be tested
61 @Override
62 public synchronized TestEnvironment createTestEnvironment( TestParameters Param,
63 PrintWriter log )
64 throws StatusException {
66 XText aText = null;
68 // creation of testobject here
69 // first we write what we are intend to do to log file
70 log.println( "creating a test environment" );
73 // get the bodytext of textdocument here
74 log.println( "getting the TextRange of the text document" );
75 aText = xTextDoc.getText();
76 XTextCursor oCursor = aText.createTextCursor();
78 XInterface oObj = oCursor.getStart();
80 log.println( "creating a new environment for textrange object" );
81 TestEnvironment tEnv = new TestEnvironment( oObj );
83 log.println( "adding TextDocument as mod relation to environment" );
84 tEnv.addObjRelation("TEXTDOC", xTextDoc);
86 System.out.println("Implementation Name: "+utils.getImplName(oObj));
88 return tEnv;
89 } // finish method getTestEnvironment
91 } // finish class SwXTextRange