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
.DrawTools
;
28 import util
.FormTools
;
29 import util
.SOfficeFactory
;
31 import com
.sun
.star
.beans
.XPropertySet
;
32 import com
.sun
.star
.drawing
.XShape
;
33 import com
.sun
.star
.lang
.XComponent
;
34 import com
.sun
.star
.lang
.XMultiServiceFactory
;
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 SvxShapeControl
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
56 protected void initialize( TestParameters tParam
, PrintWriter log
) {
59 log
.println( "creating a drawdoc" );
60 xDrawDoc
= DrawTools
.createDrawDoc((XMultiServiceFactory
)tParam
.getMSF());
61 } catch ( Exception e
) {
62 // Some exception occurs.FAILED
63 e
.printStackTrace( log
);
64 throw new StatusException( "Couldn't create document", e
);
69 * in general this method disposes the testenvironment and document
71 * @param tParam class which contains additional test parameters
72 * @param log class to log the test state and result
79 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
80 log
.println( " disposing xDrawDoc " );
81 util
.DesktopTools
.closeDoc(xDrawDoc
);
86 * creating a Testenvironment for the interfaces to be tested
88 * @param tParam class which contains additional test parameters
89 * @param log class to log the test state and result
91 * @return Status class
96 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
98 XInterface oObj
= null;
101 // creation of testobject here
102 // first we write what we are intend to do to log file
103 log
.println( "creating a test environment" );
107 oShape
= FormTools
.insertControlShape(
108 xDrawDoc
,3000,4500,15000,1000,"CommandButton");
112 SOfficeFactory SOF
= SOfficeFactory
.getFactory((XMultiServiceFactory
)tParam
.getMSF()) ;
113 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Line");
114 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
116 catch (Exception e
) {
117 log
.println("Couldn't create insance");
118 e
.printStackTrace(log
);
121 // test environment creation
123 TestEnvironment tEnv
= new TestEnvironment(oObj
);
125 log
.println( "adding two styles as ObjRelation for ShapeDescriptor" );
126 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
127 XStyle aStyle
= null;
129 aStyle
= (XStyle
) AnyConverter
.toObject(
130 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
131 } catch (Exception e
) {}
132 tEnv
.addObjRelation("Style1",aStyle
);
133 oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
135 aStyle
= (XStyle
) AnyConverter
.toObject(
136 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
137 } catch (Exception e
) {}
138 tEnv
.addObjRelation("Style2",aStyle
);
140 log
.println( "adding document relation for XControlShape" );
141 tEnv
.addObjRelation("xDoc", xDrawDoc
) ;
144 } // finish method getTestEnvironment
146 } // finish class SvxShapeControl