merge the formfield patch from ooo-build
[ooovba.git] / framework / inc / services / contenthandlerfactory.hxx
blobfdf3c93c49e3fe07973aee5c0c0222e574d91d03
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: contenthandlerfactory.hxx,v $
10 * $Revision: 1.4 $
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 //_________________________________________________________________________________________________________________
35 // my own includes
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>
48 #endif
49 #include <general.h>
51 //_________________________________________________________________________________________________________________
52 // interface includes
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 //_________________________________________________________________________________________________________________
66 // other includes
67 //_________________________________________________________________________________________________________________
68 #include <cppuhelper/interfacecontainer.hxx>
69 #include <cppuhelper/weak.hxx>
71 //_________________________________________________________________________________________________________________
72 // namespace
73 //_________________________________________________________________________________________________________________
75 namespace framework{
77 //_________________________________________________________________________________________________________________
78 // exported const
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
93 XTypeProvider
94 XServiceInfo
95 XMultiServiceFactory
96 XNameContainer
97 XNameReplace
98 XNameAccess
99 XElementAccess
100 XFlushable
102 @base ThreadHelpBase
103 OWeakObject
105 @devstatus ready to use
106 @threadsafe yes
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 ,
115 // base classes
116 // Order is neccessary for right initialization of it!
117 private ThreadHelpBase ,
118 private TransactionBase ,
119 public ::cppu::OWeakObject
121 //-------------------------------------------------------------------------------------------------------------
122 // public methods
123 //-------------------------------------------------------------------------------------------------------------
125 public:
127 //---------------------------------------------------------------------------------------------------------
128 // constructor / destructor
129 //---------------------------------------------------------------------------------------------------------
130 ContentHandlerFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
131 virtual ~ContentHandlerFactory( );
133 //---------------------------------------------------------------------------------------------------------
134 // XInterface, XTypeProvider, XServiceInfo
135 //---------------------------------------------------------------------------------------------------------
136 DECLARE_XINTERFACE
137 DECLARE_XTYPEPROVIDER
138 DECLARE_XSERVICEINFO
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 //---------------------------------------------------------------------------------------------------------
150 // XNameContainer
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 //---------------------------------------------------------------------------------------------------------
162 // XNameReplace
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 //---------------------------------------------------------------------------------------------------------
171 // XNameAccess
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 //---------------------------------------------------------------------------------------------------------
180 // XElementAccess
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 //---------------------------------------------------------------------------------------------------------
186 // XFlushable
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 //-------------------------------------------------------------------------------------------------------------
193 // protected methods
194 //-------------------------------------------------------------------------------------------------------------
196 protected:
198 //-------------------------------------------------------------------------------------------------------------
199 // debug methods
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
214 @onerror -
215 *//*-*****************************************************************************************************/
217 #ifdef ENABLE_ASSERTIONS
219 private:
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 //-------------------------------------------------------------------------------------------------------------
231 // private variables
232 // (should be private everyway!)
233 //-------------------------------------------------------------------------------------------------------------
235 private:
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_