xref: /trunk/main/framework/inc/services/contenthandlerfactory.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __FRAMEWORK_SERVICES_CONTENTHANDLERFACTORY_HXX_
25 #define __FRAMEWORK_SERVICES_CONTENTHANDLERFACTORY_HXX_
26 
27 //_________________________________________________________________________________________________________________
28 //  my own includes
29 //_________________________________________________________________________________________________________________
30 
31 #include <classes/filtercache.hxx>
32 #include <macros/generic.hxx>
33 #include <macros/debug.hxx>
34 #include <macros/xinterface.hxx>
35 #include <macros/xtypeprovider.hxx>
36 #include <macros/xserviceinfo.hxx>
37 #include <threadhelp/threadhelpbase.hxx>
38 
39 #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_
40 #include <threadhelp/transactionbase.hxx>
41 #endif
42 #include <general.h>
43 
44 //_________________________________________________________________________________________________________________
45 //  interface includes
46 //_________________________________________________________________________________________________________________
47 #include <com/sun/star/beans/PropertyValue.hpp>
48 #include <com/sun/star/lang/XInitialization.hpp>
49 #include <com/sun/star/lang/WrappedTargetException.hpp>
50 #include <com/sun/star/lang/IllegalArgumentException.hpp>
51 #include <com/sun/star/container/ElementExistException.hpp>
52 #include <com/sun/star/container/NoSuchElementException.hpp>
53 #include <com/sun/star/container/XNameContainer.hpp>
54 #include <com/sun/star/container/NoSuchElementException.hpp>
55 #include <com/sun/star/io/XInputStream.hpp>
56 #include <com/sun/star/util/XFlushable.hpp>
57 
58 //_________________________________________________________________________________________________________________
59 //  other includes
60 //_________________________________________________________________________________________________________________
61 #include <cppuhelper/interfacecontainer.hxx>
62 #include <cppuhelper/weak.hxx>
63 
64 //_________________________________________________________________________________________________________________
65 //  namespace
66 //_________________________________________________________________________________________________________________
67 
68 namespace framework{
69 
70 //_________________________________________________________________________________________________________________
71 //  exported const
72 //_________________________________________________________________________________________________________________
73 
74 //_________________________________________________________________________________________________________________
75 //  exported definitions
76 //_________________________________________________________________________________________________________________
77 
78 /*-************************************************************************************************************//**
79     @short      factory to create handler-objects
80     @descr      These class can be used to create new handler for specified contents.
81                 We use cached values of our configuration to lay down, which handler match
82                 a given URL or handlername. (use service TypeDetection to do that)
83                 With a detected type name you can search a registered handler and create it with these factory.
84 
85     @implements XInterface
86                 XTypeProvider
87                 XServiceInfo
88                 XMultiServiceFactory
89                 XNameContainer
90                 XNameReplace
91                 XNameAccess
92                 XElementAccess
93                 XFlushable
94 
95     @base       ThreadHelpBase
96                 OWeakObject
97 
98     @devstatus  ready to use
99     @threadsafe yes
100 *//*-*************************************************************************************************************/
101 
102 class ContentHandlerFactory :   // interfaces
103                         public  css::lang::XTypeProvider            ,
104                         public  css::lang::XServiceInfo             ,
105                         public  css::lang::XMultiServiceFactory     ,
106                         public  css::container::XNameContainer      ,       // => XNameReplace => XNameAccess => XElementAccess
107                         public  css::util::XFlushable               ,
108                         // base classes
109                         // Order is necessary for right initialization of it!
110                         private ThreadHelpBase                      ,
111                         private TransactionBase                     ,
112                         public  ::cppu::OWeakObject
113 {
114     //-------------------------------------------------------------------------------------------------------------
115     //  public methods
116     //-------------------------------------------------------------------------------------------------------------
117 
118     public:
119 
120         //---------------------------------------------------------------------------------------------------------
121         //  constructor / destructor
122         //---------------------------------------------------------------------------------------------------------
123                  ContentHandlerFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
124         virtual ~ContentHandlerFactory(                                                                        );
125 
126         //---------------------------------------------------------------------------------------------------------
127         //  XInterface, XTypeProvider, XServiceInfo
128         //---------------------------------------------------------------------------------------------------------
129         DECLARE_XINTERFACE
130         DECLARE_XTYPEPROVIDER
131         DECLARE_XSERVICEINFO
132 
133         //---------------------------------------------------------------------------------------------------------
134         //  XMultiServiceFactory
135         //---------------------------------------------------------------------------------------------------------
136         virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance             ( const ::rtl::OUString&                        sTypeName   );
137         virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString&                        sTypeName   ,
138                                                                                                   const css::uno::Sequence< css::uno::Any >&    lArguments  );
139         virtual css::uno::Sequence< ::rtl::OUString >       SAL_CALL getAvailableServiceNames   (                                                           );
140 
141         //---------------------------------------------------------------------------------------------------------
142         //  XNameContainer
143         //---------------------------------------------------------------------------------------------------------
144         virtual void SAL_CALL insertByName( const ::rtl::OUString&  sHandlerName        ,
145                                             const css::uno::Any&    aHandlerProperties  );
146         virtual void SAL_CALL removeByName( const ::rtl::OUString&  sHandlerName        );
147 
148         //---------------------------------------------------------------------------------------------------------
149         //  XNameReplace
150         //---------------------------------------------------------------------------------------------------------
151         virtual void SAL_CALL replaceByName( const ::rtl::OUString& sHandlerName       ,
152                                              const css::uno::Any&   aHandlerProperties );
153 
154         //---------------------------------------------------------------------------------------------------------
155         //  XNameAccess
156         //---------------------------------------------------------------------------------------------------------
157         virtual css::uno::Any                         SAL_CALL getByName      ( const ::rtl::OUString& sName );
158         virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(                              );
159         virtual sal_Bool                              SAL_CALL hasByName      ( const ::rtl::OUString& sName );
160 
161         //---------------------------------------------------------------------------------------------------------
162         //  XElementAccess
163         //---------------------------------------------------------------------------------------------------------
164         virtual css::uno::Type SAL_CALL getElementType();
165         virtual sal_Bool       SAL_CALL hasElements   ();
166 
167         //---------------------------------------------------------------------------------------------------------
168         //  XFlushable
169         //---------------------------------------------------------------------------------------------------------
170         virtual void SAL_CALL flush              (                                                                   );
171         virtual void SAL_CALL addFlushListener   ( const css::uno::Reference< css::util::XFlushListener >& xListener );
172         virtual void SAL_CALL removeFlushListener( const css::uno::Reference< css::util::XFlushListener >& xListener );
173 
174     //-------------------------------------------------------------------------------------------------------------
175     //  protected methods
176     //-------------------------------------------------------------------------------------------------------------
177 
178     protected:
179 
180     //-------------------------------------------------------------------------------------------------------------
181     //  debug methods
182     //  (should be private everyway!)
183     //-------------------------------------------------------------------------------------------------------------
184 
185         /*-****************************************************************************************************//**
186             @short      debug-method to check incoming parameter of some other methods of this class
187             @descr      The following methods are used to check parameters for other methods
188                         of this class. The return value is used directly for an ASSERT(...).
189 
190             @seealso    ASSERTs in implementation!
191 
192             @param      references to checking variables
193             @return     sal_False ,on invalid parameter
194             @return     sal_True  ,otherwise
195 
196             @onerror    -
197         *//*-*****************************************************************************************************/
198 
199     #ifdef ENABLE_ASSERTIONS
200 
201     private:
202 
203         static sal_Bool implcp_ContentHandlerFactory        (   const   css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory            );
204         static sal_Bool implcp_createInstanceWithArguments  (   const   ::rtl::OUString&                                        sTypeName           ,
205                                                                 const   css::uno::Sequence< css::uno::Any >&                    lArguments          );
206         static sal_Bool implcp_getByName                    (   const   ::rtl::OUString&                                        sName               );
207         static sal_Bool implcp_hasByName                    (   const   ::rtl::OUString&                                        sName               );
208         static sal_Bool implcp_removeByName                 (   const   ::rtl::OUString&                                        sHandlerName        );
209 
210     #endif  //  #ifdef ENABLE_ASSERTIONS
211 
212     //-------------------------------------------------------------------------------------------------------------
213     //  private variables
214     //  (should be private everyway!)
215     //-------------------------------------------------------------------------------------------------------------
216 
217     private:
218 
219         css::uno::Reference< css::lang::XMultiServiceFactory >      m_xFactory              ;
220         FilterCache                                                 m_aCache                ;
221 //      ::cppu::OMultiTypeInterfaceContainerHelper                  m_aListenerContainer    ;
222 
223 };      //  class ContentHandlerFactory
224 
225 }       //  namespace framework
226 
227 #endif  //  #ifndef __FRAMEWORK_SERVICES_CONTENTHANDLERFACTORY_HXX_
228