xref: /trunk/main/offapi/com/sun/star/document/FilterFactory.idl (revision 341b93848998051a4360ac5c6edba28fdeb619ef)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22#ifndef __com_sun_star_document_FilterFactory_idl__
23#define __com_sun_star_document_FilterFactory_idl__
24
25#ifndef __com_sun_star_lang_XMultiServiceFactory_idl__
26#include <com/sun/star/lang/XMultiServiceFactory.idl>
27#endif
28
29#ifndef __com_sun_star_container_XNameContainer_idl__
30#include <com/sun/star/container/XNameContainer.idl>
31#endif
32
33#ifndef __com_sun_star_container_XContainerQuery_idl__
34#include <com/sun/star/container/XContainerQuery.idl>
35#endif
36
37#ifndef __com_sun_star_util_XFlushable_idl__
38#include <com/sun/star/util/XFlushable.idl>
39#endif
40
41//=============================================================================
42
43module com { module sun { module star { module document {
44
45//=============================================================================
46/** factory to create filter components.
47
48    <p>
49    After a generic <type>TypeDetection</type> an internal type name
50    will be known. Further a generic <type scope="com::sun::star::frame">FrameLoader</type>
51    can use this information, to search a suitable filter (may the default filter) at
52    this factory and use it for loading the document into a specified frame.
53    </p>
54
55    <p>
56    This factory implements read/write access on the underlying configuration set.
57    and further a validate and flush mechanism for more performance and a special query mode
58    can be used here too.
59    </p>
60 */
61published service FilterFactory
62{
63    //-------------------------------------------------------------------------
64    /** factory interface to create and initialize filter components.
65
66        <p>
67        <strong>Current behavior</strong><p>
68        The methods createInstance() or createInstanceWithArguments() of this interface must be
69        called with an internal type name!. This name is used internally to search a suitable
70        (mostly the default) filter for this type then. The found filter will be created, initialized
71        and returned then. Creation of a filter by using its internal filter name directly can be
72        reached by using createInstanceWithArguments() with an optional property "FilterName" only.
73        See the following example:
74
75        <listing>
76        private com.sun.star.uno.XInterface createFilterDirect( com.sun.star.lang.XMultiServiceFactory xFilterFactory      ,
77                                                                java.lang.String                       sInternalFilterName )
78        {
79            com.sun.star.beans.PropertyValue aFilterProp = new com.sun.star.beans.PropertyValue();
80            aFilterProp.Name  = "FilterName";
81            aFilterProp.Value = sInternalFilterName;
82
83            com.sun.star.uno.Any[] lProps = new com.sun.star.uno.Any[1];
84            lProps[0] = aFilterProp;
85
86            java.lang.Object aFilter = xFilterFactory.createInstanceWithArguments("", lProps);
87            return (com.sun.star.uno.XInterface)UnoRuntime.queryInterface(com.sun.star.uno.XInterface.class, aFilter);
88        }
89        </listing>
90        </p>
91
92        <p>
93        <strong>Proposed behavior</strong><p>
94        Searching of a suitable filter for a given internal type name, must be done by the new interface
95        <type scope="com::sun::star::container">XContainerQuery</type>, available on this factory too.
96        The factory interface can be used to create filter components by its internal filter name only.
97        </p>
98
99        <p>
100        <strong>How it can be distinguished?</strong><p>
101        The new proposed implementation will throw an <type scope="com::sun::star::container">NoSuchElementException</type>
102        if the first parameter of createInstance() or createInstanceWithArguments() does not match to a valid container (means
103        filter) item. Further it will throw an <type scope="com::sun::star::lang">IllegalArgumentException</type> if the optional
104        parameter "FilterName" could not be detected inside the argument list of call createInstanceWithArguments().
105        </p>
106
107        <p>
108        <strong>Initialization of a filter component</strong><p>
109        Every filter, which was created by this factory can(!) be initialized with its own configuration data
110        and may given optional arguments of the corresponding createInstanceWithArguments() request. To do so the filter
111        instance must support the optional interface <type scope="com::sun::star::lang">XInitialization</type>.
112        The arguments parameter will have the following structure:
113        <ul>
114            <li>sequence< Any >[0] contains a sequence< <type scope="com::sun::star::beans">PropertyValue</type> >,
115                which represent the configuration data set of this filter. The used properties are the same, as
116                they are available at the container interface of this factory service. (see below)</li>
117            <li>Every following item of the argument list sequence< Any >[1..n] contains the copied argument of the
118                corresponding createInstanceWithArguments() call. That means: Item 0 or the original list was copied as
119                item 1 of the destination list ... etc.
120        </ul>
121        </p>
122     */
123    interface com::sun::star::lang::XMultiServiceFactory;
124
125    //-------------------------------------------------------------------------
126    /** provides read access to the complete set of configuration data.
127
128        <p>
129        Every container item is specified as a set of properties and will be
130        represented by a sequence< <type scope="com::sun::star::beans">PropertyValue</type> > structure.
131        Follow properties are supported:
132        (But note: not all of them must be present every time!)
133        </p>
134        <table border=1>
135            <tr>
136                <td><strong>Property Name</strong></td>
137                <td><strong>Value Type</strong></td>
138                <td><strong>Description</strong></td>
139            </tr>
140            <tr>
141                <td><em>Name</em></td>
142                <td>[string]</td>
143                <td>The internal name is the only value, which makes a container item unique.</td>
144            </tr>
145            <tr>
146                <td><em>UIName</em></td>
147                <td>[string]</td>
148                <td>It contains the localized name for this filter for the current locale.</td>
149            </tr>
150            <tr>
151                <td><em>UINames</em></td>
152                <td>[sequence< string >]</td>
153                <td>It contains all available localized names for this filter. The are organized
154                    in pairs and represented as a structure of sequence< <type scope="com::sun::star::beans">PropertyValue</type> >.
155                    The name of such property must be interpreted as locale; its value as the localized
156                    filter name corresponding to this locale.</td>
157            </tr>
158            <tr>
159                <td><em>Type</em></td>
160                <td>[string]</td>
161                <td>Every filter is registered for a type. This value contains the internal name of it.
162                    (see service <type>TypeDetection</type> for further information)</td>
163            </tr>
164            <tr>
165                <td><em>DocumentService</em></td>
166                <td>[string]</td>
167                <td>It's the uno service name of the document type, which can be handled by this filter.
168                    (e.g. <type scope="com::sun::star::text">TextDocument</type>)</td>
169            </tr>
170            <tr>
171                <td><em>FilterService</em></td>
172                <td>[string]</td>
173                <td>It means the uno implementation name of the filter component.
174                    Note: It really means the implementation instead of the uno service name.
175                    Because it's not possible to distinguish between more then one filters; if all of them
176                    uses a generic identifier!</td>
177            </tr>
178            <tr>
179                <td><em>Flags</em></td>
180                <td>[integer]</td>
181                <td>They describe the filter more specific.<br>
182                    (e.g. they mark it as IMPORT/EXPORT or DEFAULT filter.)</td>
183            </tr>
184            <tr>
185                <td><em>UserData</em></td>
186                <td>[string]</td>
187                <td>This field contains filter specific configuration data.</td>
188            </tr>
189            <tr>
190                <td><em>FileFormatVersion</em></td>
191                <td>[integer]</td>
192                <td>It specifies the supported file format version if there exist more then ones.</td>
193            </tr>
194            <tr>
195                <td><em>TemplateName</em></td>
196                <td>[string]</td>
197                <td>It's the name of a suitable default template.</td>
198            </tr>
199        </table>
200        </p>
201
202        <p>
203        Note:<br>
204        All elements of this container will be addressed by its internal name,
205        and it must be an unambiguous value.
206        </p>
207     */
208    interface com::sun::star::container::XNameAccess;
209
210    //-------------------------------------------------------------------------
211    /** provides a write access to the configuration data.
212     */
213    [optional] interface com::sun::star::container::XNameContainer;
214
215    //-------------------------------------------------------------------------
216    /** provides search on the configuration data set.
217
218        <p>
219        Against simple property search it provides some complex algorithms too.
220        For further informations please read the SDK documentation.
221        </p>
222     */
223    interface com::sun::star::container::XContainerQuery;
224
225    //-------------------------------------------------------------------------
226    /** can be used to perform container changes.
227
228        <p>
229        Because the complexity of such configuration set can be very high,
230        it does not seem very useful to update the underlying configuration layer
231        on every container change request immediately. Another strategy can be to
232        make all changes (adding/changing/removing of items) and call flush at the end.
233        That will validate the whole container and reject inconsistent data sets.
234        Only in case all made changes was correct, they will be written back to the
235        configuration. Further this interface provides the possibility, that interested
236        changes listener can be registered too.
237        </p>
238     */
239    [optional] interface com::sun::star::util::XFlushable;
240};
241
242//=============================================================================
243
244}; }; }; };
245
246#endif
247