1*d1766043SAndrew Rist/**************************************************************
2cdf0e10cSrcweir *
3*d1766043SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*d1766043SAndrew Rist * or more contributor license agreements.  See the NOTICE file
5*d1766043SAndrew Rist * distributed with this work for additional information
6*d1766043SAndrew Rist * regarding copyright ownership.  The ASF licenses this file
7*d1766043SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*d1766043SAndrew Rist * "License"); you may not use this file except in compliance
9*d1766043SAndrew Rist * with the License.  You may obtain a copy of the License at
10*d1766043SAndrew Rist *
11*d1766043SAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
12*d1766043SAndrew Rist *
13*d1766043SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*d1766043SAndrew Rist * software distributed under the License is distributed on an
15*d1766043SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d1766043SAndrew Rist * KIND, either express or implied.  See the License for the
17*d1766043SAndrew Rist * specific language governing permissions and limitations
18*d1766043SAndrew Rist * under the License.
19*d1766043SAndrew Rist *
20*d1766043SAndrew Rist *************************************************************/
21*d1766043SAndrew Rist
22*d1766043SAndrew Rist
23cdf0e10cSrcweir#ifndef __com_sun_star_form_DataAwareControlModel_idl__
24cdf0e10cSrcweir#define __com_sun_star_form_DataAwareControlModel_idl__
25cdf0e10cSrcweir
26cdf0e10cSrcweir#ifndef __com_sun_star_form_FormControlModel_idl__
27cdf0e10cSrcweir#include <com/sun/star/form/FormControlModel.idl>
28cdf0e10cSrcweir#endif
29cdf0e10cSrcweir
30cdf0e10cSrcweir#ifndef __com_sun_star_form_XBoundComponent_idl__
31cdf0e10cSrcweir#include <com/sun/star/form/XBoundComponent.idl>
32cdf0e10cSrcweir#endif
33cdf0e10cSrcweir
34cdf0e10cSrcweir#ifndef __com_sun_star_form_XLoadListener_idl__
35cdf0e10cSrcweir#include <com/sun/star/form/XLoadListener.idl>
36cdf0e10cSrcweir#endif
37cdf0e10cSrcweir
38cdf0e10cSrcweir#ifndef __com_sun_star_form_XReset_idl__
39cdf0e10cSrcweir#include <com/sun/star/form/XReset.idl>
40cdf0e10cSrcweir#endif
41cdf0e10cSrcweir
42cdf0e10cSrcweir#ifndef __com_sun_star_beans_XPropertySet_idl__
43cdf0e10cSrcweir#include <com/sun/star/beans/XPropertySet.idl>
44cdf0e10cSrcweir#endif
45cdf0e10cSrcweir
46cdf0e10cSrcweir
47cdf0e10cSrcweir//=============================================================================
48cdf0e10cSrcweir
49cdf0e10cSrcweir module com {  module sun {  module star {  module form {
50cdf0e10cSrcweir
51cdf0e10cSrcweir//=============================================================================
52cdf0e10cSrcweir
53cdf0e10cSrcweir/** is an abstract service for specialized <type>FormControlModel</type>s
54cdf0e10cSrcweir	which are data aware and thus can be bound to a data source.
55cdf0e10cSrcweir
56cdf0e10cSrcweir	<p>The connection between a data-aware control model and a form which's data the
57cdf0e10cSrcweir	control should display is made by parentship relations. The parent of a data-aware
58cdf0e10cSrcweir	control model (see <type scope="com::sun::star::container">XChild</type>, inherited
59cdf0e10cSrcweir	via the <type>FormControlModel</type> and <type>FormComponent</type> services) has
60cdf0e10cSrcweir	always to be a <type scope="com::sun::star::form::component">DataForm</type>.</p>
61cdf0e10cSrcweir */
62cdf0e10cSrcweirpublished service DataAwareControlModel
63cdf0e10cSrcweir{
64cdf0e10cSrcweir	service com::sun::star::form::FormControlModel;
65cdf0e10cSrcweir
66cdf0e10cSrcweir	/** makes it possible to transfer the data of the model to the connected data field.
67cdf0e10cSrcweir		<p>
68cdf0e10cSrcweir		This interface is optional, if a component doesn't support it, it has to forward
69cdf0e10cSrcweir		the changes of it's value to the field it is connected to immediately (means whenever a user
70cdf0e10cSrcweir		interaction changes it's content).
71cdf0e10cSrcweir		</p>
72cdf0e10cSrcweir	 */
73cdf0e10cSrcweir	[optional] interface com::sun::star::form::XBoundComponent;
74cdf0e10cSrcweir
75cdf0e10cSrcweir
76cdf0e10cSrcweir	/** must be implemented in order to recognize when the containing form of the model connects
77cdf0e10cSrcweir		to its data source  (loads its data). After loading the form, the model may bind to its
78cdf0e10cSrcweir		related field source.<br/>
79cdf0e10cSrcweir		This interface will seldom be used directly from outside.
80cdf0e10cSrcweir	 */
81cdf0e10cSrcweir	interface com::sun::star::form::XLoadListener;
82cdf0e10cSrcweir
83cdf0e10cSrcweir
84cdf0e10cSrcweir	/** Each <type>DataAwareControlModel</type> should be resettable for setting default values.
85cdf0e10cSrcweir
86cdf0e10cSrcweir		<p>In the context of a control model which is data-aware, the semantics of <em>default value</em>
87cdf0e10cSrcweir		(see <type>XReset</type>) is as follows:<br/>
88cdf0e10cSrcweir		If (and only if) the control is valid bound to a column of it's <typee scope="com::sun::star::form::component">DataForm</type>, and the form
89cdf0e10cSrcweir		is not positioned on a new record (see <member scope="com::sun::star::sdb">RowSet::IsNew</member>), then
90cdf0e10cSrcweir		<member>XReset::reset</member> does not reset the model's value to it's default value, but uses the
91cdf0e10cSrcweir		underlying column value.<br/>
92cdf0e10cSrcweir		In all other cases, the model is reset to the default value as specified by the respective property.</p>
93cdf0e10cSrcweir
94cdf0e10cSrcweir		<p>For an example, have a look at the <type scope="com::sun::star::form::component">TextField</type>. It inherites
95cdf0e10cSrcweir		the <member scope="com::sun::star::awt">UnoControlEditModel::Text</member> property from the underlying
96cdf0e10cSrcweir		service, and additionally specifies the <member scope="com::sun::star::form::component">TextField::DefaultText</member>.
97cdf0e10cSrcweir		</p>
98cdf0e10cSrcweir
99cdf0e10cSrcweir		<p>In the context of a <type scope="com::sun::star::form::component">DataForm</type>, controls are
100cdf0e10cSrcweir		automatically reset when one of the following applies
101cdf0e10cSrcweir		<ul><li>The form is reset by invoking it's <type>XReset</type> interface.</li>
102cdf0e10cSrcweir			<li>The form moves to a new record.</li>
103cdf0e10cSrcweir			<li>The changes in the current record of the form are undone</li>
104cdf0e10cSrcweir		</ul>
105cdf0e10cSrcweir		</p>
106cdf0e10cSrcweir	*/
107cdf0e10cSrcweir	interface com::sun::star::form::XReset;
108cdf0e10cSrcweir
109cdf0e10cSrcweir	//-------------------------------------------------------------------------
110cdf0e10cSrcweir
111cdf0e10cSrcweir	/** specifies the name of the bound database field.
112cdf0e10cSrcweir
113cdf0e10cSrcweir		<p>This property makes sense in the <em>context</em> of the control model only. Normally, a control model
114cdf0e10cSrcweir		is a child of a <type scope="com::sun::star::form::component">DataForm</type>, which is bound
115cdf0e10cSrcweir		to a higher level object such as a table or query - more general, a result set.<br/>
116cdf0e10cSrcweir		This member here describes the column of this result set which the control should act for.</p>
117cdf0e10cSrcweir
118cdf0e10cSrcweir		<p>Not every control model can be bound to every database column. Usually, super services of the
119cdf0e10cSrcweir		<type>DataAwareControlModel</type> restrict the column types they can be used with.</p>
120cdf0e10cSrcweir
121cdf0e10cSrcweir		@see DataAwareControlModel::BoundField
122cdf0e10cSrcweir	 */
123cdf0e10cSrcweir	[property] string DataField;
124cdf0e10cSrcweir
125cdf0e10cSrcweir    /** determines whether or not input into this field is required, when it is actually bound to a database field.
126cdf0e10cSrcweir
127cdf0e10cSrcweir        <p>If this property is set to <FALSE/>, then the form runtime will not check the control/model for
128cdf0e10cSrcweir        <NULL/> values before submitting data to the database. Usually, if a control model is bound to
129cdf0e10cSrcweir        a database field which cannot be <NULL/>, and the model itself does not have a value, then the database
130cdf0e10cSrcweir        update is prevented, showing an error message to the user. To disable this behavior on a per-control
131cdf0e10cSrcweir        basis, use the <code>InputRequired</code> property.</p>
132cdf0e10cSrcweir
133cdf0e10cSrcweir        @since OOo 3.1
134cdf0e10cSrcweir    */
135cdf0e10cSrcweir    [optional, property] boolean InputRequired;
136cdf0e10cSrcweir
137cdf0e10cSrcweir	//-------------------------------------------------------------------------
138cdf0e10cSrcweir
139cdf0e10cSrcweir	/** references to the cursor field to which the control is bound.
140cdf0e10cSrcweir		<p>Applies only if the form the control model belongs to is loaded and the control is valid bound.
141cdf0e10cSrcweir		The referenced field supports the <type scope="com::sun::star::sdb">Column</type> service.
142cdf0e10cSrcweir		</p>
143cdf0e10cSrcweir		@see DataAwareControlModel::DataField
144cdf0e10cSrcweir	 */
145cdf0e10cSrcweir	[readonly, property] com::sun::star::beans::XPropertySet BoundField;
146cdf0e10cSrcweir
147cdf0e10cSrcweir	//-------------------------------------------------------------------------
148cdf0e10cSrcweir
149cdf0e10cSrcweir	/** references to a control model within the same document which should be used as a label.
150cdf0e10cSrcweir		<p>Any user interface action which needs to refer to the control is assumed to use this
151cdf0e10cSrcweir		property. <br/>
152cdf0e10cSrcweir		A very common design method for forms is to group a data aware control with a label control,
153cdf0e10cSrcweir		with the latter describing the content of the former. For instance, you may have a
154cdf0e10cSrcweir		<type scope="com::sun::star::form::component">TextField</type>, which is bound to the e-mail
155cdf0e10cSrcweir		column of your data source. Then you will probably add a
156cdf0e10cSrcweir		<type scope="com::sun::star::form::component">FixedText</type> which's label is "E-Mail",
157cdf0e10cSrcweir		and associate it with the TextField by setting it as <member>LabelControl</member>.<br/>
158cdf0e10cSrcweir		Now if you imagine a component offering data search in a form, this component will examine
159cdf0e10cSrcweir		the <member>LabelControl</member> property, find the <type scope="com::sun::star::form::component">FixedText</type>,
160cdf0e10cSrcweir		examine it's label, and use this label to refer to the <type scope="com::sun::star::form::component">TextField</type>.
161cdf0e10cSrcweir		</p>
162cdf0e10cSrcweir		<p>When setting the property, a number of constraints apply:
163cdf0e10cSrcweir		<ul>
164cdf0e10cSrcweir			<li>The object which is to be set has to support the following interfaces
165cdf0e10cSrcweir				<ul><li><type scope="com::sun::star::awt">XControlModel</type></li>
166cdf0e10cSrcweir					<li><type scope="com::sun::star::lang">XServiceInfo</type></li>
167cdf0e10cSrcweir					<li><type scope="com::sun::star::beans">XPropertySet</type></li>
168cdf0e10cSrcweir					<li><type scope="com::sun::star::container">XChild</type></li>
169cdf0e10cSrcweir				</ul>
170cdf0e10cSrcweir			</il>
171cdf0e10cSrcweir			<li>It has to be a part of the same document as the model who's property is to be modified.</il>
172cdf0e10cSrcweir			<li>Additionally, the support of a special service, indicating that the model is of the right type,
173cdf0e10cSrcweir				is required. Which kind of service is in the request depends on the type of the control model.<br/>
174cdf0e10cSrcweir
175cdf0e10cSrcweir				For instance, text fields (<type scope="com::sun::star::form::component">TextField</type>) can be
176cdf0e10cSrcweir				labelled by label controls only (<type scope="com::sun::star::form::component">FixedText</type>),
177cdf0e10cSrcweir				and radio buttons (<type scope="com::sun::star::form::component">RadioButton</type>) can be labelled
178cdf0e10cSrcweir				by group boxes (<type scope="com::sun::star::form::component">GroupBox</type>) only.
179cdf0e10cSrcweir			</li>
180cdf0e10cSrcweir		</ul>
181cdf0e10cSrcweir		</p>
182cdf0e10cSrcweir	 */
183cdf0e10cSrcweir	[property] com::sun::star::beans::XPropertySet LabelControl;
184cdf0e10cSrcweir
185cdf0e10cSrcweir};
186cdf0e10cSrcweir
187cdf0e10cSrcweir//=============================================================================
188cdf0e10cSrcweir
189cdf0e10cSrcweir}; }; }; };
190cdf0e10cSrcweir
191cdf0e10cSrcweir#endif
192