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 com
.sun
.star
.beans
.PropertyValue
;
21 import java
.io
.PrintWriter
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.DrawTools
;
27 import util
.FormTools
;
28 import util
.SOfficeFactory
;
30 import com
.sun
.star
.container
.XNameContainer
;
31 import com
.sun
.star
.drawing
.XDrawPage
;
32 import com
.sun
.star
.lang
.XComponent
;
33 import com
.sun
.star
.uno
.AnyConverter
;
34 import com
.sun
.star
.uno
.Type
;
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.HiddenControl</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::form::component::HiddenControl</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>
59 * This object test <b> is NOT </b> designed to be run in several
60 * threads concurrently.
61 * @see com.sun.star.io.XPersistObject
62 * @see com.sun.star.container.XChild
63 * @see com.sun.star.form
64 * @see com.sun.star.form.component.HiddenControl
65 * @see com.sun.star.form.FormComponent
66 * @see com.sun.star.beans.XPropertyAccess
67 * @see com.sun.star.beans.XPropertyContainer
68 * @see com.sun.star.beans.XPropertySet
69 * @see com.sun.star.beans.XFastPropertySet
70 * @see com.sun.star.beans.XPropertyState
71 * @see com.sun.star.container.XNamed
72 * @see com.sun.star.beans.XMultiPropertySet
73 * @see com.sun.star.lang.XComponent
74 * @see ifc.io._XPersistObject
75 * @see ifc.container._XChild
76 * @see ifc.form._FormControlModel
77 * @see ifc.form.component._HiddenControl
78 * @see ifc.form._FormComponent
79 * @see ifc.beans._XPropertySet
80 * @see ifc.beans._XFastPropertySet
81 * @see ifc.beans._XPropertyState
82 * @see ifc.container._XNamed
83 * @see ifc.beans._XMultiPropertySet
84 * @see ifc.lang._XComponent
86 public class OHiddenModel
extends TestCase
{
90 * Creates Drawing document.
93 protected void initialize(TestParameters tParam
, PrintWriter log
) throws Exception
{
94 SOfficeFactory SOF
= SOfficeFactory
.getFactory(tParam
.getMSF());
96 log
.println("creating a draw document");
97 xDrawDoc
= SOF
.createDrawDoc(null);
101 * Disposes drawing document.
104 protected void cleanup(TestParameters tParam
, PrintWriter log
) {
105 log
.println(" disposing xDrawDoc ");
108 XCloseable closer
= UnoRuntime
.queryInterface(
109 XCloseable
.class, xDrawDoc
);
111 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
112 log
.println("couldn't close document");
113 } catch (com
.sun
.star
.lang
.DisposedException e
) {
114 log
.println("couldn't close document");
119 * Creates hidden component, then adds Form into draw page,
120 * and inserts the component into Form components' collection.
121 * Object relations created :
123 * <li> <code>'OBJNAME'</code> for
124 * {@link ifc.io._XPersistObject} : name of service which is
125 * represented by this object. </li>
129 protected TestEnvironment
createTestEnvironment(TestParameters Param
,
130 PrintWriter log
) throws Exception
{
131 XInterface oObj
= null;
134 // creation of testobject here
135 // first we write what we are intend to do to log file
136 log
.println("creating a test environment");
138 // get a soffice factory object
139 SOfficeFactory SOF
= SOfficeFactory
.getFactory(Param
.getMSF());
140 String objName
= "HiddenControl";
141 XInterface ctrl
= SOF
.createControl(xDrawDoc
, objName
);
143 XDrawPage oDP
= DrawTools
.getDrawPage(xDrawDoc
, 0);
145 XNameContainer nc
= FormTools
.getForms(oDP
);
146 FormTools
.insertForm(xDrawDoc
, nc
, "OHiddenModelForm");
148 Object frm
= nc
.getByName("OHiddenModelForm");
150 XNameContainer frmNC
= UnoRuntime
.queryInterface(
151 XNameContainer
.class, frm
);
153 frmNC
.insertByName("OHiddenModel", ctrl
);
154 oObj
= (XInterface
) AnyConverter
.toObject(
155 new Type(XInterface
.class),
156 frmNC
.getByName("OHiddenModel"));
158 log
.println("creating a new environment for drawpage object");
160 TestEnvironment tEnv
= new TestEnvironment(oObj
);
162 util
.dbg
.getSuppServices(oObj
);
164 log
.println("adding DrawDocument as obj relation to environment");
165 tEnv
.addObjRelation("OBJNAME", "stardiv.one.form.component.Hidden");
167 PropertyValue prop
= new PropertyValue();
169 prop
.Value
= "new Text since XPropertyAccess";
170 tEnv
.addObjRelation("XPropertyAccess.propertyToChange", prop
);
171 tEnv
.addObjRelation("XPropertyContainer.propertyNotRemovable", "Name");
174 } // finish method getTestEnvironment
175 } // finish class OHiddenModel