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
.DefaultDsc
;
28 import util
.DrawTools
;
29 import util
.InstCreator
;
30 import util
.SOfficeFactory
;
33 import com
.sun
.star
.awt
.Point
;
34 import com
.sun
.star
.awt
.Size
;
35 import com
.sun
.star
.beans
.XPropertySet
;
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
;
46 * Test for object which is represented by service
47 * <code>com.sun.star.drawing.PolyPolygonShape</code>. <p>
48 * Object implements the following interfaces :
50 * <li> <code>com::sun::star::style::ParagraphProperties</code></li>
51 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
52 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
53 * <li> <code>com::sun::star::drawing::PolyPolygonDescriptor</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>
68 * The following files used by this test :
70 * <li><b> TransparencyChart.sxs </b> : to load predefined chart
71 * document where two 'automatic' transparency styles exists :
72 * 'Transparency 1' and 'Transparency 2'.</li>
75 * This object test <b> is NOT </b> designed to be run in several
76 * threads concurently.
78 * @see com.sun.star.style.ParagraphProperties
79 * @see com.sun.star.drawing.LineProperties
80 * @see com.sun.star.drawing.FillProperties
81 * @see com.sun.star.drawing.PolyPolygonDescriptor
82 * @see com.sun.star.drawing.ShadowProperties
83 * @see com.sun.star.drawing.XGluePointsSupplier
84 * @see com.sun.star.style.CharacterProperties
85 * @see com.sun.star.drawing.RotationDescriptor
86 * @see com.sun.star.text.XTextRange
87 * @see com.sun.star.drawing.XShape
88 * @see com.sun.star.lang.XComponent
89 * @see com.sun.star.drawing.TextProperties
90 * @see com.sun.star.beans.XPropertySet
91 * @see com.sun.star.text.XText
92 * @see com.sun.star.drawing.XShapeDescriptor
93 * @see com.sun.star.text.XSimpleText
94 * @see com.sun.star.drawing.Shape
95 * @see ifc.style._ParagraphProperties
96 * @see ifc.drawing._LineProperties
97 * @see ifc.drawing._FillProperties
98 * @see ifc.drawing._PolyPolygonDescriptor
99 * @see ifc.drawing._ShadowProperties
100 * @see ifc.drawing._XGluePointsSupplier
101 * @see ifc.style._CharacterProperties
102 * @see ifc.drawing._RotationDescriptor
103 * @see ifc.text._XTextRange
104 * @see ifc.drawing._XShape
105 * @see ifc.lang._XComponent
106 * @see ifc.drawing._TextProperties
107 * @see ifc.beans._XPropertySet
108 * @see ifc.text._XText
109 * @see ifc.drawing._XShapeDescriptor
110 * @see ifc.text._XSimpleText
111 * @see ifc.drawing._Shape
113 public class SvxShapePolyPolygon
extends TestCase
{
115 static XComponent xDrawDoc
;
118 * in general this method creates a testdocument
120 * @param tParam class which contains additional test parameters
121 * @param log class to log the test state and result
124 * @see TestParameters
128 protected void initialize( TestParameters tParam
, PrintWriter log
) {
129 // get a soffice factory object
130 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
133 log
.println( "creating a chartdocument" );
134 xDrawDoc
= SOF
.loadDocument(
135 utils
.getFullTestURL("SvxShape.sxd"));
136 } catch (com
.sun
.star
.uno
.Exception e
) {
137 // Some exception occurs.FAILED
138 e
.printStackTrace( log
);
139 throw new StatusException( "Couldn't create document", e
);
144 * in general this method disposes the testenvironment and document
146 * @param tParam class which contains additional test parameters
147 * @param log class to log the test state and result
150 * @see TestParameters
154 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
155 log
.println( " disposing xDrawDoc " );
156 util
.DesktopTools
.closeDoc(xDrawDoc
);
161 * * creating a Testenvironment for the interfaces to be tested
163 * @param tParam class which contains additional test parameters
164 * @param log class to log the test state and result
166 * @return Status class
168 * @see TestParameters
171 protected TestEnvironment createTestEnvironment
172 (TestParameters tParam
, PrintWriter log
) {
174 XInterface oObj
= null;
175 XShape oShape
= null;
177 // creation of testobject here
178 // first we write what we are intend to do to log file
179 log
.println( "creating a test environment" );
182 // adding some shapes for testing.
183 //SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
184 //oShape = SOF.createShape(xDrawDoc,6000,6000,5000,5000,"PolyPolygon");
185 XMultiServiceFactory xMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xDrawDoc
) ;
186 XInterface oInst
= (XInterface
) xMSF
.createInstance
187 ("com.sun.star.drawing.PolyPolygonShape") ;
188 oShape
= UnoRuntime
.queryInterface
189 (XShape
.class, oInst
) ;
191 oShape
.setSize(new Size(0,0)) ;
192 oShape
.setPosition(new Point(0,0)) ;
194 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
196 Point
[] square1
= new Point
[] {
197 new Point(5000, 5000),
198 new Point(10000, 5000),
199 new Point(10000, 10000),
200 new Point(5000, 10000)} ;
202 Point
[] square2
= new Point
[] {
203 new Point(6500, 6500),
204 new Point(8500, 6500),
205 new Point(8500, 8500),
206 new Point(6500, 8500)} ;
208 Point
[][] polygon
= new Point
[][] {square1
, square2
};
210 UnoRuntime
.queryInterface(XPropertySet
.class,
211 oShape
).setPropertyValue("PolyPolygon", polygon
) ;
215 SOfficeFactory SOF
= SOfficeFactory
.getFactory((XMultiServiceFactory
)tParam
.getMSF()) ;
216 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Line");
217 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
219 catch (Exception e
) {
220 log
.println("Couldn't create insance");
221 e
.printStackTrace(log
);
224 // test environment creation
226 TestEnvironment tEnv
= new TestEnvironment(oObj
);
228 log
.println( "adding two styles as ObjRelation for ShapeDescriptor" );
229 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
230 XStyle aStyle
= null;
232 aStyle
= (XStyle
) AnyConverter
.toObject(
233 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
234 } catch (Exception e
) {}
235 tEnv
.addObjRelation("Style1",aStyle
);
236 oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
238 aStyle
= (XStyle
) AnyConverter
.toObject(
239 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
240 } catch (Exception e
) {}
241 tEnv
.addObjRelation("Style2",aStyle
);
243 // adding relation for XText
244 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
245 "com.sun.star.text.TextField.URL");
246 log
.println( " adding InstCreator object" );
247 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
250 } // finish method getTestEnvironment
252 } // finish class SvxShapeCollection