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
.drawing
.XDrawPage
;
30 import com
.sun
.star
.drawing
.XDrawPageSupplier
;
31 import com
.sun
.star
.drawing
.XShape
;
32 import com
.sun
.star
.drawing
.XShapes
;
33 import com
.sun
.star
.lang
.XMultiServiceFactory
;
34 import com
.sun
.star
.text
.XTextDocument
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
39 * Test for object which is represented by service
40 * <code>com.sun.star.drawing.Shape</code>. <p>
41 * Object implements the following interfaces :
43 * <li> <code>com::sun::star::lang::XComponent</code></li>
44 * <li> <code>com::sun::star::drawing::XShape</code></li>
45 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li>
46 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
47 * <li> <code>com::sun::star::drawing::Shape</code></li>
49 * This object test <b> is NOT </b> designed to be run in several
50 * threads concurently.
51 * @see com.sun.star.lang.XComponent
52 * @see com.sun.star.drawing.XShape
53 * @see com.sun.star.drawing.XShapeDescriptor
54 * @see com.sun.star.beans.XPropertySet
55 * @see com.sun.star.drawing.Shape
56 * @see ifc.lang._XComponent
57 * @see ifc.drawing._XShape
58 * @see ifc.drawing._XShapeDescriptor
59 * @see ifc.beans._XPropertySet
60 * @see ifc.drawing._Shape
62 public class SwXShape
extends TestCase
{
63 XTextDocument xTextDoc
;
67 * Creates text document.
69 protected void initialize( TestParameters tParam
, PrintWriter log
) {
70 SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
72 log
.println( "creating a textdocument" );
73 xTextDoc
= SOF
.createTextDoc( null );
74 } catch ( com
.sun
.star
.uno
.Exception e
) {
75 e
.printStackTrace( log
);
76 throw new StatusException( "Couldn't create document", e
);
81 * Disposes text document.
83 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
84 log
.println( " disposing xTextDoc " );
85 util
.DesktopTools
.closeDoc(xTextDoc
);
89 * Creating a Testenvironment for the interfaces to be tested. At first,
90 * DrawPage is gotten from text document using <code>XDrawPageSupplier</code>
91 * interface. Then shape (rectangle) is created and added to DrawPage
92 * obtained before, then returned as a test component.
94 public synchronized TestEnvironment
createTestEnvironment(
95 TestParameters tParam
, PrintWriter log
) throws StatusException
{
96 XInterface oObj
= null;
98 XShapes oShapes
= null;
100 log
.println( "creating a test environment" );
101 log
.println( "getting Drawpage" );
102 XDrawPageSupplier oDPS
= UnoRuntime
.queryInterface(XDrawPageSupplier
.class, xTextDoc
);
103 oDP
= oDPS
.getDrawPage();
105 log
.println( "getting Shape" );
106 oShapes
= UnoRuntime
.queryInterface(XShapes
.class, oDP
);
107 oObj
= SOF
.createShape(xTextDoc
,5000,3500,7500,5000,"Rectangle");
108 oShapes
.add((XShape
) oObj
);
110 for ( int i
= 0; i
< 9; i
++){
111 XInterface oShape
= SOF
.createShape(xTextDoc
,
112 5000 + 100*i
,3500,7500,5000,"Rectangle");
113 oShapes
.add((XShape
) oShape
);
116 log
.println( "creating a new environment for XShape object" );
117 TestEnvironment tEnv
= new TestEnvironment( oObj
);
120 } // finish method getTestEnvironment
122 } // finish class SwXShape