2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.DefaultDsc
;
28 import util
.DrawTools
;
29 import util
.InstCreator
;
30 import util
.SOfficeFactory
;
32 import com
.sun
.star
.beans
.XPropertySet
;
33 import com
.sun
.star
.drawing
.XShape
;
34 import com
.sun
.star
.lang
.XComponent
;
35 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 import com
.sun
.star
.style
.XStyle
;
37 import com
.sun
.star
.uno
.AnyConverter
;
38 import com
.sun
.star
.uno
.Type
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
40 import com
.sun
.star
.uno
.XInterface
;
42 public class SvxShapeDimensioning
extends TestCase
{
44 static XComponent xDrawDoc
;
47 * in general this method creates a testdocument
49 * @param tParam class which contains additional test parameters
50 * @param log class to log the test state and result
57 protected void initialize( TestParameters tParam
, PrintWriter log
) {
60 log
.println( "creating a drawdoc" );
61 xDrawDoc
= DrawTools
.createDrawDoc((XMultiServiceFactory
)tParam
.getMSF());
62 } catch ( Exception e
) {
63 // Some exception occurs.FAILED
64 e
.printStackTrace( log
);
65 throw new StatusException( "Couldn't create document", e
);
70 * in general this method disposes the testenvironment and document
72 * @param tParam class which contains additional test parameters
73 * @param log class to log the test state and result
80 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
81 log
.println( " disposing xDrawDoc " );
82 util
.DesktopTools
.closeDoc(xDrawDoc
);
87 * creating a Testenvironment for the interfaces to be tested
89 * @param tParam class which contains additional test parameters
90 * @param log class to log the test state and result
92 * @return Status class
97 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
99 XInterface oObj
= null;
100 XShape oShape
= null;
102 // creation of testobject here
103 // first we write what we are intend to do to log file
104 log
.println( "creating a test environment" );
108 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
109 oShape
= SOF
.createShape(xDrawDoc
,4000,4000,3000,3000,"Measure");
111 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
113 for (int i
=0;i
<10;i
++) {
114 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(
115 SOF
.createShape(xDrawDoc
,
116 3000,4500,7510+10*i
,5010+10*i
,"Rectangle"));
121 //SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)tParam.getMSF()) ;
122 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Line");
123 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
125 catch (Exception e
) {
126 log
.println("Couldn't create insance");
127 e
.printStackTrace(log
);
130 // test environment creation
132 TestEnvironment tEnv
= new TestEnvironment(oObj
);
134 log
.println( "adding two styles as ObjRelation for ShapeDescriptor" );
135 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
136 XStyle aStyle
= null;
138 aStyle
= (XStyle
) AnyConverter
.toObject(
139 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
140 } catch (Exception e
) {}
141 tEnv
.addObjRelation("Style1",aStyle
);
142 oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
144 aStyle
= (XStyle
) AnyConverter
.toObject(
145 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
146 } catch (Exception e
) {}
147 tEnv
.addObjRelation("Style2",aStyle
);
149 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
150 "com.sun.star.text.TextField.URL");
151 log
.println( " adding InstCreator object" );
152 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
155 } // finish method getTestEnvironment
157 } // finish class SvxShapeDimensioning