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
.InstCreator
;
27 import util
.ParagraphDsc
;
28 import util
.SOfficeFactory
;
31 import com
.sun
.star
.beans
.XPropertySet
;
32 import com
.sun
.star
.text
.XText
;
33 import com
.sun
.star
.text
.XTextCursor
;
34 import com
.sun
.star
.text
.XTextDocument
;
35 import com
.sun
.star
.text
.XTextFrame
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
37 import com
.sun
.star
.uno
.XInterface
;
43 * @see com.sun.star.container.XElementAccess
44 * @see com.sun.star.container.XEnumerationAccess
45 * @see com.sun.star.text.XSimpleText
46 * @see com.sun.star.text.XText
47 * @see com.sun.star.text.XTextRange
48 * @see com.sun.star.text.XTextRangeMover
51 public class SwXTextFrameText
extends TestCase
{
52 XTextDocument xTextDoc
;
55 protected void initialize(TestParameters tParam
, PrintWriter log
) throws Exception
{
56 SOfficeFactory SOF
= SOfficeFactory
.getFactory(tParam
.getMSF());
58 log
.println("creating a textdocument");
59 xTextDoc
= SOF
.createTextDoc(null);
63 protected void cleanup(TestParameters tParam
, PrintWriter log
) {
64 log
.println(" disposing xTextDoc ");
65 util
.DesktopTools
.closeDoc(xTextDoc
);
69 * creating a TestEnvironment for the interfaces to be tested
72 * class which contains additional test parameters
74 * class to log the test state and result
76 * @return Status class
82 public TestEnvironment
createTestEnvironment(
83 TestParameters tParam
, PrintWriter log
) throws Exception
{
85 XInterface oObj
= null;
86 XTextFrame oFrame1
= null;
87 XPropertySet oPropSet
= null;
89 XTextCursor oCursor
= null;
91 // creation of testobject here
92 // first we write what we are intend to do to log file
93 log
.println("creating a test environment");
95 // get a soffice factory object
96 SOfficeFactory
.getFactory(tParam
.getMSF());
98 // create testobject here
100 oFrame1
= SOfficeFactory
.createTextFrame(xTextDoc
, 500, 500);
101 oPropSet
= UnoRuntime
.queryInterface(XPropertySet
.class, oFrame1
);
102 // AnchorTypes: 0 = paragraph, 1 = as char, 2 = page,
103 // 3 = frame/paragraph 4= at char
104 oPropSet
.setPropertyValue("AnchorType", Integer
.valueOf(2));
105 oText
= xTextDoc
.getText();
106 oCursor
= oText
.createTextCursor();
108 log
.println("inserting Frame1");
109 oText
.insertTextContent(oCursor
, oFrame1
, false);
111 XText oFText
= UnoRuntime
.queryInterface(XText
.class, oFrame1
);
112 XTextCursor oFCursor
= oFText
.createTextCursor();
113 oFText
.insertString(oFCursor
, "SwXTextFrameText", false);
115 oObj
= oFText
.getText();
117 log
.println("creating a new environment for TextFrameText object");
118 TestEnvironment tEnv
= new TestEnvironment(oObj
);
120 log
.println("adding TextDocument as mod relation to environment");
121 tEnv
.addObjRelation("TEXT", oObj
);
123 log
.println("adding InstDescriptor object");
124 TableDsc tDsc
= new TableDsc(6, 4);
126 log
.println("adding InstCreator object");
127 tEnv
.addObjRelation("XTEXTINFO", new InstCreator(xTextDoc
, tDsc
));
129 log
.println(" adding Paragraph");
130 ParagraphDsc pDsc
= new ParagraphDsc();
131 tEnv
.addObjRelation("PARA", new InstCreator(xTextDoc
, pDsc
));
134 } // finish method getTestEnvironment
136 } // finish class SwXTextFrameText