1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef __FRAMEWORK_SERVICES_CONTENTHANDLERFACTORY_HXX_
29*cdf0e10cSrcweir #define __FRAMEWORK_SERVICES_CONTENTHANDLERFACTORY_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32*cdf0e10cSrcweir //	my own includes
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <classes/filtercache.hxx>
36*cdf0e10cSrcweir #include <macros/generic.hxx>
37*cdf0e10cSrcweir #include <macros/debug.hxx>
38*cdf0e10cSrcweir #include <macros/xinterface.hxx>
39*cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
40*cdf0e10cSrcweir #include <macros/xserviceinfo.hxx>
41*cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_
44*cdf0e10cSrcweir #include <threadhelp/transactionbase.hxx>
45*cdf0e10cSrcweir #endif
46*cdf0e10cSrcweir #include <general.h>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49*cdf0e10cSrcweir //	interface includes
50*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
51*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/lang/WrappedTargetException.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/container/ElementExistException.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/container/NoSuchElementException.hpp>
57*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
58*cdf0e10cSrcweir #include <com/sun/star/container/NoSuchElementException.hpp>
59*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
60*cdf0e10cSrcweir #include <com/sun/star/util/XFlushable.hpp>
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63*cdf0e10cSrcweir //	other includes
64*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
65*cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx>
66*cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
69*cdf0e10cSrcweir //	namespace
70*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir namespace framework{
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
75*cdf0e10cSrcweir //	exported const
76*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
79*cdf0e10cSrcweir //	exported definitions
80*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir /*-************************************************************************************************************//**
83*cdf0e10cSrcweir     @short      factory to create handler-objects
84*cdf0e10cSrcweir     @descr      These class can be used to create new handler for specified contents.
85*cdf0e10cSrcweir                 We use cached values of our configuration to lay down, which handler match
86*cdf0e10cSrcweir                 a given URL or handlername. (use service TypeDetection to do that)
87*cdf0e10cSrcweir                 With a detected type name you can search a registered handler and create it with these factory.
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	@implements	XInterface
90*cdf0e10cSrcweir 				XTypeProvider
91*cdf0e10cSrcweir 				XServiceInfo
92*cdf0e10cSrcweir 				XMultiServiceFactory
93*cdf0e10cSrcweir 				XNameContainer
94*cdf0e10cSrcweir 				XNameReplace
95*cdf0e10cSrcweir 				XNameAccess
96*cdf0e10cSrcweir 				XElementAccess
97*cdf0e10cSrcweir 				XFlushable
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     @base       ThreadHelpBase
100*cdf0e10cSrcweir 				OWeakObject
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	@devstatus	ready to use
103*cdf0e10cSrcweir 	@threadsafe	yes
104*cdf0e10cSrcweir *//*-*************************************************************************************************************/
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir class ContentHandlerFactory :   // interfaces
107*cdf0e10cSrcweir 						public	css::lang::XTypeProvider			,
108*cdf0e10cSrcweir 						public	css::lang::XServiceInfo				,
109*cdf0e10cSrcweir 						public	css::lang::XMultiServiceFactory		,
110*cdf0e10cSrcweir 						public	css::container::XNameContainer		,		// => XNameReplace => XNameAccess => XElementAccess
111*cdf0e10cSrcweir 						public	css::util::XFlushable				,
112*cdf0e10cSrcweir 						// base classes
113*cdf0e10cSrcweir 						// Order is neccessary for right initialization of it!
114*cdf0e10cSrcweir                         private ThreadHelpBase                      ,
115*cdf0e10cSrcweir                         private TransactionBase                     ,
116*cdf0e10cSrcweir 						public	::cppu::OWeakObject
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
119*cdf0e10cSrcweir 	//	public methods
120*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	public:
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
125*cdf0e10cSrcweir 		//	constructor / destructor
126*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
127*cdf0e10cSrcweir                  ContentHandlerFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
128*cdf0e10cSrcweir         virtual ~ContentHandlerFactory(                                                                        );
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
131*cdf0e10cSrcweir 		//	XInterface, XTypeProvider, XServiceInfo
132*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
133*cdf0e10cSrcweir 		DECLARE_XINTERFACE
134*cdf0e10cSrcweir 		DECLARE_XTYPEPROVIDER
135*cdf0e10cSrcweir 		DECLARE_XSERVICEINFO
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
138*cdf0e10cSrcweir 		//	XMultiServiceFactory
139*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
140*cdf0e10cSrcweir         virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance             ( const ::rtl::OUString&                        sTypeName   ) throw( css::uno::Exception        ,
141*cdf0e10cSrcweir                                                                                                                                                                      css::uno::RuntimeException );
142*cdf0e10cSrcweir         virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString&                        sTypeName   ,
143*cdf0e10cSrcweir                                                                                                   const css::uno::Sequence< css::uno::Any >&    lArguments  ) throw( css::uno::Exception, css::uno::RuntimeException );
144*cdf0e10cSrcweir         virtual css::uno::Sequence< ::rtl::OUString >       SAL_CALL getAvailableServiceNames   (                                                           ) throw( css::uno::RuntimeException );
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
147*cdf0e10cSrcweir 		//	XNameContainer
148*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
149*cdf0e10cSrcweir         virtual void SAL_CALL insertByName( const ::rtl::OUString&  sHandlerName        ,
150*cdf0e10cSrcweir                                             const css::uno::Any&    aHandlerProperties  ) throw( css::lang::IllegalArgumentException     ,
151*cdf0e10cSrcweir                                                                                                  css::container::ElementExistException   ,
152*cdf0e10cSrcweir                                                                                                  css::lang::WrappedTargetException       ,
153*cdf0e10cSrcweir                                                                                                  css::uno::RuntimeException              );
154*cdf0e10cSrcweir         virtual void SAL_CALL removeByName( const ::rtl::OUString&  sHandlerName        ) throw( css::container::NoSuchElementException  ,
155*cdf0e10cSrcweir                                                                                                  css::lang::WrappedTargetException       ,
156*cdf0e10cSrcweir                                                                                                  css::uno::RuntimeException              );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
159*cdf0e10cSrcweir 		//	XNameReplace
160*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
161*cdf0e10cSrcweir         virtual void SAL_CALL replaceByName( const ::rtl::OUString& sHandlerName       ,
162*cdf0e10cSrcweir                                              const css::uno::Any&   aHandlerProperties ) throw( css::lang::IllegalArgumentException    ,
163*cdf0e10cSrcweir                                                                                                 css::container::NoSuchElementException ,
164*cdf0e10cSrcweir                                                                                                 css::lang::WrappedTargetException      ,
165*cdf0e10cSrcweir                                                                                                 css::uno::RuntimeException             );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
168*cdf0e10cSrcweir 		//	XNameAccess
169*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
170*cdf0e10cSrcweir         virtual css::uno::Any                         SAL_CALL getByName      ( const ::rtl::OUString& sName ) throw( css::container::NoSuchElementException ,
171*cdf0e10cSrcweir                                                                                                                       css::lang::WrappedTargetException      ,
172*cdf0e10cSrcweir                                                                                                                       css::uno::RuntimeException             );
173*cdf0e10cSrcweir         virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(                              ) throw( css::uno::RuntimeException             );
174*cdf0e10cSrcweir         virtual sal_Bool                              SAL_CALL hasByName      ( const ::rtl::OUString& sName ) throw( css::uno::RuntimeException             );
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
177*cdf0e10cSrcweir 		//	XElementAccess
178*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
179*cdf0e10cSrcweir         virtual css::uno::Type SAL_CALL getElementType() throw( css::uno::RuntimeException );
180*cdf0e10cSrcweir         virtual sal_Bool       SAL_CALL hasElements   () throw( css::uno::RuntimeException );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
183*cdf0e10cSrcweir 		//	XFlushable
184*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
185*cdf0e10cSrcweir         virtual void SAL_CALL flush              (                                                                   ) throw ( css::uno::RuntimeException );
186*cdf0e10cSrcweir         virtual void SAL_CALL addFlushListener   ( const css::uno::Reference< css::util::XFlushListener >& xListener ) throw ( css::uno::RuntimeException );
187*cdf0e10cSrcweir     	virtual void SAL_CALL removeFlushListener( const css::uno::Reference< css::util::XFlushListener >& xListener ) throw ( css::uno::RuntimeException );
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
190*cdf0e10cSrcweir 	//	protected methods
191*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	protected:
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
196*cdf0e10cSrcweir 	//	debug methods
197*cdf0e10cSrcweir 	//	(should be private everyway!)
198*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
201*cdf0e10cSrcweir 			@short		debug-method to check incoming parameter of some other mehods of this class
202*cdf0e10cSrcweir 			@descr		The following methods are used to check parameters for other methods
203*cdf0e10cSrcweir 						of this class. The return value is used directly for an ASSERT(...).
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 			@seealso	ASSERTs in implementation!
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 			@param		references to checking variables
208*cdf0e10cSrcweir 			@return		sal_False ,on invalid parameter
209*cdf0e10cSrcweir 			@return		sal_True  ,otherwise
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 			@onerror	-
212*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 	#ifdef ENABLE_ASSERTIONS
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 	private:
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir         static sal_Bool implcp_ContentHandlerFactory        (   const   css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory            );
219*cdf0e10cSrcweir     	static sal_Bool implcp_createInstanceWithArguments	(	const	::rtl::OUString&										sTypeName			,
220*cdf0e10cSrcweir 							  									const	css::uno::Sequence< css::uno::Any >&					lArguments			);
221*cdf0e10cSrcweir     	static sal_Bool implcp_getByName					(	const	::rtl::OUString&										sName				);
222*cdf0e10cSrcweir     	static sal_Bool implcp_hasByName					(	const	::rtl::OUString&										sName				);
223*cdf0e10cSrcweir         static sal_Bool implcp_removeByName                 (   const   ::rtl::OUString&                                        sHandlerName        );
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 	#endif	//	#ifdef ENABLE_ASSERTIONS
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
228*cdf0e10cSrcweir 	//	private variables
229*cdf0e10cSrcweir 	//	(should be private everyway!)
230*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 	private:
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir 		css::uno::Reference< css::lang::XMultiServiceFactory >		m_xFactory				;
235*cdf0e10cSrcweir         FilterCache                                                 m_aCache                ;
236*cdf0e10cSrcweir //		::cppu::OMultiTypeInterfaceContainerHelper					m_aListenerContainer	;
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir };      //  class ContentHandlerFactory
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir }		//	namespace framework
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir #endif  //  #ifndef __FRAMEWORK_SERVICES_CONTENTHANDLERFACTORY_HXX_
243