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
.InstCreator
;
28 import util
.SOfficeFactory
;
31 import com
.sun
.star
.drawing
.XDrawPage
;
32 import com
.sun
.star
.drawing
.XDrawPageSupplier
;
33 import com
.sun
.star
.drawing
.XShapes
;
34 import com
.sun
.star
.lang
.XMultiServiceFactory
;
35 import com
.sun
.star
.text
.XTextDocument
;
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.DrawPage</code>. <p>
42 * Object implements the following interfaces :
44 * <li> <code>com::sun::star::drawing::GenericDrawPage</code></li>
45 * <li> <code>com::sun::star::drawing::XShapeBinder</code></li>
46 * <li> <code>com::sun::star::drawing::XShapeGrouper</code></li>
47 * <li> <code>com::sun::star::drawing::XShapes</code></li>
48 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
49 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
50 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
51 * <li> <code>com::sun::star::container::XElementAccess</code></li>
52 * <li> <code>com::sun::star::drawing::XMasterPageTarget</code></li>
53 * <li> <code>com::sun::star::container::XNamed</code></li>
54 * <li> <code>com::sun::star::drawing::XShapeCombiner</code></li>
56 * This object test <b> is NOT </b> designed to be run in several
57 * threads concurently.
58 * @see com.sun.star.drawing.GenericDrawPage
59 * @see com.sun.star.drawing.XShapeBinder
60 * @see com.sun.star.drawing.XShapeGrouper
61 * @see com.sun.star.drawing.XShapes
62 * @see com.sun.star.lang.XServiceInfo
63 * @see com.sun.star.beans.XPropertySet
64 * @see com.sun.star.container.XIndexAccess
65 * @see com.sun.star.container.XElementAccess
66 * @see com.sun.star.drawing.XMasterPageTarget
67 * @see com.sun.star.container.XNamed
68 * @see com.sun.star.drawing.XShapeCombiner
69 * @see ifc.drawing._GenericDrawPage
70 * @see ifc.drawing._XShapeBinder
71 * @see ifc.drawing._XShapeGrouper
72 * @see ifc.drawing._XShapes
73 * @see ifc.lang._XServiceInfo
74 * @see ifc.beans._XPropertySet
75 * @see ifc.container._XIndexAccess
76 * @see ifc.container._XElementAccess
77 * @see ifc.drawing._XMasterPageTarget
78 * @see ifc.container._XNamed
79 * @see ifc.drawing._XShapeCombiner
81 public class SwXDrawPage
extends TestCase
{
82 XTextDocument xTextDoc
;
85 * Creates text document.
87 protected void initialize( TestParameters tParam
, PrintWriter log
) {
88 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
90 log
.println( "creating a textdocument" );
91 xTextDoc
= SOF
.createTextDoc( null );
92 } catch ( com
.sun
.star
.uno
.Exception e
) {
93 e
.printStackTrace( log
);
94 throw new StatusException( "Couldn't create document", e
);
99 * Disposes text document.
101 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
102 log
.println( " disposing xTextDoc " );
103 util
.DesktopTools
.closeDoc(xTextDoc
);
107 * Creating a Testenvironment for the interfaces to be tested. After
108 * obtaining DrawPage object several shapes are inserted to it.
109 * Object relations created :
111 * <li> <code>'Shape'</code> for
112 * {@link ifc.drawing._XShapes} : shape creator. </li>
113 * <li> <code>'DrawPage'</code> for
114 * {@link ifc.drawing._XShapeBinder},
115 * {@link ifc.drawing._XShapeCombiner},
116 * {@link ifc.drawing._XShapeGrouper} : DrawPage component we are
120 public synchronized TestEnvironment
createTestEnvironment(
121 TestParameters Param
, PrintWriter log
) throws StatusException
{
122 XInterface oObj
= null;
123 XDrawPageSupplier XDPSupp
;
124 XDrawPage xDP
= null;
125 XShapes oShapes
= null;
127 log
.println( "creating a test environment" );
128 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF() );
129 XDPSupp
= UnoRuntime
.queryInterface
130 (XDrawPageSupplier
.class, xTextDoc
);
131 xDP
= XDPSupp
.getDrawPage();
134 //dbg.printInterfaces(oObj);
137 log
.println( "inserting some Shapes" );
138 oShapes
= UnoRuntime
.queryInterface(XShapes
.class, oObj
);
139 oShapes
.add(SOF
.createShape(xTextDoc
,2000,1500,1000,1000,"Line"));
140 oShapes
.add(SOF
.createShape(xTextDoc
,3000,4500,15000,1000,"Ellipse"));
141 oShapes
.add(SOF
.createShape(xTextDoc
,5000,3500,7500,5000,"Rectangle"));
143 log
.println( "creating a new environment for bodytext object" );
144 TestEnvironment tEnv
= new TestEnvironment( oObj
);
146 ShapeDsc sDsc
= new ShapeDsc(15000,13500,7500,10000,"Rectangle");
147 log
.println( "adding Shape as mod relation to environment" );
148 tEnv
.addObjRelation("Shape", new InstCreator( xTextDoc
, sDsc
));
149 tEnv
.addObjRelation("DrawPage", oObj
);
152 } // finish method getTestEnvironment
154 } // finish class SwXDrawPage