1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package mod._sc; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 import util.DrawTools; 33 import util.SOfficeFactory; 34 35 import com.sun.star.drawing.XShape; 36 import com.sun.star.lang.XComponent; 37 import com.sun.star.lang.XMultiServiceFactory; 38 import com.sun.star.uno.UnoRuntime; 39 import com.sun.star.uno.XInterface; 40 41 public class ScShapeObj extends TestCase { 42 43 static XComponent xSheetDoc; 44 initialize( TestParameters tParam, PrintWriter log )45 protected void initialize( TestParameters tParam, PrintWriter log ) { 46 47 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 48 49 try { 50 log.println( "creating a sheetdoc" ); 51 xSheetDoc = (XComponent) UnoRuntime.queryInterface(XComponent.class, SOF.createCalcDoc(null)); 52 } catch ( com.sun.star.uno.Exception e ) { 53 // Some exception occures.FAILED 54 e.printStackTrace( log ); 55 throw new StatusException( "Couldn't create document", e ); 56 } 57 } 58 cleanup( TestParameters tParam, PrintWriter log )59 protected void cleanup( TestParameters tParam, PrintWriter log ) { 60 log.println( " disposing xSheetDoc " ); 61 util.DesktopTools.closeDoc(xSheetDoc); 62 } 63 64 /** 65 * Creating a Testenvironment for the interfaces to be tested. 66 * Creates an instance of the service 67 * <code>com.sun.star.drawing.EllipseShape</code> as tested component 68 * and adds it to the document. 69 * Object relations created : 70 * <ul> 71 * <li> <code>'Style1', 'Style2'</code> for 72 * {@link ifc.drawing._Shape} : 73 * two values of 'Style' property. The first is taken 74 * from the shape tested, the second from another 75 * shape added to the draw page. </li> 76 * <li> <code>'XTEXTINFO'</code> for 77 * {@link ifc.text._XText} : 78 * creator which can create instnaces of 79 * <code>com.sun.star.text.TextField.URL</code> 80 * service. </li> 81 * </ul> 82 */ createTestEnvironment(TestParameters tParam, PrintWriter log)83 protected TestEnvironment createTestEnvironment 84 (TestParameters tParam, PrintWriter log) { 85 86 XInterface oObj = null; 87 XShape oShape = null; 88 89 // creation of testobject here 90 // first we write what we are intend to do to log file 91 log.println( "creating a test environment" ); 92 93 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 94 oShape = SOF.createShape(xSheetDoc,5000, 3500, 7500, 5000,"Rectangle"); 95 DrawTools.getShapes(DrawTools.getDrawPage(xSheetDoc,0)).add(oShape); 96 oObj = oShape ; 97 98 for (int i=0; i < 10; i++) { 99 DrawTools.getShapes(DrawTools.getDrawPage(xSheetDoc,0)).add( 100 SOF.createShape(xSheetDoc, 101 5000, 3500, 7510 + 10 * i, 5010 + 10 * i, "Rectangle")); 102 } 103 104 // create test environment here 105 TestEnvironment tEnv = new TestEnvironment( oShape ); 106 107 log.println("Implementation name: "+util.utils.getImplName(oObj)); 108 tEnv.addObjRelation("DOCUMENT",xSheetDoc); 109 110 return tEnv; 111 } // finish method getTestEnvironment 112 113 } // finish class ScShapeObj 114