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 java
.io
.PrintWriter
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.SOfficeFactory
;
28 import com
.sun
.star
.text
.ControlCharacter
;
29 import com
.sun
.star
.text
.XText
;
30 import com
.sun
.star
.text
.XTextCursor
;
31 import com
.sun
.star
.text
.XTextDocument
;
32 import com
.sun
.star
.uno
.UnoRuntime
;
33 import com
.sun
.star
.uno
.XInterface
;
34 import com
.sun
.star
.util
.XSearchDescriptor
;
35 import com
.sun
.star
.util
.XSearchable
;
40 * @see com.sun.star.container.XElementAccess
41 * @see com.sun.star.container.XIndexAccess
44 public class SwXTextRanges
extends TestCase
{
45 XTextDocument xTextDoc
;
48 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
49 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
51 log
.println( "creating a textdocument" );
52 xTextDoc
= SOF
.createTextDoc( null );
56 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
57 log
.println( " disposing xTextDoc " );
58 util
.DesktopTools
.closeDoc(xTextDoc
);
62 * creating a TestEnvironment for the interfaces to be tested
64 * @param tParam class which contains additional test parameters
65 * @param log class to log the test state and result
67 * @return Status class
73 public TestEnvironment createTestEnvironment
74 (TestParameters tParam
, PrintWriter log
) {
76 XInterface oObj
= null;
78 // creation of testobject here
79 // first we write what we are intend to do to log file
80 log
.println( "creating a test environment" );
82 // create testobject here
83 XText oText
= xTextDoc
.getText();
84 XTextCursor oCursor
= oText
.createTextCursor();
86 for (int j
=0; j
< 5; j
++){
88 oText
.insertString( oCursor
,
89 "SwXTextRanges...SwXTextRanges...SwXTextRanges", false);
90 oText
.insertControlCharacter( oCursor
,
91 ControlCharacter
.PARAGRAPH_BREAK
, false );
94 log
.println( "EXCEPTION: " + e
);
98 XSearchable oSearch
= UnoRuntime
.queryInterface
99 (XSearchable
.class, xTextDoc
);
100 XSearchDescriptor xSDesc
= oSearch
.createSearchDescriptor();
101 xSDesc
.setSearchString("SwXTextRanges");
103 oObj
= oSearch
.findAll(xSDesc
);
105 log
.println( "creating a new environment for textrange object" );
106 TestEnvironment tEnv
= new TestEnvironment( oObj
);
108 log
.println( "adding TextDocument as mod relation to environment" );
109 tEnv
.addObjRelation("TEXTDOC", xTextDoc
);
112 } // finish method getTestEnvironment
114 } // finish class SwXTextRanges