bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScIndexEnumeration_CellAnnotationsEnumeration.java
bloba8737a126d7df6d6e4ddad33e52a2c5fda9eaa8d
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.SOfficeFactory;
29 import com.sun.star.container.XEnumerationAccess;
30 import com.sun.star.container.XIndexAccess;
31 import com.sun.star.lang.XComponent;
32 import com.sun.star.lang.XMultiServiceFactory;
33 import com.sun.star.sheet.XSheetAnnotations;
34 import com.sun.star.sheet.XSheetAnnotationsSupplier;
35 import com.sun.star.sheet.XSpreadsheet;
36 import com.sun.star.sheet.XSpreadsheetDocument;
37 import com.sun.star.sheet.XSpreadsheets;
38 import com.sun.star.uno.AnyConverter;
39 import com.sun.star.uno.Type;
40 import com.sun.star.uno.UnoRuntime;
41 import com.sun.star.uno.XInterface;
44 public class ScIndexEnumeration_CellAnnotationsEnumeration extends TestCase {
45 private XSpreadsheetDocument xSheetDoc = null;
47 /**
48 * Creates Spreadsheet document.
50 protected void initialize( TestParameters tParam, PrintWriter log ) {
51 // get a soffice factory object
52 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
54 try {
55 log.println( "creating a sheetdocument" );
56 xSheetDoc = SOF.createCalcDoc(null);
57 } catch (com.sun.star.uno.Exception e) {
58 // Some exception occurs.FAILED
59 e.printStackTrace( log );
60 throw new StatusException( "Couldn't create document", e );
64 /**
65 * Disposes Spreadsheet document.
67 protected void cleanup( TestParameters tParam, PrintWriter log ) {
68 log.println( " disposing xSheetDoc " );
69 XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc);
70 util.DesktopTools.closeDoc(oComp);
73 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
75 XInterface oObj = null;
77 log.println("getting sheets");
78 XSpreadsheets xSpreadsheets = xSheetDoc.getSheets();
80 log.println("getting a sheet");
81 XSpreadsheet oSheet = null;
82 XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
83 try {
84 oSheet = (XSpreadsheet) AnyConverter.toObject(
85 new Type(XSpreadsheet.class),oIndexAccess.getByIndex(0));
86 } catch (com.sun.star.lang.WrappedTargetException e) {
87 e.printStackTrace(log);
88 throw new StatusException( "Couldn't get a spreadsheet", e);
89 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
90 e.printStackTrace(log);
91 throw new StatusException( "Couldn't get a spreadsheet", e);
92 } catch (com.sun.star.lang.IllegalArgumentException e) {
93 e.printStackTrace(log);
94 throw new StatusException( "Couldn't get a spreadsheet", e);
97 log.println("filling some cells");
98 try {
99 oSheet.getCellByPosition(5, 5).setValue(15);
100 oSheet.getCellByPosition(1, 4).setValue(10);
101 oSheet.getCellByPosition(2, 0).setValue(-5.15);
102 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
103 e.printStackTrace(log);
104 throw new StatusException(
105 "Exception occurred while filling cells", e);
108 XSheetAnnotationsSupplier sas = UnoRuntime.queryInterface(XSheetAnnotationsSupplier.class, oSheet);
110 XSheetAnnotations anno = sas.getAnnotations();
111 XEnumerationAccess ea = UnoRuntime.queryInterface(XEnumerationAccess.class, anno);
113 oObj = ea.createEnumeration();
115 log.println("ImplementationName: "+util.utils.getImplName(oObj));
117 log.println("creating a new environment for object");
118 TestEnvironment tEnv = new TestEnvironment(oObj);
120 tEnv.addObjRelation("ENUM",ea);
122 return tEnv;