tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScCellTextCursor.java
blob882f25702e54edcb3680087a2120d2411660529c
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 .
18 package mod._sc;
20 import java.io.PrintWriter;
22 import lib.TestCase;
23 import lib.TestEnvironment;
24 import lib.TestParameters;
25 import util.SOfficeFactory;
27 import com.sun.star.container.XIndexAccess;
28 import com.sun.star.lang.XComponent;
29 import com.sun.star.sheet.XSpreadsheet;
30 import com.sun.star.sheet.XSpreadsheetDocument;
31 import com.sun.star.sheet.XSpreadsheets;
32 import com.sun.star.table.XCell;
33 import com.sun.star.text.XText;
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 /**
40 * Test for object which is represented by service
41 * <code>com.sun.star.text.TextCursor</code>. <p>
42 * Object implements the following interfaces :
43 * <ul>
44 * <li> <code>com::sun::star::text::XTextCursor</code></li>
45 * <li> <code>com::sun::star::text::XWordCursor</code></li>
46 * <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li>
47 * <li> <code>com::sun::star::text::XTextRange</code></li>
48 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
49 * <li> <code>com::sun::star::container::XContentEnumerationAccess</code></li>
50 * <li> <code>com::sun::star::beans::XPropertyState</code></li>
51 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
52 * <li> <code>com::sun::star::text::XSentenceCursor</code></li>
53 * <li> <code>com::sun::star::style::ParagraphProperties</code></li>
54 * <li> <code>com::sun::star::text::XParagraphCursor</code></li>
55 * <li> <code>com::sun::star::document::XDocumentInsertable</code></li>
56 * <li> <code>com::sun::star::util::XSortable</code></li>
57 * <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li>
58 * </ul>
59 * @see com.sun.star.text.TextCursor
60 * @see com.sun.star.text.XTextCursor
61 * @see com.sun.star.text.XWordCursor
62 * @see com.sun.star.style.CharacterPropertiesComplex
63 * @see com.sun.star.text.XTextRange
64 * @see com.sun.star.beans.XPropertySet
65 * @see com.sun.star.container.XContentEnumerationAccess
66 * @see com.sun.star.beans.XPropertyState
67 * @see com.sun.star.style.CharacterProperties
68 * @see com.sun.star.text.XSentenceCursor
69 * @see com.sun.star.style.ParagraphProperties
70 * @see com.sun.star.text.XParagraphCursor
71 * @see com.sun.star.document.XDocumentInsertable
72 * @see com.sun.star.util.XSortable
73 * @see com.sun.star.style.CharacterPropertiesAsian
74 * @see ifc.text._XTextCursor
75 * @see ifc.text._XWordCursor
76 * @see ifc.style._CharacterPropertiesComplex
77 * @see ifc.text._XTextRange
78 * @see ifc.beans._XPropertySet
79 * @see ifc.container._XContentEnumerationAccess
80 * @see ifc.beans._XPropertyState
81 * @see ifc.style._CharacterProperties
82 * @see ifc.text._XSentenceCursor
83 * @see ifc.style._ParagraphProperties
84 * @see ifc.text._XParagraphCursor
85 * @see ifc.document._XDocumentInsertable
86 * @see ifc.util._XSortable
87 * @see ifc.style._CharacterPropertiesAsian
89 public class ScCellTextCursor extends TestCase {
90 private XSpreadsheetDocument xSheetDoc = null;
92 /**
93 * Creates Spreadsheet document.
95 @Override
96 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
97 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
98 log.println( "creating a Spreadsheet document" );
99 xSheetDoc = SOF.createCalcDoc(null);
103 * Disposes Spreadsheet document.
105 @Override
106 protected void cleanup( TestParameters tParam, PrintWriter log ) {
107 log.println( " disposing xSheetDoc " );
108 XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
109 util.DesktopTools.closeDoc(oComp);
113 * Creating a TestEnvironment for the interfaces to be tested.
114 * Retrieves a collection of spreadsheets from a document
115 * and takes one of them. Retrieves the cell from the spreadsheet
116 * and creates text cursor of the cell using the interface
117 * <code>XText</code>. This text cursor is the instance of
118 * the service <code>com.sun.star.text.TextCursor</code>.
119 * Object relations created :
120 * <ul>
121 * <li> <code>'XTEXT'</code> for
122 * {@link ifc.text._XTextRange} (type of
123 * <code>XEnumerationAccess</code> that was retrieved from the
124 * collection of visible cells)</li>
125 * </ul>
126 * @see com.sun.star.text.XText
128 @Override
129 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception {
131 XInterface oObj = null;
132 XCell aCell = null;
134 // creation of testobject here
135 // first we write what we are intend to do to log file
136 log.println( "Creating a test environment" );
138 // get a soffice factory object
139 log.println("Getting spreadsheet") ;
140 XSpreadsheets oSheets = xSheetDoc.getSheets() ;
141 XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
142 XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject(
143 new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
145 log.println("Getting a cell from sheet") ;
146 aCell = oSheet.getCellByPosition(1,1) ;
148 XText aText = UnoRuntime.queryInterface(XText.class, aCell);
149 aText.setString("ScCellTextCursor");
150 oObj = aText.createTextCursor();
152 log.println( "creating a new environment for ScCellTextCursor object" );
153 TestEnvironment tEnv = new TestEnvironment( oObj );
155 // Object relations for interface tests
156 tEnv.addObjRelation("XTEXT", aText);
158 return tEnv;
159 } // finish method getTestEnvironment
161 } // finish class ScCellTextCursor