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 util
.SOfficeFactory
;
29 import com
.sun
.star
.container
.XIndexAccess
;
30 import com
.sun
.star
.container
.XNameAccess
;
31 import com
.sun
.star
.drawing
.XLayer
;
32 import com
.sun
.star
.drawing
.XLayerManager
;
33 import com
.sun
.star
.drawing
.XLayerSupplier
;
34 import com
.sun
.star
.lang
.XComponent
;
35 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 import com
.sun
.star
.uno
.AnyConverter
;
37 import com
.sun
.star
.uno
.Type
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
42 * Test for object which is represented by service
43 * <code>com.sun.star.drawing.Layer</code>. <p>
44 * Object implements the following interfaces :
46 * <li> <code>com::sun::star::drawing::Layer</code></li>
47 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
49 * @see com.sun.star.drawing.Layer
50 * @see com.sun.star.beans.XPropertySet
51 * @see ifc.drawing._Layer
52 * @see ifc.beans._XPropertySet
54 public class SdLayer
extends TestCase
{
58 * Creates Drawing document.
60 protected void initialize(TestParameters Param
, PrintWriter log
) {
61 // get a soffice factory object
62 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
63 (XMultiServiceFactory
)Param
.getMSF());
66 log
.println( "creating a draw document" );
67 xDrawDoc
= SOF
.createDrawDoc(null);
68 } catch (com
.sun
.star
.uno
.Exception e
) {
69 e
.printStackTrace( log
);
70 throw new StatusException("Couldn't create document", e
);
75 * Disposes Drawing document.
77 protected void cleanup( TestParameters Param
, PrintWriter log
) {
78 log
.println("disposing xDrawDoc");
79 util
.DesktopTools
.closeDoc(xDrawDoc
);
83 * Creating a Testenvironment for the interfaces to be tested.
84 * Retrieves the layer manager from the document and takes one of the layer.
85 * The obtained layer is the instance of the service
86 * <code>com.sun.star.drawing.Layer</code>.
87 * @see com.sun.star.drawing.Layer
89 protected synchronized TestEnvironment
createTestEnvironment(
90 TestParameters Param
, PrintWriter log
) {
92 XInterface oObj
= null;
93 XLayerManager oLM
= null;
95 // creation of testobject here
96 // first we write what we are intend to do to log file
97 log
.println( "creating a test environment" );
99 // get the drawpage of drawing here
100 log
.println( "getting LayerManager" );
101 XLayerSupplier oLS
= UnoRuntime
.queryInterface(XLayerSupplier
.class, xDrawDoc
);
102 XNameAccess oNA
= oLS
.getLayerManager();
103 oLM
= UnoRuntime
.queryInterface(XLayerManager
.class, oNA
);
104 XIndexAccess oIA
= UnoRuntime
.queryInterface(XIndexAccess
.class,oLM
);
105 log
.println( "getting LayerManager" );
107 oObj
= (XLayer
) AnyConverter
.toObject(
108 new Type(XLayer
.class),oIA
.getByIndex(0));
109 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
110 e
.printStackTrace( log
);
111 throw new StatusException("Couldn't get by index", e
);
112 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
113 e
.printStackTrace( log
);
114 throw new StatusException("Couldn't get by index", e
);
115 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
116 e
.printStackTrace( log
);
117 throw new StatusException("Couldn't get by index", e
);
120 log
.println( "creating a new environment for drawpage object" );
121 TestEnvironment tEnv
= new TestEnvironment( oObj
);
124 } // finish method createTestEnvironment
126 } // finish class SdLayer