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
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.DefaultDsc
;
27 import util
.DrawTools
;
28 import util
.InstCreator
;
29 import util
.SOfficeFactory
;
32 import com
.sun
.star
.beans
.XPropertySet
;
33 import com
.sun
.star
.drawing
.XShape
;
34 import com
.sun
.star
.lang
.XComponent
;
35 import com
.sun
.star
.style
.XStyle
;
36 import com
.sun
.star
.uno
.AnyConverter
;
37 import com
.sun
.star
.uno
.Type
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
42 * Test for object which is represented by service
43 * <code>com.sun.star.drawing.EllipseShape</code>. <p>
44 * Object implements the following interfaces :
46 * <li> <code>com::sun::star::style::ParagraphProperties</code></li>
47 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
48 * <li> <code>com::sun::star::drawing::EllipseShape</code></li>
49 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
50 * <li> <code>com::sun::star::drawing::ShadowProperties</code></li>
51 * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li>
52 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
53 * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li>
54 * <li> <code>com::sun::star::text::XTextRange</code></li>
55 * <li> <code>com::sun::star::drawing::XShape</code></li>
56 * <li> <code>com::sun::star::lang::XComponent</code></li>
57 * <li> <code>com::sun::star::drawing::TextProperties</code></li>
58 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
59 * <li> <code>com::sun::star::text::XText</code></li>
60 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li>
61 * <li> <code>com::sun::star::text::XSimpleText</code></li>
62 * <li> <code>com::sun::star::drawing::Shape</code></li>
64 * The following files used by this test :
66 * <li><b> SvxShape.sxd </b> : this document is loaded for
67 * adding a shape tested to it. </li>
69 * This object test <b> is NOT </b> designed to be run in several
70 * threads concurrently.
72 * @see com.sun.star.style.ParagraphProperties
73 * @see com.sun.star.drawing.LineProperties
74 * @see com.sun.star.drawing.EllipseShape
75 * @see com.sun.star.drawing.FillProperties
76 * @see com.sun.star.drawing.ShadowProperties
77 * @see com.sun.star.drawing.XGluePointsSupplier
78 * @see com.sun.star.style.CharacterProperties
79 * @see com.sun.star.drawing.RotationDescriptor
80 * @see com.sun.star.text.XTextRange
81 * @see com.sun.star.drawing.XShape
82 * @see com.sun.star.lang.XComponent
83 * @see com.sun.star.drawing.TextProperties
84 * @see com.sun.star.beans.XPropertySet
85 * @see com.sun.star.text.XText
86 * @see com.sun.star.drawing.XShapeDescriptor
87 * @see com.sun.star.text.XSimpleText
88 * @see com.sun.star.drawing.Shape
89 * @see ifc.style._ParagraphProperties
90 * @see ifc.drawing._LineProperties
91 * @see ifc.drawing._EllipseShape
92 * @see ifc.drawing._FillProperties
93 * @see ifc.drawing._ShadowProperties
94 * @see ifc.drawing._XGluePointsSupplier
95 * @see ifc.style._CharacterProperties
96 * @see ifc.drawing._RotationDescriptor
97 * @see ifc.text._XTextRange
98 * @see ifc.drawing._XShape
99 * @see ifc.lang._XComponent
100 * @see ifc.drawing._TextProperties
101 * @see ifc.beans._XPropertySet
102 * @see ifc.text._XText
103 * @see ifc.drawing._XShapeDescriptor
104 * @see ifc.text._XSimpleText
105 * @see ifc.drawing._Shape
107 public class SvxShapeCircle
extends TestCase
{
109 static XComponent xDrawDoc
;
112 * Loads a Draw document with name 'SvxShape.sxd' from test
113 * documents directory
116 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
117 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
118 log
.println( "creating a drawdoc" );
119 xDrawDoc
= SOF
.loadDocument(
120 utils
.getFullTestURL("SvxShape.sxd"));
124 * Disposes the Draw document loaded before.
127 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
128 log
.println( " disposing xDrawDoc " );
129 util
.DesktopTools
.closeDoc(xDrawDoc
);
134 * Creating a TestEnvironment for the interfaces to be tested.
135 * Creates an instance of the service
136 * <code>com.sun.star.drawing.EllipseShape</code> as tested component
137 * and adds it to the document. Then the FULL type of circle is set.
139 * Object relations created :
141 * <li> <code>'Style1', 'Style2'</code> for
142 * {@link ifc.drawing._Shape} :
143 * two values of 'Style' property. The first is taken
144 * from the shape tested, the second from another
145 * shape added to the draw page. </li>
146 * <li> <code>'XTEXTINFO'</code> for
147 * {@link ifc.text._XText} :
148 * creator which can create instances of
149 * <code>com.sun.star.text.TextField.URL</code>
154 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) throws Exception
{
156 XInterface oObj
= null;
157 XShape oShape
= null;
159 // creation of testobject here
160 // first we write what we are intend to do to log file
161 log
.println( "creating a test environment" );
163 SOfficeFactory SOF
= SOfficeFactory
.getFactory(tParam
.getMSF()) ;
164 oShape
= SOF
.createShape(xDrawDoc
,5000,5000,3000,3000,"Ellipse");
166 XPropertySet props
= UnoRuntime
.queryInterface
167 (XPropertySet
.class, oShape
) ;
169 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
170 props
.setPropertyValue("CircleKind",
171 com
.sun
.star
.drawing
.CircleKind
.FULL
) ;
175 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Line");
176 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
178 // test environment creation
180 TestEnvironment tEnv
= new TestEnvironment(oObj
);
182 log
.println( "adding two styles as ObjRelation for ShapeDescriptor" );
183 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
184 XStyle aStyle
= null;
187 aStyle
= (XStyle
) AnyConverter
.toObject(
188 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
189 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
190 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
191 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
194 tEnv
.addObjRelation("Style1",aStyle
);
195 oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
197 aStyle
= (XStyle
) AnyConverter
.toObject(
198 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
199 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
200 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
201 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
204 tEnv
.addObjRelation("Style2",aStyle
);
206 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
207 "com.sun.star.text.TextField.URL");
208 log
.println( " adding InstCreator object" );
209 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
212 } // finish method getTestEnvironment
214 } // finish class SvxShapeCircle