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 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import com
.sun
.star
.container
.XIndexAccess
;
28 import com
.sun
.star
.uno
.AnyConverter
;
29 import com
.sun
.star
.uno
.Type
;
30 import com
.sun
.star
.uno
.UnoRuntime
;
31 import com
.sun
.star
.uno
.XInterface
;
34 * Test for object which is represented by service
35 * <code>com.sun.star.sheet.TableAutoFormatField</code>.
36 * In StarCalc application there is a collection of autoformats
37 * for tables (you can select a predefined format for a
38 * table or create your own). Each autoformat has a number
39 * of fields with definitions of font parameters, number
40 * formats etc. for different parts of a table (column and
41 * row names, footers, data). This object represents the
42 * field of the same kind. <p>
43 * Object implements the following interfaces :
45 * <li> <code>com::sun::star::sheet::TableAutoFormatField</code></li>
46 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
48 * This object test <b> is NOT </b> designed to be run in several
49 * threads concurrently.
50 * @see com.sun.star.sheet.TableAutoFormatField
51 * @see com.sun.star.beans.XPropertySet
52 * @see ifc.sheet._TableAutoFormatField
53 * @see ifc.beans._XPropertySet
55 public class ScAutoFormatFieldObj
extends TestCase
{
58 * Creating a TestEnvironment for the interfaces to be tested.
59 * Using SOffice ServiceManager an instance of
60 * <code>com.sun.star.sheet.TableAutoFormatField</code> service
61 * is created. From this collection one Format is retrieved
62 * and then from this format one of its compound fields is
66 public TestEnvironment createTestEnvironment
67 ( TestParameters Param
, PrintWriter log
) throws StatusException
{
69 XInterface oObj
= null;
73 log
.println ("create Object ...") ;
74 // creation of testobject here
75 XInterface formats
= (XInterface
)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
) ;
96 } // finish class ScAutoFormatFieldObj