tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScAccessibleSpreadsheet.java
blobdd177b7e35f3d7f602d4fd0c21d4a42def33e1ab
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._sc;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.AccessibilityTools;
28 import util.SOfficeFactory;
29 import util.utils;
31 import com.sun.star.accessibility.AccessibleRole;
32 import com.sun.star.accessibility.XAccessible;
33 import com.sun.star.awt.XWindow;
34 import com.sun.star.container.XIndexAccess;
35 import com.sun.star.frame.XModel;
36 import com.sun.star.lang.XComponent;
37 import com.sun.star.sheet.XSpreadsheet;
38 import com.sun.star.sheet.XSpreadsheetDocument;
39 import com.sun.star.sheet.XSpreadsheets;
40 import com.sun.star.table.XCell;
41 import com.sun.star.uno.AnyConverter;
42 import com.sun.star.uno.Type;
43 import com.sun.star.uno.UnoRuntime;
44 import com.sun.star.uno.XInterface;
46 /**
47 * Test for accessible object of spreadsheet document.<p>
48 * Object implements the following interfaces:
49 * <ul>
50 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code>
51 * </li>
52 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code>
53 * </li>
54 * <li> <code>::com::sun::star::accessibility::XAccessibleSelection
55 * </code></li>
56 * <li><code>::com::sun::star::accessibility::XAccessibleTable</code>
57 * </li>
58 * </ul>
59 * @see com.sun.star.accessibility.XAccessibleComponent
60 * @see com.sun.star.accessibility.XAccessibleContext
61 * @see com.sun.star.accessibility.XAccessibleSelection
62 * @see com.sun.star.accessibility.XAccessibleTable
63 * @see ifc.accessibility._XAccessibleComponent
64 * @see ifc.accessibility._XAccessibleContext
65 * @see ifc.accessibility._XAccessibleSelection
66 * @see ifc.accessibility._XAccessibleTable
68 public class ScAccessibleSpreadsheet extends TestCase {
69 private XSpreadsheetDocument xSheetDoc = null;
71 /**
72 * Creates a spreadsheet document.
74 @Override
75 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
76 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
77 log.println( "creating a Spreadsheet document" );
78 xSheetDoc = SOF.createCalcDoc(null);
81 /**
82 * Disposes a spreadsheet document.
84 @Override
85 protected void cleanup( TestParameters tParam, PrintWriter log ) {
86 log.println( " disposing xSheetDoc " );
87 XComponent oComp = UnoRuntime.queryInterface
88 (XComponent.class, xSheetDoc);
89 util.DesktopTools.closeDoc(oComp);
93 /**
94 * Creating a TestEnvironment for the interfaces to be tested.
95 * Obtains the accessible object for the spreadsheet.
97 @Override
98 public TestEnvironment createTestEnvironment
99 ( TestParameters Param, PrintWriter log )
100 throws StatusException {
102 XInterface oObj = null;
104 XModel xModel = UnoRuntime.queryInterface(XModel.class, xSheetDoc);
106 XWindow xWindow = AccessibilityTools.getCurrentWindow(xModel);
107 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
109 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE );
111 log.println("ImplementationName " + utils.getImplName(oObj));
113 TestEnvironment tEnv = new TestEnvironment( oObj );
115 // relation for XAccessibleEventBroadcaster
116 XCell xCell = null;
117 final String text = "Text for testing of the interface XAccessibleText";
118 try {
119 XSpreadsheets oSheets = xSheetDoc.getSheets() ;
120 XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
121 XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject(
122 new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
123 xCell = oSheet.getCellByPosition(5, 5) ;
124 xCell.setFormula(text);
125 } catch(com.sun.star.lang.WrappedTargetException e) {
126 log.println("Exception creating accessible text :");
127 e.printStackTrace(log);
128 } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
129 log.println("Exception creating accessible text :");
130 e.printStackTrace(log);
131 } catch(com.sun.star.lang.IllegalArgumentException e) {
132 log.println("Exception creating accessible text :");
133 e.printStackTrace(log);
136 final XCell fCell = xCell ;
138 tEnv.addObjRelation("EventProducer",
139 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){
140 public void fireEvent() {
141 fCell.setFormula("firing event");
142 fCell.setFormula(text);
146 return tEnv;