tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXTextPortionEnumeration.java
blobb5cf80e3033bc797109fe97f0dd8cd5be3ce0e52
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._sw;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.SOfficeFactory;
28 import com.sun.star.container.XEnumeration;
29 import com.sun.star.container.XEnumerationAccess;
30 import com.sun.star.text.ControlCharacter;
31 import com.sun.star.text.XText;
32 import com.sun.star.text.XTextCursor;
33 import com.sun.star.text.XTextDocument;
34 import com.sun.star.uno.AnyConverter;
35 import com.sun.star.uno.Type;
36 import com.sun.star.uno.UnoRuntime;
37 import com.sun.star.uno.XInterface;
39 /**
41 * initial description
43 * @see com.sun.star.text.TextPortion
46 public class SwXTextPortionEnumeration extends TestCase {
48 XTextDocument xTextDoc;
50 @Override
51 protected void initialize(TestParameters tParam, PrintWriter log) throws Exception {
52 SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF());
54 log.println("creating a textdocument");
55 xTextDoc = SOF.createTextDoc(null);
58 @Override
59 protected void cleanup(TestParameters tParam, PrintWriter log) {
60 log.println(" disposing xTextDoc ");
61 util.DesktopTools.closeDoc(xTextDoc);
64 /**
65 * creating a TestEnvironment for the interfaces to be tested
67 * @param tParam
68 * class which contains additional test parameters
69 * @param log
70 * class to log the test state and result
72 * @return Status class
74 * @see TestParameters
75 * @see PrintWriter
77 @Override
78 protected TestEnvironment createTestEnvironment(
79 TestParameters tParam, PrintWriter log) throws Exception {
81 XInterface param = null;
83 // creation of testobject here
84 // first we write what we are intend to do to log file
85 log.println("creating a test environment");
87 // create testobject here
89 XText oText = xTextDoc.getText();
90 XTextCursor oCursor = oText.createTextCursor();
92 log.println("inserting Strings");
93 log.println("inserting ControlCharacter");
95 for (int i = 0; i < 5; i++) {
96 oText.insertString(oCursor, "Paragraph Number: " + i, false);
97 oText.insertControlCharacter(oCursor, ControlCharacter.LINE_BREAK,
98 false);
99 oText.insertString(
100 oCursor,
101 "The quick brown fox jumps over the lazy Dog: SwXParagraph\n",
102 false);
103 oText.insertControlCharacter(oCursor, ControlCharacter.LINE_BREAK,
104 false);
105 oText.insertString(
106 oCursor,
107 "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph",
108 false);
109 oText.insertControlCharacter(oCursor,
110 ControlCharacter.PARAGRAPH_BREAK, false);
113 // Enumeration
114 XEnumerationAccess oEnumA = UnoRuntime.queryInterface(
115 XEnumerationAccess.class, oText);
116 XEnumeration oEnum = oEnumA.createEnumeration();
118 while (oEnum.hasMoreElements()) {
119 param = (XInterface) AnyConverter.toObject(new Type(
120 XInterface.class), oEnum.nextElement());
123 XEnumerationAccess oEnumP = UnoRuntime.queryInterface(
124 XEnumerationAccess.class, param);
125 XEnumeration oEnum2 = oEnumP.createEnumeration();
127 log.println("creating a new environment for TextPortionEnumeration object");
128 TestEnvironment tEnv = new TestEnvironment(oEnum2);
130 log.println("adding ObjRelation ENUM for XEnumeration");
131 tEnv.addObjRelation("ENUM", oEnumP);
133 return tEnv;
134 } // finish method getTestEnvironment
136 } // finish class SwXTextPortionEnumeration