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/implbase3.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 ThreadHelpBase
, // Struct for right initalization of mutex member! Mst first of baseclasses
111 public ::cppu::WeakImplHelper3
< ::com::sun::star::lang::XServiceInfo
,::com::sun::star::lang::XMultiServiceFactory
,::com::sun::star::container::XNameAccess
>
113 //-------------------------------------------------------------------------------------------------------------
115 //-------------------------------------------------------------------------------------------------------------
119 //---------------------------------------------------------------------------------------------------------
120 // constructor / destructor
121 //---------------------------------------------------------------------------------------------------------
123 /*-****************************************************************************************************//**
124 @short standard constructor
125 @descr Initialize a new instance and fill the registrycache with values.
126 To do this - xFactory must be valid!
128 @seealso class RegistryCache
129 @seealso member m_aRegistryCache
131 @param "xFactory", factory which has created us.
134 @onerror An ASSERTION is thrown in debug version, if xFactory is invalid or cache can't filled.
135 *//*-*****************************************************************************************************/
137 FrameLoaderFactory( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
139 /*-****************************************************************************************************//**
140 @short standard destructor to delete instance
141 @descr We use it to clear ouer cache.
143 @seealso class RegistryCache
149 *//*-*****************************************************************************************************/
151 virtual ~FrameLoaderFactory();
153 //---------------------------------------------------------------------------------------------------------
154 // XInterface, XTypeProvider, XServiceInfo
155 //---------------------------------------------------------------------------------------------------------
159 //---------------------------------------------------------------------------------------------------------
160 // XMultiServiceFactory
161 //---------------------------------------------------------------------------------------------------------
163 /*-****************************************************************************************************//**
164 @short create a new frameloder (without arguments!)
165 @descr We search for an agreement between given type name and our cache-content.
166 If we found some information, we create the registered frameloader for these type.
167 Otherwise - we return NULL.
168 We search from begin to end of internal loader list!
170 @seealso method impl_createFrameLoader()
171 @seealso method createInstanceWithArguments()
173 @param "sTypeName", type name of a document to filter, open or save.
174 @return A reference to a new created frameloader.
176 @onerror A null reference is returned.
177 *//*-*****************************************************************************************************/
179 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstance( const ::rtl::OUString
& sTypeName
) throw( css::uno::Exception
,
180 css::uno::RuntimeException
);
182 /*-****************************************************************************************************//**
183 @short create a new frameloder
184 @descr We search for an agreement between given type name and our cache-content.
185 If we found some information, we create the registered frameloader for these type.
186 Otherwise - we return NULL.
187 You can give us some optional arguments to influence our search!
189 @seealso method impl_createFrameLoader()
190 @seealso method createInstance()
192 @param "sTypeName", type name of a document to filter, open or save.
193 @param "seqArguments", list of optional arguments for initializing of new frameloader.
194 @return A reference to a new created frameloader.
196 @onerror A null reference is returned.
197 *//*-*****************************************************************************************************/
199 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstanceWithArguments( const ::rtl::OUString
& sTypeName
,
200 const css::uno::Sequence
< css::uno::Any
>& seqArguments
) throw( css::uno::Exception
,
201 css::uno::RuntimeException
);
203 /*-****************************************************************************************************//**
205 @descr Please use XNameAcces instead of these!
213 *//*-*****************************************************************************************************/
215 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getAvailableServiceNames() throw( css::uno::RuntimeException
);
217 //---------------------------------------------------------------------------------------------------------
219 //---------------------------------------------------------------------------------------------------------
221 /*-****************************************************************************************************//**
222 @short return properties of registered frame loader specified by his implementation name
223 @descr Use these method to get all informations about our internal loader cache
224 and a special frame loader.
225 We return a Sequence< PropertyValue > in an Any packed as result.
227 structure of return value:
229 [0].Value = list of supported types of these loader as [sequence< oustring >]
232 [1].Value = localized name of loader as [string]
234 @seealso method getElementNames()
235 @seealso method hasByName()
237 @param "sName", the name of searched frame loader (use getElementNames() to get it!)
238 @return A Sequence< PropertyValue > packed in an Any.
240 @onerror If given name not exist a NoSuchElementException is thrown.
241 *//*-*****************************************************************************************************/
243 virtual css::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& sName
) throw( css::container::NoSuchElementException
,
244 css::lang::WrappedTargetException
,
245 css::uno::RuntimeException
);
247 /*-****************************************************************************************************//**
248 @short return list of all well known loader names from configuration
249 @descr Use these method to get all names of well known loader.
250 You can use it to get the properties of a loader by calling getByName()!
252 @seealso method getByName()
253 @seealso method hasByName()
256 @return A list of well known loader. Is static at runtime!
258 @onerror No error should occure.
259 *//*-*****************************************************************************************************/
261 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames() throw( css::uno::RuntimeException
);
263 /*-****************************************************************************************************//**
264 @short check if searched frame loader exist in configuration
265 @descr Normaly nobody need these method realy (use getElementNames() in combination with getByName()).
266 We guarantee correctness of these mechanism. There is no reason to check for existing elements then ...
267 but if you have an unknwon name and has no fun to search it in returned sequence ...
268 you can call these ...
270 @seealso method getByName()
271 @seealso method getElementNames()
273 @param "sName", implementation name of searched frame loader
274 @return sal_True if loader exist, sal_False otherwise.
276 @onerror No error should occure.
277 *//*-*****************************************************************************************************/
279 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& sName
) throw( css::uno::RuntimeException
);
281 //---------------------------------------------------------------------------------------------------------
283 //---------------------------------------------------------------------------------------------------------
285 /*-****************************************************************************************************//**
286 @short return the type of retrun value of method XNameAccess::getByName()
287 @descr In these implementation its a Sequence< PropertyValue > everytime!
289 @seealso description of interface XNameAccess
292 @return Type of Sequence< PropertyValue >.
294 @onerror No error should occure.
295 *//*-*****************************************************************************************************/
297 virtual css::uno::Type SAL_CALL
getElementType() throw( css::uno::RuntimeException
);
299 /*-****************************************************************************************************//**
300 @short return state if informations about frame loader available
301 @descr If these method return false - no information could'nt read from configuration ...
302 I think nothing will work then. Normaly we return TRUE!
304 @seealso class FilterCache!
307 @return sal_True if information available, sal_False otherwise.
309 @onerror No error should occure.
310 *//*-*****************************************************************************************************/
312 virtual sal_Bool SAL_CALL
hasElements() throw( css::uno::RuntimeException
);
314 //-------------------------------------------------------------------------------------------------------------
316 //-------------------------------------------------------------------------------------------------------------
320 //-------------------------------------------------------------------------------------------------------------
322 //-------------------------------------------------------------------------------------------------------------
326 /*-****************************************************************************************************//**
327 @short try to set configuration properties at created loader
328 @descr We support the old async. loader interface ( XFrameLoader ) and the new one XSynchronousFrameLoader.
329 The new one should implement a property set on which we can set his configuration values!
330 We try to cast given loader to these interface - if it's exist we set the values - otherwise not!
332 @seealso service FrameLoader
333 @seealso service SynchronousFrameLoader
335 @param "xLoader" loader with generic XInterface! (We don't know before which service type is used!)
336 @param "pLoaderInfo" configuration structure of these loader.
339 @onerror No error should occure.
340 *//*-*****************************************************************************************************/
342 void impl_initializeLoader( css::uno::Reference
< css::uno::XInterface
>& xLoader
, const Loader
& pLoaderInfo
);
344 //-------------------------------------------------------------------------------------------------------------
346 // (should be private everyway!)
347 //-------------------------------------------------------------------------------------------------------------
349 /*-****************************************************************************************************//**
350 @short debug-method to check incoming parameter of some other mehods of this class
351 @descr The following methods are used to check parameters for other methods
352 of this class. The return value is used directly for an ASSERT(...).
354 @seealso ASSERTs in implementation!
356 @param references to checking variables
357 @return sal_False ,on invalid parameter
358 @return sal_True ,otherwise
361 *//*-*****************************************************************************************************/
364 #ifdef ENABLE_ASSERTIONS
368 static sal_Bool
impldbg_checkParameter_FrameLoaderFactory ( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
369 static sal_Bool
impldbg_checkParameter_createInstance ( const ::rtl::OUString
& sTypeName
);
370 static sal_Bool
impldbg_checkParameter_createInstanceWithArguments ( const ::rtl::OUString
& sTypeName
,
371 const css::uno::Sequence
< css::uno::Any
>& seqArguments
);
372 static sal_Bool
impldbg_checkParameter_getByName ( const ::rtl::OUString
& sName
);
373 static sal_Bool
impldbg_checkParameter_hasByName ( const ::rtl::OUString
& sName
);
375 #endif // #ifdef ENABLE_ASSERTIONS
377 //-------------------------------------------------------------------------------------------------------------
379 // (should be private everyway!)
380 //-------------------------------------------------------------------------------------------------------------
384 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xFactory
;
385 FilterCache m_aCache
;
387 }; // class FrameLoaderFactory
389 } // namespace framework
391 #endif // #ifndef __FRAMEWORK_SERVICES_FRAMELOADERFACTORY_HXX_