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.Shape</code>. <p>
45 * Object implements the following interfaces :
47 * <li> <code>com::sun::star::style::ParagraphProperties</code></li>
48 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
49 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
50 * <li> <code>com::sun::star::drawing::TextShape</code></li>
51 * <li> <code>com::sun::star::drawing::ShadowProperties</code></li>
52 * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li>
53 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
54 * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li>
55 * <li> <code>com::sun::star::text::XTextRange</code></li>
56 * <li> <code>com::sun::star::drawing::XShape</code></li>
57 * <li> <code>com::sun::star::lang::XComponent</code></li>
58 * <li> <code>com::sun::star::drawing::TextProperties</code></li>
59 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
60 * <li> <code>com::sun::star::text::XText</code></li>
61 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li>
62 * <li> <code>com::sun::star::text::XSimpleText</code></li>
63 * <li> <code>com::sun::star::drawing::Shape</code></li>
66 * The following files used by this test :
68 * <li><b> SvxShape.sxd </b> : this document is loaded for
69 * adding a shape tested to it. </li>
72 * This object test <b> is NOT </b> designed to be run in several
73 * threads concurrently.
75 * @see com.sun.star.style.ParagraphProperties
76 * @see com.sun.star.drawing.LineProperties
77 * @see com.sun.star.drawing.FillProperties
78 * @see com.sun.star.drawing.TextShape
79 * @see com.sun.star.drawing.ShadowProperties
80 * @see com.sun.star.drawing.XGluePointsSupplier
81 * @see com.sun.star.style.CharacterProperties
82 * @see com.sun.star.drawing.RotationDescriptor
83 * @see com.sun.star.text.XTextRange
84 * @see com.sun.star.drawing.XShape
85 * @see com.sun.star.lang.XComponent
86 * @see com.sun.star.drawing.TextProperties
87 * @see com.sun.star.beans.XPropertySet
88 * @see com.sun.star.text.XText
89 * @see com.sun.star.drawing.XShapeDescriptor
90 * @see com.sun.star.text.XSimpleText
91 * @see com.sun.star.drawing.Shape
92 * @see ifc.style._ParagraphProperties
93 * @see ifc.drawing._LineProperties
94 * @see ifc.drawing._FillProperties
95 * @see ifc.drawing._TextShape
96 * @see ifc.drawing._ShadowProperties
97 * @see ifc.drawing._XGluePointsSupplier
98 * @see ifc.style._CharacterProperties
99 * @see ifc.drawing._RotationDescriptor
100 * @see ifc.text._XTextRange
101 * @see ifc.drawing._XShape
102 * @see ifc.lang._XComponent
103 * @see ifc.drawing._TextProperties
104 * @see ifc.beans._XPropertySet
105 * @see ifc.text._XText
106 * @see ifc.drawing._XShapeDescriptor
107 * @see ifc.text._XSimpleText
108 * @see ifc.drawing._Shape
110 public class SvxShape
extends TestCase
{
112 static XComponent xDrawDoc
;
115 * Loads a Draw document with name 'SvxShape.sxd' from test
116 * documents directory
119 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
121 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
123 log
.println( "creating a drawdoc" );
124 xDrawDoc
= SOF
.loadDocument(
125 utils
.getFullTestURL("SvxShape.sxd"));
129 * Disposes the Draw document loaded before.
132 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
133 log
.println( " disposing xDrawDoc " );
134 util
.DesktopTools
.closeDoc(xDrawDoc
);
138 * Creating a TestEnvironment for the interfaces to be tested.
139 * Creates an instance of the service
140 * <code>com.sun.star.drawing.EllipseShape</code> as tested component
141 * and adds it to the document.
142 * Object relations created :
144 * <li> <code>'Style1', 'Style2'</code> for
145 * {@link ifc.drawing._Shape} :
146 * two values of 'Style' property. The first is taken
147 * from the shape tested, the second from another
148 * shape added to the draw page. </li>
149 * <li> <code>'XTEXTINFO'</code> for
150 * {@link ifc.text._XText} :
151 * creator which can create instances of
152 * <code>com.sun.star.text.TextField.URL</code>
157 protected TestEnvironment createTestEnvironment
158 (TestParameters tParam
, PrintWriter log
) {
160 XInterface oObj
= null;
161 XShape oShape
= null;
163 // creation of testobject here
164 // first we write what we are intend to do to log file
165 log
.println( "creating a test environment" );
167 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
168 oShape
= SOF
.createShape(xDrawDoc
,3000,4500,15000,1000,"Text");
169 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
173 // create test environment here
174 TestEnvironment tEnv
= new TestEnvironment( oShape
);
176 // adding relations for Shape service
177 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Text");
178 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
180 log
.println( "adding two style as ObjRelation for ShapeDescriptor" );
181 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
182 XStyle aStyle
= null;
184 aStyle
= (XStyle
) AnyConverter
.toObject(
185 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
186 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
187 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
188 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
190 tEnv
.addObjRelation("Style1",aStyle
);
192 oShapeProps
= UnoRuntime
.queryInterface
193 (XPropertySet
.class,oShape
);
195 aStyle
= (XStyle
) AnyConverter
.toObject(
196 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
197 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
198 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
199 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
201 tEnv
.addObjRelation("Style2",aStyle
);
203 // adding relation for XText
204 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
205 "com.sun.star.text.TextField.URL");
206 log
.println( " adding InstCreator object" );
207 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
210 } // finish method getTestEnvironment
212 } // finish class SvxShape