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
.DrawTools
;
27 import util
.SOfficeFactory
;
29 import com
.sun
.star
.drawing
.XShape
;
30 import com
.sun
.star
.lang
.XComponent
;
31 import com
.sun
.star
.lang
.XMultiServiceFactory
;
32 import com
.sun
.star
.text
.XText
;
33 import com
.sun
.star
.text
.XTextContent
;
34 import com
.sun
.star
.text
.XTextCursor
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
41 * @see ifc._XComponent
42 * @see ifc._TextContent
43 * @see ifc._XTextContent
44 * @see ifc._XTextField
47 public class SvxUnoTextField
extends TestCase
{
49 static XComponent xDrawDoc
;
52 * in general this method creates a testdocument
54 * @param tParam class which contains additional test parameters
55 * @param log class to log the test state and result
63 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
64 log
.println( "creating a drawdoc" );
65 xDrawDoc
= DrawTools
.createDrawDoc( tParam
.getMSF());
69 * in general this method disposes the testenvironment and document
71 * @param tParam class which contains additional test parameters
72 * @param log class to log the test state and result
80 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
81 log
.println( " disposing xDrawDoc " );
82 util
.DesktopTools
.closeDoc(xDrawDoc
);
85 * creating a TestEnvironment for the interfaces to be tested
87 * @param tParam class which contains additional test parameters
88 * @param log class to log the test state and result
90 * @return Status class
96 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) throws Exception
{
98 XInterface oObj
= null;
101 // creation of testobject here
102 // first we write what we are intend to do to log file
103 log
.println( "creating a test environment" );
104 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
105 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Rectangle");
106 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
108 XTextCursor the_Cursor
= null;
110 // create testobject here
111 XText the_Text
= UnoRuntime
.queryInterface(XText
.class,oShape
);
112 XMultiServiceFactory oDocMSF
= UnoRuntime
.queryInterface( XMultiServiceFactory
.class, xDrawDoc
);
113 the_Cursor
= the_Text
.createTextCursor();
115 oDocMSF
.createInstance( "com.sun.star.text.TextField.DateTime" );
116 XTextContent the_Field
= UnoRuntime
.queryInterface(XTextContent
.class,oObj
);
119 the_Text
.insertTextContent(the_Cursor
,the_Field
,false);
121 log
.println( "creating a new environment for FieldMaster object" );
122 TestEnvironment tEnv
= new TestEnvironment( oObj
);
123 tEnv
.addObjRelation("RANGE", the_Cursor
);
126 } // finish method getTestEnvironment
128 } // finish class SvxUnoTextField