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: SvxShapeDimensioning.java,v $
10 * $Revision: 1.7.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
.DefaultDsc
;
40 import util
.DrawTools
;
41 import util
.InstCreator
;
42 import util
.SOfficeFactory
;
44 import com
.sun
.star
.beans
.XPropertySet
;
45 import com
.sun
.star
.drawing
.XShape
;
46 import com
.sun
.star
.lang
.XComponent
;
47 import com
.sun
.star
.lang
.XMultiServiceFactory
;
48 import com
.sun
.star
.style
.XStyle
;
49 import com
.sun
.star
.uno
.AnyConverter
;
50 import com
.sun
.star
.uno
.Type
;
51 import com
.sun
.star
.uno
.UnoRuntime
;
52 import com
.sun
.star
.uno
.XInterface
;
54 public class SvxShapeDimensioning
extends TestCase
{
56 static XComponent xDrawDoc
;
59 * in general this method creates a testdocument
61 * @param tParam class which contains additional test parameters
62 * @param log class to log the test state and result
69 protected void initialize( TestParameters tParam
, PrintWriter log
) {
72 log
.println( "creating a drawdoc" );
73 xDrawDoc
= DrawTools
.createDrawDoc((XMultiServiceFactory
)tParam
.getMSF());
74 } catch ( Exception e
) {
75 // Some exception occures.FAILED
76 e
.printStackTrace( log
);
77 throw new StatusException( "Couldn't create document", e
);
82 * in general this method disposes the testenvironment and document
84 * @param tParam class which contains additional test parameters
85 * @param log class to log the test state and result
92 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
93 log
.println( " disposing xDrawDoc " );
94 util
.DesktopTools
.closeDoc(xDrawDoc
);
99 * creating a Testenvironment for the interfaces to be tested
101 * @param tParam class which contains additional test parameters
102 * @param log class to log the test state and result
104 * @return Status class
106 * @see TestParameters
109 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
111 XInterface oObj
= null;
112 XShape oShape
= null;
114 // creation of testobject here
115 // first we write what we are intend to do to log file
116 log
.println( "creating a test environment" );
120 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
121 oShape
= SOF
.createShape(xDrawDoc
,4000,4000,3000,3000,"Measure");
123 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
125 for (int i
=0;i
<10;i
++) {
126 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(
127 SOF
.createShape(xDrawDoc
,
128 3000,4500,7510+10*i
,5010+10*i
,"Rectangle"));
133 //SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)tParam.getMSF()) ;
134 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Line");
135 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
137 catch (Exception e
) {
138 log
.println("Couldn't create insance");
139 e
.printStackTrace(log
);
142 // test environment creation
144 TestEnvironment tEnv
= new TestEnvironment(oObj
);
146 log
.println( "adding two styles as ObjRelation for ShapeDescriptor" );
147 XPropertySet oShapeProps
= (XPropertySet
)
148 UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
149 XStyle aStyle
= null;
151 aStyle
= (XStyle
) AnyConverter
.toObject(
152 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
153 } catch (Exception e
) {}
154 tEnv
.addObjRelation("Style1",aStyle
);
155 oShapeProps
= (XPropertySet
)
156 UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
158 aStyle
= (XStyle
) AnyConverter
.toObject(
159 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
160 } catch (Exception e
) {}
161 tEnv
.addObjRelation("Style2",aStyle
);
163 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
164 "com.sun.star.text.TextField.URL");
165 log
.println( " adding InstCreator object" );
166 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
169 } // finish method getTestEnvironment
171 } // finish class SvxShapeDimensioning