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
.style
.XStyle
;
36 import com
.sun
.star
.uno
.AnyConverter
;
37 import com
.sun
.star
.uno
.Type
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
41 public class SvxShapeDimensioning
extends TestCase
{
43 static XComponent xDrawDoc
;
46 * in general this method creates a testdocument
48 * @param tParam class which contains additional test parameters
49 * @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(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
81 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
82 log
.println( " disposing xDrawDoc " );
83 util
.DesktopTools
.closeDoc(xDrawDoc
);
88 * creating a Testenvironment for the interfaces to be tested
90 * @param tParam class which contains additional test parameters
91 * @param log class to log the test state and result
93 * @return Status class
99 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
101 XInterface oObj
= null;
102 XShape oShape
= null;
104 // creation of testobject here
105 // first we write what we are intend to do to log file
106 log
.println( "creating a test environment" );
110 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
111 oShape
= SOF
.createShape(xDrawDoc
,4000,4000,3000,3000,"Measure");
113 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
115 for (int i
=0;i
<10;i
++) {
116 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(
117 SOF
.createShape(xDrawDoc
,
118 3000,4500,7510+10*i
,5010+10*i
,"Rectangle"));
123 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Line");
124 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
126 catch (Exception e
) {
127 log
.println("Couldn't create insance");
128 e
.printStackTrace(log
);
131 // test environment creation
133 TestEnvironment tEnv
= new TestEnvironment(oObj
);
135 log
.println( "adding two styles as ObjRelation for ShapeDescriptor" );
136 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
137 XStyle aStyle
= null;
139 aStyle
= (XStyle
) AnyConverter
.toObject(
140 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
141 } catch (Exception e
) {}
142 tEnv
.addObjRelation("Style1",aStyle
);
143 oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
145 aStyle
= (XStyle
) AnyConverter
.toObject(
146 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
147 } catch (Exception e
) {}
148 tEnv
.addObjRelation("Style2",aStyle
);
150 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
151 "com.sun.star.text.TextField.URL");
152 log
.println( " adding InstCreator object" );
153 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
156 } // finish method getTestEnvironment
158 } // finish class SvxShapeDimensioning