bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScIndexEnumeration_CellAreaLinksEnumeration.java
blobc129ffed8d88cb7f388b9f63917008ea93baa2ad
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.beans.XPropertySet;
30 import com.sun.star.container.XEnumerationAccess;
31 import com.sun.star.lang.XComponent;
32 import com.sun.star.lang.XMultiServiceFactory;
33 import com.sun.star.sheet.XAreaLinks;
34 import com.sun.star.sheet.XSpreadsheetDocument;
35 import com.sun.star.table.CellAddress;
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_CellAreaLinksEnumeration extends TestCase {
42 private XSpreadsheetDocument xSheetDoc = null;
44 /**
45 * Creates Spreadsheet document.
47 protected void initialize( TestParameters tParam, PrintWriter log ) {
48 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
50 try {
51 log.println( "creating a Spreadsheet document" );
52 xSheetDoc = SOF.createCalcDoc(null);
53 } catch ( com.sun.star.uno.Exception e ) {
54 // Some exception occurs.FAILED
55 e.printStackTrace( log );
56 throw new StatusException( "Couldn't create document", e );
61 /**
62 * Disposes Spreadsheet document.
64 protected void cleanup( TestParameters tParam, PrintWriter log ) {
65 log.println( " disposing xSheetDoc " );
66 XComponent oComp = UnoRuntime.queryInterface
67 (XComponent.class, xSheetDoc) ;
68 util.DesktopTools.closeDoc(oComp);
72 public synchronized TestEnvironment createTestEnvironment
73 (TestParameters Param, PrintWriter log){
75 XInterface oObj = null;
76 TestEnvironment tEnv = null ;
78 try {
80 // creation of testobject here
81 XPropertySet props = UnoRuntime.queryInterface
82 (XPropertySet.class, xSheetDoc);
83 oObj = (XInterface) AnyConverter.toObject(
84 new Type(XInterface.class),props.getPropertyValue("AreaLinks")) ;
85 XAreaLinks links = null ;
87 // adding one link into collection (for best testing)
88 links = UnoRuntime.queryInterface(XAreaLinks.class, oObj) ;
89 CellAddress addr = new CellAddress ((short) 1,2,3) ;
90 String aSourceArea = util.utils.getFullTestURL("calcshapes.sxc");
91 links.insertAtPosition (addr, aSourceArea, "a2:b5", "", "") ;
93 XEnumerationAccess ea = UnoRuntime.queryInterface(XEnumerationAccess.class,oObj);
95 oObj = ea.createEnumeration();
97 log.println("ImplementationName: "+util.utils.getImplName(oObj));
98 // creating test environment
99 tEnv = new TestEnvironment(oObj);
101 tEnv.addObjRelation("ENUM",ea);
103 } catch (com.sun.star.beans.UnknownPropertyException e) {
104 log.println ("Exception occurred while creating test Object.") ;
105 e.printStackTrace(log) ;
106 throw new StatusException("Couldn't create test object", e);
107 } catch (com.sun.star.lang.WrappedTargetException e) {
108 log.println ("Exception occurred while creating test Object.") ;
109 e.printStackTrace(log) ;
110 throw new StatusException("Couldn't create test object", e);
111 } catch (com.sun.star.lang.IllegalArgumentException e) {
112 log.println ("Exception occurred while creating test Object.") ;
113 e.printStackTrace(log) ;
114 throw new StatusException("Couldn't create test object", e);
117 return tEnv ;