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
.InstCreator
;
27 import util
.SOfficeFactory
;
30 import com
.sun
.star
.container
.XIndexAccess
;
31 import com
.sun
.star
.drawing
.XDrawPage
;
32 import com
.sun
.star
.drawing
.XDrawPages
;
33 import com
.sun
.star
.drawing
.XDrawPagesSupplier
;
34 import com
.sun
.star
.drawing
.XLayerSupplier
;
35 import com
.sun
.star
.drawing
.XShapes
;
36 import com
.sun
.star
.lang
.XComponent
;
37 import com
.sun
.star
.uno
.AnyConverter
;
38 import com
.sun
.star
.uno
.Type
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
40 import com
.sun
.star
.uno
.XInterface
;
43 * Test for object which is represented by service
44 * <code>com.sun.star.drawing.LayerManager</code>. <p>
45 * Object implements the following interfaces :
47 * <li> <code>com::sun::star::drawing::XLayerManager</code></li>
48 * <li> <code>com::sun::star::container::XNameAccess</code></li>
49 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
50 * <li> <code>com::sun::star::container::XElementAccess</code></li>
52 * @see com.sun.star.drawing.LayerManager
53 * @see com.sun.star.drawing.XLayerManager
54 * @see com.sun.star.container.XNameAccess
55 * @see com.sun.star.container.XIndexAccess
56 * @see com.sun.star.container.XElementAccess
57 * @see ifc.drawing._XLayerManager
58 * @see ifc.container._XNameAccess
59 * @see ifc.container._XIndexAccess
60 * @see ifc.container._XElementAccess
62 public class SdLayerManager
extends TestCase
{
66 * Creates Drawing document.
69 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
70 // get a soffice factory object
71 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
73 log
.println("creating a draw document");
74 xDrawDoc
= SOF
.createDrawDoc(null);
78 * Disposes Drawing document.
81 protected void cleanup( TestParameters Param
, PrintWriter log
) {
82 log
.println("disposing xDrawDoc");
83 util
.DesktopTools
.closeDoc(xDrawDoc
);
87 * Creating a TestEnvironment for the interfaces to be tested.
88 * Retrieves the layer manager using the interface <code>XLayerSupplier</code>.
89 * The manager is the instance of the service
90 * <code>com.sun.star.drawing.LayerManager</code>. Creates a rectangle shape.
91 * Retrieves the collection of the draw pages and take one of them.
93 * <li> <code>'Shape'</code> for
94 * {@link ifc.drawing._XLayerManager}(the created shape)</li>
95 * <li> <code>'Shapes'</code> for
96 * {@link ifc.drawing._XLayerManager}(the shape collection of
97 * the retrieved draw page)</li>
99 * @see com.sun.star.drawing.XLayerSupplier
100 * @see com.sun.star.drawing.LayerManager
103 protected TestEnvironment
createTestEnvironment(
104 TestParameters Param
, PrintWriter log
) throws Exception
{
106 // creation of testobject here
107 // first we write what we are intend to do to log file
108 log
.println( "creating a test environment" );
110 // create testobject here
111 XLayerSupplier oLS
= UnoRuntime
.queryInterface(XLayerSupplier
.class, xDrawDoc
);
112 XInterface oObj
= oLS
.getLayerManager();
114 log
.println( "creating a new environment for XLayerManager object" );
115 TestEnvironment tEnv
= new TestEnvironment( oObj
);
117 ShapeDsc sDsc
= new ShapeDsc(5000, 3500, 7500, 10000, "Rectangle");
118 log
.println( "adding Shape as mod relation to environment" );
119 tEnv
.addObjRelation("Shape", new InstCreator(xDrawDoc
, sDsc
));
122 // get the drawpage of drawing here
123 log
.println( "getting Drawpage" );
124 XDrawPagesSupplier oDPS
= UnoRuntime
.queryInterface(XDrawPagesSupplier
.class,xDrawDoc
);
125 XDrawPages oDPn
= oDPS
.getDrawPages();
126 XIndexAccess oDPi
= UnoRuntime
.queryInterface(XIndexAccess
.class,oDPn
);
128 XDrawPage oDP
= (XDrawPage
) AnyConverter
.toObject(
129 new Type(XDrawPage
.class),oDPi
.getByIndex(0));
131 XShapes oShapes
= UnoRuntime
.queryInterface(XShapes
.class, oDP
);
133 log
.println( "adding Shapes as mod relation to environment" );
134 tEnv
.addObjRelation("Shapes", oShapes
);
137 } // finish method getTestEnvironment
139 } // finish class SdLayerManager