remove assert looking for new compatibilityMode DOCX
[LibreOffice.git] / offapi / com / sun / star / form / runtime / XFormController.idl
blobcc7e6e69568d0abfa490a0d1c8492c0f5d747fc4
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 .
21 module com { module sun { module star { module form { module runtime {
23 interface XFormOperations;
24 interface XFormControllerContext;
27 /** specifies a component controlling the interaction between the user and form functionality.
29 <p>As soon as a form (containing controls) is to be presented to the user,
30 there is a need for an instance controlling the user interaction.<br/>
31 Such a <code>FormController</code> is responsible for dialog processing,
32 like controlling the tab order and the grouping of controls.</p>
34 <p>As a form may contain one or many subforms, a FormController may
35 contain one or more other FormControllers, so the form model structure or hierarchy
36 is reflected in the structure of FormControllers. That is, retrieving the parent of
37 the model of a controller will give you the same object as retrieving the model of the parent of
38 the controller. Similarly, retrieving the model of the <code>n</code><sup>th</sup> child of
39 a controller gives you the same object as retrieving the <code>n</code><sup>th</sup> child of
40 the model of the controller.</p>
42 <p>A controller is called <em>active</em> if one of the controls it is responsible for has the focus,
43 else inactive. To be notified whenever this activation state of a given controller changes, you can
44 add listeners.</p>
46 <p>This interface supersedes the com::sun::star::form::FormController.</p>
48 <h3>Responsibilities</h3>
49 <p>A FormController is responsible for a com::sun::star::awt::UnoControlContainer,
50 and all controls therein.</p>
52 <p>Furthermore, a form controller is responsible for preventing invalid user input. That is, if the form
53 contains controls bound to a database, or to an external validator, then the form controller will
54 check their current value when the current record is to be saved to the database.</p>
56 <p>First, it will check whether any controls with an external validator exist. If so, those validators
57 will be asked to validate the current control content. If this fails, the message provided by the validator
58 is displayed to the user, the control is focused, and the update of the record is vetoed.</p>
60 <p>Second, the controls are examined for NULL values. If a control is bound to a database field which
61 is declared to be <code>NOT NULL</code>, no auto-increment field, but still `NULL`, then an error
62 message is shown to the user saying that input is required, the respective control is focused, and
63 the update of the record is vetoed.</p>
65 <p>Note that you can present the second check - for database fields containing `NULL` values - on
66 a per-form and a per-database basis.<br/>
67 For the former, you need to add a boolean property <code>FormsCheckRequiredFields</code> to the form
68 (aka the <code>FormController</code>'s model), using its
69 com::sun::star::beans::XPropertyContainer::addProperty() method, with a value
70 of `FALSE`.<br/>
71 For the latter, you need to set the respective property of the data source's <code>Settings</code>
72 (also named <code>FormsCheckRequiredFields</code>) to `FALSE`.</p>
74 <p>Alternatively, you can prevent the check on a per-control basis, using the
75 DataAwareControlModel::InputRequired property of a single control model.</p>
77 <p>If a control which the controller is responsible for supports the com::sun::star::frame::XDispatchProviderInterception
78 interface, the controller registers a dispatch interceptor. Then, the control can try to delegate part of its
79 functionality to the controller by querying the dispatch interceptor for it.</p>
81 <p>Below, there's a list of URLs which have a defined meaning - if an implementation supports one of them,
82 there must be a guaranteed semantics. However, concrete implementations may support an arbitrary sub or super
83 set of these URLs.</p>
85 <p>In general, all URLs start with the same prefix, namely <em>.uno:FormController/</em>. To this, a suffix is
86 appended which describes the requested functionality.<br/>
87 Example: The URL suffix for deleting the current record is <em>deleteRecord</em>, so the complete URL for
88 requesting a dispatcher for this functionality is <em>.uno:FormController/deleteRecord</em>.</p>
90 <p>Some URLs may require parameters. For this, the sequence of com::sun::star::beans::PropertyValues
91 passed to the com::sun::star::frame::XDispatch::dispatch() call is used - every property value is
92 used as one named parameter.</p>
94 <p>For all URLs, interested parties can register as status listeners (com::sun::star::frame::XStatusListener)
95 at the dispatchers, and be notified whenever the functionality associated with the URL becomes enabled or
96 disabled.<br/>
97 For instance, the URL with the suffix <em>moveToFirst</em> is associated with moving the form to the first
98 record, and it will be disabled in case the form is already positioned on the first record.</p>
100 <table style="width:100%;" border="0" cellpadding="2" cellspacing="2">
102 <tr style="vertical-align: top;">
103 <td><b>URL suffix</b></td>
104 <td><b>functionality</b></td>
105 </tr>
107 <tr style="vertical-align: top;">
108 <td><em>positionForm</em></td>
109 <td>positions the form on a record given by absolute number.<br/>
110 There's one parameter for this functionality, named <em>Position</em>, which must be a long
111 value specifying the absolute position to which the form should be moved</td>
112 </tr>
114 <tr style="vertical-align: top;">
115 <td><em>RecordCount</em></td>
116 <td>This is a passive functionality: It cannot be dispatched, instead, interested parties may
117 use the dispatcher to add as com::sun::star::frame::XStatusListener, and be
118 notified when the record count changes.<br/>
119 The status value which is being notified (com::sun::star::frame::FeatureStateEvent::State)
120 is a string which can be used to display the record count. In particular, if the record count is not yet known
121 (com::sun::star::sdb::RowSet::IsRowCountFinal is `FALSE`), this is indicated in the
122 string, too.</td>
123 </tr>
125 <tr style="vertical-align: top;">
126 <td><em>moveToFirst</em></td>
127 <td>moves the form to the first record</td>
128 </tr>
130 <tr style="vertical-align: top;">
131 <td><em>moveToPrev</em></td>
132 <td>moves the form to the record preceding the current one</td>
133 </tr>
135 <tr style="vertical-align: top;">
136 <td><em>moveToNext</em></td>
137 <td>moves the form to the record after the current one</td>
138 </tr>
140 <tr style="vertical-align: top;">
141 <td><em>moveToLast</em></td>
142 <td>moves the form to the last record</td>
143 </tr>
145 <tr style="vertical-align: top;">
146 <td><em>moveToNew</em></td>
147 <td>moves the form to the virtual "insert row", where new records can be inserted</td>
148 </tr>
150 <tr style="vertical-align: top;">
151 <td><em>saveRecord</em></td>
152 <td>Commits any potentially pending changes in the current control, and saves the current record to
153 the database, or inserts a new record if the form is currently positioned on the virtual insertion row.</td>
154 </tr>
156 <tr style="vertical-align: top;">
157 <td><em>undoRecord</em></td>
158 <td>reverts the changes done to the current record. Basically, this means refreshing the
159 current row from the database, and updating all controls with the new content.</td>
160 </tr>
162 <tr style="vertical-align: top;">
163 <td><em>deleteRecord</em></td>
164 <td>deletes the current record, after asking the user for confirmation.</td>
165 </tr>
167 <tr style="vertical-align: top;">
168 <td><em>refreshForm</em></td>
169 <td>reloads the complete form. After this, the form is positioned on the first record</td>
170 </tr>
172 <tr style="vertical-align: top;">
173 <td><em>sortUp</em></td>
174 <td>Adds an order clause to the form, to sort it ascending by the field which the current control is bound to,
175 and then reloads the form.</td>
176 </tr>
178 <tr style="vertical-align: top;">
179 <td><em>sortDown</em></td>
180 <td>Adds an order clause to the form, to sort it descending by the field which the current control is bound to,
181 and then reloads the form.</td>
182 </tr>
184 <tr style="vertical-align: top;">
185 <td><em>sort</em></td>
186 <td>opens a dialog, which allows the user to manipulate the current sorting order of the form. If the dialog
187 is closed with OK, the form is reloaded after setting the new sorting order.</td>
188 </tr>
190 <tr style="vertical-align: top;">
191 <td><em>autoFilter</em></td>
192 <td>creates, from the current control, a filter for the form. This is, if the current control is bound to
193 the field, say, "customer", and contains the value "Furs, Inc.", then a filter "customer = 'Furs, Inc.'"
194 is created and set at the form. After this, the form is reloaded.</td>
195 </tr>
197 <tr style="vertical-align: top;">
198 <td><em>filter</em></td>
199 <td>opens a dialog, which allows the user to manipulate the current filter of the form. If the dialog
200 is closed with OK, the form is reloaded after setting the new filter.</td>
201 </tr>
203 <tr style="vertical-align: top;">
204 <td><em>applyFilter</em></td>
205 <td><p>Toggles the com::sun::star::sdb::RowSet::ApplyFilter property
206 of the form.</p>
207 <p>Additionally, status listeners will be provided with the current (boolean) state of this property
208 in the com::sun::star::frame::FeatureStateEvent::State member of the event
209 notified by the dispatcher.</p></td>
210 </tr>
212 <tr style="vertical-align: top;">
213 <td><em>removeFilterOrder</em></td>
214 <td>completely removes any filter and sorting order from the form, and reloads it.</td>
215 </tr>
216 </table>
218 @see ::com::sun::star::form::component:Form
219 @see ::com::sun::star::form::binding::BindableControlModel
220 @see ::com::sun::star::sdb::DataSource::Settings
222 @since OOo 3.3
224 interface XFormController
226 /** is used for tab controlling and grouping of the controls.
228 <p>The model obtained via com::sun::star::awt::XTabController::getModel() is the form for which the
229 controller is responsible.</p>
231 interface ::com::sun::star::awt::XTabController;
233 /** allows access to the parent controller.
235 interface ::com::sun::star::container::XChild;
237 /** allows access to the sub controllers.
239 interface ::com::sun::star::container::XIndexAccess;
241 /** allows enumerating sub controllers
243 interface ::com::sun::star::container::XEnumerationAccess;
245 /** allows life time control of the controller.
247 interface ::com::sun::star::lang::XComponent;
249 /** allows to register as listener for modifications in the controls which the controller is responsible
250 for.
252 interface ::com::sun::star::util::XModifyBroadcaster;
254 /** used to notify deletions of data in the form before they happen.
256 <p>A form controller listens for deletion events at the form it is responsible for. If and only if no
257 com::sun::star::form::XConfirmDeleteListener is registered at
258 the controller, it uses an own dialog to ask the user for confirmation.</p>
260 interface ::com::sun::star::form::XConfirmDeleteBroadcaster;
262 /** is used to notify errors which happen in the form the controller is responsible for.
264 <p>A form controller listens for error events at the form it is responsible for. If and only if no
265 com::sun::star::sdb::XSQLErrorListener is registered at the controller, it
266 uses an own dialog to notify the user of the error.</p>
269 interface ::com::sun::star::sdb::XSQLErrorBroadcaster;
271 /** is used for multiplexing row set events happening on the form which the controller is responsible for.
273 interface ::com::sun::star::sdb::XRowSetApproveBroadcaster;
275 /** is used broadcasting parameter events in the form.
277 <p>A form controller listens for parameter events at the form it is responsible for. If and only if no
278 com::sun::star::form::XDatabaseParameterListener is registered at the controller, it
279 uses an own dialog to ask the user for parameter values.</p>
281 interface ::com::sun::star::form::XDatabaseParameterBroadcaster2;
283 /** allows switching the form controller to different operation modes.
285 <a name="mode_selector"></a>
286 <p>The two modes usually (but not necessarily) supported by a form controller are the <code>DataMode</code>
287 and the <code>FilterMode</code>, where the former is the usual modus operandi for displaying and modifying
288 data, and the latter is a special mode to enter a filter for the database form which the controller is
289 responsible for.</p>
291 interface ::com::sun::star::util::XModeSelector;
293 /** allows controlling the filter mode.
295 <p>If the form controller supports a <a href="#mode_selector">form based filter mode</a>, then it shall also
296 support the XFilterController interface, which allows controlling this mode.</p>
298 [optional] interface XFilterController;
300 /** denotes the instance which is used to implement operations on the form which the controller
301 works for.
303 <p>This instance can be used, for instance, to determine the current state of certain form features.</p>
305 [attribute, readonly] XFormOperations FormOperations;
307 /** provides access to the currently active control
309 [attribute, readonly] ::com::sun::star::awt::XControl CurrentControl;
311 /** allows to delegate certain tasks to the context of the form controller
313 [attribute] XFormControllerContext Context;
315 /** used (if not `NULL`) for user interactions triggered by the form controller.
317 [attribute] ::com::sun::star::task::XInteractionHandler InteractionHandler;
319 /** adds the specified listener to receive notifications whenever the activation state of
320 the controller changes.
322 void addActivateListener( [in] ::com::sun::star::form::XFormControllerListener Listener );
324 /** removes the specified listener from the list of components to receive notifications whenever the activation
325 state of the controller changes.
327 void removeActivateListener( [in] ::com::sun::star::form::XFormControllerListener Listener );
329 /** adds a controller to the list of child controllers
330 @throws ::com::sun::star::lang::IllegalArgumentException
331 if the given controller is `NULL`, or cannot rightfully be a child controller. Since controllers
332 mirror the hierarchy of the forms the are responsible for, this means that the form of the given
333 child controller must be a child of the controller at which the method is invoked.
335 void addChildController( [in] XFormController ChildController )
336 raises ( ::com::sun::star::lang::IllegalArgumentException );
340 }; }; }; }; };
343 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */