1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: detectorfactory.hxx,v $
* $Revision: 1.4 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef __FRAMEWORK_SERVICES_DETECTORFACTORY_HXX_
#define __FRAMEWORK_SERVICES_DETECTORFACTORY_HXX_
//_______________________________________________
// includes of own project
#include <classes/filtercache.hxx>
#include <threadhelp/threadhelpbase.hxx>
#include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx>
#include <macros/xserviceinfo.hxx>
#include <macros/generic.hxx>
#include <macros/debug.hxx>
#include <general.h>
//_______________________________________________
// includes of interfaces
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/WrappedTargetException.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/container/ElementExistException.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/util/XFlushable.hpp>
//_______________________________________________
// includes of other projects
#include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/weak.hxx>
//_______________________________________________
// namespace
namespace framework{
//_______________________________________________
// exported const
//_______________________________________________
// exported definitions
/// @HTML
/** @short factory to create detect service objects and initialize it in the right way.
@descr This class can be used to create new detect services for specified contents.
It uses cached values of the configuration to lay down, which detector match
a given name. Further this class provides full access to the configuration data
of such detect services and following implementations will support some special
query modes.
@author as96863
@docdate 07.03.2003 by as96863
@todo <ul>
<li>implementation of query mode</li>
<li>simple restore mechanism of last consistent cache state,
if flush failed</li>
</ul>
*/
/// @NOHTML
class DetectorFactory : // interfaces
public css::lang::XTypeProvider ,
public css::lang::XServiceInfo ,
public css::lang::XMultiServiceFactory ,
public css::container::XNameContainer , // => XNameReplace => XNameAccess => XElementAccess
public css::util::XFlushable ,
// base classes
// Order is neccessary for right initialization of it!
private ThreadHelpBase ,
public ::cppu::OWeakObject
{
//-------------------------------------------
// member
private:
/** reference to the global uno service manager.
It will be used to create own needed services on demand. */
css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
/** singleton, which contains all needed configuration data and provides
read/write access on it. */
FilterCache m_aCache;
/** contains all registered listener. */
::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer;
//-------------------------------------------
// interface
public:
//---------------------------------------
// XInterface, XTypeProvider, XServiceInfo
DECLARE_XINTERFACE
DECLARE_XTYPEPROVIDER
DECLARE_XSERVICEINFO
#ifdef ENABLE_AUTODOC_FIX
;
#endif
//---------------------------------------
/** @short initialize new instance of this class.
@param xSMGR
reference to the global uno service manager, which created this new factory instance.
It must be used during runtime to create own needed services.
*/
DetectorFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
//---------------------------------------
/** @short release internal structures.
*/
virtual ~DetectorFactory();
//---------------------------------------
// XMultiServiceFactory
/** @short create a new detect service and initialize it with it's own configuration data.
@param sName
means the uno implementation name of a detect service.
@exception com::sun::star::uno::Exception
if the requested service could not be created or initialized.
*/
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& sName )
throw(css::uno::Exception ,
css::uno::RuntimeException);
//---------------------------------------
// XMultiServiceFactory
/** @short does the same as createInstance() method, but initialize created detect service with some
additional data.
@param sName
means the uno implementation name of a detect service.
@param lArguments
the optional arguments, which are passed to the created detect service against
it's own configuration data.
@exception com::sun::star::uno::Exception
if the requested service could not be created or initialized.
*/
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& sName ,
const css::uno::Sequence< css::uno::Any >& lArguments )
throw(css::uno::Exception ,
css::uno::RuntimeException);
//---------------------------------------
// XMultiServiceFactory
/** @short return list of all well know detect services, which can be created by this factory.
@attention Because this service implements read/write access to the configuration too,
this list is dynamic. Means: in multithreaded environments some items of this
return list could be invalid next time!
@return A list of all registered detect services.
*/
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames()
throw(css::uno::RuntimeException);
//---------------------------------------
// XNameContainer
/** @short add new detect service entry to this container.
@descr This will change all internal structures only!
Updating of the configuration layer and notify of all registered
listener will be done inside API call XFlushable::flush() on this
container.
@param sName
means the uno implementation name of this new detect service entry.
@param aPropertySet [sequence< com::sun::star::beans::PropertyValue >!]
describe this new entry. For a list of all supported properties
have a look on method >>getByName()<<.
Note: Missing values will be created with defaults!
@exception com::sun::star::lang::IllegalArgumentException
if one of the incoming parameters seams to be invalid.
That doesn't include the check, if this item already exist!
@exception com::sun::star::container::ElementExistException
if this item already exist inside this container.
@exception com::sun::star::lang::WrappedTargetException
f creation of the internal structures failed.
*/
virtual void SAL_CALL insertByName( const ::rtl::OUString& sName ,
const css::uno::Any& aPropertySet )
throw(css::lang::IllegalArgumentException ,
css::container::ElementExistException,
css::lang::WrappedTargetException ,
css::uno::RuntimeException );
//---------------------------------------
// XNameContainer
/** @short remove a detect service entry from this container.
@descr This will change all internal structures only!
Updating of the configuration layer and notify of all registered
listener will be done inside API call XFlushable::flush() on this
container.
@param sName
means the uno implementation name of a detect service entry.
@exception com::sun::star::container::NoSuchElementException
if the requested item does not exist inside this container.
@exception com::sun::star::lang::WrappedTargetException
if creation of the internal structures failed.
*/
virtual void SAL_CALL removeByName( const ::rtl::OUString& sName )
throw(css::container::NoSuchElementException,
css::lang::WrappedTargetException ,
css::uno::RuntimeException );
//---------------------------------------
// XNameReplace
/** @short change a detect service entry inside this container.
@descr This will change all internal structures only!
Updating of the configuration layer and notify of all registered
listener will be done inside API call XFlushable::flush() on this
container.
@param sName
means the uno implementation name of a detect service entry.
@param aPropertySet [sequence< com::sun::star::beans::PropertyValue >!]
describe the changes on this entry. For a list of all supported properties
have a look on method getByName().
Note: Missing properties will be untouched.
@exception com::sun::star::lang::IllegalArgumentException
if one of the incoming parameters seams to be invalid.
That doesn't include the check, if this item exist!
@exception com::sun::star::container::NoSuchElementException
if the requested item does not exist inside this container.
@exception com::sun::star::lang::WrappedTargetException
if updating of the internal structures failed.
*/
virtual void SAL_CALL replaceByName( const ::rtl::OUString& sName ,
const css::uno::Any& aPropertySet )
throw(css::lang::IllegalArgumentException ,
css::container::NoSuchElementException,
css::lang::WrappedTargetException ,
css::uno::RuntimeException );
//---------------------------------------
// XNameAccess
/// @HTML
/** @short return properties of queried detector item.
@descr Use this method to get all informations about a detector item of this cache.
A sequence< com::sun::star::beans::PropertyValue > packed inside an Any will be returned.
Following properties are defined:
<table border=1>
<tr>
<td><b>Property</b></td>
<td><b>Value<b></td>
<td><b>Description<b></td>
</tr>
<tr>
<td>Name</td>
<td>[string]</td>
<td>the uno implementation name for this detect service</td>
</tr>
<tr>
<td>Types</td>
<td>[sequence< string >]</td>
<td>a list of all internbal type names, which this detect service is registered for</td>
</tr>
</table>
@param sName
the uno implementation name the requested detector.
@return A property set, which describe this detect service.
It uses a sequence< com::sun::star::beans::PropertyValue > internaly.
@exception com::sun::star::container::NoSuchElementException
if the requested entry does not exist inside this container.
*/
/// @NOHTML
virtual css::uno::Any SAL_CALL getByName( const ::rtl::OUString& sName )
throw(css::container::NoSuchElementException,
css::lang::WrappedTargetException ,
css::uno::RuntimeException );
//---------------------------------------
// XNameAccess
/** @short return list of all well know container entries available on this container.
@attention Because this service implements read/write access to the configuration too,
this list is dynamic. Means: in multithreaded environments some items of this
return list could be invalid next time!
@return A list of all well known container items.
*/
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
throw(css::uno::RuntimeException);
//---------------------------------------
// XNameAccess
/** @short check if searched entry exist inside this container.
@attention In multithreaded environments it's not guaranteed, that a
queried item exist next time realy! It can be deleted by
another thread ...
@param sName
the name of the queried container entry.
@return TRUE if the requested item exist; FALSE otherwise.
*/
virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& sName )
throw(css::uno::RuntimeException);
//---------------------------------------
// XElementAccess
/** @short return the uno type, which is used for all container items.
@return Type of sequence< com::sun::star::beans::PropertyValue > everytime - because it's fix.
*/
virtual css::uno::Type SAL_CALL getElementType()
throw(css::uno::RuntimeException);
//---------------------------------------
// XElementAccess
/** @short return fill state of this cache.
@return TRUE if any item exist inside this conatiner; FALSE otherwhise.
*/
virtual sal_Bool SAL_CALL hasElements()
throw(css::uno::RuntimeException);
//---------------------------------------
// XFlushable
/** @short update the configuration layer and notify all registered listener.
@descr All container interface methods update the internal structures of
this container only. But the underlying configuration layer and
may some possible other caches was not updated.
Calling of flush() will do that.
At the same time all currently registered flush listener will be informed,
so they can update her structures too.
Note: Before all these operations are started realy, all changes will be
verified and if neccessary some corrections will be done.
In case the cache will be invalid and could not be repaired an exception is thrown!
Normaly this container will not work correctly afterwards ...
@exception com::sun::star::uno::RuntimeException
if the changes on this container was invald and could not be repaired.
*/
virtual void SAL_CALL flush()
throw(css::uno::RuntimeException);
//---------------------------------------
// XFlushable
/** @short register listener for container updates.
@param xListener
reference to listener, which wish to be registered.
@exception com::sun::star::uno::RuntimeException
if the given listener is an invalid reference.
Note: multiple calls of this method for the same listener won't be checked!
*/
virtual void SAL_CALL addFlushListener( const css::uno::Reference< css::util::XFlushListener >& xListener )
throw(css::uno::RuntimeException);
//---------------------------------------
// XFlushable
/** @short deregister listener for container updates.
@param xListener
reference to listener, which wish to be deregistered.
@exception com::sun::star::uno::RuntimeException
if the given listener is an invalid reference.
Note: multiple calls of this method for the same listener won't be checked!
*/
virtual void SAL_CALL removeFlushListener( const css::uno::Reference< css::util::XFlushListener >& xListener )
throw(css::uno::RuntimeException);
}; // class DetectorFactory
} // namespace framework
#endif // #ifndef __FRAMEWORK_SERVICES_DETECTORFACTORY_HXX_
|