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: contenthandlerfactory.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_CONTENTHANDLERFACTORY_HXX_
32 #define __FRAMEWORK_SERVICES_CONTENTHANDLERFACTORY_HXX_
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #include <classes/filtercache.hxx>
39 #include <macros/generic.hxx>
40 #include <macros/debug.hxx>
41 #include <macros/xinterface.hxx>
42 #include <macros/xtypeprovider.hxx>
43 #include <macros/xserviceinfo.hxx>
44 #include <threadhelp/threadhelpbase.hxx>
46 #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_
47 #include <threadhelp/transactionbase.hxx>
51 //_________________________________________________________________________________________________________________
53 //_________________________________________________________________________________________________________________
54 #include <com/sun/star/beans/PropertyValue.hpp>
55 #include <com/sun/star/lang/XInitialization.hpp>
56 #include <com/sun/star/lang/WrappedTargetException.hpp>
57 #include <com/sun/star/lang/IllegalArgumentException.hpp>
58 #include <com/sun/star/container/ElementExistException.hpp>
59 #include <com/sun/star/container/NoSuchElementException.hpp>
60 #include <com/sun/star/container/XNameContainer.hpp>
61 #include <com/sun/star/container/NoSuchElementException.hpp>
62 #include <com/sun/star/io/XInputStream.hpp>
63 #include <com/sun/star/util/XFlushable.hpp>
65 //_________________________________________________________________________________________________________________
67 //_________________________________________________________________________________________________________________
68 #include <cppuhelper/interfacecontainer.hxx>
69 #include <cppuhelper/weak.hxx>
71 //_________________________________________________________________________________________________________________
73 //_________________________________________________________________________________________________________________
77 //_________________________________________________________________________________________________________________
79 //_________________________________________________________________________________________________________________
81 //_________________________________________________________________________________________________________________
82 // exported definitions
83 //_________________________________________________________________________________________________________________
85 /*-************************************************************************************************************//**
86 @short factory to create handler-objects
87 @descr These class can be used to create new handler for specified contents.
88 We use cached values of our configuration to lay down, which handler match
89 a given URL or handlername. (use service TypeDetection to do that)
90 With a detected type name you can search a registered handler and create it with these factory.
92 @implements XInterface
105 @devstatus ready to use
107 *//*-*************************************************************************************************************/
109 class ContentHandlerFactory
: // interfaces
110 public css::lang::XTypeProvider
,
111 public css::lang::XServiceInfo
,
112 public css::lang::XMultiServiceFactory
,
113 public css::container::XNameContainer
, // => XNameReplace => XNameAccess => XElementAccess
114 public css::util::XFlushable
,
116 // Order is neccessary for right initialization of it!
117 private ThreadHelpBase
,
118 private TransactionBase
,
119 public ::cppu::OWeakObject
121 //-------------------------------------------------------------------------------------------------------------
123 //-------------------------------------------------------------------------------------------------------------
127 //---------------------------------------------------------------------------------------------------------
128 // constructor / destructor
129 //---------------------------------------------------------------------------------------------------------
130 ContentHandlerFactory( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
131 virtual ~ContentHandlerFactory( );
133 //---------------------------------------------------------------------------------------------------------
134 // XInterface, XTypeProvider, XServiceInfo
135 //---------------------------------------------------------------------------------------------------------
137 DECLARE_XTYPEPROVIDER
140 //---------------------------------------------------------------------------------------------------------
141 // XMultiServiceFactory
142 //---------------------------------------------------------------------------------------------------------
143 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstance ( const ::rtl::OUString
& sTypeName
) throw( css::uno::Exception
,
144 css::uno::RuntimeException
);
145 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstanceWithArguments( const ::rtl::OUString
& sTypeName
,
146 const css::uno::Sequence
< css::uno::Any
>& lArguments
) throw( css::uno::Exception
, css::uno::RuntimeException
);
147 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getAvailableServiceNames ( ) throw( css::uno::RuntimeException
);
149 //---------------------------------------------------------------------------------------------------------
151 //---------------------------------------------------------------------------------------------------------
152 virtual void SAL_CALL
insertByName( const ::rtl::OUString
& sHandlerName
,
153 const css::uno::Any
& aHandlerProperties
) throw( css::lang::IllegalArgumentException
,
154 css::container::ElementExistException
,
155 css::lang::WrappedTargetException
,
156 css::uno::RuntimeException
);
157 virtual void SAL_CALL
removeByName( const ::rtl::OUString
& sHandlerName
) throw( css::container::NoSuchElementException
,
158 css::lang::WrappedTargetException
,
159 css::uno::RuntimeException
);
161 //---------------------------------------------------------------------------------------------------------
163 //---------------------------------------------------------------------------------------------------------
164 virtual void SAL_CALL
replaceByName( const ::rtl::OUString
& sHandlerName
,
165 const css::uno::Any
& aHandlerProperties
) throw( css::lang::IllegalArgumentException
,
166 css::container::NoSuchElementException
,
167 css::lang::WrappedTargetException
,
168 css::uno::RuntimeException
);
170 //---------------------------------------------------------------------------------------------------------
172 //---------------------------------------------------------------------------------------------------------
173 virtual css::uno::Any SAL_CALL
getByName ( const ::rtl::OUString
& sName
) throw( css::container::NoSuchElementException
,
174 css::lang::WrappedTargetException
,
175 css::uno::RuntimeException
);
176 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames( ) throw( css::uno::RuntimeException
);
177 virtual sal_Bool SAL_CALL
hasByName ( const ::rtl::OUString
& sName
) throw( css::uno::RuntimeException
);
179 //---------------------------------------------------------------------------------------------------------
181 //---------------------------------------------------------------------------------------------------------
182 virtual css::uno::Type SAL_CALL
getElementType() throw( css::uno::RuntimeException
);
183 virtual sal_Bool SAL_CALL
hasElements () throw( css::uno::RuntimeException
);
185 //---------------------------------------------------------------------------------------------------------
187 //---------------------------------------------------------------------------------------------------------
188 virtual void SAL_CALL
flush ( ) throw ( css::uno::RuntimeException
);
189 virtual void SAL_CALL
addFlushListener ( const css::uno::Reference
< css::util::XFlushListener
>& xListener
) throw ( css::uno::RuntimeException
);
190 virtual void SAL_CALL
removeFlushListener( const css::uno::Reference
< css::util::XFlushListener
>& xListener
) throw ( css::uno::RuntimeException
);
192 //-------------------------------------------------------------------------------------------------------------
194 //-------------------------------------------------------------------------------------------------------------
198 //-------------------------------------------------------------------------------------------------------------
200 // (should be private everyway!)
201 //-------------------------------------------------------------------------------------------------------------
203 /*-****************************************************************************************************//**
204 @short debug-method to check incoming parameter of some other mehods of this class
205 @descr The following methods are used to check parameters for other methods
206 of this class. The return value is used directly for an ASSERT(...).
208 @seealso ASSERTs in implementation!
210 @param references to checking variables
211 @return sal_False ,on invalid parameter
212 @return sal_True ,otherwise
215 *//*-*****************************************************************************************************/
217 #ifdef ENABLE_ASSERTIONS
221 static sal_Bool
implcp_ContentHandlerFactory ( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
222 static sal_Bool
implcp_createInstanceWithArguments ( const ::rtl::OUString
& sTypeName
,
223 const css::uno::Sequence
< css::uno::Any
>& lArguments
);
224 static sal_Bool
implcp_getByName ( const ::rtl::OUString
& sName
);
225 static sal_Bool
implcp_hasByName ( const ::rtl::OUString
& sName
);
226 static sal_Bool
implcp_removeByName ( const ::rtl::OUString
& sHandlerName
);
228 #endif // #ifdef ENABLE_ASSERTIONS
230 //-------------------------------------------------------------------------------------------------------------
232 // (should be private everyway!)
233 //-------------------------------------------------------------------------------------------------------------
237 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xFactory
;
238 FilterCache m_aCache
;
239 // ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer ;
241 }; // class ContentHandlerFactory
243 } // namespace framework
245 #endif // #ifndef __FRAMEWORK_SERVICES_CONTENTHANDLERFACTORY_HXX_