bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScIndexEnumeration_SpreadsheetViewPanesEnumeration.java
blobb6ef6302ae674dd5cf1350e2f125221fcdd6f4d6
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.sheet.XSpreadsheetDocument;
35 import com.sun.star.uno.AnyConverter;
36 import com.sun.star.uno.Type;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
40 public class ScIndexEnumeration_SpreadsheetViewPanesEnumeration extends TestCase {
41 private XSpreadsheetDocument xSpreadsheetDoc;
42 private static SOfficeFactory SOF;
43 private static XInterface oObj;
45 /**
46 * Creates Spreadsheet document.
48 @Override
49 public void initialize( TestParameters Param, PrintWriter log ) {
50 // get a soffice factory object
51 SOF = SOfficeFactory.getFactory( 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 @Override
66 protected void cleanup( TestParameters tParam, PrintWriter log ) {
67 log.println("disposing xSpreadsheetDocument");
68 XComponent oComp = UnoRuntime.queryInterface(XComponent.class, xSpreadsheetDoc);
69 util.DesktopTools.closeDoc(oComp);
72 @Override
73 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
75 XModel xm = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc);
76 XController xc = xm.getCurrentController();
77 XIndexAccess xIA = UnoRuntime.queryInterface(XIndexAccess.class, xc);
78 try {
79 oObj = (XInterface) AnyConverter.toObject(
80 new Type(XInterface.class),xIA.getByIndex(0));
81 } catch (com.sun.star.lang.WrappedTargetException e) {
82 e.printStackTrace(log);
83 throw new StatusException("Couldn't get by index", e);
84 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
85 e.printStackTrace(log);
86 throw new StatusException("Couldn't get by index", e);
87 } catch (com.sun.star.lang.IllegalArgumentException e) {
88 e.printStackTrace(log);
89 throw new StatusException("Couldn't get by index", e);
92 XEnumerationAccess ea = UnoRuntime.queryInterface(XEnumerationAccess.class,xIA);
94 oObj = ea.createEnumeration();
96 log.println("ImplementationName: "+util.utils.getImplName(oObj));
97 // creating test environment
98 TestEnvironment tEnv = new TestEnvironment( oObj );
100 tEnv.addObjRelation("ENUM",ea);
102 return tEnv;