1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski package mod._svx; 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski import java.io.PrintWriter; 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski import lib.StatusException; 29*b1cdbd2cSJim Jagielski import lib.TestCase; 30*b1cdbd2cSJim Jagielski import lib.TestEnvironment; 31*b1cdbd2cSJim Jagielski import lib.TestParameters; 32*b1cdbd2cSJim Jagielski import util.DrawTools; 33*b1cdbd2cSJim Jagielski import util.InstCreator; 34*b1cdbd2cSJim Jagielski import util.SOfficeFactory; 35*b1cdbd2cSJim Jagielski import util.utils; 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielski import com.sun.star.awt.Point; 38*b1cdbd2cSJim Jagielski import com.sun.star.awt.Size; 39*b1cdbd2cSJim Jagielski import com.sun.star.beans.XPropertySet; 40*b1cdbd2cSJim Jagielski import com.sun.star.drawing.PolyPolygonBezierCoords; 41*b1cdbd2cSJim Jagielski import com.sun.star.drawing.PolygonFlags; 42*b1cdbd2cSJim Jagielski import com.sun.star.drawing.XShape; 43*b1cdbd2cSJim Jagielski import com.sun.star.lang.XComponent; 44*b1cdbd2cSJim Jagielski import com.sun.star.lang.XMultiServiceFactory; 45*b1cdbd2cSJim Jagielski import com.sun.star.style.XStyle; 46*b1cdbd2cSJim Jagielski import com.sun.star.uno.AnyConverter; 47*b1cdbd2cSJim Jagielski import com.sun.star.uno.Type; 48*b1cdbd2cSJim Jagielski import com.sun.star.uno.UnoRuntime; 49*b1cdbd2cSJim Jagielski import com.sun.star.uno.XInterface; 50*b1cdbd2cSJim Jagielski 51*b1cdbd2cSJim Jagielski /** 52*b1cdbd2cSJim Jagielski * Test for object which is represented by service 53*b1cdbd2cSJim Jagielski * <code>com.sun.star.drawing.ClosedBezierShape</code>. <p> 54*b1cdbd2cSJim Jagielski * Object implements the following interfaces : 55*b1cdbd2cSJim Jagielski * <ul> 56*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::style::ParagraphProperties</code></li> 57*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::PolyPolygonBezierDescriptor</code></li> 58*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::LineProperties</code></li> 59*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::FillProperties</code></li> 60*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::ShadowProperties</code></li> 61*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li> 62*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::style::CharacterProperties</code></li> 63*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li> 64*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::text::XTextRange</code></li> 65*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::XShape</code></li> 66*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::lang::XComponent</code></li> 67*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::TextProperties</code></li> 68*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::beans::XPropertySet</code></li> 69*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::text::XText</code></li> 70*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> 71*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::text::XSimpleText</code></li> 72*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::Shape</code></li> 73*b1cdbd2cSJim Jagielski * </ul> <p> 74*b1cdbd2cSJim Jagielski * 75*b1cdbd2cSJim Jagielski * The following files used by this test : 76*b1cdbd2cSJim Jagielski * <ul> 77*b1cdbd2cSJim Jagielski * <li><b> TransparencyChart.sxs </b> : to load predefined chart 78*b1cdbd2cSJim Jagielski * document where two 'automatic' transparency styles exists : 79*b1cdbd2cSJim Jagielski * 'Transparency 1' and 'Transparency 2'.</li> 80*b1cdbd2cSJim Jagielski * </ul> <p> 81*b1cdbd2cSJim Jagielski * 82*b1cdbd2cSJim Jagielski * This object test <b> is NOT </b> designed to be run in several 83*b1cdbd2cSJim Jagielski * threads concurently. 84*b1cdbd2cSJim Jagielski * 85*b1cdbd2cSJim Jagielski * @see com.sun.star.style.ParagraphProperties 86*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.PolyPolygonBezierDescriptor 87*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.LineProperties 88*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.FillProperties 89*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.ShadowProperties 90*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.XGluePointsSupplier 91*b1cdbd2cSJim Jagielski * @see com.sun.star.style.CharacterProperties 92*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.RotationDescriptor 93*b1cdbd2cSJim Jagielski * @see com.sun.star.text.XTextRange 94*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.XShape 95*b1cdbd2cSJim Jagielski * @see com.sun.star.lang.XComponent 96*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.TextProperties 97*b1cdbd2cSJim Jagielski * @see com.sun.star.beans.XPropertySet 98*b1cdbd2cSJim Jagielski * @see com.sun.star.text.XText 99*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.XShapeDescriptor 100*b1cdbd2cSJim Jagielski * @see com.sun.star.text.XSimpleText 101*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.Shape 102*b1cdbd2cSJim Jagielski * @see ifc.style._ParagraphProperties 103*b1cdbd2cSJim Jagielski * @see ifc.drawing._PolyPolygonBezierDescriptor 104*b1cdbd2cSJim Jagielski * @see ifc.drawing._LineProperties 105*b1cdbd2cSJim Jagielski * @see ifc.drawing._FillProperties 106*b1cdbd2cSJim Jagielski * @see ifc.drawing._ShadowProperties 107*b1cdbd2cSJim Jagielski * @see ifc.drawing._XGluePointsSupplier 108*b1cdbd2cSJim Jagielski * @see ifc.style._CharacterProperties 109*b1cdbd2cSJim Jagielski * @see ifc.drawing._RotationDescriptor 110*b1cdbd2cSJim Jagielski * @see ifc.text._XTextRange 111*b1cdbd2cSJim Jagielski * @see ifc.drawing._XShape 112*b1cdbd2cSJim Jagielski * @see ifc.lang._XComponent 113*b1cdbd2cSJim Jagielski * @see ifc.drawing._TextProperties 114*b1cdbd2cSJim Jagielski * @see ifc.beans._XPropertySet 115*b1cdbd2cSJim Jagielski * @see ifc.text._XText 116*b1cdbd2cSJim Jagielski * @see ifc.drawing._XShapeDescriptor 117*b1cdbd2cSJim Jagielski * @see ifc.text._XSimpleText 118*b1cdbd2cSJim Jagielski * @see ifc.drawing._Shape 119*b1cdbd2cSJim Jagielski */ 120*b1cdbd2cSJim Jagielski public class SvxShapePolyPolygonBezier extends TestCase { 121*b1cdbd2cSJim Jagielski 122*b1cdbd2cSJim Jagielski static XComponent xDrawDoc; 123*b1cdbd2cSJim Jagielski 124*b1cdbd2cSJim Jagielski /** 125*b1cdbd2cSJim Jagielski * in general this method creates a testdocument 126*b1cdbd2cSJim Jagielski * 127*b1cdbd2cSJim Jagielski * @param tParam class which contains additional test parameters 128*b1cdbd2cSJim Jagielski * @param log class to log the test state and result 129*b1cdbd2cSJim Jagielski * 130*b1cdbd2cSJim Jagielski * 131*b1cdbd2cSJim Jagielski * @see TestParameters 132*b1cdbd2cSJim Jagielski * * @see PrintWriter 133*b1cdbd2cSJim Jagielski * 134*b1cdbd2cSJim Jagielski */ initialize( TestParameters tParam, PrintWriter log )135*b1cdbd2cSJim Jagielski protected void initialize( TestParameters tParam, PrintWriter log ) { 136*b1cdbd2cSJim Jagielski // get a soffice factory object 137*b1cdbd2cSJim Jagielski SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 138*b1cdbd2cSJim Jagielski 139*b1cdbd2cSJim Jagielski try { 140*b1cdbd2cSJim Jagielski log.println( "creating a chartdocument" ); 141*b1cdbd2cSJim Jagielski xDrawDoc = SOF.loadDocument( 142*b1cdbd2cSJim Jagielski utils.getFullTestURL("SvxShape.sxd")); 143*b1cdbd2cSJim Jagielski } catch (com.sun.star.uno.Exception e) { 144*b1cdbd2cSJim Jagielski // Some exception occures.FAILED 145*b1cdbd2cSJim Jagielski e.printStackTrace( log ); 146*b1cdbd2cSJim Jagielski throw new StatusException( "Couldn't create document", e ); 147*b1cdbd2cSJim Jagielski } 148*b1cdbd2cSJim Jagielski } 149*b1cdbd2cSJim Jagielski 150*b1cdbd2cSJim Jagielski /** 151*b1cdbd2cSJim Jagielski * in general this method disposes the testenvironment and document 152*b1cdbd2cSJim Jagielski * 153*b1cdbd2cSJim Jagielski * @param tParam class which contains additional test parameters 154*b1cdbd2cSJim Jagielski * @param log class to log the test state and result 155*b1cdbd2cSJim Jagielski * 156*b1cdbd2cSJim Jagielski * 157*b1cdbd2cSJim Jagielski * @see TestParameters 158*b1cdbd2cSJim Jagielski * * @see PrintWriter 159*b1cdbd2cSJim Jagielski * 160*b1cdbd2cSJim Jagielski */ cleanup( TestParameters tParam, PrintWriter log )161*b1cdbd2cSJim Jagielski protected void cleanup( TestParameters tParam, PrintWriter log ) { 162*b1cdbd2cSJim Jagielski log.println( " disposing xDrawDoc " ); 163*b1cdbd2cSJim Jagielski util.DesktopTools.closeDoc(xDrawDoc); 164*b1cdbd2cSJim Jagielski } 165*b1cdbd2cSJim Jagielski 166*b1cdbd2cSJim Jagielski 167*b1cdbd2cSJim Jagielski /** 168*b1cdbd2cSJim Jagielski * * creating a Testenvironment for the interfaces to be tested 169*b1cdbd2cSJim Jagielski * 170*b1cdbd2cSJim Jagielski * @param tParam class which contains additional test parameters 171*b1cdbd2cSJim Jagielski * @param log class to log the test state and result 172*b1cdbd2cSJim Jagielski * 173*b1cdbd2cSJim Jagielski * @return Status class 174*b1cdbd2cSJim Jagielski * 175*b1cdbd2cSJim Jagielski * @see TestParameters 176*b1cdbd2cSJim Jagielski * * @see PrintWriter 177*b1cdbd2cSJim Jagielski */ createTestEnvironment(TestParameters tParam, PrintWriter log)178*b1cdbd2cSJim Jagielski protected TestEnvironment createTestEnvironment 179*b1cdbd2cSJim Jagielski (TestParameters tParam, PrintWriter log) { 180*b1cdbd2cSJim Jagielski 181*b1cdbd2cSJim Jagielski XInterface oObj = null; 182*b1cdbd2cSJim Jagielski XShape oShape = null; 183*b1cdbd2cSJim Jagielski 184*b1cdbd2cSJim Jagielski // creation of testobject here 185*b1cdbd2cSJim Jagielski // first we write what we are intend to do to log file 186*b1cdbd2cSJim Jagielski log.println( "creating a test environment" ); 187*b1cdbd2cSJim Jagielski 188*b1cdbd2cSJim Jagielski try { 189*b1cdbd2cSJim Jagielski 190*b1cdbd2cSJim Jagielski SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 191*b1cdbd2cSJim Jagielski 192*b1cdbd2cSJim Jagielski XMultiServiceFactory xMSF = (XMultiServiceFactory) 193*b1cdbd2cSJim Jagielski UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc) ; 194*b1cdbd2cSJim Jagielski 195*b1cdbd2cSJim Jagielski XInterface oInst = (XInterface) xMSF.createInstance 196*b1cdbd2cSJim Jagielski ("com.sun.star.drawing.ClosedBezierShape") ; 197*b1cdbd2cSJim Jagielski oShape = (XShape) UnoRuntime.queryInterface 198*b1cdbd2cSJim Jagielski (XShape.class, oInst) ; 199*b1cdbd2cSJim Jagielski 200*b1cdbd2cSJim Jagielski Point[] points = new Point[2]; 201*b1cdbd2cSJim Jagielski points[0] = new Point(); 202*b1cdbd2cSJim Jagielski points[0].X = 50; 203*b1cdbd2cSJim Jagielski points[0].Y = 50; 204*b1cdbd2cSJim Jagielski points[1] = new Point(); 205*b1cdbd2cSJim Jagielski points[1].X = 5000; 206*b1cdbd2cSJim Jagielski points[1].Y = 5000; 207*b1cdbd2cSJim Jagielski 208*b1cdbd2cSJim Jagielski Point[][] the_points = new Point[1][2]; 209*b1cdbd2cSJim Jagielski the_points[0] = points; 210*b1cdbd2cSJim Jagielski 211*b1cdbd2cSJim Jagielski PolygonFlags[] flags = new PolygonFlags[2]; 212*b1cdbd2cSJim Jagielski flags[0] = PolygonFlags.NORMAL; 213*b1cdbd2cSJim Jagielski flags[1] = PolygonFlags.NORMAL; 214*b1cdbd2cSJim Jagielski 215*b1cdbd2cSJim Jagielski PolygonFlags[][] the_flags = new PolygonFlags[1][2]; 216*b1cdbd2cSJim Jagielski the_flags[0] = flags; 217*b1cdbd2cSJim Jagielski 218*b1cdbd2cSJim Jagielski PolyPolygonBezierCoords coords = new PolyPolygonBezierCoords(); 219*b1cdbd2cSJim Jagielski coords.Coordinates=the_points; 220*b1cdbd2cSJim Jagielski coords.Flags = the_flags; 221*b1cdbd2cSJim Jagielski 222*b1cdbd2cSJim Jagielski DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); 223*b1cdbd2cSJim Jagielski 224*b1cdbd2cSJim Jagielski oShape.setSize(new Size(3000,3000)) ; 225*b1cdbd2cSJim Jagielski oShape.setPosition(new Point(4000,4000)) ; 226*b1cdbd2cSJim Jagielski 227*b1cdbd2cSJim Jagielski oObj = oShape ; 228*b1cdbd2cSJim Jagielski 229*b1cdbd2cSJim Jagielski XPropertySet shapeProps = (XPropertySet) UnoRuntime.queryInterface 230*b1cdbd2cSJim Jagielski (XPropertySet.class, oObj); 231*b1cdbd2cSJim Jagielski 232*b1cdbd2cSJim Jagielski shapeProps.setPropertyValue("PolyPolygonBezier",coords); 233*b1cdbd2cSJim Jagielski 234*b1cdbd2cSJim Jagielski //SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)tParam.getMSF()) ; 235*b1cdbd2cSJim Jagielski oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Line"); 236*b1cdbd2cSJim Jagielski DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; 237*b1cdbd2cSJim Jagielski } 238*b1cdbd2cSJim Jagielski catch (Exception e) { 239*b1cdbd2cSJim Jagielski log.println("Couldn't create instance"); 240*b1cdbd2cSJim Jagielski e.printStackTrace(log); 241*b1cdbd2cSJim Jagielski } 242*b1cdbd2cSJim Jagielski 243*b1cdbd2cSJim Jagielski // test environment creation 244*b1cdbd2cSJim Jagielski 245*b1cdbd2cSJim Jagielski TestEnvironment tEnv = new TestEnvironment(oObj); 246*b1cdbd2cSJim Jagielski 247*b1cdbd2cSJim Jagielski log.println( "adding two styles as ObjRelation for ShapeDescriptor" ); 248*b1cdbd2cSJim Jagielski XPropertySet oShapeProps = (XPropertySet) 249*b1cdbd2cSJim Jagielski UnoRuntime.queryInterface(XPropertySet.class,oObj); 250*b1cdbd2cSJim Jagielski XStyle aStyle = null; 251*b1cdbd2cSJim Jagielski try { 252*b1cdbd2cSJim Jagielski aStyle = (XStyle) AnyConverter.toObject( 253*b1cdbd2cSJim Jagielski new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); 254*b1cdbd2cSJim Jagielski } catch (Exception e) {} 255*b1cdbd2cSJim Jagielski tEnv.addObjRelation("Style1",aStyle); 256*b1cdbd2cSJim Jagielski oShapeProps = (XPropertySet) 257*b1cdbd2cSJim Jagielski UnoRuntime.queryInterface(XPropertySet.class,oShape); 258*b1cdbd2cSJim Jagielski try { 259*b1cdbd2cSJim Jagielski aStyle = (XStyle) AnyConverter.toObject( 260*b1cdbd2cSJim Jagielski new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); 261*b1cdbd2cSJim Jagielski } catch (Exception e) {} 262*b1cdbd2cSJim Jagielski tEnv.addObjRelation("Style2",aStyle); 263*b1cdbd2cSJim Jagielski 264*b1cdbd2cSJim Jagielski // adding relation for XText 265*b1cdbd2cSJim Jagielski util.DefaultDsc tDsc = new util.DefaultDsc 266*b1cdbd2cSJim Jagielski ("com.sun.star.text.XTextContent", 267*b1cdbd2cSJim Jagielski "com.sun.star.text.TextField.URL"); 268*b1cdbd2cSJim Jagielski log.println( " adding InstCreator object" ); 269*b1cdbd2cSJim Jagielski tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); 270*b1cdbd2cSJim Jagielski 271*b1cdbd2cSJim Jagielski return tEnv; 272*b1cdbd2cSJim Jagielski } // finish method getTestEnvironment 273*b1cdbd2cSJim Jagielski 274*b1cdbd2cSJim Jagielski } // finish class SvxShapePolyPolygonBezier 275