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
.FormTools
;
27 import util
.InstCreator
;
28 import util
.SOfficeFactory
;
31 import com
.sun
.star
.container
.XIndexAccess
;
32 import com
.sun
.star
.drawing
.XControlShape
;
33 import com
.sun
.star
.drawing
.XDrawPage
;
34 import com
.sun
.star
.drawing
.XDrawPages
;
35 import com
.sun
.star
.drawing
.XDrawPagesSupplier
;
36 import com
.sun
.star
.drawing
.XMasterPagesSupplier
;
37 import com
.sun
.star
.drawing
.XShapes
;
38 import com
.sun
.star
.lang
.XComponent
;
39 import com
.sun
.star
.uno
.AnyConverter
;
40 import com
.sun
.star
.uno
.Type
;
41 import com
.sun
.star
.uno
.UnoRuntime
;
42 import com
.sun
.star
.uno
.XInterface
;
45 * Test for object which is represented by service
46 * <code>com.sun.star.drawing.DrawPage</code>. <p>
47 * Object implements the following interfaces :
49 * <li> <code>com::sun::star::drawing::GenericDrawPage</code></li>
50 * <li> <code>com::sun::star::drawing::XShapeBinder</code></li>
51 * <li> <code>com::sun::star::drawing::XShapeGrouper</code></li>
52 * <li> <code>com::sun::star::drawing::XShapes</code></li>
53 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
54 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
55 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
56 * <li> <code>com::sun::star::container::XElementAccess</code></li>
57 * <li> <code>com::sun::star::drawing::XMasterPageTarget</code></li>
58 * <li> <code>com::sun::star::container::XNamed</code></li>
59 * <li> <code>com::sun::star::drawing::XShapeCombiner</code></li>
61 * @see com.sun.star.drawing.DrawPage
62 * @see com.sun.star.drawing.GenericDrawPage
63 * @see com.sun.star.drawing.XShapeBinder
64 * @see com.sun.star.drawing.XShapeGrouper
65 * @see com.sun.star.drawing.XShapes
66 * @see com.sun.star.lang.XServiceInfo
67 * @see com.sun.star.beans.XPropertySet
68 * @see com.sun.star.container.XIndexAccess
69 * @see com.sun.star.container.XElementAccess
70 * @see com.sun.star.drawing.XMasterPageTarget
71 * @see com.sun.star.container.XNamed
72 * @see com.sun.star.drawing.XShapeCombiner
73 * @see ifc.drawing._GenericDrawPage
74 * @see ifc.drawing._XShapeBinder
75 * @see ifc.drawing._XShapeGrouper
76 * @see ifc.drawing._XShapes
77 * @see ifc.lang._XServiceInfo
78 * @see ifc.beans._XPropertySet
79 * @see ifc.container._XIndexAccess
80 * @see ifc.container._XElementAccess
81 * @see ifc.drawing._XMasterPageTarget
82 * @see ifc.container._XNamed
83 * @see ifc.drawing._XShapeCombiner
85 public class SdDrawPage
extends TestCase
{
89 * Creates Drawing document.
92 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
93 // get a soffice factory object
94 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
96 log
.println( "creating a draw document" );
97 xDrawDoc
= SOF
.createDrawDoc(null);
101 * Disposes Drawing document.
104 protected void cleanup( TestParameters Param
, PrintWriter log
) {
105 log
.println("disposing xDrawDoc");
106 util
.DesktopTools
.closeDoc(xDrawDoc
);
110 * Creating a TestEnvironment for the interfaces to be tested.
111 * Retrieves the collection of the draw pages from the drawing document using
112 * the interface <code>XDrawPagesSupplier</code> and take one of them.
113 * The retrieved draw page is the instance of the service
114 * <code>com.sun.star.drawing.DrawPage</code>. Inserts some shapes
115 * into the draw page. Obtains the MasterPages collection. Creates
116 * the rectangle shape.
117 * Object relations created :
119 * <li> <code>'Shape'</code> for
120 * {@link ifc.drawing._XShapes}( the created rectangle shape )</li>
121 * <li> <code>'DrawPage'</code> for
122 * {@link ifc.drawing._XShapeBinder}, {@link ifc.drawing._XShapeGrouper},
123 * {@link ifc.drawing._XShapeCombiner}( the retrieved draw page )</li>
124 * <li> <code>'MasterPageSupplier'</code> for
125 * {@link ifc.drawing._XMasterPageTarget}(the obtained master pages
128 * @see com.sun.star.drawing.DrawPage
129 * @see com.sun.star.drawing.XDrawPagesSupplier
132 protected TestEnvironment
createTestEnvironment(
133 TestParameters Param
, PrintWriter log
) throws Exception
{
135 XInterface oObj
= null;
137 // creation of testobject here
138 // first we write what we are intend to do to log file
139 log
.println( "creating a test environment" );
141 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
144 // get the drawpage of drawing here
145 log
.println( "getting Drawpage" );
146 XDrawPagesSupplier oDPS
= UnoRuntime
.queryInterface(XDrawPagesSupplier
.class, xDrawDoc
);
147 XDrawPages oDPn
= oDPS
.getDrawPages();
148 XIndexAccess oDPi
= UnoRuntime
.queryInterface(XIndexAccess
.class,oDPn
);
149 oObj
= (XDrawPage
) AnyConverter
.toObject(
150 new Type(XDrawPage
.class),oDPi
.getByIndex(0));
152 //put something on the drawpage
153 log
.println( "inserting some Shapes" );
154 XShapes oShapes
= UnoRuntime
.queryInterface
155 (XShapes
.class,oObj
);
156 oShapes
.add(SOF
.createShape
157 (xDrawDoc
, 2000, 1500, 1000, 1000, "Line"));
158 oShapes
.add(SOF
.createShape
159 (xDrawDoc
, 3000, 4500, 15000, 1000, "Ellipse"));
160 oShapes
.add(SOF
.createShape
161 (xDrawDoc
, 5000, 3500, 7500, 5000, "Rectangle"));
163 //get the XMasterPagesSupplier
164 log
.println("get XMasterPagesSupplier");
165 XMasterPagesSupplier oMPS
= UnoRuntime
.queryInterface(XMasterPagesSupplier
.class, xDrawDoc
);
166 XDrawPages oGroup
= oMPS
.getMasterPages();
168 log
.println( "creating a new environment for drawpage object" );
169 TestEnvironment tEnv
= new TestEnvironment( oObj
);
171 XControlShape aShape
= FormTools
.createControlShape(
172 xDrawDoc
,3000,4500,15000,10000,"CommandButton");
176 ShapeDsc sDsc
= new ShapeDsc(5000, 3500, 7500, 10000, "Rectangle");
177 log
.println( "adding Shape as mod relation to environment" );
178 tEnv
.addObjRelation("Shape", new InstCreator( xDrawDoc
, sDsc
));
179 tEnv
.addObjRelation("DrawPage", oObj
);
180 tEnv
.addObjRelation("MasterPageSupplier",oGroup
);
183 } // finish method createTestEnvironment
185 } // finish class SdDrawPage