Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "basecontainer.hxx"
31 : : #include "constant.hxx"
32 : :
33 : : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
34 : : #include <com/sun/star/uno/Type.h>
35 : : #include <comphelper/enumhelper.hxx>
36 : : #include <osl/diagnose.h>
37 : : #include <rtl/instance.hxx>
38 : :
39 : :
40 : : #define LOAD_IMPLICIT
41 : :
42 : : namespace css = ::com::sun::star;
43 : :
44 : : namespace filter{
45 : : namespace config{
46 : :
47 : :
48 : : namespace
49 : : {
50 : : typedef ::salhelper::SingletonRef< FilterCache > FilterCacheRefHold;
51 : : /** @short hold at least one filter cache instance alive and
52 : : prevent the office from unloading this cache if no filter
53 : : is currently used.*/
54 : : struct thePerformanceOptimizer :
55 : : public rtl::Static<FilterCacheRefHold, thePerformanceOptimizer>
56 : : {
57 : : };
58 : : }
59 : :
60 : 25782 : BaseContainer::BaseContainer()
61 : : : BaseLock ( )
62 : : , m_rCache ( )
63 : : , m_pFlushCache(NULL )
64 [ + - ][ + - ]: 25782 : , m_lListener (m_aLock)
[ + - ][ + - ]
[ + - ]
65 : : {
66 [ + - ][ + - ]: 25782 : m_rCache->load(FilterCache::E_CONTAINS_STANDARD);
67 [ + - ]: 25782 : thePerformanceOptimizer::get();
68 : 25782 : }
69 : :
70 : :
71 : :
72 [ + - ][ + - ]: 25782 : BaseContainer::~BaseContainer()
[ + - ][ + - ]
[ + - ]
73 : : {
74 [ - + ]: 25782 : }
75 : :
76 : :
77 : :
78 : 25782 : void BaseContainer::init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
79 : : const ::rtl::OUString& sImplementationName,
80 : : const css::uno::Sequence< ::rtl::OUString >& lServiceNames ,
81 : : FilterCache::EItemType eType )
82 : : {
83 : : // SAFE ->
84 [ + - ]: 25782 : ::osl::ResettableMutexGuard aLock(m_aLock);
85 : :
86 : 25782 : m_sImplementationName = sImplementationName;
87 [ + - ]: 25782 : m_lServiceNames = lServiceNames ;
88 [ + - ]: 25782 : m_xSMGR = xSMGR ;
89 : 25782 : m_eType = eType ;
90 : : m_xRefreshBroadcaster = css::uno::Reference< css::util::XRefreshable >(
91 [ + - ]: 25782 : xSMGR->createInstance(SERVICE_FILTERCONFIGREFRESH),
92 [ + - ][ + - ]: 25782 : css::uno::UNO_QUERY);
[ + - ][ + - ]
[ + - ]
93 : : // <- SAFE
94 : 25782 : }
95 : :
96 : :
97 : :
98 : 29199 : void BaseContainer::impl_loadOnDemand()
99 : : {
100 : : #ifdef LOAD_IMPLICIT
101 : : // SAFE ->
102 [ + - ]: 29199 : ::osl::ResettableMutexGuard aLock(m_aLock);
103 : :
104 : : // A generic container needs all items of a set of our cache!
105 : : // Of course it can block for a while, till the cache is realy filled.
106 : : // Note: dont load all sets supported by the cache here!
107 : :
108 : 29199 : FilterCache::EFillState eRequiredState = FilterCache::E_CONTAINS_NOTHING;
109 [ + + - + : 29199 : switch(m_eType)
+ - ]
110 : : {
111 : : case FilterCache::E_TYPE :
112 : 12458 : eRequiredState = FilterCache::E_CONTAINS_TYPES;
113 : 12458 : break;
114 : :
115 : : case FilterCache::E_FILTER :
116 : 12438 : eRequiredState = FilterCache::E_CONTAINS_FILTERS;
117 : 12438 : break;
118 : :
119 : : case FilterCache::E_DETECTSERVICE :
120 : 0 : eRequiredState = FilterCache::E_CONTAINS_DETECTSERVICES;
121 : 0 : break;
122 : :
123 : : case FilterCache::E_FRAMELOADER :
124 : 4130 : eRequiredState = FilterCache::E_CONTAINS_FRAMELOADERS;
125 : 4130 : break;
126 : :
127 : : case FilterCache::E_CONTENTHANDLER :
128 : 173 : eRequiredState = FilterCache::E_CONTAINS_CONTENTHANDLERS;
129 : 173 : break;
130 : : }
131 : :
132 [ + - ][ + - ]: 29199 : m_rCache->load(eRequiredState);
[ + - ]
133 : : // <- SAFE
134 : : #endif
135 : 29199 : }
136 : :
137 : :
138 : :
139 : 8 : void BaseContainer::impl_initFlushMode()
140 : : throw (css::uno::RuntimeException)
141 : : {
142 : : // SAFE ->
143 [ + - ]: 8 : ::osl::ResettableMutexGuard aLock(m_aLock);
144 [ + + ]: 8 : if (!m_pFlushCache)
145 [ + - ][ + - ]: 2 : m_pFlushCache = m_rCache->clone();
146 [ - + ]: 8 : if (!m_pFlushCache)
147 : : throw css::uno::RuntimeException(
148 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cant create write copy of internal used cache on demand." )),
149 [ # # ][ # # ]: 8 : dynamic_cast< css::container::XNameAccess* >(this));
[ # # ][ + - ]
150 : : // <- SAFE
151 : 8 : }
152 : :
153 : :
154 : :
155 : 29199 : FilterCache* BaseContainer::impl_getWorkingCache() const
156 : : {
157 : : // SAFE ->
158 [ + - ]: 29199 : ::osl::ResettableMutexGuard aLock(m_aLock);
159 [ + + ]: 29199 : if (m_pFlushCache)
160 : 16 : return m_pFlushCache;
161 : : else
162 [ + - ][ + - ]: 29199 : return &(*m_rCache);
163 : : // <- SAFE
164 : : }
165 : :
166 : :
167 : :
168 : 6 : ::rtl::OUString SAL_CALL BaseContainer::getImplementationName()
169 : : throw (css::uno::RuntimeException)
170 : : {
171 : : // SAFE ->
172 [ + - ]: 6 : ::osl::ResettableMutexGuard aLock(m_aLock);
173 [ + - ]: 6 : return m_sImplementationName;
174 : : // <- SAFE
175 : : }
176 : :
177 : :
178 : :
179 : 0 : sal_Bool SAL_CALL BaseContainer::supportsService(const ::rtl::OUString& sServiceName)
180 : : throw (css::uno::RuntimeException)
181 : : {
182 : : // SAFE ->
183 [ # # ]: 0 : ::osl::ResettableMutexGuard aLock(m_aLock);
184 : :
185 : 0 : sal_Int32 c = m_lServiceNames.getLength();
186 : 0 : const ::rtl::OUString* pNames = m_lServiceNames.getConstArray();
187 [ # # ]: 0 : for (sal_Int32 i=0; i<c; ++i)
188 : : {
189 [ # # ]: 0 : if (pNames[i].equals(sServiceName))
190 : 0 : return sal_True;
191 : : }
192 [ # # ]: 0 : return sal_False;
193 : : // <- SAFE
194 : : }
195 : :
196 : :
197 : :
198 : 0 : css::uno::Sequence< ::rtl::OUString > SAL_CALL BaseContainer::getSupportedServiceNames()
199 : : throw (css::uno::RuntimeException)
200 : : {
201 : : // SAFE ->
202 [ # # ]: 0 : ::osl::ResettableMutexGuard aLock(m_aLock);
203 [ # # ][ # # ]: 0 : return m_lServiceNames;
204 : : // <- SAFE
205 : : }
206 : :
207 : :
208 : :
209 : 6 : void SAL_CALL BaseContainer::insertByName(const ::rtl::OUString& sItem ,
210 : : const css::uno::Any& aValue)
211 : : throw (css::lang::IllegalArgumentException ,
212 : : css::container::ElementExistException,
213 : : css::lang::WrappedTargetException ,
214 : : css::uno::RuntimeException )
215 : : {
216 [ - + ]: 6 : if (sItem.isEmpty())
217 : : throw css::lang::IllegalArgumentException(
218 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "empty value not allowed as item name." )),
219 : : static_cast< css::container::XNameContainer* >(this),
220 [ # # ][ # # ]: 0 : 1);
[ # # ]
221 : :
222 [ + - ]: 6 : CacheItem aItem;
223 : : try
224 : : {
225 [ + + ]: 6 : aItem << aValue;
226 : : }
227 [ - + ]: 4 : catch(const css::uno::Exception& ex)
228 : : {
229 [ - + ][ - + ]: 2 : throw css::lang::IllegalArgumentException(ex.Message, static_cast< css::container::XNameContainer* >(this), 2);
230 : : }
231 : :
232 [ + - ]: 4 : impl_loadOnDemand();
233 : :
234 : : // SAFE -> ----------------------------------
235 [ + - ]: 4 : ::osl::ResettableMutexGuard aLock(m_aLock);
236 : :
237 : : // create write copy of used cache on demand ...
238 [ + - ]: 4 : impl_initFlushMode();
239 : :
240 [ + - ]: 4 : FilterCache* pCache = impl_getWorkingCache();
241 [ + - ][ + + ]: 4 : if (pCache->hasItem(m_eType, sItem))
242 [ + - ][ + - ]: 2 : throw css::container::ElementExistException(::rtl::OUString(), static_cast< css::container::XNameContainer* >(this));
243 [ + - ]: 2 : pCache->setItem(m_eType, sItem, aItem);
244 : :
245 [ + - ][ + - ]: 6 : aLock.clear();
[ + - ]
246 : : // <- SAFE ----------------------------------
247 : 2 : }
248 : :
249 : :
250 : :
251 : 4 : void SAL_CALL BaseContainer::removeByName(const ::rtl::OUString& sItem)
252 : : throw (css::container::NoSuchElementException,
253 : : css::lang::WrappedTargetException ,
254 : : css::uno::RuntimeException )
255 : : {
256 [ + - ]: 4 : impl_loadOnDemand();
257 : :
258 : : // SAFE -> ----------------------------------
259 [ + - ]: 4 : ::osl::ResettableMutexGuard aLock(m_aLock);
260 : :
261 : : // create write copy of used cache on demand ...
262 [ + - ]: 4 : impl_initFlushMode();
263 : :
264 [ + - ]: 4 : FilterCache* pCache = impl_getWorkingCache();
265 [ + + ]: 4 : pCache->removeItem(m_eType, sItem); // throw exceptions automaticly
266 : :
267 [ + - ][ + - ]: 4 : aLock.clear();
268 : : // <- SAFE ----------------------------------
269 : 2 : }
270 : :
271 : :
272 : :
273 : 0 : void SAL_CALL BaseContainer::replaceByName(const ::rtl::OUString& sItem ,
274 : : const css::uno::Any& aValue)
275 : : throw (css::lang::IllegalArgumentException ,
276 : : css::container::NoSuchElementException,
277 : : css::lang::WrappedTargetException ,
278 : : css::uno::RuntimeException )
279 : : {
280 [ # # ]: 0 : if (sItem.isEmpty())
281 : : throw css::lang::IllegalArgumentException(
282 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "empty value not allowed as item name." )),
283 : : static_cast< css::container::XNameContainer* >(this),
284 [ # # ][ # # ]: 0 : 1);
[ # # ]
285 : :
286 [ # # ]: 0 : CacheItem aItem;
287 : : try
288 : : {
289 [ # # ]: 0 : aItem << aValue;
290 : : }
291 [ # # ]: 0 : catch(const css::uno::Exception& ex)
292 : : {
293 [ # # # # ]: 0 : throw css::lang::IllegalArgumentException(ex.Message, static_cast< css::container::XNameContainer* >(this), 2);
294 : : }
295 : :
296 [ # # ]: 0 : impl_loadOnDemand();
297 : :
298 : : // SAFE -> ----------------------------------
299 [ # # ]: 0 : ::osl::ResettableMutexGuard aLock(m_aLock);
300 : :
301 : : // create write copy of used cache on demand ...
302 [ # # ]: 0 : impl_initFlushMode();
303 : :
304 [ # # ]: 0 : FilterCache* pCache = impl_getWorkingCache();
305 [ # # ][ # # ]: 0 : if (!pCache->hasItem(m_eType, sItem))
306 [ # # ][ # # ]: 0 : throw css::container::NoSuchElementException(::rtl::OUString(), static_cast< css::container::XNameContainer* >(this));
307 [ # # ]: 0 : pCache->setItem(m_eType, sItem, aItem);
308 : :
309 [ # # ][ # # ]: 0 : aLock.clear();
[ # # ]
310 : : // <- SAFE ----------------------------------
311 : 0 : }
312 : :
313 : :
314 : :
315 : 21160 : css::uno::Any SAL_CALL BaseContainer::getByName(const ::rtl::OUString& sItem)
316 : : throw (css::container::NoSuchElementException,
317 : : css::lang::WrappedTargetException ,
318 : : css::uno::RuntimeException )
319 : : {
320 [ + + ]: 21160 : if (sItem.isEmpty())
321 : : throw css::container::NoSuchElementException(
322 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "An empty item cant be part of this cache!" )),
323 [ + - ][ + - ]: 65 : css::uno::Reference< css::uno::XInterface >(static_cast< css::container::XNameAccess* >(this), css::uno::UNO_QUERY));
[ + - ]
324 : :
325 : 21095 : css::uno::Any aValue;
326 : :
327 [ + - ]: 21095 : impl_loadOnDemand();
328 : :
329 : : // SAFE ->
330 [ + - ]: 21095 : ::osl::ResettableMutexGuard aLock(m_aLock);
331 : :
332 [ + - ]: 21095 : CacheItem aItem;
333 : : try
334 : : {
335 [ + - ]: 21095 : FilterCache* pCache = impl_getWorkingCache();
336 [ + + ][ + - ]: 21095 : aItem = pCache->getItem(m_eType, sItem);
[ + - ]
337 [ + - ]: 21077 : pCache->addStatePropsToItem(m_eType, sItem, aItem); // add implicit props "Finalized"/"Mandatory"
338 : : }
339 : 36 : catch(const css::container::NoSuchElementException&)
340 : : {
341 : 18 : throw;
342 : : }
343 [ - + - # : 18 : catch(const css::uno::Exception&)
# ]
344 : : {
345 : : // TODO invalid cache!? How should it be handled right?
346 [ # # ]: 0 : aItem.clear();
347 : : }
348 : :
349 [ + - ][ + - ]: 21077 : aValue <<= aItem.getAsPackedPropertyValueList();
[ + - ]
350 : : // <- SAFE
351 : :
352 [ + - ][ + - ]: 21160 : return aValue;
353 : : }
354 : :
355 : :
356 : :
357 : 47 : css::uno::Sequence< ::rtl::OUString > SAL_CALL BaseContainer::getElementNames()
358 : : throw (css::uno::RuntimeException)
359 : : {
360 [ + - ]: 47 : css::uno::Sequence< ::rtl::OUString > lNames;
361 : :
362 [ + - ]: 47 : impl_loadOnDemand();
363 : :
364 : : // SAFE ->
365 [ + - ]: 47 : ::osl::ResettableMutexGuard aLock(m_aLock);
366 : :
367 : : try
368 : : {
369 [ + - ]: 47 : FilterCache* pCache = impl_getWorkingCache();
370 [ + - ]: 47 : OUStringList lKeys = pCache->getItemNames(m_eType);
371 [ + - ]: 47 : lKeys >> lNames;
372 : : }
373 [ # # # # ]: 0 : catch(const css::uno::Exception&)
374 : : {
375 : : // invalid cache!?
376 [ # # ]: 0 : lNames.realloc(0);
377 : : }
378 : :
379 : : // <- SAFE
380 : :
381 [ + - ]: 47 : return lNames;
382 : : }
383 : :
384 : :
385 : :
386 : 657 : sal_Bool SAL_CALL BaseContainer::hasByName(const ::rtl::OUString& sItem)
387 : : throw (css::uno::RuntimeException)
388 : : {
389 : 657 : sal_Bool bHasOne = sal_False;
390 : :
391 [ + - ]: 657 : impl_loadOnDemand();
392 : :
393 : : // SAFE ->
394 [ + - ]: 657 : ::osl::ResettableMutexGuard aLock(m_aLock);
395 : :
396 : : try
397 : : {
398 [ + - ]: 657 : FilterCache* pCache = impl_getWorkingCache();
399 [ + - ]: 657 : bHasOne = pCache->hasItem(m_eType, sItem);
400 : : }
401 [ # # ]: 0 : catch(const css::uno::Exception&)
402 : : {
403 : : // invalid cache!?
404 : 0 : bHasOne = sal_False;
405 : : }
406 : :
407 : : // <- SAFE
408 : :
409 [ + - ][ # # ]: 657 : return bHasOne;
410 : : }
411 : :
412 : :
413 : :
414 : 6 : css::uno::Type SAL_CALL BaseContainer::getElementType()
415 : : throw (css::uno::RuntimeException)
416 : : {
417 : : // no lock neccessary - because the type of our items
418 : : // is fix! no internal call or member needed ...
419 : 6 : return ::getCppuType(static_cast< css::uno::Sequence< css::beans::PropertyValue >* >(NULL));
420 : : }
421 : :
422 : :
423 : :
424 : 6 : sal_Bool SAL_CALL BaseContainer::hasElements()
425 : : throw (css::uno::RuntimeException)
426 : : {
427 : 6 : sal_Bool bHasSome = sal_False;
428 : :
429 [ + - ]: 6 : impl_loadOnDemand();
430 : :
431 : : // SAFE ->
432 [ + - ]: 6 : ::osl::ResettableMutexGuard aLock(m_aLock);
433 : :
434 : : try
435 : : {
436 [ + - ]: 6 : FilterCache* pCache = impl_getWorkingCache();
437 [ + - ]: 6 : bHasSome = pCache->hasItems(m_eType);
438 : : }
439 [ # # ]: 0 : catch(const css::uno::Exception&)
440 : : {
441 : : // invalid cache?!
442 : 0 : bHasSome = sal_False;
443 : : }
444 : :
445 : : // <- SAFE
446 : :
447 [ + - ][ # # ]: 6 : return bHasSome;
448 : : }
449 : :
450 : :
451 : :
452 : 0 : css::uno::Reference< css::container::XEnumeration > SAL_CALL BaseContainer::createSubSetEnumerationByQuery(const ::rtl::OUString& /* sQuery */ )
453 : : throw (css::uno::RuntimeException)
454 : : {
455 : : OSL_FAIL("not pure virtual ... but not realy implemented .-)");
456 : :
457 [ # # ][ # # ]: 0 : ::comphelper::OEnumerationByName* pEnum = new ::comphelper::OEnumerationByName(this, css::uno::Sequence< ::rtl::OUString >());
[ # # ]
458 [ # # ]: 0 : return css::uno::Reference< css::container::XEnumeration >(static_cast< css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY);
459 : : }
460 : :
461 : :
462 : :
463 : 7386 : css::uno::Reference< css::container::XEnumeration > SAL_CALL BaseContainer::createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue >& lProperties)
464 : : throw (css::uno::RuntimeException)
465 : : {
466 : 7386 : css::uno::Reference< css::container::XEnumeration > xEnum;
467 [ + - ]: 7386 : OUStringList lKeys;
468 : :
469 [ + - ]: 7386 : impl_loadOnDemand();
470 : :
471 : : // SAFE ->
472 [ + - ]: 7386 : ::osl::ResettableMutexGuard aLock(m_aLock);
473 : :
474 : : try
475 : : {
476 : : // convert the given properties first to our internal representation
477 [ + - ]: 7386 : CacheItem lProps;
478 [ + - ]: 7386 : lProps << lProperties;
479 : :
480 : : // search the key names of all items, where its properties match
481 : : // the given ones in its minimum
482 [ + - ]: 7386 : FilterCache* pCache = impl_getWorkingCache();
483 [ + - ][ + - ]: 7386 : lKeys = pCache->getMatchingItemsByProps(m_eType, lProps);
[ + - ][ + - ]
[ + - ][ # # ]
484 : : }
485 [ # # ]: 0 : catch(const css::uno::Exception&)
486 : : {
487 : : // invalid cache, internal failure, wrong conversion ...!?
488 : : // doesnt matter
489 : 0 : lKeys.clear();
490 : : }
491 : :
492 : : // <- SAFE
493 : :
494 : : // create a specialized enumeration helper, which
495 : : // provides the collected informations outside.
496 : : // It hold a reference to us ... and call our container interface directly.
497 : : // be aware of some direct callbacks if it will be created :-)
498 : :
499 : : /* Note: Its not allowed to return NULL. Because an empty enumeration
500 : : transport the same information but make no trouble outside.
501 : : Further its easiear to work directly with the return value
502 : : instaed of checking of NULL returns! */
503 : :
504 [ + - ]: 7386 : css::uno::Sequence< ::rtl::OUString > lSubSet;
505 [ + - ]: 7386 : lKeys >> lSubSet;
506 [ + - ][ + - ]: 7386 : ::comphelper::OEnumerationByName* pEnum = new ::comphelper::OEnumerationByName(this, lSubSet);
507 [ + - ][ + - ]: 7386 : return css::uno::Reference< css::container::XEnumeration >(static_cast< css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY);
[ + - ][ + - ]
508 : : }
509 : :
510 : :
511 : :
512 : 2 : void SAL_CALL BaseContainer::flush()
513 : : throw (css::uno::RuntimeException)
514 : : {
515 : : // SAFE ->
516 [ + - ]: 2 : ::osl::ResettableMutexGuard aLock(m_aLock);
517 : :
518 [ - + ]: 2 : if (!m_pFlushCache)
519 : : throw css::lang::WrappedTargetRuntimeException(
520 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cant guarantee cache consistency. Special flush container does not exists!" )),
521 : : dynamic_cast< css::container::XNameAccess* >(this),
522 [ # # ][ # # ]: 0 : css::uno::Any());
[ # # ]
523 : :
524 : : try
525 : : {
526 [ + - ]: 2 : m_pFlushCache->flush();
527 : : // Take over all changes into the global cache and
528 : : // forget the clone.
529 : : /* TODO
530 : : -think about me
531 : : If the global cache gets this information via listener,
532 : : we should remove this method!
533 : : */
534 [ + - ][ + - ]: 2 : m_rCache->takeOver(*m_pFlushCache);
535 : : }
536 [ # # ]: 0 : catch(const css::uno::Exception& ex)
537 : : {
538 : : // Dont remove the clone. May be the outside
539 : : // user whish to repair it now and calls flush()
540 : : // later again ...
541 : :
542 : : throw css::lang::WrappedTargetRuntimeException(
543 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Flush rejected by internal container." )),
544 : : dynamic_cast< css::container::XNameAccess* >(this),
545 [ # # # # : 0 : css::uno::makeAny(ex));
# # # # ]
546 : : }
547 : :
548 [ + - ][ + - ]: 2 : delete m_pFlushCache;
549 : 2 : m_pFlushCache = NULL;
550 : :
551 [ + - ]: 2 : css::uno::Reference< css::util::XRefreshable > xRefreshBroadcaster = m_xRefreshBroadcaster;
552 : :
553 [ + - ]: 2 : aLock.clear();
554 : : // <- SAFE
555 : :
556 [ + - ]: 2 : if (xRefreshBroadcaster.is())
557 [ + - ][ + - ]: 2 : xRefreshBroadcaster->refresh();
558 : :
559 : : // notify listener outside the lock!
560 : : // The used listener helper lives if we live
561 : : // and is threadsafe by itself.
562 : : // Further its not a good idea to hold the own lock
563 : : // if an outside object is called :-)
564 [ + - ][ + - ]: 2 : css::lang::EventObject aSource (static_cast< css::util::XFlushable* >(this));
565 [ + - ][ + - ]: 2 : ::cppu::OInterfaceContainerHelper* pContainer = m_lListener.getContainer(::getCppuType(static_cast< css::uno::Reference< css::util::XFlushListener >* >(NULL)));
566 [ + - ]: 2 : if (pContainer)
567 : : {
568 [ + - ]: 2 : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
569 [ + + ]: 4 : while (pIterator.hasMoreElements())
570 : : {
571 : : try
572 : : {
573 : : // ... this pointer can be interesting to find out, where will be called as listener
574 : : // Dont optimize it to a direct iterator cast :-)
575 [ + - ]: 2 : css::util::XFlushListener* pListener = (css::util::XFlushListener*)pIterator.next();
576 [ + - ]: 2 : pListener->flushed(aSource);
577 : : }
578 [ # # # # ]: 0 : catch(const css::uno::Exception&)
579 : : {
580 : : // ignore any "damaged" flush listener!
581 : : // May its remote reference is broken ...
582 [ # # ]: 0 : pIterator.remove();
583 : : }
584 [ + - ]: 2 : }
585 [ + - ][ + - ]: 2 : }
586 : 2 : }
587 : :
588 : :
589 : :
590 : 4 : void SAL_CALL BaseContainer::addFlushListener(const css::uno::Reference< css::util::XFlushListener >& xListener)
591 : : throw (css::uno::RuntimeException)
592 : : {
593 : : // no locks neccessary
594 : : // used helper lives if we live and is threadsafe by itself ...
595 : 4 : m_lListener.addInterface(::getCppuType(static_cast< css::uno::Reference< css::util::XFlushListener >* >(NULL)),
596 : 8 : xListener );
597 : 4 : }
598 : :
599 : :
600 : :
601 : 2 : void SAL_CALL BaseContainer::removeFlushListener(const css::uno::Reference< css::util::XFlushListener >& xListener)
602 : : throw (css::uno::RuntimeException)
603 : : {
604 : : // no locks neccessary
605 : : // used helper lives if we live and is threadsafe by itself ...
606 : 2 : m_lListener.removeInterface(::getCppuType(static_cast< css::uno::Reference< css::util::XFlushListener >* >(NULL)),
607 : 4 : xListener );
608 : 2 : }
609 : :
610 : : } // namespace config
611 : : } // namespace filter
612 : :
613 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|