/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef __com_sun_star_document_FilterFactory_idl__
#define __com_sun_star_document_FilterFactory_idl__

#ifndef __com_sun_star_lang_XMultiServiceFactory_idl__
#include <com/sun/star/lang/XMultiServiceFactory.idl>
#endif

#ifndef __com_sun_star_container_XNameContainer_idl__
#include <com/sun/star/container/XNameContainer.idl>
#endif

#ifndef __com_sun_star_container_XContainerQuery_idl__
#include <com/sun/star/container/XContainerQuery.idl>
#endif

#ifndef __com_sun_star_util_XFlushable_idl__
#include <com/sun/star/util/XFlushable.idl>
#endif

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

module com { module sun { module star { module document {

//=============================================================================
/** factory to create filter components.

    <p>
    After a generic <type>TypeDetection</type> an internal type name
    will be known. Further a generic <type scope="com::sun::star::frame">FrameLoader</type>
    can use this information, to search a suitable filter (may the default filter) at
    this factory and use it for loading the document into a specified frame.
    </p>

    <p>
    This factory implements read/write access on the underlying configuration set.
    and further a validate and flush mechanism for more performance and a special query mode
    can be used here too.
    </p>
 */
published service FilterFactory
{
    //-------------------------------------------------------------------------
    /** factory interface to create and initialize filter components.

        <p>
        <strong>Current behavior</strong><p>
        The methods createInstance() or createInstanceWithArguments() of this interface must be
        called with an internal type name!. This name is used internally to search a suitable
        (mostly the default) filter for this type then. The found filter will be created, initialized
        and returned then. Creation of a filter by using it's internal filter name directly can be
        reached by using createInstanceWithArguments() with an optional property "FilterName" only.
        See the following example:

        <listing>
        private com.sun.star.uno.XInterface createFilterDirect( com.sun.star.lang.XMultiServiceFactory xFilterFactory      ,
                                                                java.lang.String                       sInternalFilterName )
        {
            com.sun.star.beans.PropertyValue aFilterProp = new com.sun.star.beans.PropertyValue();
            aFilterProp.Name  = "FilterName";
            aFilterProp.Value = sInternalFilterName;

            com.sun.star.uno.Any[] lProps = new com.sun.star.uno.Any[1];
            lProps[0] = aFilterProp;

            java.lang.Object aFilter = xFilterFactory.createInstanceWithArguments("", lProps);
            return (com.sun.star.uno.XInterface)UnoRuntime.queryInterface(com.sun.star.uno.XInterface.class, aFilter);
        }
        </listing>
        </p>

        <p>
        <strong>Proposed behavior</strong><p>
        Searching of a suitable filter for a given internal type name, must be done by the new interface
        <type scope="com::sun::star::container">XContainerQuery</type>, available on this factory too.
        The factory interface can be used to create filter components by it's internal filter name only.
        </p>

        <p>
        <strong>How it can be distinguished?</strong><p>
        The new proposed implementation will throw an <type scope="com::sun::star::container">NoSuchElementException</type>
        if the first parameter of createInstance() or createInstanceWithArguments() does not match to a valid container (means
        filter) item. Further it will throw an <type scope="com::sun::star::lang">IllegalArgumentException</type> if the optional
        parameter "FilterName" could not be detected inside the argument list of call createInstanceWithArguments().
        </p>

        <p>
        <strong>Initialization of a filter component</strong><p>
        Every filter, which was created by this factory can(!) be initialized with it's own configuration data
        and may given optional arguments of the corresponding createInstanceWithArguments() request. To do so the filter
        instance must support the optional interface <type scope="com::sun::star::lang">XInitialization</type>.
        The arguments parameter will have the following structure:
        <ul>
            <li>sequence< Any >[0] contains a sequence< <type scope="com::sun::star::beans">PropertyValue</type> >,
                which represent the configuration data set of this filter. The used properties are the same, as
                they are available at the container interface of this factory service. (see below)</li>
            <li>Every following item of the argument list sequence< Any >[1..n] contains the copied argument of the
                corresponding createInstanceWithArguments() call. That means: Item 0 or the original list was copied as
                item 1 of the destination list ... etc.
        </ul>
        </p>
     */
    interface com::sun::star::lang::XMultiServiceFactory;

    //-------------------------------------------------------------------------
    /** provides read access to the complete set of configuration data.

        <p>
        Every container item is specified as a set of properties and will be
        represented by a sequence< <type scope="com::sun::star::beans">PropertyValue</type> > structure.
        Follow properties are supported:
        (But note: not all of them must be present every time!)
        </p>
        <table border=1>
            <tr>
                <td><strong>Property Name</strong></td>
                <td><strong>Value Type</strong></td>
                <td><strong>Description</strong></td>
            </tr>
            <tr>
                <td><em>Name</em></td>
                <td>[string]</td>
                <td>The internal name is the only value, which makes a container item unique.</td>
            </tr>
            <tr>
                <td><em>UIName</em></td>
                <td>[string]</td>
                <td>It contains the localized name for this filter for the current locale.</td>
            </tr>
            <tr>
                <td><em>UINames</em></td>
                <td>[sequence< string >]</td>
                <td>It contains all available localized names for this filter. The are organized
                    in pairs and represented as a structure of sequence< <type scope="com::sun::star::beans">PropertyValue</type> >.
                    The name of such property must be interpreted as locale; it's value as the localized
                    filter name corresponding to this locale.</td>
            </tr>
            <tr>
                <td><em>Type</em></td>
                <td>[string]</td>
                <td>Every filter is registered for a type. This value contains the internal name of it.
                    (see service <type>TypeDetection</type> for further informations)</td>
            </tr>
            <tr>
                <td><em>DocumentService</em></td>
                <td>[string]</td>
                <td>It's the UNO service name of the document type, which can be handled by this filter.
                    (e.g. <type scope="com::sun::star::text">TextDocument</type>)</td>
            </tr>
            <tr>
                <td><em>FilterService</em></td>
                <td>[string]</td>
                <td>It means the UNO implementation name of the filter component.
                    Note: It really means the implementation instead of the UNO service name.
                    Because it's not possible to distinguish between more then one filters; if all of them
                    uses a generic identifier!</td>
            </tr>
            <tr>
                <td><em>Flags</em></td>
                <td>[integer]</td>
                <td>They describe the filter more specific.<br>
                    (e.g. they mark it as IMPORT/EXPORT or DEFAULT filter.)</td>
            </tr>
            <tr>
                <td><em>UserData</em></td>
                <td>[string]</td>
                <td>This field contains filter specific configuration data.</td>
            </tr>
            <tr>
                <td><em>FileFormatVersion</em></td>
                <td>[integer]</td>
                <td>It specifies the supported file format version if there exist more then ones.</td>
            </tr>
            <tr>
                <td><em>TemplateName</em></td>
                <td>[string]</td>
                <td>It's the name of a suitable default template.</td>
            </tr>
        </table>
        </p>

        <p>
        Note:<br>
        All elements of this container will be addressed by his internal name,
        and it must be an unambiguous value.
        </p>
     */
    interface com::sun::star::container::XNameAccess;

    //-------------------------------------------------------------------------
    /** provides a write access to the configuration data.
     */
    [optional] interface com::sun::star::container::XNameContainer;

    //-------------------------------------------------------------------------
    /** provides search on the configuration data set.

        <p>
        Against simple property search it provides some complex algorithms too.
        For further informations please read the SDK documentation.
        </p>
     */
    interface com::sun::star::container::XContainerQuery;

    //-------------------------------------------------------------------------
    /** can be used to perform container changes.

        <p>
        Because the complexness of such configuration set can be very high,
        it seams not very useful to update the underlying configuration layer
        on every container change request immediately. Another strategy can be to
        make all changes (adding/changing/removing of items) and call flush at the end.
        That will validate the whole container and reject inconsistent data sets.
        Only in case all made changes was correct, they will be written back to the
        configuration. Further this interface provides the possibility, that interested
        changes listener can be registered too.
        </p>
     */
    [optional] interface com::sun::star::util::XFlushable;
};

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

}; }; }; };

#endif
