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: SvxShapeCollection.java,v $
10 * $Revision: 1.6.8.1 $
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
.InstCreator
;
41 import util
.SOfficeFactory
;
44 import com
.sun
.star
.drawing
.XShape
;
45 import com
.sun
.star
.drawing
.XShapes
;
46 import com
.sun
.star
.lang
.XComponent
;
47 import com
.sun
.star
.lang
.XMultiServiceFactory
;
48 import com
.sun
.star
.uno
.UnoRuntime
;
49 import com
.sun
.star
.uno
.XInterface
;
51 public class SvxShapeCollection
extends TestCase
{
53 static XComponent xDrawDoc
;
56 * in general this method creates a testdocument
58 * @param tParam class which contains additional test parameters
59 * @param log class to log the test state and result
66 protected void initialize( TestParameters tParam
, PrintWriter log
) {
69 log
.println( "creating a drawdoc" );
70 xDrawDoc
= DrawTools
.createDrawDoc((XMultiServiceFactory
)tParam
.getMSF());
71 } catch ( Exception e
) {
72 // Some exception occures.FAILED
73 e
.printStackTrace( log
);
74 throw new StatusException( "Couldn't create document", e
);
79 * in general this method disposes the testenvironment and document
81 * @param tParam class which contains additional test parameters
82 * @param log class to log the test state and result
89 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
90 log
.println( " disposing xDrawDoc " );
91 util
.DesktopTools
.closeDoc(xDrawDoc
);
96 * creating a Testenvironment for the interfaces to be tested
98 * @param tParam class which contains additional test parameters
99 * @param log class to log the test state and result
101 * @return Status class
103 * @see TestParameters
106 protected TestEnvironment createTestEnvironment
107 (TestParameters tParam
, PrintWriter log
) {
109 XInterface oObj
= null;
110 XShape oShape
= null;
112 // creation of testobject here
113 // first we write what we are intend to do to log file
114 log
.println( "creating a test environment" );
117 // adding some shapes for testing.
118 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
119 Object col
= ((XMultiServiceFactory
)tParam
.getMSF()).createInstance
120 ("com.sun.star.drawing.ShapeCollection");
121 XShapes shapes
= (XShapes
) UnoRuntime
.queryInterface
124 oShape
= SOF
.createShape(xDrawDoc
,3000,4500,15000,1000,"Ellipse");
125 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
128 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Rectangle");
129 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
132 oObj
= (XInterface
) col
;
135 catch (Exception e
) {
136 log
.println("Couldn't create insance");
137 e
.printStackTrace(log
);
140 // test environment creation
142 TestEnvironment tEnv
= new TestEnvironment(oObj
);
143 System
.out
.println("IName: "+util
.utils
.getImplName(oObj
));
144 ShapeDsc sDsc
= new ShapeDsc(5000,3500,7500,10000,"Line");
145 tEnv
.addObjRelation("Shape", new InstCreator(xDrawDoc
, sDsc
)) ;
148 } // finish method getTestEnvironment
150 } // finish class SvxShapeCollection