1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SvxShapeCircle.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 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.DefaultDsc
;
40 import util
.DrawTools
;
41 import util
.InstCreator
;
42 import util
.SOfficeFactory
;
45 import com
.sun
.star
.beans
.XPropertySet
;
46 import com
.sun
.star
.drawing
.XShape
;
47 import com
.sun
.star
.lang
.XComponent
;
48 import com
.sun
.star
.lang
.XMultiServiceFactory
;
49 import com
.sun
.star
.style
.XStyle
;
50 import com
.sun
.star
.uno
.AnyConverter
;
51 import com
.sun
.star
.uno
.Type
;
52 import com
.sun
.star
.uno
.UnoRuntime
;
53 import com
.sun
.star
.uno
.XInterface
;
56 * Test for object which is represented by service
57 * <code>com.sun.star.drawing.EllipseShape</code>. <p>
58 * Object implements the following interfaces :
60 * <li> <code>com::sun::star::style::ParagraphProperties</code></li>
61 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
62 * <li> <code>com::sun::star::drawing::EllipseShape</code></li>
63 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
64 * <li> <code>com::sun::star::drawing::ShadowProperties</code></li>
65 * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li>
66 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
67 * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li>
68 * <li> <code>com::sun::star::text::XTextRange</code></li>
69 * <li> <code>com::sun::star::drawing::XShape</code></li>
70 * <li> <code>com::sun::star::lang::XComponent</code></li>
71 * <li> <code>com::sun::star::drawing::TextProperties</code></li>
72 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
73 * <li> <code>com::sun::star::text::XText</code></li>
74 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li>
75 * <li> <code>com::sun::star::text::XSimpleText</code></li>
76 * <li> <code>com::sun::star::drawing::Shape</code></li>
78 * The following files used by this test :
80 * <li><b> SvxShape.sxd </b> : this document is loaded for
81 * adding a shape tested to it. </li>
83 * This object test <b> is NOT </b> designed to be run in several
84 * threads concurently.
86 * @see com.sun.star.style.ParagraphProperties
87 * @see com.sun.star.drawing.LineProperties
88 * @see com.sun.star.drawing.EllipseShape
89 * @see com.sun.star.drawing.FillProperties
90 * @see com.sun.star.drawing.ShadowProperties
91 * @see com.sun.star.drawing.XGluePointsSupplier
92 * @see com.sun.star.style.CharacterProperties
93 * @see com.sun.star.drawing.RotationDescriptor
94 * @see com.sun.star.text.XTextRange
95 * @see com.sun.star.drawing.XShape
96 * @see com.sun.star.lang.XComponent
97 * @see com.sun.star.drawing.TextProperties
98 * @see com.sun.star.beans.XPropertySet
99 * @see com.sun.star.text.XText
100 * @see com.sun.star.drawing.XShapeDescriptor
101 * @see com.sun.star.text.XSimpleText
102 * @see com.sun.star.drawing.Shape
103 * @see ifc.style._ParagraphProperties
104 * @see ifc.drawing._LineProperties
105 * @see ifc.drawing._EllipseShape
106 * @see ifc.drawing._FillProperties
107 * @see ifc.drawing._ShadowProperties
108 * @see ifc.drawing._XGluePointsSupplier
109 * @see ifc.style._CharacterProperties
110 * @see ifc.drawing._RotationDescriptor
111 * @see ifc.text._XTextRange
112 * @see ifc.drawing._XShape
113 * @see ifc.lang._XComponent
114 * @see ifc.drawing._TextProperties
115 * @see ifc.beans._XPropertySet
116 * @see ifc.text._XText
117 * @see ifc.drawing._XShapeDescriptor
118 * @see ifc.text._XSimpleText
119 * @see ifc.drawing._Shape
121 public class SvxShapeCircle
extends TestCase
{
123 static XComponent xDrawDoc
;
126 * Loads a Draw document with name 'SvxShape.sxd' from test
127 * documents directory
129 protected void initialize( TestParameters tParam
, PrintWriter log
) {
131 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
134 log
.println( "creating a drawdoc" );
135 xDrawDoc
= SOF
.loadDocument(
136 utils
.getFullTestURL("SvxShape.sxd"));
137 } catch ( com
.sun
.star
.uno
.Exception e
) {
138 // Some exception occures.FAILED
139 e
.printStackTrace( log
);
140 throw new StatusException( "Couldn't create document", e
);
145 * Disposes the Draw document loaded before.
147 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
148 log
.println( " disposing xDrawDoc " );
149 util
.DesktopTools
.closeDoc(xDrawDoc
);
154 * Creating a Testenvironment for the interfaces to be tested.
155 * Creates an instance of the service
156 * <code>com.sun.star.drawing.EllipseShape</code> as tested component
157 * and adds it to the document. Then the FULL type of circle is set.
159 * Object relations created :
161 * <li> <code>'Style1', 'Style2'</code> for
162 * {@link ifc.drawing._Shape} :
163 * two values of 'Style' property. The first is taken
164 * from the shape tested, the second from another
165 * shape added to the draw page. </li>
166 * <li> <code>'XTEXTINFO'</code> for
167 * {@link ifc.text._XText} :
168 * creator which can create instnaces of
169 * <code>com.sun.star.text.TextField.URL</code>
173 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
175 XInterface oObj
= null;
176 XShape oShape
= null;
178 // creation of testobject here
179 // first we write what we are intend to do to log file
180 log
.println( "creating a test environment" );
182 SOfficeFactory SOF
= SOfficeFactory
.getFactory((XMultiServiceFactory
)tParam
.getMSF()) ;
183 oShape
= SOF
.createShape(xDrawDoc
,5000,5000,3000,3000,"Ellipse");
185 XPropertySet props
= (XPropertySet
) UnoRuntime
.queryInterface
186 (XPropertySet
.class, oShape
) ;
188 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
190 props
.setPropertyValue("CircleKind",
191 com
.sun
.star
.drawing
.CircleKind
.FULL
) ;
192 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
193 log
.println("Cann't set 'CircleKind' property : " + e
);
194 throw new StatusException("Can't create component", e
) ;
195 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
196 log
.println("Cann't set 'CircleKind' property : " + e
);
197 throw new StatusException("Can't create component", e
) ;
198 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
199 log
.println("Cann't set 'CircleKind' property : " + e
);
200 throw new StatusException("Can't create component", e
) ;
201 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
202 log
.println("Cann't set 'CircleKind' property : " + e
);
203 throw new StatusException("Can't create component", e
) ;
209 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Line");
210 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
212 // test environment creation
214 TestEnvironment tEnv
= new TestEnvironment(oObj
);
216 log
.println( "adding two styles as ObjRelation for ShapeDescriptor" );
217 XPropertySet oShapeProps
= (XPropertySet
)
218 UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
219 XStyle aStyle
= null;
222 aStyle
= (XStyle
) AnyConverter
.toObject(
223 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
224 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
225 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
226 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
229 tEnv
.addObjRelation("Style1",aStyle
);
230 oShapeProps
= (XPropertySet
)
231 UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
233 aStyle
= (XStyle
) AnyConverter
.toObject(
234 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
235 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
236 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
237 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
240 tEnv
.addObjRelation("Style2",aStyle
);
242 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
243 "com.sun.star.text.TextField.URL");
244 log
.println( " adding InstCreator object" );
245 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
248 } // finish method getTestEnvironment
250 } // finish class SvxShapeCircle