Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScIndexEnumeration_CellAreaLinksEnumeration.java
blobe7d96f121baeefede8da69660c7592eb573d4e3b
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.sheet.XAreaLinks;
33 import com.sun.star.sheet.XSpreadsheetDocument;
34 import com.sun.star.table.CellAddress;
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_CellAreaLinksEnumeration extends TestCase {
41 private XSpreadsheetDocument xSheetDoc = null;
43 /**
44 * Creates Spreadsheet document.
46 @Override
47 protected void initialize( TestParameters tParam, PrintWriter log ) {
48 SOfficeFactory SOF = SOfficeFactory.getFactory( 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 @Override
65 protected void cleanup( TestParameters tParam, PrintWriter log ) {
66 log.println( " disposing xSheetDoc " );
67 XComponent oComp = UnoRuntime.queryInterface
68 (XComponent.class, xSheetDoc) ;
69 util.DesktopTools.closeDoc(oComp);
73 @Override
74 public synchronized TestEnvironment createTestEnvironment
75 (TestParameters Param, PrintWriter log){
77 XInterface oObj = null;
78 TestEnvironment tEnv = null ;
80 try {
82 // creation of testobject here
83 XPropertySet props = UnoRuntime.queryInterface
84 (XPropertySet.class, xSheetDoc);
85 oObj = (XInterface) AnyConverter.toObject(
86 new Type(XInterface.class),props.getPropertyValue("AreaLinks")) ;
87 XAreaLinks links = null ;
89 // adding one link into collection (for best testing)
90 links = UnoRuntime.queryInterface(XAreaLinks.class, oObj) ;
91 CellAddress addr = new CellAddress ((short) 1,2,3) ;
92 String aSourceArea = util.utils.getFullTestURL("calcshapes.sxc");
93 links.insertAtPosition (addr, aSourceArea, "a2:b5", "", "") ;
95 XEnumerationAccess ea = UnoRuntime.queryInterface(XEnumerationAccess.class,oObj);
97 oObj = ea.createEnumeration();
99 log.println("ImplementationName: "+util.utils.getImplName(oObj));
100 // creating test environment
101 tEnv = new TestEnvironment(oObj);
103 tEnv.addObjRelation("ENUM",ea);
105 } catch (com.sun.star.beans.UnknownPropertyException e) {
106 log.println ("Exception occurred while creating test Object.") ;
107 e.printStackTrace(log) ;
108 throw new StatusException("Couldn't create test object", e);
109 } catch (com.sun.star.lang.WrappedTargetException e) {
110 log.println ("Exception occurred while creating test Object.") ;
111 e.printStackTrace(log) ;
112 throw new StatusException("Couldn't create test object", e);
113 } catch (com.sun.star.lang.IllegalArgumentException e) {
114 log.println ("Exception occurred while creating test Object.") ;
115 e.printStackTrace(log) ;
116 throw new StatusException("Couldn't create test object", e);
119 return tEnv ;