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
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.DrawTools
;
28 import util
.SOfficeFactory
;
30 import com
.sun
.star
.drawing
.XShape
;
31 import com
.sun
.star
.lang
.XComponent
;
32 import com
.sun
.star
.text
.ControlCharacter
;
33 import com
.sun
.star
.text
.XText
;
34 import com
.sun
.star
.text
.XTextCursor
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
38 public class SvxUnoTextCursor
extends TestCase
{
40 static XComponent xDrawDoc
;
43 * in general this method creates a testdocument
45 * @param tParam class which contains additional test parameters
46 * @param log class to log the test state and result
54 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
55 log
.println( "creating a drawdoc" );
56 xDrawDoc
= DrawTools
.createDrawDoc(tParam
.getMSF());
60 * in general this method disposes the testenvironment and document
62 * @param tParam class which contains additional test parameters
63 * @param log class to log the test state and result
71 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
72 log
.println( " disposing xDrawDoc " );
73 util
.DesktopTools
.closeDoc(xDrawDoc
);
78 * creating a TestEnvironment for the interfaces to be tested
80 * @param tParam class which contains additional test parameters
81 * @param log class to log the test state and result
83 * @return Status class
89 public TestEnvironment
createTestEnvironment( TestParameters tParam
,
91 throws StatusException
{
93 XInterface oObj
= null;
94 // create testobject here
97 SOfficeFactory SOF
= SOfficeFactory
.getFactory(tParam
.getMSF()) ;
98 XShape oShape
= SOF
.createShape
99 (xDrawDoc
,5000,3500,7500,5000,"Text");
100 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
102 XText text
= UnoRuntime
.queryInterface(XText
.class, oShape
) ;
104 XTextCursor cursor
= text
.createTextCursor() ;
106 text
.insertString(cursor
, "Paragraph 1", false) ;
107 text
.insertControlCharacter(cursor
,
108 ControlCharacter
.PARAGRAPH_BREAK
, false) ;
109 text
.insertString(cursor
, "Paragraph 2", false) ;
110 text
.insertControlCharacter(cursor
,
111 ControlCharacter
.PARAGRAPH_BREAK
, false) ;
112 text
.insertString(cursor
, "Paragraph 3", false) ;
113 text
.insertControlCharacter(cursor
,
114 ControlCharacter
.PARAGRAPH_BREAK
, false) ;
118 } catch (Exception e
) {
119 log
.println("Can't create test object") ;
120 e
.printStackTrace(log
) ;
123 // create test environment here
124 TestEnvironment tEnv
= new TestEnvironment( oObj
);
128 } // finish method getTestEnvironment
130 } // finish class SvxUnoTextCursor