Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / offapi / com / sun / star / form / DataAwareControlModel.idl
blobd2d40017ff49351868aacd90b191e8edcda12d47
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef __com_sun_star_form_DataAwareControlModel_idl__
20 #define __com_sun_star_form_DataAwareControlModel_idl__
22 #include <com/sun/star/form/FormControlModel.idl>
24 #include <com/sun/star/form/XBoundComponent.idl>
26 #include <com/sun/star/form/XLoadListener.idl>
28 #include <com/sun/star/form/XReset.idl>
30 #include <com/sun/star/beans/XPropertySet.idl>
34 module com { module sun { module star { module form {
37 /** is an abstract service for specialized FormControlModels
38 which are data aware and thus can be bound to a data source.
40 <p>The connection between a data-aware control model and a form whose data the
41 control should display is made by parentship relations. The parent of a data-aware
42 control model (see com::sun::star::container::XChild, inherited
43 via the FormControlModel and FormComponent services) has
44 always to be a com::sun::star::form::component::DataForm.</p>
46 published service DataAwareControlModel
48 service com::sun::star::form::FormControlModel;
50 /** makes it possible to transfer the data of the model to the connected data field.
51 <p>
52 This interface is optional, if a component doesn't support it, it has to forward
53 the changes of its value to the field it is connected to immediately (means whenever a user
54 interaction changes it's content).
55 </p>
57 [optional] interface com::sun::star::form::XBoundComponent;
60 /** must be implemented in order to recognize when the containing form of the model connects
61 to its data source (loads its data). After loading the form, the model may bind to its
62 related field source.<br/>
63 This interface will seldom be used directly from outside.
65 interface com::sun::star::form::XLoadListener;
68 /** Each DataAwareControlModel should be resettable for setting default values.
70 <p>In the context of a control model which is data-aware, the semantics of <em>default value</em>
71 (see XReset) is as follows:<br/>
72 If (and only if) the control is valid bound to a column of its com::sun::star::form::component::DataForm, and the form
73 is not positioned on a new record (see com::sun::star::sdb::RowSet::IsNew), then
74 XReset::reset() does not reset the model's value to its default value, but uses the
75 underlying column value.<br/>
76 In all other cases, the model is reset to the default value as specified by the respective property.</p>
78 <p>For an example, have a look at the com::sun::star::form::component::TextField. It inherits
79 the com::sun::star::awt::UnoControlEditModel::Text property from the underlying
80 service, and additionally specifies the com::sun::star::form::component::TextField::DefaultText.
81 </p>
83 <p>In the context of a com::sun::star::form::component::DataForm, controls are
84 automatically reset when one of the following applies
85 <ul><li>The form is reset by invoking its XReset interface.</li>
86 <li>The form moves to a new record.</li>
87 <li>The changes in the current record of the form are undone</li>
88 </ul>
89 </p>
91 interface com::sun::star::form::XReset;
94 /** specifies the name of the bound database field.
96 <p>This property makes sense in the <em>context</em> of the control model only. Normally, a control model
97 is a child of a com::sun::star::form::component::DataForm, which is bound
98 to a higher level object such as a table or query - more general, a result set.<br/>
99 This member here describes the column of this result set which the control should act for.</p>
101 <p>Not every control model can be bound to every database column. Usually, super services of the
102 DataAwareControlModel restrict the column types they can be used with.</p>
104 @see DataAwareControlModel::BoundField
106 [property] string DataField;
108 /** determines whether or not input into this field is required, when it is actually bound to a database field.
110 <p>If this property is set to `FALSE`, then the form runtime will not check the control/model for
111 `NULL` values before submitting data to the database. Usually, if a control model is bound to
112 a database field which cannot be `NULL`, and the model itself does not have a value, then the database
113 update is prevented, showing an error message to the user. To disable this behavior on a per-control
114 basis, use the <code>InputRequired</code> property.</p>
116 @since OOo 3.1
118 [optional, property] boolean InputRequired;
121 /** references to the cursor field to which the control is bound.
122 <p>Applies only if the form the control model belongs to is loaded and the control is valid bound.
123 The referenced field supports the com::sun::star::sdb::Column service.
124 </p>
125 @see DataAwareControlModel::DataField
127 [readonly, property] com::sun::star::beans::XPropertySet BoundField;
130 /** references to a control model within the same document which should be used as a label.
131 <p>Any user interface action which needs to refer to the control is assumed to use this
132 property. <br/>
133 A very common design method for forms is to group a data aware control with a label control,
134 with the latter describing the content of the former. For instance, you may have a
135 com::sun::star::form::component::TextField, which is bound to the e-mail
136 column of your data source. Then you will probably add a
137 com::sun::star::form::component::FixedText whose label is "E-Mail",
138 and associate it with the TextField by setting it as #LabelControl.<br/>
139 Now if you imagine a component offering data search in a form, this component will examine
140 the #LabelControl property, find the com::sun::star::form::component::FixedText,
141 examine it's label, and use this label to refer to the com::sun::star::form::component::TextField.
142 </p>
143 <p>When setting the property, a number of constraints apply:
144 <ul>
145 <li>The object which is to be set has to support the following interfaces
146 <ul><li>com::sun::star::awt::XControlModel</li>
147 <li>com::sun::star::lang::XServiceInfo</li>
148 <li>com::sun::star::beans::XPropertySet</li>
149 <li>com::sun::star::container::XChild</li>
150 </ul>
151 </li>
152 <li>It has to be a part of the same document as the model who's property is to be modified.</li>
153 <li>Additionally, the support of a special service, indicating that the model is of the right type,
154 is required. Which kind of service is in the request depends on the type of the control model.<br/>
156 For instance, text fields (com::sun::star::form::component::TextField) can be
157 labeled by label controls only (com::sun::star::form::component::FixedText),
158 and radio buttons (com::sun::star::form::component::RadioButton) can be labeled
159 by group boxes (com::sun::star::form::component::GroupBox) only.
160 </li>
161 </ul>
162 </p>
164 [property] com::sun::star::beans::XPropertySet LabelControl;
169 }; }; }; };
171 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */