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
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.SOfficeFactory
;
28 import com
.sun
.star
.container
.XIndexAccess
;
29 import com
.sun
.star
.container
.XNameAccess
;
30 import com
.sun
.star
.drawing
.XLayer
;
31 import com
.sun
.star
.drawing
.XLayerManager
;
32 import com
.sun
.star
.drawing
.XLayerSupplier
;
33 import com
.sun
.star
.lang
.XComponent
;
34 import com
.sun
.star
.uno
.AnyConverter
;
35 import com
.sun
.star
.uno
.Type
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
37 import com
.sun
.star
.uno
.XInterface
;
40 * Test for object which is represented by service
41 * <code>com.sun.star.drawing.Layer</code>. <p>
42 * Object implements the following interfaces :
44 * <li> <code>com::sun::star::drawing::Layer</code></li>
45 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
47 * @see com.sun.star.drawing.Layer
48 * @see com.sun.star.beans.XPropertySet
49 * @see ifc.drawing._Layer
50 * @see ifc.beans._XPropertySet
52 public class SdLayer
extends TestCase
{
56 * Creates Drawing document.
59 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
60 // get a soffice factory object
61 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
63 log
.println( "creating a draw document" );
64 xDrawDoc
= SOF
.createDrawDoc(null);
68 * Disposes Drawing document.
71 protected void cleanup( TestParameters Param
, PrintWriter log
) {
72 log
.println("disposing xDrawDoc");
73 util
.DesktopTools
.closeDoc(xDrawDoc
);
77 * Creating a TestEnvironment for the interfaces to be tested.
78 * Retrieves the layer manager from the document and takes one of the layer.
79 * The obtained layer is the instance of the service
80 * <code>com.sun.star.drawing.Layer</code>.
81 * @see com.sun.star.drawing.Layer
84 protected TestEnvironment
createTestEnvironment(
85 TestParameters Param
, PrintWriter log
) throws Exception
{
87 XInterface oObj
= null;
88 XLayerManager oLM
= null;
90 // creation of testobject here
91 // first we write what we are intend to do to log file
92 log
.println( "creating a test environment" );
94 // get the drawpage of drawing here
95 log
.println( "getting LayerManager" );
96 XLayerSupplier oLS
= UnoRuntime
.queryInterface(XLayerSupplier
.class, xDrawDoc
);
97 XNameAccess oNA
= oLS
.getLayerManager();
98 oLM
= UnoRuntime
.queryInterface(XLayerManager
.class, oNA
);
99 XIndexAccess oIA
= UnoRuntime
.queryInterface(XIndexAccess
.class,oLM
);
100 log
.println( "getting LayerManager" );
101 oObj
= (XLayer
) AnyConverter
.toObject(
102 new Type(XLayer
.class),oIA
.getByIndex(0));
104 log
.println( "creating a new environment for drawpage object" );
105 TestEnvironment tEnv
= new TestEnvironment( oObj
);
108 } // finish method createTestEnvironment
110 } // finish class SdLayer