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
;
28 import com
.sun
.star
.container
.XIndexAccess
;
29 import com
.sun
.star
.container
.XNamed
;
30 import com
.sun
.star
.lang
.XMultiServiceFactory
;
31 import com
.sun
.star
.uno
.AnyConverter
;
32 import com
.sun
.star
.uno
.Type
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.XInterface
;
37 * Test for object which is represented by service
38 * <code>com.sun.star.sheet.TableAutoFormat</code>. <p>
39 * In StarCalc application there is a collection of autoformats
40 * for tables (you can select a predefined format for a
41 * table or create your own). This object represents
42 * one of these autoformats. <p>
43 * Object implements the following interfaces :
45 * <li> <code>com::sun::star::container::XNamed</code></li>
46 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
47 * <li> <code>com::sun::star::container::XElementAccess</code></li>
48 * <li> <code>com::sun::star::sheet::TableAutoFormat</code></li>
49 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
51 * This object test <b> is NOT </b> designed to be run in several
52 * threads concurently.
53 * @see com.sun.star.container.XNamed
54 * @see com.sun.star.container.XIndexAccess
55 * @see com.sun.star.container.XElementAccess
56 * @see com.sun.star.sheet.TableAutoFormat
57 * @see com.sun.star.beans.XPropertySet
58 * @see ifc.container._XNamed
59 * @see ifc.container._XIndexAccess
60 * @see ifc.container._XElementAccess
61 * @see ifc.sheet._TableAutoFormat
62 * @see ifc.beans._XPropertySet
64 public class ScAutoFormatObj
extends TestCase
{
67 * Creating a Testenvironment for the interfaces to be tested.
68 * Using SOffice ServiceManager an instance of
69 * <code>com.sun.star.sheet.TableAutoFormatField</code> service
70 * is created. From this collection one Format is retrieved as
74 public TestEnvironment
createTestEnvironment(TestParameters tParam
,
77 XInterface oObj
= null;
78 XMultiServiceFactory oMSF
= tParam
.getMSF();
80 XInterface formats
= (XInterface
)oMSF
.createInstance
81 ("com.sun.star.sheet.TableAutoFormats");
82 XIndexAccess formatsIndex
= UnoRuntime
.queryInterface(XIndexAccess
.class, formats
);
83 oObj
= (XInterface
) AnyConverter
.toObject(
84 new Type(XInterface
.class),formatsIndex
.getByIndex
85 (formatsIndex
.getCount() - 1));
87 XNamed objNamed
= UnoRuntime
.queryInterface(XNamed
.class, oObj
) ;
88 log
.println("AutoFormat name is '" + objNamed
.getName() + "'") ;
89 } catch (com
.sun
.star
.uno
.Exception e
) {
90 e
.printStackTrace(log
);
91 throw new StatusException("Unexpected exception", e
);
94 TestEnvironment tEnv
= new TestEnvironment(oObj
);