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 .
20 import java
.io
.PrintWriter
;
23 import lib
.TestEnvironment
;
24 import lib
.TestParameters
;
25 import util
.DrawTools
;
26 import util
.SOfficeFactory
;
28 import com
.sun
.star
.awt
.Point
;
29 import com
.sun
.star
.awt
.Size
;
30 import com
.sun
.star
.awt
.XControlModel
;
31 import com
.sun
.star
.beans
.PropertyValue
;
32 import com
.sun
.star
.drawing
.XControlShape
;
33 import com
.sun
.star
.lang
.XComponent
;
34 import com
.sun
.star
.lang
.XMultiServiceFactory
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
37 import com
.sun
.star
.util
.XCloseable
;
41 * Test for object which is represented by service
42 * <code>com.sun.star.form.component.FileControl</code>. <p>
43 * Object implements the following interfaces :
45 * <li> <code>com::sun::star::io::XPersistObject</code></li>
46 * <li> <code>com::sun::star::container::XChild</code></li>
47 * <li> <code>com::sun::star::form::FormControlModel</code></li>
48 * <li> <code>com::sun::star::awt::UnoControlFileControlModel</code></li>
49 * <li> <code>com::sun::star::form::FormComponent</code></li>
50 * <li> <code>com::sun::star::beans::XPropertyAccess</code></li>
51 * <li> <code>com::sun::star::beans::XPropertyContainer</code></li>
52 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
53 * <li> <code>com::sun::star::beans::XFastPropertySet</code></li>
54 * <li> <code>com::sun::star::beans::XPropertyState</code></li>
55 * <li> <code>com::sun::star::container::XNamed</code></li>
56 * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li>
57 * <li> <code>com::sun::star::lang::XComponent</code></li>
58 * <li> <code>com::sun::star::form::component::FileControl</code></li>
60 * This object test <b> is NOT </b> designed to be run in several
61 * threads concurrently.
62 * @see com.sun.star.io.XPersistObject
63 * @see com.sun.star.container.XChild
64 * @see com.sun.star.form
65 * @see com.sun.star.awt.UnoControlFileControlModel
66 * @see com.sun.star.form.FormComponent
67 * @see com.sun.star.beans.XPropertyAccess
68 * @see com.sun.star.beans.XPropertyContainer
69 * @see com.sun.star.beans.XPropertySet
70 * @see com.sun.star.beans.XFastPropertySet
71 * @see com.sun.star.beans.XPropertyState
72 * @see com.sun.star.container.XNamed
73 * @see com.sun.star.beans.XMultiPropertySet
74 * @see com.sun.star.lang.XComponent
75 * @see com.sun.star.form.component.FileControl
76 * @see ifc.io._XPersistObject
77 * @see ifc.container._XChild
78 * @see ifc.form._FormControlModel
79 * @see ifc.awt._UnoControlFileControlModel
80 * @see ifc.form._FormComponent
81 * @see ifc.beans._XPropertySet
82 * @see ifc.beans._XFastPropertySet
83 * @see ifc.beans._XPropertyState
84 * @see ifc.container._XNamed
85 * @see ifc.beans._XMultiPropertySet
86 * @see ifc.lang._XComponent
87 * @see ifc.form.component._FileControl
89 public class OFileControlModel
extends TestCase
{
93 * Creates Draw document where controls are placed.
96 protected void initialize(TestParameters tParam
, PrintWriter log
) throws Exception
{
97 SOfficeFactory SOF
= SOfficeFactory
.getFactory(tParam
.getMSF());
98 log
.println("creating a draw document");
99 xDrawDoc
= SOF
.createDrawDoc(null);
103 * Disposes Draw document.
106 protected void cleanup(TestParameters tParam
, PrintWriter log
) {
107 log
.println(" disposing xDrawDoc ");
110 XCloseable closer
= UnoRuntime
.queryInterface(
111 XCloseable
.class, xDrawDoc
);
113 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
114 log
.println("couldn't close document");
115 } catch (com
.sun
.star
.lang
.DisposedException e
) {
116 log
.println("couldn't close document");
121 * Creating a TestEnvironment for the interfaces to be tested.
122 * Creates FileControl in the Form. <p>
123 * Object relations created :
125 * <li> <code>'OBJNAME'</code> for
126 * {@link ifc.io._XPersistObject} : name of service which is
127 * represented by this object. </li>
131 protected TestEnvironment
createTestEnvironment(TestParameters Param
,
132 PrintWriter log
) throws Exception
{
133 XInterface oObj
= null;
136 // creation of testobject here
137 // first we write what we are intend to do to log file
138 log
.println("creating a test environment");
140 //get FileControlModel
141 String objName
= "FileControl";
143 XControlShape aShape
= null;
145 Size size
= new Size();
146 Point position
= new Point();
147 XControlModel aControl
= null;
150 XMultiServiceFactory oDocMSF
= UnoRuntime
.queryInterface(
151 XMultiServiceFactory
.class,
154 Object oInt
= oDocMSF
.createInstance(
155 "com.sun.star.drawing.ControlShape");
156 Object aCon
= oDocMSF
.createInstance(
157 "com.sun.star.form.component." + objName
);
158 aControl
= UnoRuntime
.queryInterface(
159 XControlModel
.class, aCon
);
160 aShape
= UnoRuntime
.queryInterface(
161 XControlShape
.class, oInt
);
166 aShape
.setSize(size
);
167 aShape
.setPosition(position
);
169 aShape
.setControl(aControl
);
171 DrawTools
.getDrawPage(xDrawDoc
, 0).add(aShape
);
172 oObj
= aShape
.getControl();
174 log
.println("creating a new environment for drawpage object");
176 TestEnvironment tEnv
= new TestEnvironment(oObj
);
178 tEnv
.addObjRelation("OBJNAME", "stardiv.one.form.component." +
180 PropertyValue prop
= new PropertyValue();
181 prop
.Name
= "HelpText";
182 prop
.Value
= "new Help Text since XPropertyAccess";
183 tEnv
.addObjRelation("XPropertyAccess.propertyToChange", prop
);
184 tEnv
.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText");
187 } // finish method getTestEnvironment
188 } // finish class OFileControlModel