tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScCellObj.java
blob1c5e02d3700f0d594ece095b1d630567f36f20d6
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.DefaultDsc;
26 import util.InstCreator;
27 import util.SOfficeFactory;
29 import com.sun.star.beans.XPropertySet;
30 import com.sun.star.container.XIndexAccess;
31 import com.sun.star.lang.XComponent;
32 import com.sun.star.sheet.XSpreadsheet;
33 import com.sun.star.sheet.XSpreadsheetDocument;
34 import com.sun.star.sheet.XSpreadsheets;
35 import com.sun.star.table.XCell;
36 import com.sun.star.uno.AnyConverter;
37 import com.sun.star.uno.Type;
38 import com.sun.star.uno.UnoRuntime;
39 import com.sun.star.uno.XInterface;
40 import ifc.sheet._XCellRangesQuery;
42 /**
43 * Test for object which is represented by service
44 * <code>com.sun.star.sheet.SheetCell</code>. <p>
45 * Object implements the following interfaces :
46 * <ul>
47 * <li> <code>com::sun::star::table::CellProperties</code></li>
48 * <li> <code>com::sun::star::text::XSimpleText</code></li>
49 * <li> <code>com::sun::star::table::XCell</code></li>
50 * <li> <code>com::sun::star::text::XTextRange</code></li>
51 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
52 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
53 * <li> <code>com::sun::star::document::XActionLockable</code></li>
54 * <li> <code>com::sun::star::style::ParagraphProperties</code></li>
55 * <li> <code>com::sun::star::text::XText</code></li>
56 * <li> <code>com::sun::star::sheet::XCellAddressable</code></li>
57 * </ul>
58 * @see com.sun.star.sheet.SheetCell
59 * @see com.sun.star.table.CellProperties
60 * @see com.sun.star.text.XSimpleText
61 * @see com.sun.star.table.XCell
62 * @see com.sun.star.text.XTextRange
63 * @see com.sun.star.beans.XPropertySet
64 * @see com.sun.star.style.CharacterProperties
65 * @see com.sun.star.document.XActionLockable
66 * @see com.sun.star.style.ParagraphProperties
67 * @see com.sun.star.text.XText
68 * @see com.sun.star.sheet.XCellAddressable
69 * @see ifc.table._CellProperties
70 * @see ifc.text._XSimpleText
71 * @see ifc.table._XCell
72 * @see ifc.text._XTextRange
73 * @see ifc.beans._XPropertySet
74 * @see ifc.style._CharacterProperties
75 * @see ifc.document._XActionLockable
76 * @see ifc.style._ParagraphProperties
77 * @see ifc.text._XText
78 * @see ifc.sheet._XCellAddressable
80 public class ScCellObj extends TestCase {
81 private XSpreadsheetDocument xSheetDoc = null;
84 /**
85 * Creates Spreadsheet document.
87 @Override
88 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
89 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
90 log.println( "Creating a Spreadsheet document" );
91 xSheetDoc = SOF.createCalcDoc(null);
94 /**
95 * Disposes Spreadsheet document.
97 @Override
98 protected void cleanup( TestParameters tParam, PrintWriter log ) {
99 log.println( " disposing xSheetDoc " );
100 XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc);
101 util.DesktopTools.closeDoc(oComp);
105 * Creating a TestEnvironment for the interfaces to be tested.
106 * Retrieves a collection of spreadsheets from a document,
107 * and takes one of them. Retrieves some cell from the spreadsheet
108 * that is instance of the service <code>com.sun.star.sheet.SheetCell</code>.
109 * Object relations created :
110 * <ul>
111 * <li> <code>'XTEXTINFO',</code> for
112 * {@link ifc.text._XText} </li>
113 * </ul>
114 * @see com.sun.star.sheet.SheetCell
116 @Override
117 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
119 XInterface oObj = null;
121 // creation of testobject here
122 // first we write what we are intend to do to log file
123 log.println( "Creating a test environment" );
125 XSpreadsheet oSheet = null;
126 XCell cell = null;
127 log.println("Getting spreadsheet") ;
128 XSpreadsheets oSheets = xSheetDoc.getSheets() ;
129 XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
130 oSheet = (XSpreadsheet) AnyConverter.toObject(
131 new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
133 log.println("Getting a cell from sheet") ;
134 oObj = oSheet.getCellByPosition(2, 3) ;
135 cell = UnoRuntime.queryInterface(XCell.class, oObj);
137 log.println( "creating a new environment for ScCellObj object" );
138 TestEnvironment tEnv = new TestEnvironment( oObj );
140 // Object relations for interface tests
141 DefaultDsc tDsc = new DefaultDsc(
142 "com.sun.star.text.XTextContent", "com.sun.star.text.TextField.URL");
143 log.println( " adding InstCreator object" );
144 tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xSheetDoc, tDsc ) );
145 // add the sheet
146 tEnv.addObjRelation("SHEET", oSheet);
147 // add expected results for the XCellRangesQuery interface test
148 String[]expectedResults = new String[7];
150 expectedResults[_XCellRangesQuery.QUERYCOLUMNDIFFERENCES] = "Sheet1.C4";
151 expectedResults[_XCellRangesQuery.QUERYCONTENTCELLS] = "";
152 expectedResults[_XCellRangesQuery.QUERYEMPTYCELLS] = "Sheet1.C4";
153 expectedResults[_XCellRangesQuery.QUERYFORMULACELLS] = "";
154 expectedResults[_XCellRangesQuery.QUERYINTERSECTION] = "";
155 expectedResults[_XCellRangesQuery.QUERYROWDIFFERENCES] = "Sheet1.C4";
156 expectedResults[_XCellRangesQuery.QUERYVISIBLECELLS] = "Sheet1.C4";
157 tEnv.addObjRelation("XCellRangesQuery.EXPECTEDRESULTS", expectedResults);
158 tEnv.addObjRelation("XCellRangesQuery.CREATEENTRIES", Boolean.TRUE);
160 // make entries in this cell at the interface test
161 tEnv.addObjRelation("XTextFieldsSupplier.MAKEENTRY", Boolean.TRUE);
162 tEnv.addObjRelation("MAKEENTRYINCELL", cell);
164 // for XSearchable and XReplaceable interface test
165 tEnv.addObjRelation("XSearchable.MAKEENTRYINCELL", cell);
166 tEnv.addObjRelation("EXCLUDEFINDNEXT", Boolean.TRUE);
168 // for XFormulaQuery interface test
169 tEnv.addObjRelation("EXPECTEDDEPENDENTVALUES", new int[]{2,2,3,3});
170 tEnv.addObjRelation("EXPECTEDPRECEDENTVALUES", new int[]{0,3,0,0});
171 tEnv.addObjRelation("RANGEINDICES", new int[]{0,0});
173 // XTextFieldsSupplier
174 tEnv.addObjRelation("SPREADSHEET", xSheetDoc);
176 XPropertySet PropSet = UnoRuntime.queryInterface(XPropertySet.class, oObj);
177 tEnv.addObjRelation("PropSet",PropSet);
179 return tEnv;
180 } // finish method getTestEnvironment
182 } // finish class ScCellObj