merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _svx / SvxShapeConnector.java
blob89a34431908ed08e089b9fdd262a899ffe7bd85b
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: SvxShapeConnector.java,v $
10 * $Revision: 1.7.8.1 $
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._svx;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.DefaultDsc;
40 import util.DrawTools;
41 import util.InstCreator;
42 import util.SOfficeFactory;
44 import com.sun.star.beans.XPropertySet;
45 import com.sun.star.drawing.XShape;
46 import com.sun.star.lang.XComponent;
47 import com.sun.star.lang.XMultiServiceFactory;
48 import com.sun.star.style.XStyle;
49 import com.sun.star.uno.AnyConverter;
50 import com.sun.star.uno.Type;
51 import com.sun.star.uno.UnoRuntime;
52 import com.sun.star.uno.XInterface;
54 /**
56 * initial description
57 * @see com.sun.star.beans.XPropertySet
58 * @see com.sun.star.document.LinkTarget
59 * @see com.sun.star.document.XLinkTargetSupplier
60 * @see com.sun.star.drawing.ConnectorShapeDescriptor
61 * @see com.sun.star.drawing.LineShapeDescriptor
62 * @see com.sun.star.drawing.PolyPolygonDescriptor
63 * @see com.sun.star.drawing.RotationDescriptor
64 * @see com.sun.star.drawing.ShadowDescriptor
65 * @see com.sun.star.drawing.ShapeDescriptor
66 * @see com.sun.star.drawing.Text
67 * @see com.sun.star.drawing.XConnectorShape
68 * @see com.sun.star.drawing.XShape
69 * @see com.sun.star.drawing.XShapeDescriptor
70 * @see com.sun.star.lang.XComponent
71 * @see com.sun.star.style.CharacterProperties
72 * @see com.sun.star.style.ParagraphProperties
73 * @see com.sun.star.text.XSimpleText
74 * @see com.sun.star.text.XText
75 * @see com.sun.star.text.XTextRange
78 public class SvxShapeConnector extends TestCase {
80 static XComponent xDrawDoc;
82 /**
83 * in general this method creates a testdocument
85 * @param tParam class which contains additional test parameters
86 * @param log class to log the test state and result
89 * @see TestParameters
90 * * @see PrintWriter
93 protected void initialize( TestParameters tParam, PrintWriter log ) {
95 try {
96 log.println( "creating a drawdoc" );
97 xDrawDoc = DrawTools.createDrawDoc((XMultiServiceFactory)tParam.getMSF());
98 } catch ( Exception e ) {
99 // Some exception occures.FAILED
100 e.printStackTrace( log );
101 throw new StatusException( "Couldn't create document", e );
106 * in general this method disposes the testenvironment and document
108 * @param tParam class which contains additional test parameters
109 * @param log class to log the test state and result
112 * @see TestParameters
113 * * @see PrintWriter
116 protected void cleanup( TestParameters tParam, PrintWriter log ) {
117 log.println( " disposing xDrawDoc " );
118 util.DesktopTools.closeDoc(xDrawDoc);
123 * * creating a Testenvironment for the interfaces to be tested
125 * @param tParam class which contains additional test parameters
126 * @param log class to log the test state and result
128 * @return Status class
130 * @see TestParameters
131 * * @see PrintWriter
133 protected TestEnvironment createTestEnvironment
134 (TestParameters tParam, PrintWriter log) {
136 XInterface oObj = null;
137 XShape oShape = null;
139 // creation of testobject here
140 // first we write what we are intend to do to log file
141 log.println( "creating a test environment" );
142 try {
143 XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
144 UnoRuntime.queryInterface(XMultiServiceFactory.class,xDrawDoc);
145 Object oInt = oDocMSF.createInstance
146 ( "com.sun.star.drawing.ConnectorShape" );
148 oShape = (XShape)UnoRuntime.queryInterface( XShape.class, oInt );
149 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape);
151 catch (Exception e) {
152 log.println("Couldn't create insance");
153 e.printStackTrace(log);
156 // create testobject here
157 oObj = oShape;
159 TestEnvironment tEnv = new TestEnvironment( oObj );
161 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
162 oShape = SOF.createShape(xDrawDoc,3000,4500,15000,1000,"Ellipse");
163 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape);
165 for (int i=0;i<10;i++) {
166 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(
167 SOF.createShape(xDrawDoc,
168 3000,4500,7510+10*i,5010+10*i,"Rectangle"));
171 log.println( "adding two style as ObjRelation for ShapeDescriptor" );
172 XPropertySet oShapeProps = (XPropertySet)
173 UnoRuntime.queryInterface(XPropertySet.class,oObj);
174 XStyle aStyle = null;
175 try {
176 aStyle = (XStyle) AnyConverter.toObject(
177 new Type(XStyle.class),oShapeProps.getPropertyValue("Style"));
178 } catch (Exception e) {}
180 tEnv.addObjRelation("Style1",aStyle);
181 oShapeProps = (XPropertySet)
182 UnoRuntime.queryInterface(XPropertySet.class,oShape);
183 try {
184 aStyle = (XStyle) AnyConverter.toObject(
185 new Type(XStyle.class),oShapeProps.getPropertyValue("Style"));
186 } catch (Exception e) {}
188 tEnv.addObjRelation("Style2",aStyle);
190 DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent",
191 "com.sun.star.text.TextField.URL");
192 log.println( " adding InstCreator object" );
193 tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) );
194 tEnv.addObjRelation("NoSetSize","SvxShapeConnector");
195 // adding relation for XConnectorShape
196 XShape oShape1 = SOF.createShape(xDrawDoc,1000,2000,1500,1000,"Line");
197 XShape oShape2 = SOF.createShape(xDrawDoc,1000,2000,4000,3000,"Line");
198 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape1);
199 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape2);
200 tEnv.addObjRelation("XConnectorShape.Shapes",
201 new XShape[] {oShape1, oShape2}) ;
202 System.out.println("IName: "+util.utils.getImplName(oObj));
203 return tEnv;
204 } // finish method getTestEnvironment
206 } // finish class SvxShapeConnector