Update git submodules
[LibreOffice.git] / qadevOOo / tests / java / mod / _svx / SvxUnoTextContent.java
blob3550663a4aca0cc67bbfab4f1a551f41ee89c9fa
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._svx;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.DrawTools;
27 import util.SOfficeFactory;
29 import com.sun.star.container.XEnumerationAccess;
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.XSimpleText;
34 import com.sun.star.text.XTextCursor;
35 import com.sun.star.uno.AnyConverter;
36 import com.sun.star.uno.Type;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
40 public class SvxUnoTextContent extends TestCase {
42 static XComponent xDrawDoc;
44 /**
45 * in general this method creates a testdocument
47 * @param tParam class which contains additional test parameters
48 * @param log class to log the test state and result
51 * @see TestParameters
52 * @see PrintWriter
55 @Override
56 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
57 log.println( "creating a drawdoc" );
58 xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF());
61 /**
62 * in general this method disposes the testenvironment and document
64 * @param tParam class which contains additional test parameters
65 * @param log class to log the test state and result
68 * @see TestParameters
69 * @see PrintWriter
72 @Override
73 protected void cleanup( TestParameters tParam, PrintWriter log ) {
74 log.println( " disposing xDrawDoc " );
75 util.DesktopTools.closeDoc(xDrawDoc);
79 /**
80 * creating a TestEnvironment for the interfaces to be tested
82 * @param tParam class which contains additional test parameters
83 * @param log class to log the test state and result
85 * @return Status class
87 * @see TestParameters
88 * @see PrintWriter
90 @Override
91 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception {
93 XInterface oObj = null;
94 // create testobject here
96 XEnumerationAccess xEA = null ;
97 SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()) ;
98 XShape oShape = SOF.createShape(xDrawDoc,
99 5000,3500,7500,5000,"Text");
100 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ;
102 XSimpleText text = UnoRuntime.queryInterface
103 (XSimpleText.class, oShape) ;
105 XTextCursor cursor = text.createTextCursor() ;
107 text.insertString(cursor, "Paragraph 1", false) ;
108 text.insertControlCharacter(cursor,
109 ControlCharacter.PARAGRAPH_BREAK, false) ;
110 text.insertString(cursor, "Paragraph 2", false) ;
111 text.insertControlCharacter(cursor,
112 ControlCharacter.PARAGRAPH_BREAK, false) ;
113 text.insertString(cursor, "Paragraph 3", false) ;
114 text.insertControlCharacter(cursor,
115 ControlCharacter.PARAGRAPH_BREAK, false) ;
117 xEA = UnoRuntime.queryInterface
118 (XEnumerationAccess.class, text) ;
120 oObj = (XInterface) AnyConverter.toObject(
121 new Type(XInterface.class),xEA.createEnumeration().nextElement());
123 // create test environment here
124 TestEnvironment tEnv = new TestEnvironment( oObj );
126 return tEnv;
127 } // finish method getTestEnvironment