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
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.DrawTools
;
28 import util
.InstCreator
;
29 import util
.SOfficeFactory
;
32 import com
.sun
.star
.awt
.Point
;
33 import com
.sun
.star
.awt
.Size
;
34 import com
.sun
.star
.beans
.XPropertySet
;
35 import com
.sun
.star
.drawing
.PolyPolygonBezierCoords
;
36 import com
.sun
.star
.drawing
.PolygonFlags
;
37 import com
.sun
.star
.drawing
.XShape
;
38 import com
.sun
.star
.lang
.XComponent
;
39 import com
.sun
.star
.lang
.XMultiServiceFactory
;
40 import com
.sun
.star
.style
.XStyle
;
41 import com
.sun
.star
.uno
.AnyConverter
;
42 import com
.sun
.star
.uno
.Type
;
43 import com
.sun
.star
.uno
.UnoRuntime
;
44 import com
.sun
.star
.uno
.XInterface
;
47 * Test for object which is represented by service
48 * <code>com.sun.star.drawing.ClosedBezierShape</code>. <p>
49 * Object implements the following interfaces :
51 * <li> <code>com::sun::star::style::ParagraphProperties</code></li>
52 * <li> <code>com::sun::star::drawing::PolyPolygonBezierDescriptor</code></li>
53 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
54 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
55 * <li> <code>com::sun::star::drawing::ShadowProperties</code></li>
56 * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li>
57 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
58 * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li>
59 * <li> <code>com::sun::star::text::XTextRange</code></li>
60 * <li> <code>com::sun::star::drawing::XShape</code></li>
61 * <li> <code>com::sun::star::lang::XComponent</code></li>
62 * <li> <code>com::sun::star::drawing::TextProperties</code></li>
63 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
64 * <li> <code>com::sun::star::text::XText</code></li>
65 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li>
66 * <li> <code>com::sun::star::text::XSimpleText</code></li>
67 * <li> <code>com::sun::star::drawing::Shape</code></li>
70 * The following files used by this test :
72 * <li><b> TransparencyChart.sxs </b> : to load predefined chart
73 * document where two 'automatic' transparency styles exists :
74 * 'Transparency 1' and 'Transparency 2'.</li>
77 * This object test <b> is NOT </b> designed to be run in several
78 * threads concurently.
80 * @see com.sun.star.style.ParagraphProperties
81 * @see com.sun.star.drawing.PolyPolygonBezierDescriptor
82 * @see com.sun.star.drawing.LineProperties
83 * @see com.sun.star.drawing.FillProperties
84 * @see com.sun.star.drawing.ShadowProperties
85 * @see com.sun.star.drawing.XGluePointsSupplier
86 * @see com.sun.star.style.CharacterProperties
87 * @see com.sun.star.drawing.RotationDescriptor
88 * @see com.sun.star.text.XTextRange
89 * @see com.sun.star.drawing.XShape
90 * @see com.sun.star.lang.XComponent
91 * @see com.sun.star.drawing.TextProperties
92 * @see com.sun.star.beans.XPropertySet
93 * @see com.sun.star.text.XText
94 * @see com.sun.star.drawing.XShapeDescriptor
95 * @see com.sun.star.text.XSimpleText
96 * @see com.sun.star.drawing.Shape
97 * @see ifc.style._ParagraphProperties
98 * @see ifc.drawing._PolyPolygonBezierDescriptor
99 * @see ifc.drawing._LineProperties
100 * @see ifc.drawing._FillProperties
101 * @see ifc.drawing._ShadowProperties
102 * @see ifc.drawing._XGluePointsSupplier
103 * @see ifc.style._CharacterProperties
104 * @see ifc.drawing._RotationDescriptor
105 * @see ifc.text._XTextRange
106 * @see ifc.drawing._XShape
107 * @see ifc.lang._XComponent
108 * @see ifc.drawing._TextProperties
109 * @see ifc.beans._XPropertySet
110 * @see ifc.text._XText
111 * @see ifc.drawing._XShapeDescriptor
112 * @see ifc.text._XSimpleText
113 * @see ifc.drawing._Shape
115 public class SvxShapePolyPolygonBezier
extends TestCase
{
117 static XComponent xDrawDoc
;
120 * in general this method creates a testdocument
122 * @param tParam class which contains additional test parameters
123 * @param log class to log the test state and result
126 * @see TestParameters
131 protected void initialize( TestParameters tParam
, PrintWriter log
) {
132 // get a soffice factory object
133 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
136 log
.println( "creating a chartdocument" );
137 xDrawDoc
= SOF
.loadDocument(
138 utils
.getFullTestURL("SvxShape.sxd"));
139 } catch (com
.sun
.star
.uno
.Exception e
) {
140 // Some exception occurs.FAILED
141 e
.printStackTrace( log
);
142 throw new StatusException( "Couldn't create document", e
);
147 * in general this method disposes the testenvironment and document
149 * @param tParam class which contains additional test parameters
150 * @param log class to log the test state and result
153 * @see TestParameters
158 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
159 log
.println( " disposing xDrawDoc " );
160 util
.DesktopTools
.closeDoc(xDrawDoc
);
165 * * creating a Testenvironment for the interfaces to be tested
167 * @param tParam class which contains additional test parameters
168 * @param log class to log the test state and result
170 * @return Status class
172 * @see TestParameters
176 protected TestEnvironment createTestEnvironment
177 (TestParameters tParam
, PrintWriter log
) {
179 XInterface oObj
= null;
180 XShape oShape
= null;
182 // creation of testobject here
183 // first we write what we are intend to do to log file
184 log
.println( "creating a test environment" );
188 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
190 XMultiServiceFactory xMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xDrawDoc
) ;
192 XInterface oInst
= (XInterface
) xMSF
.createInstance
193 ("com.sun.star.drawing.ClosedBezierShape") ;
194 oShape
= UnoRuntime
.queryInterface
195 (XShape
.class, oInst
) ;
197 Point
[] points
= new Point
[2];
198 points
[0] = new Point();
201 points
[1] = new Point();
205 Point
[][] the_points
= new Point
[1][2];
206 the_points
[0] = points
;
208 PolygonFlags
[] flags
= new PolygonFlags
[2];
209 flags
[0] = PolygonFlags
.NORMAL
;
210 flags
[1] = PolygonFlags
.NORMAL
;
212 PolygonFlags
[][] the_flags
= new PolygonFlags
[1][2];
213 the_flags
[0] = flags
;
215 PolyPolygonBezierCoords coords
= new PolyPolygonBezierCoords();
216 coords
.Coordinates
=the_points
;
217 coords
.Flags
= the_flags
;
219 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
221 oShape
.setSize(new Size(3000,3000)) ;
222 oShape
.setPosition(new Point(4000,4000)) ;
226 XPropertySet shapeProps
= UnoRuntime
.queryInterface
227 (XPropertySet
.class, oObj
);
229 shapeProps
.setPropertyValue("PolyPolygonBezier",coords
);
231 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Line");
232 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
234 catch (Exception e
) {
235 log
.println("Couldn't create instance");
236 e
.printStackTrace(log
);
239 // test environment creation
241 TestEnvironment tEnv
= new TestEnvironment(oObj
);
243 log
.println( "adding two styles as ObjRelation for ShapeDescriptor" );
244 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
245 XStyle aStyle
= null;
247 aStyle
= (XStyle
) AnyConverter
.toObject(
248 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
249 } catch (Exception e
) {}
250 tEnv
.addObjRelation("Style1",aStyle
);
251 oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
253 aStyle
= (XStyle
) AnyConverter
.toObject(
254 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
255 } catch (Exception e
) {}
256 tEnv
.addObjRelation("Style2",aStyle
);
258 // adding relation for XText
259 util
.DefaultDsc tDsc
= new util
.DefaultDsc
260 ("com.sun.star.text.XTextContent",
261 "com.sun.star.text.TextField.URL");
262 log
.println( " adding InstCreator object" );
263 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
266 } // finish method getTestEnvironment
268 } // finish class SvxShapePolyPolygonBezier