/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: FormControllerDispatcher.idl,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: rt $ $Date: 2005/09/08 00:20:14 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef __com_sun_star_form_FormControllerDispatcher_idl__
#define __com_sun_star_form_FormControllerDispatcher_idl__

#ifndef __com_sun_star_frame_XDispatchProvider_idl__
#include <com/sun/star/frame/XDispatchProvider.idl>
#endif

//=============================================================================

module com {  module sun {  module star {  module form {

//=============================================================================

/** specifies a component which can be used to dispatch form controller functionality.

    <p>A form controller dispatcher is an instance which provides access to dispatchers
    (<type scope="com::sun::star::frame">XDispatch</type>) for certain form controller
    functionality.</p>

    <p>The way how access to these dispatchers is provided is not defined. It may either
    be directly via an <type scope="com::sun::star::frame">XDispatchProvider</type> interface,
    or indirectly, e.g. by registering dispatch interceptors (<type scope="com::sun::star::frame">XDispatchProviderInterceptor</type>)
    at another instance which supports this (by exposing the <type scope="com::sun::star::frame">XDispatchProviderInterception</type>
    interface).</p>

    <p>In any scenario, foreign components have a (implicit or explicit) possibility to request a dispatcher
    for a given URL.</p>

    <p>Below, there's a list of URLs which have a defined meaning - if a <type>FormControllerDispatcher</type>
    implementation supports one of them, there must be a guaranteed semantices. However, concrete implementations
    may support an arbitrary sub or super set of these URLs.</p>

    <p>In general, all URLs start with the same prefix, namely <em>.uno:FormController/</em>. To this, a suffix is
    appended which describes the requested functionality.<br/>
    Example: The URL suffix for deleting the current record is <em>deleteRecord</em>, so the complete URL for
    requesting a dispatcher for this functionality is <em>.uno:FormController/deleteRecord</em>.</p>

    <p>Some URLs may require parameters. For this, the sequence of <type scope="com::sun::star::beans">PropertyValue</type>s
    passed to the <member scope="com::sun::star::frame">XDispatch::dispatch</member> call is used - every property value is
    used as one named parameter.</p>

    <p>For all URLs, interested parties can register as status listeners (<type scope="com::sun::star::frame">XStatusListener</type>)
    at the dispatchers, and be notified whenever the functionality associated with the URL becomes enabled or
    disabled.<br/>
    For instance, the URL with the suffix <em>moveToFirst</em> is associated with moving the form to the first
    record, and it will be disabled in case the form is already positioned on the first record.</p>

    <p>Nearly all of the functionality offered by a <type>FormControllerDispatcher</type> can also be
    reached by other means. E.g., moving a form to its first record can be achieved by calling the
    method <member scope="com::sun::star::sdbc">XResultSet::first</member> of the form.<br/>
    However, the advantage of using a <type>FormControllerDispatcher</type> is that it's usually implemented
    by a component which has additional knowledge about the form. For instance, in a document which
    displays a form, there might be a control which contains uncommitted changes, plus a control
    whose changes were already committed to the current record, but <em>not</em> to the database. Simply
    calling <member scope="com::sun::star::sdbc">XResultSet::first</member> on the form would lose
    both the content in the uncommitted control, and the changes in the current record.<br/>
    An <type>FormControllerDispatcher</type> is expected to care for both of these.</p>

    <table style="width:100%;" border="0" cellpadding="2" cellspacing="2"><tbody>

      <tr style="vertical-align: top;">
        <td><b>URL suffix</b></td>
        <td><b>functionality</b></td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>positionForm</em></td>
        <td>positions the form on a record given by absolute number.<br/>
        There's one parameter for this functionality, named <em>Position</em>, which must be a long
        value specifying the absolute position to which the form should be moved</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>RecordCount</em></td>
        <td>This is a passive functionality: It cannot be dispatched, instead, interested parties may
        use the dispatcher to add as <type scope="com::sun::star::frame">XStatusListener</type>, and be
        notified when the record count changes.<br/>
        The status value which is being notified (<member scope="com::sun::star::frame">FeatureStateEvent::State</member>)
        is a string which can be used to display the record count. In particular, if the record count is not yet known
        (<member scope="com::sun::star::sdb">RowSet::IsRowCountFinal</member> is <FALSE/>), this is indicated in the
        string, too.</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>moveToFirst</em></td>
        <td>moves the form to the first record</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>moveToPrev</em></td>
        <td>moves the form to the record preceding the current one</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>moveToNext</em></td>
        <td>moves the form to the record after the current one</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>moveToLast</em></td>
        <td>moves the form to the last record</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>moveToNew</em></td>
        <td>moves the form to the virtual "insert row", where new records can be inserted</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>saveRecord</em></td>
        <td>Commits any potentially pending changes in the current control, and saves the current record to
        the database, or inserts a new record if the form is currently positioned on the virtual insertion row.</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>undoRecord</em></td>
        <td>reverts the changes done to the current record. Basically, this means refreshing the
        current row from the database, and updating all controls with the new content.</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>deleteRecord</em></td>
        <td>deletes the current record, after asking the user for confirmation.</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>refreshForm</em></td>
        <td>reloads the complete form. After this, the form is positioned on the first record</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>sortUp</em></td>
        <td>Adds an order clause to the form, to sort it ascending by the the field which the current control is bound to,
        and then reloads the form.</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>sortDown</em></td>
        <td>Adds an order clause to the form, to sort it descending by the the field which the current control is bound to,
        and then reloads the form.</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>sort</em></td>
        <td>opens an dialog, which allows the user to manipulate the current sorting order of the form. If the dialog
        is closed with OK, the form is reloaded after setting the new sorting order.</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>autoFilter</em></td>
        <td>creates, from the current control, a filter for the form. This is, if the current control is bound to
        the field, say, "customer", and contains the value "Furs, Inc.", then a filter "customer = 'Furs, Inc.'"
        is created and set at the form. After this, the form is reloaded.</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>filter</em></td>
        <td>opens an dialog, which allows the user to manipulate the current filter of the form. If the dialog
        is closed with OK, the form is reloaded after setting the new filter.</td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>applyFilter</em></td>
        <td><p>Toggles the <member scope="com::sun::star::sdb">RowSet::ApplyFilter</member> property
        of the form.</p>
        <p>Additionally, status listeners will be provided with the current (boolean) state of this property
        in the <member scope="com::sun::star::frame">FeatureStateEvent::State</member> member of the event
        notified by the dispatcher.</p></td>
      </tr>

      <tr style="vertical-align: top;">
        <td><em>removeFilterOrder</em></td>
        <td>completely removes any filter and sorting order from the form, and reloads it.</td>
      </tr>

    </tbody></table>

    @see FormController
 */
published service FormControllerDispatcher
{
    //-------------------------------------------------------------------------
    /** allows direct access to the dispatchers provided by the component.
    */
    [optional] interface com::sun::star::frame::XDispatchProvider;
};

//=============================================================================

}; }; }; };

/*=============================================================================

=============================================================================*/
#endif
