Update git submodules
[LibreOffice.git] / qadevOOo / tests / java / mod / _svx / SvxShapePolyPolygonBezier.java
blobf053a2e0f13f0ae787b8823224d7fcadb275a76b
1 /*
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 .
19 package mod._svx;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.DrawTools;
27 import util.InstCreator;
28 import util.SOfficeFactory;
29 import util.utils;
31 import com.sun.star.awt.Point;
32 import com.sun.star.awt.Size;
33 import com.sun.star.beans.XPropertySet;
34 import com.sun.star.drawing.PolyPolygonBezierCoords;
35 import com.sun.star.drawing.PolygonFlags;
36 import com.sun.star.drawing.XShape;
37 import com.sun.star.lang.XComponent;
38 import com.sun.star.lang.XMultiServiceFactory;
39 import com.sun.star.style.XStyle;
40 import com.sun.star.uno.AnyConverter;
41 import com.sun.star.uno.Type;
42 import com.sun.star.uno.UnoRuntime;
43 import com.sun.star.uno.XInterface;
45 /**
46 * Test for object which is represented by service
47 * <code>com.sun.star.drawing.ClosedBezierShape</code>. <p>
48 * Object implements the following interfaces :
49 * <ul>
50 * <li> <code>com::sun::star::style::ParagraphProperties</code></li>
51 * <li> <code>com::sun::star::drawing::PolyPolygonBezierDescriptor</code></li>
52 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
53 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
54 * <li> <code>com::sun::star::drawing::ShadowProperties</code></li>
55 * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li>
56 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
57 * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li>
58 * <li> <code>com::sun::star::text::XTextRange</code></li>
59 * <li> <code>com::sun::star::drawing::XShape</code></li>
60 * <li> <code>com::sun::star::lang::XComponent</code></li>
61 * <li> <code>com::sun::star::drawing::TextProperties</code></li>
62 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
63 * <li> <code>com::sun::star::text::XText</code></li>
64 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li>
65 * <li> <code>com::sun::star::text::XSimpleText</code></li>
66 * <li> <code>com::sun::star::drawing::Shape</code></li>
67 * </ul> <p>
69 * The following files used by this test :
70 * <ul>
71 * <li><b> TransparencyChart.sxs </b> : to load predefined chart
72 * document where two 'automatic' transparency styles exists :
73 * 'Transparency 1' and 'Transparency 2'.</li>
74 * </ul> <p>
76 * This object test <b> is NOT </b> designed to be run in several
77 * threads concurrently.
79 * @see com.sun.star.style.ParagraphProperties
80 * @see com.sun.star.drawing.PolyPolygonBezierDescriptor
81 * @see com.sun.star.drawing.LineProperties
82 * @see com.sun.star.drawing.FillProperties
83 * @see com.sun.star.drawing.ShadowProperties
84 * @see com.sun.star.drawing.XGluePointsSupplier
85 * @see com.sun.star.style.CharacterProperties
86 * @see com.sun.star.drawing.RotationDescriptor
87 * @see com.sun.star.text.XTextRange
88 * @see com.sun.star.drawing.XShape
89 * @see com.sun.star.lang.XComponent
90 * @see com.sun.star.drawing.TextProperties
91 * @see com.sun.star.beans.XPropertySet
92 * @see com.sun.star.text.XText
93 * @see com.sun.star.drawing.XShapeDescriptor
94 * @see com.sun.star.text.XSimpleText
95 * @see com.sun.star.drawing.Shape
96 * @see ifc.style._ParagraphProperties
97 * @see ifc.drawing._PolyPolygonBezierDescriptor
98 * @see ifc.drawing._LineProperties
99 * @see ifc.drawing._FillProperties
100 * @see ifc.drawing._ShadowProperties
101 * @see ifc.drawing._XGluePointsSupplier
102 * @see ifc.style._CharacterProperties
103 * @see ifc.drawing._RotationDescriptor
104 * @see ifc.text._XTextRange
105 * @see ifc.drawing._XShape
106 * @see ifc.lang._XComponent
107 * @see ifc.drawing._TextProperties
108 * @see ifc.beans._XPropertySet
109 * @see ifc.text._XText
110 * @see ifc.drawing._XShapeDescriptor
111 * @see ifc.text._XSimpleText
112 * @see ifc.drawing._Shape
114 public class SvxShapePolyPolygonBezier extends TestCase {
116 static XComponent xDrawDoc;
119 * in general this method creates a testdocument
121 * @param tParam class which contains additional test parameters
122 * @param log class to log the test state and result
125 * @see TestParameters
126 * * @see PrintWriter
129 @Override
130 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
131 // get a soffice factory object
132 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
133 log.println( "creating a chartdocument" );
134 xDrawDoc = SOF.loadDocument(
135 utils.getFullTestURL("SvxShape.sxd"));
139 * in general this method disposes the testenvironment and document
141 * @param tParam class which contains additional test parameters
142 * @param log class to log the test state and result
145 * @see TestParameters
146 * * @see PrintWriter
149 @Override
150 protected void cleanup( TestParameters tParam, PrintWriter log ) {
151 log.println( " disposing xDrawDoc " );
152 util.DesktopTools.closeDoc(xDrawDoc);
157 * * creating a TestEnvironment for the interfaces to be tested
159 * @param tParam class which contains additional test parameters
160 * @param log class to log the test state and result
162 * @return Status class
164 * @see TestParameters
165 * * @see PrintWriter
167 @Override
168 protected TestEnvironment createTestEnvironment
169 (TestParameters tParam, PrintWriter log) {
171 XInterface oObj = null;
172 XShape oShape = null;
174 // creation of testobject here
175 // first we write what we are intend to do to log file
176 log.println( "creating a test environment" );
178 try {
180 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
182 XMultiServiceFactory xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc) ;
184 XInterface oInst = (XInterface) xMSF.createInstance
185 ("com.sun.star.drawing.ClosedBezierShape") ;
186 oShape = UnoRuntime.queryInterface
187 (XShape.class, oInst) ;
189 Point[] points = new Point[2];
190 points[0] = new Point();
191 points[0].X = 50;
192 points[0].Y = 50;
193 points[1] = new Point();
194 points[1].X = 5000;
195 points[1].Y = 5000;
197 Point[][] the_points = new Point[1][2];
198 the_points[0] = points;
200 PolygonFlags[] flags = new PolygonFlags[2];
201 flags[0] = PolygonFlags.NORMAL;
202 flags[1] = PolygonFlags.NORMAL;
204 PolygonFlags[][] the_flags = new PolygonFlags[1][2];
205 the_flags[0] = flags;
207 PolyPolygonBezierCoords coords = new PolyPolygonBezierCoords();
208 coords.Coordinates=the_points;
209 coords.Flags = the_flags;
211 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape);
213 oShape.setSize(new Size(3000,3000)) ;
214 oShape.setPosition(new Point(4000,4000)) ;
216 oObj = oShape ;
218 XPropertySet shapeProps = UnoRuntime.queryInterface
219 (XPropertySet.class, oObj);
221 shapeProps.setPropertyValue("PolyPolygonBezier",coords);
223 oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Line");
224 DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ;
226 catch (Exception e) {
227 log.println("Couldn't create instance");
228 e.printStackTrace(log);
231 // test environment creation
233 TestEnvironment tEnv = new TestEnvironment(oObj);
235 log.println( "adding two styles as ObjRelation for ShapeDescriptor" );
236 XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj);
237 XStyle aStyle = null;
238 try {
239 aStyle = (XStyle) AnyConverter.toObject(
240 new Type(XStyle.class),oShapeProps.getPropertyValue("Style"));
241 } catch (Exception e) {
242 System.out.println("caught exception: " + e);
244 tEnv.addObjRelation("Style1",aStyle);
245 oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape);
246 try {
247 aStyle = (XStyle) AnyConverter.toObject(
248 new Type(XStyle.class),oShapeProps.getPropertyValue("Style"));
249 } catch (Exception e) {
250 System.out.println("caught exception: " + e);
252 tEnv.addObjRelation("Style2",aStyle);
254 // adding relation for XText
255 util.DefaultDsc tDsc = new util.DefaultDsc
256 ("com.sun.star.text.XTextContent",
257 "com.sun.star.text.TextField.URL");
258 log.println( " adding InstCreator object" );
259 tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) );
261 return tEnv;
262 } // finish method getTestEnvironment
264 } // finish class SvxShapePolyPolygonBezier