bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScIndexEnumeration_SpreadsheetViewPanesEnumeration.java
blob3ee20b7d5a98d6dd148bc0f0b8d0b69779ecc0b3
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.frame.XController;
32 import com.sun.star.frame.XModel;
33 import com.sun.star.lang.XComponent;
34 import com.sun.star.lang.XMultiServiceFactory;
35 import com.sun.star.sheet.XSpreadsheetDocument;
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;
41 public class ScIndexEnumeration_SpreadsheetViewPanesEnumeration extends TestCase {
42 private XSpreadsheetDocument xSpreadsheetDoc;
43 private static SOfficeFactory SOF;
44 private static XInterface oObj;
46 /**
47 * Creates Spreadsheet document.
49 public void initialize( TestParameters Param, PrintWriter log ) {
50 // get a soffice factory object
51 SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
53 try {
54 log.println("creating a spreadsheetdocument");
55 xSpreadsheetDoc = SOF.createCalcDoc(null);
56 } catch (com.sun.star.uno.Exception e) {
57 e.printStackTrace( log );
58 throw new StatusException( "Couldn't create document ", e );
62 /**
63 * Disposes Spreadsheet document.
65 protected void cleanup( TestParameters tParam, PrintWriter log ) {
66 log.println("disposing xSpreadsheetDocument");
67 XComponent oComp = UnoRuntime.queryInterface(XComponent.class, xSpreadsheetDoc);
68 util.DesktopTools.closeDoc(oComp);
71 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
73 XModel xm = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc);
74 XController xc = xm.getCurrentController();
75 XIndexAccess xIA = UnoRuntime.queryInterface(XIndexAccess.class, xc);
76 try {
77 oObj = (XInterface) AnyConverter.toObject(
78 new Type(XInterface.class),xIA.getByIndex(0));
79 } catch (com.sun.star.lang.WrappedTargetException e) {
80 e.printStackTrace(log);
81 throw new StatusException("Couldn't get by index", e);
82 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
83 e.printStackTrace(log);
84 throw new StatusException("Couldn't get by index", e);
85 } catch (com.sun.star.lang.IllegalArgumentException e) {
86 e.printStackTrace(log);
87 throw new StatusException("Couldn't get by index", e);
90 XEnumerationAccess ea = UnoRuntime.queryInterface(XEnumerationAccess.class,xIA);
92 oObj = ea.createEnumeration();
94 log.println("ImplementationName: "+util.utils.getImplName(oObj));
95 // creating test environment
96 TestEnvironment tEnv = new TestEnvironment( oObj );
98 tEnv.addObjRelation("ENUM",ea);
100 return tEnv;