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