merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sw / SwXDrawPage.java
blob9dbb811f507a36e95eb73245acf40dd499eaa229
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SwXDrawPage.java,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._sw;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.InstCreator;
40 import util.SOfficeFactory;
41 import util.ShapeDsc;
43 import com.sun.star.drawing.XDrawPage;
44 import com.sun.star.drawing.XDrawPageSupplier;
45 import com.sun.star.drawing.XShapes;
46 import com.sun.star.lang.XMultiServiceFactory;
47 import com.sun.star.text.XTextDocument;
48 import com.sun.star.uno.UnoRuntime;
49 import com.sun.star.uno.XInterface;
51 /**
52 * Test for object which is represented by service
53 * <code>com.sun.star.drawing.DrawPage</code>. <p>
54 * Object implements the following interfaces :
55 * <ul>
56 * <li> <code>com::sun::star::drawing::GenericDrawPage</code></li>
57 * <li> <code>com::sun::star::drawing::XShapeBinder</code></li>
58 * <li> <code>com::sun::star::drawing::XShapeGrouper</code></li>
59 * <li> <code>com::sun::star::drawing::XShapes</code></li>
60 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
61 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
62 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
63 * <li> <code>com::sun::star::container::XElementAccess</code></li>
64 * <li> <code>com::sun::star::drawing::XMasterPageTarget</code></li>
65 * <li> <code>com::sun::star::container::XNamed</code></li>
66 * <li> <code>com::sun::star::drawing::XShapeCombiner</code></li>
67 * </ul> <p>
68 * This object test <b> is NOT </b> designed to be run in several
69 * threads concurently.
70 * @see com.sun.star.drawing.GenericDrawPage
71 * @see com.sun.star.drawing.XShapeBinder
72 * @see com.sun.star.drawing.XShapeGrouper
73 * @see com.sun.star.drawing.XShapes
74 * @see com.sun.star.lang.XServiceInfo
75 * @see com.sun.star.beans.XPropertySet
76 * @see com.sun.star.container.XIndexAccess
77 * @see com.sun.star.container.XElementAccess
78 * @see com.sun.star.drawing.XMasterPageTarget
79 * @see com.sun.star.container.XNamed
80 * @see com.sun.star.drawing.XShapeCombiner
81 * @see ifc.drawing._GenericDrawPage
82 * @see ifc.drawing._XShapeBinder
83 * @see ifc.drawing._XShapeGrouper
84 * @see ifc.drawing._XShapes
85 * @see ifc.lang._XServiceInfo
86 * @see ifc.beans._XPropertySet
87 * @see ifc.container._XIndexAccess
88 * @see ifc.container._XElementAccess
89 * @see ifc.drawing._XMasterPageTarget
90 * @see ifc.container._XNamed
91 * @see ifc.drawing._XShapeCombiner
93 public class SwXDrawPage extends TestCase {
94 XTextDocument xTextDoc;
96 /**
97 * Creates text document.
99 protected void initialize( TestParameters tParam, PrintWriter log ) {
100 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
101 try {
102 log.println( "creating a textdocument" );
103 xTextDoc = SOF.createTextDoc( null );
104 } catch ( com.sun.star.uno.Exception e ) {
105 e.printStackTrace( log );
106 throw new StatusException( "Couldn't create document", e );
111 * Disposes text document.
113 protected void cleanup( TestParameters tParam, PrintWriter log ) {
114 log.println( " disposing xTextDoc " );
115 util.DesktopTools.closeDoc(xTextDoc);
119 * Creating a Testenvironment for the interfaces to be tested. After
120 * obtaining DrawPage object several shapes are inserted to it.
121 * Object relations created :
122 * <ul>
123 * <li> <code>'Shape'</code> for
124 * {@link ifc.drawing._XShapes} : shape creator. </li>
125 * <li> <code>'DrawPage'</code> for
126 * {@link ifc.drawing._XShapeBinder},
127 * {@link ifc.drawing._XShapeCombiner},
128 * {@link ifc.drawing._XShapeGrouper} : DrawPage component we are
129 * testing.</li>
130 * </ul>
132 public synchronized TestEnvironment createTestEnvironment(
133 TestParameters Param, PrintWriter log ) throws StatusException {
134 XInterface oObj = null;
135 XDrawPageSupplier XDPSupp;
136 XDrawPage xDP = null;
137 XShapes oShapes = null;
139 log.println( "creating a test environment" );
140 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() );
141 XDPSupp = (XDrawPageSupplier) UnoRuntime.queryInterface
142 (XDrawPageSupplier.class, xTextDoc);
143 xDP = XDPSupp.getDrawPage();
144 oObj = xDP;
146 //dbg.printInterfaces(oObj);
147 //System.exit(0);
149 log.println( "inserting some Shapes" );
150 oShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, oObj);
151 oShapes.add(SOF.createShape(xTextDoc,2000,1500,1000,1000,"Line"));
152 oShapes.add(SOF.createShape(xTextDoc,3000,4500,15000,1000,"Ellipse"));
153 oShapes.add(SOF.createShape(xTextDoc,5000,3500,7500,5000,"Rectangle"));
155 log.println( "creating a new environment for bodytext object" );
156 TestEnvironment tEnv = new TestEnvironment( oObj );
158 ShapeDsc sDsc = new ShapeDsc(15000,13500,7500,10000,"Rectangle");
159 log.println( "adding Shape as mod relation to environment" );
160 tEnv.addObjRelation("Shape", new InstCreator( xTextDoc, sDsc));
161 tEnv.addObjRelation("DrawPage", oObj);
163 return tEnv;
164 } // finish method getTestEnvironment
166 } // finish class SwXDrawPage