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.DefaultDsc; 33*b1cdbd2cSJim Jagielski import util.DrawTools; 34*b1cdbd2cSJim Jagielski import util.InstCreator; 35*b1cdbd2cSJim Jagielski import util.SOfficeFactory; 36*b1cdbd2cSJim Jagielski import util.utils; 37*b1cdbd2cSJim Jagielski 38*b1cdbd2cSJim Jagielski import com.sun.star.awt.Point; 39*b1cdbd2cSJim Jagielski import com.sun.star.awt.Size; 40*b1cdbd2cSJim Jagielski import com.sun.star.beans.XPropertySet; 41*b1cdbd2cSJim Jagielski import com.sun.star.drawing.XShape; 42*b1cdbd2cSJim Jagielski import com.sun.star.lang.XComponent; 43*b1cdbd2cSJim Jagielski import com.sun.star.lang.XMultiServiceFactory; 44*b1cdbd2cSJim Jagielski import com.sun.star.style.XStyle; 45*b1cdbd2cSJim Jagielski import com.sun.star.uno.AnyConverter; 46*b1cdbd2cSJim Jagielski import com.sun.star.uno.Type; 47*b1cdbd2cSJim Jagielski import com.sun.star.uno.UnoRuntime; 48*b1cdbd2cSJim Jagielski import com.sun.star.uno.XInterface; 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski /** 51*b1cdbd2cSJim Jagielski * Test for object which is represented by service 52*b1cdbd2cSJim Jagielski * <code>com.sun.star.drawing.PolyPolygonShape</code>. <p> 53*b1cdbd2cSJim Jagielski * Object implements the following interfaces : 54*b1cdbd2cSJim Jagielski * <ul> 55*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::style::ParagraphProperties</code></li> 56*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::LineProperties</code></li> 57*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::FillProperties</code></li> 58*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::PolyPolygonDescriptor</code></li> 59*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::ShadowProperties</code></li> 60*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li> 61*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::style::CharacterProperties</code></li> 62*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li> 63*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::text::XTextRange</code></li> 64*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::XShape</code></li> 65*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::lang::XComponent</code></li> 66*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::TextProperties</code></li> 67*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::beans::XPropertySet</code></li> 68*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::text::XText</code></li> 69*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> 70*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::text::XSimpleText</code></li> 71*b1cdbd2cSJim Jagielski * <li> <code>com::sun::star::drawing::Shape</code></li> 72*b1cdbd2cSJim Jagielski * </ul> <p> 73*b1cdbd2cSJim Jagielski * The following files used by this test : 74*b1cdbd2cSJim Jagielski * <ul> 75*b1cdbd2cSJim Jagielski * <li><b> TransparencyChart.sxs </b> : to load predefined chart 76*b1cdbd2cSJim Jagielski * document where two 'automatic' transparency styles exists : 77*b1cdbd2cSJim Jagielski * 'Transparency 1' and 'Transparency 2'.</li> 78*b1cdbd2cSJim Jagielski * </ul> <p> 79*b1cdbd2cSJim Jagielski * 80*b1cdbd2cSJim Jagielski * This object test <b> is NOT </b> designed to be run in several 81*b1cdbd2cSJim Jagielski * threads concurently. 82*b1cdbd2cSJim Jagielski * 83*b1cdbd2cSJim Jagielski * @see com.sun.star.style.ParagraphProperties 84*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.LineProperties 85*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.FillProperties 86*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.PolyPolygonDescriptor 87*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.ShadowProperties 88*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.XGluePointsSupplier 89*b1cdbd2cSJim Jagielski * @see com.sun.star.style.CharacterProperties 90*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.RotationDescriptor 91*b1cdbd2cSJim Jagielski * @see com.sun.star.text.XTextRange 92*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.XShape 93*b1cdbd2cSJim Jagielski * @see com.sun.star.lang.XComponent 94*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.TextProperties 95*b1cdbd2cSJim Jagielski * @see com.sun.star.beans.XPropertySet 96*b1cdbd2cSJim Jagielski * @see com.sun.star.text.XText 97*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.XShapeDescriptor 98*b1cdbd2cSJim Jagielski * @see com.sun.star.text.XSimpleText 99*b1cdbd2cSJim Jagielski * @see com.sun.star.drawing.Shape 100*b1cdbd2cSJim Jagielski * @see ifc.style._ParagraphProperties 101*b1cdbd2cSJim Jagielski * @see ifc.drawing._LineProperties 102*b1cdbd2cSJim Jagielski * @see ifc.drawing._FillProperties 103*b1cdbd2cSJim Jagielski * @see ifc.drawing._PolyPolygonDescriptor 104*b1cdbd2cSJim Jagielski * @see ifc.drawing._ShadowProperties 105*b1cdbd2cSJim Jagielski * @see ifc.drawing._XGluePointsSupplier 106*b1cdbd2cSJim Jagielski * @see ifc.style._CharacterProperties 107*b1cdbd2cSJim Jagielski * @see ifc.drawing._RotationDescriptor 108*b1cdbd2cSJim Jagielski * @see ifc.text._XTextRange 109*b1cdbd2cSJim Jagielski * @see ifc.drawing._XShape 110*b1cdbd2cSJim Jagielski * @see ifc.lang._XComponent 111*b1cdbd2cSJim Jagielski * @see ifc.drawing._TextProperties 112*b1cdbd2cSJim Jagielski * @see ifc.beans._XPropertySet 113*b1cdbd2cSJim Jagielski * @see ifc.text._XText 114*b1cdbd2cSJim Jagielski * @see ifc.drawing._XShapeDescriptor 115*b1cdbd2cSJim Jagielski * @see ifc.text._XSimpleText 116*b1cdbd2cSJim Jagielski * @see ifc.drawing._Shape 117*b1cdbd2cSJim Jagielski */ 118*b1cdbd2cSJim Jagielski public class SvxShapePolyPolygon extends TestCase { 119*b1cdbd2cSJim Jagielski 120*b1cdbd2cSJim Jagielski static XComponent xDrawDoc; 121*b1cdbd2cSJim Jagielski 122*b1cdbd2cSJim Jagielski /** 123*b1cdbd2cSJim Jagielski * in general this method creates a testdocument 124*b1cdbd2cSJim Jagielski * 125*b1cdbd2cSJim Jagielski * @param tParam class which contains additional test parameters 126*b1cdbd2cSJim Jagielski * @param log class to log the test state and result 127*b1cdbd2cSJim Jagielski * 128*b1cdbd2cSJim Jagielski * 129*b1cdbd2cSJim Jagielski * @see TestParameters 130*b1cdbd2cSJim Jagielski * * @see PrintWriter 131*b1cdbd2cSJim Jagielski * 132*b1cdbd2cSJim Jagielski */ initialize( TestParameters tParam, PrintWriter log )133*b1cdbd2cSJim Jagielski protected void initialize( TestParameters tParam, PrintWriter log ) { 134*b1cdbd2cSJim Jagielski // get a soffice factory object 135*b1cdbd2cSJim Jagielski SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 136*b1cdbd2cSJim Jagielski 137*b1cdbd2cSJim Jagielski try { 138*b1cdbd2cSJim Jagielski log.println( "creating a chartdocument" ); 139*b1cdbd2cSJim Jagielski xDrawDoc = SOF.loadDocument( 140*b1cdbd2cSJim Jagielski utils.getFullTestURL("SvxShape.sxd")); 141*b1cdbd2cSJim Jagielski } catch (com.sun.star.uno.Exception e) { 142*b1cdbd2cSJim Jagielski // Some exception occures.FAILED 143*b1cdbd2cSJim Jagielski e.printStackTrace( log ); 144*b1cdbd2cSJim Jagielski throw new StatusException( "Couldn't create document", e ); 145*b1cdbd2cSJim Jagielski } 146*b1cdbd2cSJim Jagielski } 147*b1cdbd2cSJim Jagielski 148*b1cdbd2cSJim Jagielski /** 149*b1cdbd2cSJim Jagielski * in general this method disposes the testenvironment and document 150*b1cdbd2cSJim Jagielski * 151*b1cdbd2cSJim Jagielski * @param tParam class which contains additional test parameters 152*b1cdbd2cSJim Jagielski * @param log class to log the test state and result 153*b1cdbd2cSJim Jagielski * 154*b1cdbd2cSJim Jagielski * 155*b1cdbd2cSJim Jagielski * @see TestParameters 156*b1cdbd2cSJim Jagielski * * @see PrintWriter 157*b1cdbd2cSJim Jagielski * 158*b1cdbd2cSJim Jagielski */ cleanup( TestParameters tParam, PrintWriter log )159*b1cdbd2cSJim Jagielski protected void cleanup( TestParameters tParam, PrintWriter log ) { 160*b1cdbd2cSJim Jagielski log.println( " disposing xDrawDoc " ); 161*b1cdbd2cSJim Jagielski util.DesktopTools.closeDoc(xDrawDoc); 162*b1cdbd2cSJim Jagielski } 163*b1cdbd2cSJim Jagielski 164*b1cdbd2cSJim Jagielski 165*b1cdbd2cSJim Jagielski /** 166*b1cdbd2cSJim Jagielski * * creating a Testenvironment for the interfaces to be tested 167*b1cdbd2cSJim Jagielski * 168*b1cdbd2cSJim Jagielski * @param tParam class which contains additional test parameters 169*b1cdbd2cSJim Jagielski * @param log class to log the test state and result 170*b1cdbd2cSJim Jagielski * 171*b1cdbd2cSJim Jagielski * @return Status class 172*b1cdbd2cSJim Jagielski * 173*b1cdbd2cSJim Jagielski * @see TestParameters 174*b1cdbd2cSJim Jagielski * * @see PrintWriter 175*b1cdbd2cSJim Jagielski */ createTestEnvironment(TestParameters tParam, PrintWriter log)176*b1cdbd2cSJim Jagielski protected TestEnvironment createTestEnvironment 177*b1cdbd2cSJim Jagielski (TestParameters tParam, PrintWriter log) { 178*b1cdbd2cSJim Jagielski 179*b1cdbd2cSJim Jagielski XInterface oObj = null; 180*b1cdbd2cSJim Jagielski XShape oShape = null; 181*b1cdbd2cSJim Jagielski 182*b1cdbd2cSJim Jagielski // creation of testobject here 183*b1cdbd2cSJim Jagielski // first we write what we are intend to do to log file 184*b1cdbd2cSJim Jagielski log.println( "creating a test environment" ); 185*b1cdbd2cSJim Jagielski 186*b1cdbd2cSJim Jagielski try { 187*b1cdbd2cSJim Jagielski // adding some shapes for testing. 188*b1cdbd2cSJim Jagielski //SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 189*b1cdbd2cSJim Jagielski //oShape = SOF.createShape(xDrawDoc,6000,6000,5000,5000,"PolyPolygon"); 190*b1cdbd2cSJim Jagielski XMultiServiceFactory xMSF = (XMultiServiceFactory) 191*b1cdbd2cSJim Jagielski UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc) ; 192*b1cdbd2cSJim Jagielski XInterface oInst = (XInterface) xMSF.createInstance 193*b1cdbd2cSJim Jagielski ("com.sun.star.drawing.PolyPolygonShape") ; 194*b1cdbd2cSJim Jagielski oShape = (XShape) UnoRuntime.queryInterface 195*b1cdbd2cSJim Jagielski (XShape.class, oInst) ; 196*b1cdbd2cSJim Jagielski 197*b1cdbd2cSJim Jagielski oShape.setSize(new Size(0,0)) ; 198*b1cdbd2cSJim Jagielski oShape.setPosition(new Point(0,0)) ; 199*b1cdbd2cSJim Jagielski 200*b1cdbd2cSJim Jagielski DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); 201*b1cdbd2cSJim Jagielski 202*b1cdbd2cSJim Jagielski Point[] square1 = new Point[] { 203*b1cdbd2cSJim Jagielski new Point(5000, 5000), 204*b1cdbd2cSJim Jagielski new Point(10000, 5000), 205*b1cdbd2cSJim Jagielski new Point(10000, 10000), 206*b1cdbd2cSJim Jagielski new Point(5000, 10000)} ; 207*b1cdbd2cSJim Jagielski 208*b1cdbd2cSJim Jagielski Point[] square2 = new Point[] { 209*b1cdbd2cSJim Jagielski new Point(6500, 6500), 210*b1cdbd2cSJim Jagielski new Point(8500, 6500), 211*b1cdbd2cSJim Jagielski new Point(8500, 8500), 212*b1cdbd2cSJim Jagielski new Point(6500, 8500)} ; 213*b1cdbd2cSJim Jagielski 214*b1cdbd2cSJim Jagielski Point[][] polygon = new Point[][] {square1, square2}; 215*b1cdbd2cSJim Jagielski 216*b1cdbd2cSJim Jagielski ((XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, 217*b1cdbd2cSJim Jagielski oShape)).setPropertyValue("PolyPolygon", polygon) ; 218*b1cdbd2cSJim Jagielski 219*b1cdbd2cSJim Jagielski oObj = oShape ; 220*b1cdbd2cSJim Jagielski 221*b1cdbd2cSJim Jagielski SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)tParam.getMSF()) ; 222*b1cdbd2cSJim Jagielski oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Line"); 223*b1cdbd2cSJim Jagielski DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; 224*b1cdbd2cSJim Jagielski } 225*b1cdbd2cSJim Jagielski catch (Exception e) { 226*b1cdbd2cSJim Jagielski log.println("Couldn't create insance"); 227*b1cdbd2cSJim Jagielski e.printStackTrace(log); 228*b1cdbd2cSJim Jagielski } 229*b1cdbd2cSJim Jagielski 230*b1cdbd2cSJim Jagielski // test environment creation 231*b1cdbd2cSJim Jagielski 232*b1cdbd2cSJim Jagielski TestEnvironment tEnv = new TestEnvironment(oObj); 233*b1cdbd2cSJim Jagielski 234*b1cdbd2cSJim Jagielski log.println( "adding two styles as ObjRelation for ShapeDescriptor" ); 235*b1cdbd2cSJim Jagielski XPropertySet oShapeProps = (XPropertySet) 236*b1cdbd2cSJim Jagielski UnoRuntime.queryInterface(XPropertySet.class,oObj); 237*b1cdbd2cSJim Jagielski XStyle aStyle = null; 238*b1cdbd2cSJim Jagielski try { 239*b1cdbd2cSJim Jagielski aStyle = (XStyle) AnyConverter.toObject( 240*b1cdbd2cSJim Jagielski new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); 241*b1cdbd2cSJim Jagielski } catch (Exception e) {} 242*b1cdbd2cSJim Jagielski tEnv.addObjRelation("Style1",aStyle); 243*b1cdbd2cSJim Jagielski oShapeProps = (XPropertySet) 244*b1cdbd2cSJim Jagielski UnoRuntime.queryInterface(XPropertySet.class,oShape); 245*b1cdbd2cSJim Jagielski try { 246*b1cdbd2cSJim Jagielski aStyle = (XStyle) AnyConverter.toObject( 247*b1cdbd2cSJim Jagielski new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); 248*b1cdbd2cSJim Jagielski } catch (Exception e) {} 249*b1cdbd2cSJim Jagielski tEnv.addObjRelation("Style2",aStyle); 250*b1cdbd2cSJim Jagielski 251*b1cdbd2cSJim Jagielski // adding relation for XText 252*b1cdbd2cSJim Jagielski DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", 253*b1cdbd2cSJim Jagielski "com.sun.star.text.TextField.URL"); 254*b1cdbd2cSJim Jagielski log.println( " adding InstCreator object" ); 255*b1cdbd2cSJim Jagielski tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); 256*b1cdbd2cSJim Jagielski 257*b1cdbd2cSJim Jagielski return tEnv; 258*b1cdbd2cSJim Jagielski } // finish method getTestEnvironment 259*b1cdbd2cSJim Jagielski 260*b1cdbd2cSJim Jagielski } // finish class SvxShapeCollection 261*b1cdbd2cSJim Jagielski 262