1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: frameloaderfactory.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_SERVICES_FRAMELOADERFACTORY_HXX_
32 #define __FRAMEWORK_SERVICES_FRAMELOADERFACTORY_HXX_
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #include <classes/filtercache.hxx>
39 #include <threadhelp/threadhelpbase.hxx>
40 #include <macros/generic.hxx>
41 #include <macros/debug.hxx>
42 #include <macros/xinterface.hxx>
43 #include <macros/xtypeprovider.hxx>
44 #include <macros/xserviceinfo.hxx>
47 //_________________________________________________________________________________________________________________
49 //_________________________________________________________________________________________________________________
50 #include <com/sun/star/beans/PropertyValue.hpp>
51 #include <com/sun/star/lang/XInitialization.hpp>
52 #include <com/sun/star/lang/WrappedTargetException.hpp>
53 #include <com/sun/star/container/XNameAccess.hpp>
54 #include <com/sun/star/container/NoSuchElementException.hpp>
55 #include <com/sun/star/io/XInputStream.hpp>
57 //_________________________________________________________________________________________________________________
59 //_________________________________________________________________________________________________________________
60 #include <cppuhelper/weak.hxx>
62 //_________________________________________________________________________________________________________________
64 //_________________________________________________________________________________________________________________
68 //_________________________________________________________________________________________________________________
70 //_________________________________________________________________________________________________________________
72 //_________________________________________________________________________________________________________________
73 // exported definitions
74 //_________________________________________________________________________________________________________________
76 struct tIMPLExtractedArguments
78 ::rtl::OUString sMimeType
;
80 ::rtl::OUString sFilterName
;
81 sal_Int32 nClipboardFormat
;
82 ::rtl::OUString sDetectService
;
83 css::uno::Reference
< css::io::XInputStream
> xInputStream
;
85 sal_Int32 nValidMask
;
88 /*-************************************************************************************************************//**
89 @short factory to create frameloader-objects
90 @descr These class can be used to create new loader for specified contents.
91 We use cached values of the registry to lay down, wich frameloader match
92 a given URL or filtername. To do this, we use the XMultiServiceFactory-interface.
94 @ATTENTION In a specialmode of these implementation we support a simple filterdetection.
95 But there is no special interface. You must call some existing methods in another context!
96 see createInstanceWithArguments() fo rfurther informations!
98 @implements XInterface
107 @devstatus deprecated
108 *//*-*************************************************************************************************************/
110 class FrameLoaderFactory
: public css::lang::XTypeProvider
,
111 public css::lang::XServiceInfo
,
112 public css::lang::XMultiServiceFactory
,
113 public css::container::XNameAccess
, // => XElementAccess
114 public ThreadHelpBase
, // Struct for right initalization of mutex member! Mst first of baseclasses
115 public ::cppu::OWeakObject
117 //-------------------------------------------------------------------------------------------------------------
119 //-------------------------------------------------------------------------------------------------------------
123 //---------------------------------------------------------------------------------------------------------
124 // constructor / destructor
125 //---------------------------------------------------------------------------------------------------------
127 /*-****************************************************************************************************//**
128 @short standard constructor
129 @descr Initialize a new instance and fill the registrycache with values.
130 To do this - xFactory must be valid!
132 @seealso class RegistryCache
133 @seealso member m_aRegistryCache
135 @param "xFactory", factory which has created us.
138 @onerror An ASSERTION is thrown in debug version, if xFactory is invalid or cache can't filled.
139 *//*-*****************************************************************************************************/
141 FrameLoaderFactory( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
143 /*-****************************************************************************************************//**
144 @short standard destructor to delete instance
145 @descr We use it to clear ouer cache.
147 @seealso class RegistryCache
153 *//*-*****************************************************************************************************/
155 virtual ~FrameLoaderFactory();
157 //---------------------------------------------------------------------------------------------------------
158 // XInterface, XTypeProvider, XServiceInfo
159 //---------------------------------------------------------------------------------------------------------
162 DECLARE_XTYPEPROVIDER
165 //---------------------------------------------------------------------------------------------------------
166 // XMultiServiceFactory
167 //---------------------------------------------------------------------------------------------------------
169 /*-****************************************************************************************************//**
170 @short create a new frameloder (without arguments!)
171 @descr We search for an agreement between given type name and our cache-content.
172 If we found some information, we create the registered frameloader for these type.
173 Otherwise - we return NULL.
174 We search from begin to end of internal loader list!
176 @seealso method impl_createFrameLoader()
177 @seealso method createInstanceWithArguments()
179 @param "sTypeName", type name of a document to filter, open or save.
180 @return A reference to a new created frameloader.
182 @onerror A null reference is returned.
183 *//*-*****************************************************************************************************/
185 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstance( const ::rtl::OUString
& sTypeName
) throw( css::uno::Exception
,
186 css::uno::RuntimeException
);
188 /*-****************************************************************************************************//**
189 @short create a new frameloder
190 @descr We search for an agreement between given type name and our cache-content.
191 If we found some information, we create the registered frameloader for these type.
192 Otherwise - we return NULL.
193 You can give us some optional arguments to influence our search!
195 @seealso method impl_createFrameLoader()
196 @seealso method createInstance()
198 @param "sTypeName", type name of a document to filter, open or save.
199 @param "seqArguments", list of optional arguments for initializing of new frameloader.
200 @return A reference to a new created frameloader.
202 @onerror A null reference is returned.
203 *//*-*****************************************************************************************************/
205 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstanceWithArguments( const ::rtl::OUString
& sTypeName
,
206 const css::uno::Sequence
< css::uno::Any
>& seqArguments
) throw( css::uno::Exception
,
207 css::uno::RuntimeException
);
209 /*-****************************************************************************************************//**
211 @descr Please use XNameAcces instead of these!
219 *//*-*****************************************************************************************************/
221 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getAvailableServiceNames() throw( css::uno::RuntimeException
);
223 //---------------------------------------------------------------------------------------------------------
225 //---------------------------------------------------------------------------------------------------------
227 /*-****************************************************************************************************//**
228 @short return properties of registered frame loader specified by his implementation name
229 @descr Use these method to get all informations about our internal loader cache
230 and a special frame loader.
231 We return a Sequence< PropertyValue > in an Any packed as result.
233 structure of return value:
235 [0].Value = list of supported types of these loader as [sequence< oustring >]
238 [1].Value = localized name of loader as [string]
240 @seealso method getElementNames()
241 @seealso method hasByName()
243 @param "sName", the name of searched frame loader (use getElementNames() to get it!)
244 @return A Sequence< PropertyValue > packed in an Any.
246 @onerror If given name not exist a NoSuchElementException is thrown.
247 *//*-*****************************************************************************************************/
249 virtual css::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& sName
) throw( css::container::NoSuchElementException
,
250 css::lang::WrappedTargetException
,
251 css::uno::RuntimeException
);
253 /*-****************************************************************************************************//**
254 @short return list of all well known loader names from configuration
255 @descr Use these method to get all names of well known loader.
256 You can use it to get the properties of a loader by calling getByName()!
258 @seealso method getByName()
259 @seealso method hasByName()
262 @return A list of well known loader. Is static at runtime!
264 @onerror No error should occure.
265 *//*-*****************************************************************************************************/
267 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames() throw( css::uno::RuntimeException
);
269 /*-****************************************************************************************************//**
270 @short check if searched frame loader exist in configuration
271 @descr Normaly nobody need these method realy (use getElementNames() in combination with getByName()).
272 We guarantee correctness of these mechanism. There is no reason to check for existing elements then ...
273 but if you have an unknwon name and has no fun to search it in returned sequence ...
274 you can call these ...
276 @seealso method getByName()
277 @seealso method getElementNames()
279 @param "sName", implementation name of searched frame loader
280 @return sal_True if loader exist, sal_False otherwise.
282 @onerror No error should occure.
283 *//*-*****************************************************************************************************/
285 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& sName
) throw( css::uno::RuntimeException
);
287 //---------------------------------------------------------------------------------------------------------
289 //---------------------------------------------------------------------------------------------------------
291 /*-****************************************************************************************************//**
292 @short return the type of retrun value of method XNameAccess::getByName()
293 @descr In these implementation its a Sequence< PropertyValue > everytime!
295 @seealso description of interface XNameAccess
298 @return Type of Sequence< PropertyValue >.
300 @onerror No error should occure.
301 *//*-*****************************************************************************************************/
303 virtual css::uno::Type SAL_CALL
getElementType() throw( css::uno::RuntimeException
);
305 /*-****************************************************************************************************//**
306 @short return state if informations about frame loader available
307 @descr If these method return false - no information could'nt read from configuration ...
308 I think nothing will work then. Normaly we return TRUE!
310 @seealso class FilterCache!
313 @return sal_True if information available, sal_False otherwise.
315 @onerror No error should occure.
316 *//*-*****************************************************************************************************/
318 virtual sal_Bool SAL_CALL
hasElements() throw( css::uno::RuntimeException
);
320 //-------------------------------------------------------------------------------------------------------------
322 //-------------------------------------------------------------------------------------------------------------
326 //-------------------------------------------------------------------------------------------------------------
328 //-------------------------------------------------------------------------------------------------------------
332 /*-****************************************************************************************************//**
333 @short try to set configuration properties at created loader
334 @descr We support the old async. loader interface ( XFrameLoader ) and the new one XSynchronousFrameLoader.
335 The new one should implement a property set on which we can set his configuration values!
336 We try to cast given loader to these interface - if it's exist we set the values - otherwise not!
338 @seealso service FrameLoader
339 @seealso service SynchronousFrameLoader
341 @param "xLoader" loader with generic XInterface! (We don't know before which service type is used!)
342 @param "pLoaderInfo" configuration structure of these loader.
345 @onerror No error should occure.
346 *//*-*****************************************************************************************************/
348 void impl_initializeLoader( css::uno::Reference
< css::uno::XInterface
>& xLoader
, const Loader
& pLoaderInfo
);
350 //-------------------------------------------------------------------------------------------------------------
352 // (should be private everyway!)
353 //-------------------------------------------------------------------------------------------------------------
355 /*-****************************************************************************************************//**
356 @short debug-method to check incoming parameter of some other mehods of this class
357 @descr The following methods are used to check parameters for other methods
358 of this class. The return value is used directly for an ASSERT(...).
360 @seealso ASSERTs in implementation!
362 @param references to checking variables
363 @return sal_False ,on invalid parameter
364 @return sal_True ,otherwise
367 *//*-*****************************************************************************************************/
370 #ifdef ENABLE_ASSERTIONS
374 static sal_Bool
impldbg_checkParameter_FrameLoaderFactory ( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
375 static sal_Bool
impldbg_checkParameter_createInstance ( const ::rtl::OUString
& sTypeName
);
376 static sal_Bool
impldbg_checkParameter_createInstanceWithArguments ( const ::rtl::OUString
& sTypeName
,
377 const css::uno::Sequence
< css::uno::Any
>& seqArguments
);
378 static sal_Bool
impldbg_checkParameter_getByName ( const ::rtl::OUString
& sName
);
379 static sal_Bool
impldbg_checkParameter_hasByName ( const ::rtl::OUString
& sName
);
381 #endif // #ifdef ENABLE_ASSERTIONS
383 //-------------------------------------------------------------------------------------------------------------
385 // (should be private everyway!)
386 //-------------------------------------------------------------------------------------------------------------
390 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xFactory
;
391 FilterCache m_aCache
;
393 }; // class FrameLoaderFactory
395 } // namespace framework
397 #endif // #ifndef __FRAMEWORK_SERVICES_FRAMELOADERFACTORY_HXX_