1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScShapeObj.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.DrawTools
;
40 import util
.SOfficeFactory
;
42 import com
.sun
.star
.drawing
.XShape
;
43 import com
.sun
.star
.lang
.XComponent
;
44 import com
.sun
.star
.lang
.XMultiServiceFactory
;
45 import com
.sun
.star
.uno
.UnoRuntime
;
46 import com
.sun
.star
.uno
.XInterface
;
48 public class ScShapeObj
extends TestCase
{
50 static XComponent xSheetDoc
;
52 protected void initialize( TestParameters tParam
, PrintWriter log
) {
54 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
57 log
.println( "creating a sheetdoc" );
58 xSheetDoc
= (XComponent
) UnoRuntime
.queryInterface(XComponent
.class, SOF
.createCalcDoc(null));
59 } catch ( com
.sun
.star
.uno
.Exception e
) {
60 // Some exception occures.FAILED
61 e
.printStackTrace( log
);
62 throw new StatusException( "Couldn't create document", e
);
66 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
67 log
.println( " disposing xSheetDoc " );
68 util
.DesktopTools
.closeDoc(xSheetDoc
);
72 * Creating a Testenvironment for the interfaces to be tested.
73 * Creates an instance of the service
74 * <code>com.sun.star.drawing.EllipseShape</code> as tested component
75 * and adds it to the document.
76 * Object relations created :
78 * <li> <code>'Style1', 'Style2'</code> for
79 * {@link ifc.drawing._Shape} :
80 * two values of 'Style' property. The first is taken
81 * from the shape tested, the second from another
82 * shape added to the draw page. </li>
83 * <li> <code>'XTEXTINFO'</code> for
84 * {@link ifc.text._XText} :
85 * creator which can create instnaces of
86 * <code>com.sun.star.text.TextField.URL</code>
90 protected TestEnvironment createTestEnvironment
91 (TestParameters tParam
, PrintWriter log
) {
93 XInterface oObj
= null;
96 // creation of testobject here
97 // first we write what we are intend to do to log file
98 log
.println( "creating a test environment" );
100 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
101 oShape
= SOF
.createShape(xSheetDoc
,5000, 3500, 7500, 5000,"Rectangle");
102 DrawTools
.getShapes(DrawTools
.getDrawPage(xSheetDoc
,0)).add(oShape
);
105 for (int i
=0; i
< 10; i
++) {
106 DrawTools
.getShapes(DrawTools
.getDrawPage(xSheetDoc
,0)).add(
107 SOF
.createShape(xSheetDoc
,
108 5000, 3500, 7510 + 10 * i
, 5010 + 10 * i
, "Rectangle"));
111 // create test environment here
112 TestEnvironment tEnv
= new TestEnvironment( oShape
);
114 log
.println("Implementation name: "+util
.utils
.getImplName(oObj
));
115 tEnv
.addObjRelation("DOCUMENT",xSheetDoc
);
118 } // finish method getTestEnvironment
120 } // finish class ScShapeObj