Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScIndexEnumeration_TableAutoFormatEnumeration.java
blob19f8f15a41323c1cb53d7e8290a0da168dbeae3b
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.lang.XComponent;
31 import com.sun.star.sheet.XSpreadsheetDocument;
32 import com.sun.star.uno.UnoRuntime;
33 import com.sun.star.uno.XInterface;
35 public class ScIndexEnumeration_TableAutoFormatEnumeration extends TestCase{
36 private XSpreadsheetDocument xSheetDoc = null;
37 static SOfficeFactory SOF = null;
39 /**
40 * Creates Spreadsheet document.
42 @Override
43 protected void initialize( TestParameters tParam, PrintWriter log ) {
44 SOF = SOfficeFactory.getFactory( tParam.getMSF() );
46 try {
47 log.println( "creating a Spreadsheet document" );
48 xSheetDoc = SOF.createCalcDoc(null);
49 } catch ( com.sun.star.uno.Exception e ) {
50 // Some exception occurs.FAILED
51 e.printStackTrace( log );
52 throw new StatusException( "Couldn't create document", e );
56 /**
57 * Disposes Spreadsheet document.
59 @Override
60 protected void cleanup( TestParameters tParam, PrintWriter log ) {
61 log.println( " disposing xSheetDoc " );
62 XComponent oComp = UnoRuntime.queryInterface
63 (XComponent.class, xSheetDoc) ;
64 util.DesktopTools.closeDoc(oComp);
67 @Override
68 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
70 XInterface oObj = null;
72 try {
73 // creation of testobject here
74 // get AutoFormats
75 oObj = (XInterface)Param.getMSF().createInstance
76 ("com.sun.star.sheet.TableAutoFormats");
78 XEnumerationAccess ea = UnoRuntime.queryInterface(XEnumerationAccess.class,oObj);
80 oObj = ea.createEnumeration();
82 log.println("ImplementationName: "+util.utils.getImplName(oObj));
83 // creating test environment
84 TestEnvironment tEnv = new TestEnvironment( oObj );
86 tEnv.addObjRelation("ENUM",ea);
88 return tEnv;
89 } catch (com.sun.star.uno.Exception e) {
90 log.println ("Exception occurred while creating test Object.");
91 e.printStackTrace(log);
92 throw new StatusException("Couldn't create test object", e);
96 } // finish class ScAutoFormatsObj