bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScAutoFormatFieldObj.java
blob1e7ccb439711ed8c32189380d3da12e614b19998
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 com.sun.star.container.XIndexAccess;
28 import com.sun.star.lang.XMultiServiceFactory;
29 import com.sun.star.uno.AnyConverter;
30 import com.sun.star.uno.Type;
31 import com.sun.star.uno.UnoRuntime;
32 import com.sun.star.uno.XInterface;
34 /**
35 * Test for object which is represented by service
36 * <code>com.sun.star.sheet.TableAutoFormatField</code>.
37 * In StarCalc application there is a collection of autoformats
38 * for tables (you can select a predefined format for a
39 * table or create your own). Each autoformat has a number
40 * of fields with definitions of font parameters, number
41 * formats etc. for different parts of a table (column and
42 * row names, footers, data). This object represents the
43 * field of the same kind. <p>
44 * Object implements the following interfaces :
45 * <ul>
46 * <li> <code>com::sun::star::sheet::TableAutoFormatField</code></li>
47 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
48 * </ul>
49 * This object test <b> is NOT </b> designed to be run in several
50 * threads concurently.
51 * @see com.sun.star.sheet.TableAutoFormatField
52 * @see com.sun.star.beans.XPropertySet
53 * @see ifc.sheet._TableAutoFormatField
54 * @see ifc.beans._XPropertySet
56 public class ScAutoFormatFieldObj extends TestCase {
58 /**
59 * Creating a Testenvironment for the interfaces to be tested.
60 * Using SOffice ServiceManager an instance of
61 * <code>com.sun.star.sheet.TableAutoFormatField</code> service
62 * is created. From this collection one Format is retrieved
63 * and then from this format one of its compound fields is
64 * retrieved.
66 public synchronized TestEnvironment createTestEnvironment
67 ( TestParameters Param, PrintWriter log ) throws StatusException {
69 XInterface oObj = null;
71 try {
73 log.println ("create Object ...") ;
74 // creation of testobject here
75 XInterface formats = (XInterface)((XMultiServiceFactory)Param.getMSF()).createInstance
76 ("com.sun.star.sheet.TableAutoFormats");
77 XIndexAccess formatsIndex = UnoRuntime.queryInterface
78 (XIndexAccess.class, formats);
79 XInterface format = (XInterface) AnyConverter.toObject(
80 new Type(XInterface.class),formatsIndex.getByIndex(0));
81 XIndexAccess formatIndex = UnoRuntime.queryInterface
82 (XIndexAccess.class, format);
83 oObj = (XInterface) AnyConverter.toObject(
84 new Type(XInterface.class),formatIndex.getByIndex(0));
86 } catch (com.sun.star.uno.Exception e) {
87 log.println ("Exception occurred while creating test Object.") ;
88 e.printStackTrace(log) ;
91 TestEnvironment tEnv = new TestEnvironment(oObj) ;
93 return tEnv;
96 } // finish class ScAutoFormatFieldObj