Bug Summary

File:home/maarten/src/libreoffice/core/framework/source/uiconfiguration/imagemanagerimpl.cxx
Warning:line 865, column 39
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name imagemanagerimpl.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D FWK_DLLIMPLEMENTATION -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/framework/source/inc -I /home/maarten/src/libreoffice/core/framework/inc -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/framework/source/uiconfiguration/imagemanagerimpl.cxx
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include "imagemanagerimpl.hxx"
21#include <xml/imagesconfiguration.hxx>
22#include <uiconfiguration/imagetype.hxx>
23#include <uiconfiguration/graphicnameaccess.hxx>
24
25#include <properties.h>
26
27#include <com/sun/star/frame/theUICommandDescription.hpp>
28#include <com/sun/star/ui/ConfigurationEvent.hpp>
29#include <com/sun/star/lang/DisposedException.hpp>
30#include <com/sun/star/lang/IllegalAccessException.hpp>
31#include <com/sun/star/beans/XPropertySet.hpp>
32#include <com/sun/star/beans/PropertyValue.hpp>
33#include <com/sun/star/embed/ElementModes.hpp>
34#include <com/sun/star/embed/InvalidStorageException.hpp>
35#include <com/sun/star/embed/StorageWrappedTargetException.hpp>
36#include <com/sun/star/io/IOException.hpp>
37#include <com/sun/star/io/XStream.hpp>
38#include <com/sun/star/ui/ImageType.hpp>
39#include <vcl/graph.hxx>
40#include <vcl/svapp.hxx>
41#include <o3tl/enumrange.hxx>
42#include <osl/mutex.hxx>
43#include <comphelper/sequence.hxx>
44#include <unotools/ucbstreamhelper.hxx>
45#include <vcl/pngread.hxx>
46#include <vcl/pngwrite.hxx>
47#include <rtl/instance.hxx>
48#include <memory>
49
50using ::com::sun::star::uno::Sequence;
51using ::com::sun::star::uno::XInterface;
52using ::com::sun::star::uno::RuntimeException;
53using ::com::sun::star::uno::UNO_QUERY;
54using ::com::sun::star::uno::Any;
55using ::com::sun::star::graphic::XGraphic;
56using namespace ::com::sun::star;
57using namespace ::com::sun::star::io;
58using namespace ::com::sun::star::embed;
59using namespace ::com::sun::star::lang;
60using namespace ::com::sun::star::container;
61using namespace ::com::sun::star::beans;
62using namespace ::com::sun::star::ui;
63using namespace ::cppu;
64
65const sal_Int16 MAX_IMAGETYPE_VALUE = css::ui::ImageType::SIZE_32;
66
67const char IMAGE_FOLDER[] = "images";
68const char BITMAPS_FOLDER[] = "Bitmaps";
69
70const o3tl::enumarray<vcl::ImageType, const char*> IMAGELIST_XML_FILE =
71{
72 "sc_imagelist.xml",
73 "lc_imagelist.xml",
74 "xc_imagelist.xml"
75};
76
77const o3tl::enumarray<vcl::ImageType, const char*> BITMAP_FILE_NAMES =
78{
79 "sc_userimages.png",
80 "lc_userimages.png",
81 "xc_userimages.png"
82};
83
84namespace framework
85{
86
87static GlobalImageList* pGlobalImageList = nullptr;
88
89namespace
90{
91 class theGlobalImageListMutex
92 : public rtl::Static<osl::Mutex, theGlobalImageListMutex> {};
93}
94
95static osl::Mutex& getGlobalImageListMutex()
96{
97 return theGlobalImageListMutex::get();
98}
99
100static GlobalImageList* getGlobalImageList( const uno::Reference< uno::XComponentContext >& rxContext )
101{
102 osl::MutexGuard guard( getGlobalImageListMutex() );
103
104 if ( pGlobalImageList == nullptr )
105 pGlobalImageList = new GlobalImageList( rxContext );
106
107 return pGlobalImageList;
108}
109
110CmdImageList::CmdImageList( const uno::Reference< uno::XComponentContext >& rxContext, const OUString& aModuleIdentifier ) :
111 m_bInitialized(false),
112 m_aModuleIdentifier( aModuleIdentifier ),
113 m_xContext( rxContext )
114{
115}
116
117CmdImageList::~CmdImageList()
118{
119}
120
121void CmdImageList::initialize()
122{
123 if (m_bInitialized)
124 return;
125
126 const OUString aCommandImageList(UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST"private:resource/image/commandimagelist");
127
128 Sequence<OUString> aCommandImageSeq;
129 uno::Reference<XNameAccess> xCommandDesc = frame::theUICommandDescription::get(m_xContext);
130
131 if (!m_aModuleIdentifier.isEmpty())
132 {
133 // If we have a module identifier - use to retrieve the command image name list from it.
134 // Otherwise we will use the global command image list
135 try
136 {
137 xCommandDesc->getByName(m_aModuleIdentifier) >>= xCommandDesc;
138 if (xCommandDesc.is())
139 xCommandDesc->getByName(aCommandImageList) >>= aCommandImageSeq;
140 }
141 catch (const NoSuchElementException&)
142 {
143 // Module unknown we will work with an empty command image list!
144 return;
145 }
146 }
147
148 if (xCommandDesc.is())
149 {
150 try
151 {
152 xCommandDesc->getByName(aCommandImageList) >>= aCommandImageSeq;
153 }
154 catch (const NoSuchElementException&)
155 {
156 }
157 catch (const WrappedTargetException&)
158 {
159 }
160 }
161
162 m_aResolver.registerCommands(aCommandImageSeq);
163
164 m_bInitialized = true;
165}
166
167
168Image CmdImageList::getImageFromCommandURL(vcl::ImageType nImageType, const OUString& rCommandURL)
169{
170 initialize();
171 return m_aResolver.getImageFromCommandURL(nImageType, rCommandURL);
172}
173
174bool CmdImageList::hasImage(vcl::ImageType /*nImageType*/, const OUString& rCommandURL)
175{
176 initialize();
177 return m_aResolver.hasImage(rCommandURL);
178}
179
180std::vector<OUString>& CmdImageList::getImageCommandNames()
181{
182 return m_aResolver.getCommandNames();
183}
184
185GlobalImageList::GlobalImageList( const uno::Reference< uno::XComponentContext >& rxContext ) :
186 CmdImageList( rxContext, OUString() )
187{
188}
189
190GlobalImageList::~GlobalImageList()
191{
192 osl::MutexGuard guard( getGlobalImageListMutex() );
193 // remove global pointer as we destroy the object now
194 pGlobalImageList = nullptr;
195}
196
197Image GlobalImageList::getImageFromCommandURL( vcl::ImageType nImageType, const OUString& rCommandURL )
198{
199 osl::MutexGuard guard( getGlobalImageListMutex() );
200 return CmdImageList::getImageFromCommandURL( nImageType, rCommandURL );
201}
202
203bool GlobalImageList::hasImage( vcl::ImageType nImageType, const OUString& rCommandURL )
204{
205 osl::MutexGuard guard( getGlobalImageListMutex() );
206 return CmdImageList::hasImage( nImageType, rCommandURL );
207}
208
209::std::vector< OUString >& GlobalImageList::getImageCommandNames()
210{
211 osl::MutexGuard guard( getGlobalImageListMutex() );
212 return CmdImageList::getImageCommandNames();
213}
214
215static bool implts_checkAndScaleGraphic( uno::Reference< XGraphic >& rOutGraphic, const uno::Reference< XGraphic >& rInGraphic, vcl::ImageType nImageType )
216{
217 if ( !rInGraphic.is() )
218 {
219 rOutGraphic = uno::Reference<graphic::XGraphic>();
220 return false;
221 }
222
223 static const o3tl::enumarray<vcl::ImageType, Size> BITMAP_SIZE =
224 {
225 Size(16, 16), Size(24, 24), Size(32, 32)
226 };
227
228 // Check size and scale it
229 Graphic aImage(rInGraphic);
230 if (BITMAP_SIZE[nImageType] != aImage.GetSizePixel())
231 {
232 BitmapEx aBitmap = aImage.GetBitmapEx();
233 aBitmap.Scale(BITMAP_SIZE[nImageType]);
234 aImage = Graphic(aBitmap);
235 rOutGraphic = aImage.GetXGraphic();
236 }
237 else
238 rOutGraphic = rInGraphic;
239
240 return true;
241}
242
243static vcl::ImageType implts_convertImageTypeToIndex( sal_Int16 nImageType )
244{
245 if (nImageType & css::ui::ImageType::SIZE_LARGE)
246 return vcl::ImageType::Size26;
247 else if (nImageType & css::ui::ImageType::SIZE_32)
248 return vcl::ImageType::Size32;
249 else
250 return vcl::ImageType::Size16;
251}
252
253ImageList* ImageManagerImpl::implts_getUserImageList( vcl::ImageType nImageType )
254{
255 SolarMutexGuard g;
256 if ( !m_pUserImageList[nImageType] )
13
Taking false branch
257 implts_loadUserImages( nImageType, m_xUserImageStorage, m_xUserBitmapsStorage );
258
259 return m_pUserImageList[nImageType].get();
14
Value assigned to field 'm_bUseGlobal', which participates in a condition later
260}
261
262void ImageManagerImpl::implts_initialize()
263{
264 // Initialize the top-level structures with the storage data
265 if ( !m_xUserConfigStorage.is() )
266 return;
267
268 long nModes = m_bReadOnly ? ElementModes::READ : ElementModes::READWRITE;
269
270 try
271 {
272 m_xUserImageStorage = m_xUserConfigStorage->openStorageElement( IMAGE_FOLDER,
273 nModes );
274 if ( m_xUserImageStorage.is() )
275 {
276 m_xUserBitmapsStorage = m_xUserImageStorage->openStorageElement( BITMAPS_FOLDER,
277 nModes );
278 }
279 }
280 catch ( const css::container::NoSuchElementException& )
281 {
282 }
283 catch ( const css::embed::InvalidStorageException& )
284 {
285 }
286 catch ( const css::lang::IllegalArgumentException& )
287 {
288 }
289 catch ( const css::io::IOException& )
290 {
291 }
292 catch ( const css::embed::StorageWrappedTargetException& )
293 {
294 }
295}
296
297void ImageManagerImpl::implts_loadUserImages(
298 vcl::ImageType nImageType,
299 const uno::Reference< XStorage >& xUserImageStorage,
300 const uno::Reference< XStorage >& xUserBitmapsStorage )
301{
302 SolarMutexGuard g;
303
304 if ( xUserImageStorage.is() && xUserBitmapsStorage.is() )
305 {
306 try
307 {
308 uno::Reference< XStream > xStream = xUserImageStorage->openStreamElement( OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ),
309 ElementModes::READ );
310 uno::Reference< XInputStream > xInputStream = xStream->getInputStream();
311
312 ImageItemDescriptorList aUserImageListInfo;
313 ImagesConfiguration::LoadImages( m_xContext,
314 xInputStream,
315 aUserImageListInfo );
316 if ( !aUserImageListInfo.empty() )
317 {
318 sal_Int32 nCount = aUserImageListInfo.size();
319 std::vector< OUString > aUserImagesVector;
320 aUserImagesVector.reserve(nCount);
321 for ( sal_Int32 i=0; i < nCount; i++ )
322 {
323 const ImageItemDescriptor& rItem = aUserImageListInfo[i];
324 aUserImagesVector.push_back( rItem.aCommandURL );
325 }
326
327 uno::Reference< XStream > xBitmapStream = xUserBitmapsStorage->openStreamElement(
328 OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ),
329 ElementModes::READ );
330
331 if ( xBitmapStream.is() )
332 {
333 BitmapEx aUserBitmap;
334 {
335 std::unique_ptr<SvStream> pSvStream(utl::UcbStreamHelper::CreateStream( xBitmapStream ));
336 vcl::PNGReader aPngReader( *pSvStream );
337 aUserBitmap = aPngReader.Read();
338 }
339
340 // Delete old image list and create a new one from the read bitmap
341 m_pUserImageList[nImageType].reset(new ImageList());
342 m_pUserImageList[nImageType]->InsertFromHorizontalStrip
343 ( aUserBitmap, aUserImagesVector );
344 return;
345 }
346 }
347 }
348 catch ( const css::container::NoSuchElementException& )
349 {
350 }
351 catch ( const css::embed::InvalidStorageException& )
352 {
353 }
354 catch ( const css::lang::IllegalArgumentException& )
355 {
356 }
357 catch ( const css::io::IOException& )
358 {
359 }
360 catch ( const css::embed::StorageWrappedTargetException& )
361 {
362 }
363 }
364
365 // Destroy old image list - create a new empty one
366 m_pUserImageList[nImageType].reset(new ImageList);
367}
368
369bool ImageManagerImpl::implts_storeUserImages(
370 vcl::ImageType nImageType,
371 const uno::Reference< XStorage >& xUserImageStorage,
372 const uno::Reference< XStorage >& xUserBitmapsStorage )
373{
374 SolarMutexGuard g;
375
376 if ( m_bModified )
377 {
378 ImageList* pImageList = implts_getUserImageList( nImageType );
379 if ( pImageList->GetImageCount() > 0 )
380 {
381 ImageItemDescriptorList aUserImageListInfo;
382
383 for ( sal_uInt16 i=0; i < pImageList->GetImageCount(); i++ )
384 {
385 ImageItemDescriptor aItem;
386 aItem.aCommandURL = pImageList->GetImageName( i );
387 aUserImageListInfo.push_back( aItem );
388 }
389
390 uno::Reference< XTransactedObject > xTransaction;
391 uno::Reference< XOutputStream > xOutputStream;
392 uno::Reference< XStream > xStream = xUserImageStorage->openStreamElement( OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ),
393 ElementModes::WRITE|ElementModes::TRUNCATE );
394 if ( xStream.is() )
395 {
396 uno::Reference< XStream > xBitmapStream =
397 xUserBitmapsStorage->openStreamElement( OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ),
398 ElementModes::WRITE|ElementModes::TRUNCATE );
399 if ( xBitmapStream.is() )
400 {
401 {
402 std::unique_ptr<SvStream> pSvStream(utl::UcbStreamHelper::CreateStream( xBitmapStream ));
403 vcl::PNGWriter aPngWriter( pImageList->GetAsHorizontalStrip() );
404 aPngWriter.Write( *pSvStream );
405 }
406
407 // Commit user bitmaps storage
408 xTransaction.set( xUserBitmapsStorage, UNO_QUERY );
409 if ( xTransaction.is() )
410 xTransaction->commit();
411 }
412
413 xOutputStream = xStream->getOutputStream();
414 if ( xOutputStream.is() )
415 ImagesConfiguration::StoreImages( m_xContext, xOutputStream, aUserImageListInfo );
416
417 // Commit user image storage
418 xTransaction.set( xUserImageStorage, UNO_QUERY );
419 if ( xTransaction.is() )
420 xTransaction->commit();
421 }
422
423 return true;
424 }
425 else
426 {
427 // Remove the streams from the storage, if we have no data. We have to catch
428 // the NoSuchElementException as it can be possible that there is no stream at all!
429 try
430 {
431 xUserImageStorage->removeElement( OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ));
432 }
433 catch ( const css::container::NoSuchElementException& )
434 {
435 }
436
437 try
438 {
439 xUserBitmapsStorage->removeElement( OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ));
440 }
441 catch ( const css::container::NoSuchElementException& )
442 {
443 }
444
445 uno::Reference< XTransactedObject > xTransaction;
446
447 // Commit user image storage
448 xTransaction.set( xUserImageStorage, UNO_QUERY );
449 if ( xTransaction.is() )
450 xTransaction->commit();
451
452 // Commit user bitmaps storage
453 xTransaction.set( xUserBitmapsStorage, UNO_QUERY );
454 if ( xTransaction.is() )
455 xTransaction->commit();
456
457 return true;
458 }
459 }
460
461 return false;
462}
463
464const rtl::Reference< GlobalImageList >& ImageManagerImpl::implts_getGlobalImageList()
465{
466 SolarMutexGuard g;
467
468 if ( !m_pGlobalImageList.is() )
469 m_pGlobalImageList = getGlobalImageList( m_xContext );
470 return m_pGlobalImageList;
471}
472
473CmdImageList* ImageManagerImpl::implts_getDefaultImageList()
474{
475 SolarMutexGuard g;
476
477 if ( !m_pDefaultImageList )
478 m_pDefaultImageList.reset(new CmdImageList( m_xContext, m_aModuleIdentifier ));
479
480 return m_pDefaultImageList.get();
481}
482
483ImageManagerImpl::ImageManagerImpl( const uno::Reference< uno::XComponentContext >& rxContext,::cppu::OWeakObject* pOwner,bool _bUseGlobal ) :
484 m_xContext( rxContext )
485 , m_pOwner(pOwner)
486 , m_aResourceString( "private:resource/images/moduleimages" )
487 , m_aListenerContainer( m_mutex )
488 , m_bUseGlobal(_bUseGlobal)
489 , m_bReadOnly( true )
490 , m_bInitialized( false )
491 , m_bModified( false )
492 , m_bDisposed( false )
493{
494 for ( vcl::ImageType n : o3tl::enumrange<vcl::ImageType>() )
495 {
496 m_pUserImageList[n] = nullptr;
497 m_bUserImageListModified[n] = false;
498 }
499}
500
501ImageManagerImpl::~ImageManagerImpl()
502{
503 clear();
504}
505
506void ImageManagerImpl::dispose()
507{
508 uno::Reference< uno::XInterface > xOwner(m_pOwner);
509 css::lang::EventObject aEvent( xOwner );
510 m_aListenerContainer.disposeAndClear( aEvent );
511
512 {
513 SolarMutexGuard g;
514 m_xUserConfigStorage.clear();
515 m_xUserImageStorage.clear();
516 m_xUserRootCommit.clear();
517 m_bModified = false;
518 m_bDisposed = true;
519
520 // delete user and default image list on dispose
521 for (auto& n : m_pUserImageList)
522 {
523 n.reset();
524 }
525 m_pDefaultImageList.reset();
526 }
527
528}
529void ImageManagerImpl::addEventListener( const uno::Reference< XEventListener >& xListener )
530{
531 {
532 SolarMutexGuard g;
533
534 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
535 if ( m_bDisposed )
536 throw DisposedException();
537 }
538
539 m_aListenerContainer.addInterface( cppu::UnoType<XEventListener>::get(), xListener );
540}
541
542void ImageManagerImpl::removeEventListener( const uno::Reference< XEventListener >& xListener )
543{
544 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
545 m_aListenerContainer.removeInterface( cppu::UnoType<XEventListener>::get(), xListener );
546}
547
548// XInitialization
549void ImageManagerImpl::initialize( const Sequence< Any >& aArguments )
550{
551 SolarMutexGuard g;
552
553 if ( m_bInitialized )
554 return;
555
556 for ( const Any& rArg : aArguments )
557 {
558 PropertyValue aPropValue;
559 if ( rArg >>= aPropValue )
560 {
561 if ( aPropValue.Name == "UserConfigStorage" )
562 {
563 aPropValue.Value >>= m_xUserConfigStorage;
564 }
565 else if ( aPropValue.Name == "ModuleIdentifier" )
566 {
567 aPropValue.Value >>= m_aModuleIdentifier;
568 }
569 else if ( aPropValue.Name == "UserRootCommit" )
570 {
571 aPropValue.Value >>= m_xUserRootCommit;
572 }
573 }
574 }
575
576 if ( m_xUserConfigStorage.is() )
577 {
578 uno::Reference< XPropertySet > xPropSet( m_xUserConfigStorage, UNO_QUERY );
579 if ( xPropSet.is() )
580 {
581 long nOpenMode = 0;
582 if ( xPropSet->getPropertyValue("OpenMode") >>= nOpenMode )
583 m_bReadOnly = !( nOpenMode & ElementModes::WRITE );
584 }
585 }
586
587 implts_initialize();
588
589 m_bInitialized = true;
590}
591
592// XImageManagerImpl
593void ImageManagerImpl::reset()
594{
595 SolarMutexGuard g;
596
597 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
598 if ( m_bDisposed )
1
Assuming field 'm_bDisposed' is false
2
Taking false branch
599 throw DisposedException();
600
601 std::vector< OUString > aUserImageNames;
602
603 for ( vcl::ImageType i : o3tl::enumrange<vcl::ImageType>() )
604 {
605 aUserImageNames.clear();
606 ImageList* pImageList = implts_getUserImageList(i);
607 pImageList->GetImageNames( aUserImageNames );
608
609 Sequence< OUString > aRemoveList( comphelper::containerToSequence(aUserImageNames) );
610
611 // Remove images
612 removeImages( sal_Int16( i ), aRemoveList );
3
Calling 'ImageManagerImpl::removeImages'
613 m_bUserImageListModified[i] = true;
614 }
615
616 m_bModified = true;
617}
618
619Sequence< OUString > ImageManagerImpl::getAllImageNames( ::sal_Int16 nImageType )
620{
621 SolarMutexGuard g;
622
623 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
624 if ( m_bDisposed )
625 throw DisposedException();
626
627 ImageNameMap aImageCmdNameMap;
628
629 vcl::ImageType nIndex = implts_convertImageTypeToIndex( nImageType );
630
631 sal_uInt32 i( 0 );
632 if ( m_bUseGlobal )
633 {
634 rtl::Reference< GlobalImageList > rGlobalImageList = implts_getGlobalImageList();
635
636 const std::vector< OUString >& rGlobalImageNameVector = rGlobalImageList->getImageCommandNames();
637 const sal_uInt32 nGlobalCount = rGlobalImageNameVector.size();
638 for ( i = 0; i < nGlobalCount; i++ )
639 aImageCmdNameMap.emplace( rGlobalImageNameVector[i], true );
640
641 const std::vector< OUString >& rModuleImageNameVector = implts_getDefaultImageList()->getImageCommandNames();
642 const sal_uInt32 nModuleCount = rModuleImageNameVector.size();
643 for ( i = 0; i < nModuleCount; i++ )
644 aImageCmdNameMap.emplace( rModuleImageNameVector[i], true );
645 }
646
647 ImageList* pImageList = implts_getUserImageList(nIndex);
648 std::vector< OUString > rUserImageNames;
649 pImageList->GetImageNames( rUserImageNames );
650 const sal_uInt32 nUserCount = rUserImageNames.size();
651 for ( i = 0; i < nUserCount; i++ )
652 aImageCmdNameMap.emplace( rUserImageNames[i], true );
653
654 return comphelper::mapKeysToSequence( aImageCmdNameMap );
655}
656
657bool ImageManagerImpl::hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL )
658{
659 SolarMutexGuard g;
660
661 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
662 if ( m_bDisposed )
663 throw DisposedException();
664
665 if (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE ))
666 throw IllegalArgumentException();
667
668 vcl::ImageType nIndex = implts_convertImageTypeToIndex( nImageType );
669 if ( m_bUseGlobal && implts_getGlobalImageList()->hasImage( nIndex, aCommandURL ))
670 return true;
671 else
672 {
673 if ( m_bUseGlobal && implts_getDefaultImageList()->hasImage( nIndex, aCommandURL ))
674 return true;
675 else
676 {
677 // User layer
678 ImageList* pImageList = implts_getUserImageList(nIndex);
679 if ( pImageList )
680 return ( pImageList->GetImagePos( aCommandURL ) != IMAGELIST_IMAGE_NOTFOUND(sal_uInt16(0xFFFF)) );
681 }
682 }
683
684 return false;
685}
686
687namespace
688{
689 css::uno::Reference< css::graphic::XGraphic > GetXGraphic(const Image &rImage)
690 {
691 return Graphic(rImage).GetXGraphic();
692 }
693}
694
695Sequence< uno::Reference< XGraphic > > ImageManagerImpl::getImages(
696 ::sal_Int16 nImageType,
697 const Sequence< OUString >& aCommandURLSequence )
698{
699 SolarMutexGuard g;
700
701 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
702 if ( m_bDisposed )
703 throw DisposedException();
704
705 if (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE ))
706 throw IllegalArgumentException();
707
708 Sequence< uno::Reference< XGraphic > > aGraphSeq( aCommandURLSequence.getLength() );
709
710 vcl::ImageType nIndex = implts_convertImageTypeToIndex( nImageType );
711 rtl::Reference< GlobalImageList > rGlobalImageList;
712 CmdImageList* pDefaultImageList = nullptr;
713 if ( m_bUseGlobal )
714 {
715 rGlobalImageList = implts_getGlobalImageList();
716 pDefaultImageList = implts_getDefaultImageList();
717 }
718 ImageList* pUserImageList = implts_getUserImageList(nIndex);
719
720 // We have to search our image list in the following order:
721 // 1. user image list (read/write)
722 // 2. module image list (read)
723 // 3. global image list (read)
724 sal_Int32 n = 0;
725 for ( const OUString& rURL : aCommandURLSequence )
726 {
727 Image aImage = pUserImageList->GetImage( rURL );
728 if ( !aImage && m_bUseGlobal )
729 {
730 aImage = pDefaultImageList->getImageFromCommandURL( nIndex, rURL );
731 if ( !aImage )
732 aImage = rGlobalImageList->getImageFromCommandURL( nIndex, rURL );
733 }
734
735 aGraphSeq[n++] = GetXGraphic(aImage);
736 }
737
738 return aGraphSeq;
739}
740
741void ImageManagerImpl::replaceImages(
742 ::sal_Int16 nImageType,
743 const Sequence< OUString >& aCommandURLSequence,
744 const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence )
745{
746 GraphicNameAccess* pInsertedImages( nullptr );
747 GraphicNameAccess* pReplacedImages( nullptr );
748
749 {
750 SolarMutexGuard g;
751
752 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
753 if ( m_bDisposed )
754 throw DisposedException();
755
756 if (( aCommandURLSequence.getLength() != aGraphicsSequence.getLength() ) ||
757 (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE )))
758 throw IllegalArgumentException();
759
760 if ( m_bReadOnly )
761 throw IllegalAccessException();
762
763 vcl::ImageType nIndex = implts_convertImageTypeToIndex( nImageType );
764 ImageList* pImageList = implts_getUserImageList(nIndex);
765
766 uno::Reference< XGraphic > xGraphic;
767 for ( sal_Int32 i = 0; i < aCommandURLSequence.getLength(); i++ )
768 {
769 // Check size and scale. If we don't have any graphics ignore it
770 if ( !implts_checkAndScaleGraphic( xGraphic, aGraphicsSequence[i], nIndex ))
771 continue;
772
773 sal_uInt16 nPos = pImageList->GetImagePos( aCommandURLSequence[i] );
774 if ( nPos == IMAGELIST_IMAGE_NOTFOUND(sal_uInt16(0xFFFF)) )
775 {
776 pImageList->AddImage(aCommandURLSequence[i], Image(xGraphic));
777 if ( !pInsertedImages )
778 pInsertedImages = new GraphicNameAccess();
779 pInsertedImages->addElement( aCommandURLSequence[i], xGraphic );
780 }
781 else
782 {
783 pImageList->ReplaceImage(aCommandURLSequence[i], Image(xGraphic));
784 if ( !pReplacedImages )
785 pReplacedImages = new GraphicNameAccess();
786 pReplacedImages->addElement( aCommandURLSequence[i], xGraphic );
787 }
788 }
789
790 if (( pInsertedImages != nullptr ) || ( pReplacedImages != nullptr ))
791 {
792 m_bModified = true;
793 m_bUserImageListModified[nIndex] = true;
794 }
795 }
796
797 uno::Reference< uno::XInterface > xOwner(m_pOwner);
798 // Notify listeners
799 if ( pInsertedImages != nullptr )
800 {
801 ConfigurationEvent aInsertEvent;
802 aInsertEvent.aInfo <<= nImageType;
803 aInsertEvent.Accessor <<= xOwner;
804 aInsertEvent.Source = xOwner;
805 aInsertEvent.ResourceURL = m_aResourceString;
806 aInsertEvent.Element <<= uno::Reference< XNameAccess >(
807 static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY );
808 implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert );
809 }
810 if ( pReplacedImages != nullptr )
811 {
812 ConfigurationEvent aReplaceEvent;
813 aReplaceEvent.aInfo <<= nImageType;
814 aReplaceEvent.Accessor <<= xOwner;
815 aReplaceEvent.Source = xOwner;
816 aReplaceEvent.ResourceURL = m_aResourceString;
817 aReplaceEvent.ReplacedElement = Any();
818 aReplaceEvent.Element <<= uno::Reference< XNameAccess >(
819 static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY );
820 implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace );
821 }
822}
823
824void ImageManagerImpl::removeImages( ::sal_Int16 nImageType, const Sequence< OUString >& aCommandURLSequence )
825{
826 GraphicNameAccess* pRemovedImages( nullptr );
827 GraphicNameAccess* pReplacedImages( nullptr );
828
829 {
830 SolarMutexGuard g;
831
832 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
833 if ( m_bDisposed )
4
Assuming field 'm_bDisposed' is false
5
Taking false branch
834 throw DisposedException();
835
836 if (( nImageType
5.1
'nImageType' is >= 0
< 0 ) || ( nImageType
5.2
'nImageType' is <= 'MAX_IMAGETYPE_VALUE'
> MAX_IMAGETYPE_VALUE ))
6
Taking false branch
837 throw IllegalArgumentException();
838
839 if ( m_bReadOnly )
7
Assuming field 'm_bReadOnly' is false
8
Taking false branch
840 throw IllegalAccessException();
841
842 vcl::ImageType nIndex = implts_convertImageTypeToIndex( nImageType );
843 rtl::Reference< GlobalImageList > rGlobalImageList;
844 CmdImageList* pDefaultImageList = nullptr;
9
'pDefaultImageList' initialized to a null pointer value
845 if ( m_bUseGlobal )
10
Assuming field 'm_bUseGlobal' is false
11
Taking false branch
846 {
847 rGlobalImageList = implts_getGlobalImageList();
848 pDefaultImageList = implts_getDefaultImageList();
849 }
850 ImageList* pImageList = implts_getUserImageList(nIndex);
12
Calling 'ImageManagerImpl::implts_getUserImageList'
15
Returning from 'ImageManagerImpl::implts_getUserImageList'
851 uno::Reference<XGraphic> xEmptyGraphic;
852
853 for ( const OUString& rURL : aCommandURLSequence )
16
Assuming '__begin2' is not equal to '__end2'
854 {
855 sal_uInt16 nPos = pImageList->GetImagePos( rURL );
856 if ( nPos != IMAGELIST_IMAGE_NOTFOUND(sal_uInt16(0xFFFF)) )
17
Assuming 'nPos' is not equal to IMAGELIST_IMAGE_NOTFOUND
18
Taking true branch
857 {
858 sal_uInt16 nId = pImageList->GetImageId( nPos );
859 pImageList->RemoveImage( nId );
860
861 if ( m_bUseGlobal )
19
Assuming field 'm_bUseGlobal' is true
20
Taking true branch
862 {
863 // Check, if we have an image in our module/global image list. If we find one =>
864 // this is a replace instead of a remove operation!
865 Image aNewImage = pDefaultImageList->getImageFromCommandURL( nIndex, rURL );
21
Called C++ object pointer is null
866 if ( !aNewImage )
867 aNewImage = rGlobalImageList->getImageFromCommandURL( nIndex, rURL );
868 if ( !aNewImage )
869 {
870 if ( !pRemovedImages )
871 pRemovedImages = new GraphicNameAccess();
872 pRemovedImages->addElement( rURL, xEmptyGraphic );
873 }
874 else
875 {
876 if ( !pReplacedImages )
877 pReplacedImages = new GraphicNameAccess();
878 pReplacedImages->addElement(rURL, GetXGraphic(aNewImage));
879 }
880 } // if ( m_bUseGlobal )
881 else
882 {
883 if ( !pRemovedImages )
884 pRemovedImages = new GraphicNameAccess();
885 pRemovedImages->addElement( rURL, xEmptyGraphic );
886 }
887 }
888 }
889
890 if (( pReplacedImages != nullptr ) || ( pRemovedImages != nullptr ))
891 {
892 m_bModified = true;
893 m_bUserImageListModified[nIndex] = true;
894 }
895 }
896
897 // Notify listeners
898 uno::Reference< uno::XInterface > xOwner(m_pOwner);
899 if ( pRemovedImages != nullptr )
900 {
901 ConfigurationEvent aRemoveEvent;
902 aRemoveEvent.aInfo <<= nImageType;
903 aRemoveEvent.Accessor <<= xOwner;
904 aRemoveEvent.Source = xOwner;
905 aRemoveEvent.ResourceURL = m_aResourceString;
906 aRemoveEvent.Element <<= uno::Reference< XNameAccess >(
907 static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY );
908 implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove );
909 }
910 if ( pReplacedImages != nullptr )
911 {
912 ConfigurationEvent aReplaceEvent;
913 aReplaceEvent.aInfo <<= nImageType;
914 aReplaceEvent.Accessor <<= xOwner;
915 aReplaceEvent.Source = xOwner;
916 aReplaceEvent.ResourceURL = m_aResourceString;
917 aReplaceEvent.ReplacedElement = Any();
918 aReplaceEvent.Element <<= uno::Reference< XNameAccess >(
919 static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY );
920 implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace );
921 }
922}
923
924void ImageManagerImpl::insertImages( ::sal_Int16 nImageType, const Sequence< OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence )
925{
926 replaceImages(nImageType,aCommandURLSequence,aGraphicSequence);
927}
928
929// XUIConfigurationPersistence
930void ImageManagerImpl::reload()
931{
932 SolarMutexClearableGuard aGuard;
933
934 if ( m_bDisposed )
935 throw DisposedException();
936
937 CommandMap aOldUserCmdImageSet;
938 std::vector< OUString > aNewUserCmdImageSet;
939
940 if ( !m_bModified )
941 return;
942
943 for ( vcl::ImageType i : o3tl::enumrange<vcl::ImageType>() )
944 {
945 if ( !m_bDisposed && m_bUserImageListModified[i] )
946 {
947 std::vector< OUString > aOldUserCmdImageVector;
948 ImageList* pImageList = implts_getUserImageList(i);
949 pImageList->GetImageNames( aOldUserCmdImageVector );
950
951 // Fill hash map to speed up search afterwards
952 sal_uInt32 j( 0 );
953 const sal_uInt32 nOldCount = aOldUserCmdImageVector.size();
954 for ( j = 0; j < nOldCount; j++ )
955 aOldUserCmdImageSet.emplace( aOldUserCmdImageVector[j], false );
956
957 // Attention: This can make the old image list pointer invalid!
958 implts_loadUserImages( i, m_xUserImageStorage, m_xUserBitmapsStorage );
959 pImageList = implts_getUserImageList(i);
960 pImageList->GetImageNames( aNewUserCmdImageSet );
961
962 GraphicNameAccess* pInsertedImages( nullptr );
963 GraphicNameAccess* pReplacedImages( nullptr );
964 GraphicNameAccess* pRemovedImages( nullptr );
965
966 for (auto const& newUserCmdImage : aNewUserCmdImageSet)
967 {
968 CommandMap::iterator pIter = aOldUserCmdImageSet.find(newUserCmdImage);
969 if ( pIter != aOldUserCmdImageSet.end() )
970 {
971 pIter->second = true; // mark entry as replaced
972 if ( !pReplacedImages )
973 pReplacedImages = new GraphicNameAccess();
974 pReplacedImages->addElement( newUserCmdImage,
975 GetXGraphic(pImageList->GetImage(newUserCmdImage)) );
976 }
977 else
978 {
979 if ( !pInsertedImages )
980 pInsertedImages = new GraphicNameAccess();
981 pInsertedImages->addElement( newUserCmdImage,
982 GetXGraphic(pImageList->GetImage(newUserCmdImage)) );
983 }
984 }
985
986 // Search map for unmarked entries => they have been removed from the user list
987 // through this reload operation.
988 // We have to search the module and global image list!
989 rtl::Reference< GlobalImageList > rGlobalImageList;
990 CmdImageList* pDefaultImageList = nullptr;
991 if ( m_bUseGlobal )
992 {
993 rGlobalImageList = implts_getGlobalImageList();
994 pDefaultImageList = implts_getDefaultImageList();
995 }
996 uno::Reference<XGraphic> xEmptyGraphic;
997 for (auto const& oldUserCmdImage : aOldUserCmdImageSet)
998 {
999 if ( !oldUserCmdImage.second )
1000 {
1001 if ( m_bUseGlobal )
1002 {
1003 Image aImage = pDefaultImageList->getImageFromCommandURL( i, oldUserCmdImage.first );
1004 if ( !aImage )
1005 aImage = rGlobalImageList->getImageFromCommandURL( i, oldUserCmdImage.first );
1006
1007 if ( !aImage )
1008 {
1009 // No image in the module/global image list => remove user image
1010 if ( !pRemovedImages )
1011 pRemovedImages = new GraphicNameAccess();
1012 pRemovedImages->addElement( oldUserCmdImage.first, xEmptyGraphic );
1013 }
1014 else
1015 {
1016 // Image has been found in the module/global image list => replace user image
1017 if ( !pReplacedImages )
1018 pReplacedImages = new GraphicNameAccess();
1019 pReplacedImages->addElement(oldUserCmdImage.first, GetXGraphic(aImage));
1020 }
1021 } // if ( m_bUseGlobal )
1022 else
1023 {
1024 // No image in the user image list => remove user image
1025 if ( !pRemovedImages )
1026 pRemovedImages = new GraphicNameAccess();
1027 pRemovedImages->addElement( oldUserCmdImage.first, xEmptyGraphic );
1028 }
1029 }
1030 }
1031
1032 aGuard.clear();
1033
1034 // Now notify our listeners. Unlock mutex to prevent deadlocks
1035 uno::Reference< uno::XInterface > xOwner(m_pOwner);
1036 if ( pInsertedImages != nullptr )
1037 {
1038 ConfigurationEvent aInsertEvent;
1039 aInsertEvent.aInfo <<=static_cast<sal_uInt16>(i);
1040 aInsertEvent.Accessor <<= xOwner;
1041 aInsertEvent.Source = xOwner;
1042 aInsertEvent.ResourceURL = m_aResourceString;
1043 aInsertEvent.Element <<= uno::Reference< XNameAccess >(
1044 static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY );
1045 implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert );
1046 }
1047 if ( pReplacedImages != nullptr )
1048 {
1049 ConfigurationEvent aReplaceEvent;
1050 aReplaceEvent.aInfo <<= static_cast<sal_uInt16>(i);
1051 aReplaceEvent.Accessor <<= xOwner;
1052 aReplaceEvent.Source = xOwner;
1053 aReplaceEvent.ResourceURL = m_aResourceString;
1054 aReplaceEvent.ReplacedElement = Any();
1055 aReplaceEvent.Element <<= uno::Reference< XNameAccess >(
1056 static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY );
1057 implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace );
1058 }
1059 if ( pRemovedImages != nullptr )
1060 {
1061 ConfigurationEvent aRemoveEvent;
1062 aRemoveEvent.aInfo <<= static_cast<sal_uInt16>(i);
1063 aRemoveEvent.Accessor <<= xOwner;
1064 aRemoveEvent.Source = xOwner;
1065 aRemoveEvent.ResourceURL = m_aResourceString;
1066 aRemoveEvent.Element <<= uno::Reference< XNameAccess >(
1067 static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY );
1068 implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove );
1069 }
1070
1071 aGuard.clear();
1072 }
1073 }
1074}
1075
1076void ImageManagerImpl::store()
1077{
1078 SolarMutexGuard g;
1079
1080 if ( m_bDisposed )
1081 throw DisposedException();
1082
1083 if ( !m_bModified )
1084 return;
1085
1086 bool bWritten( false );
1087 for ( vcl::ImageType i : o3tl::enumrange<vcl::ImageType>() )
1088 {
1089 bool bSuccess = implts_storeUserImages(i, m_xUserImageStorage, m_xUserBitmapsStorage );
1090 if ( bSuccess )
1091 bWritten = true;
1092 m_bUserImageListModified[i] = false;
1093 }
1094
1095 if ( bWritten &&
1096 m_xUserConfigStorage.is() )
1097 {
1098 uno::Reference< XTransactedObject > xUserConfigStorageCommit( m_xUserConfigStorage, UNO_QUERY );
1099 if ( xUserConfigStorageCommit.is() )
1100 xUserConfigStorageCommit->commit();
1101 if ( m_xUserRootCommit.is() )
1102 m_xUserRootCommit->commit();
1103 }
1104
1105 m_bModified = false;
1106}
1107
1108void ImageManagerImpl::storeToStorage( const uno::Reference< XStorage >& Storage )
1109{
1110 SolarMutexGuard g;
1111
1112 if ( m_bDisposed )
1113 throw DisposedException();
1114
1115 if ( !(m_bModified && Storage.is()) )
1116 return;
1117
1118 long nModes = ElementModes::READWRITE;
1119
1120 uno::Reference< XStorage > xUserImageStorage = Storage->openStorageElement( IMAGE_FOLDER,
1121 nModes );
1122 if ( !xUserImageStorage.is() )
1123 return;
1124
1125 uno::Reference< XStorage > xUserBitmapsStorage = xUserImageStorage->openStorageElement( BITMAPS_FOLDER,
1126 nModes );
1127 for ( vcl::ImageType i : o3tl::enumrange<vcl::ImageType>() )
1128 {
1129 implts_getUserImageList(i);
1130 implts_storeUserImages( i, xUserImageStorage, xUserBitmapsStorage );
1131 }
1132
1133 uno::Reference< XTransactedObject > xTransaction( Storage, UNO_QUERY );
1134 if ( xTransaction.is() )
1135 xTransaction->commit();
1136}
1137
1138bool ImageManagerImpl::isModified() const
1139{
1140 SolarMutexGuard g;
1141 return m_bModified;
1142}
1143
1144bool ImageManagerImpl::isReadOnly() const
1145{
1146 SolarMutexGuard g;
1147 return m_bReadOnly;
1148}
1149// XUIConfiguration
1150void ImageManagerImpl::addConfigurationListener( const uno::Reference< css::ui::XUIConfigurationListener >& xListener )
1151{
1152 {
1153 SolarMutexGuard g;
1154
1155 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1156 if ( m_bDisposed )
1157 throw DisposedException();
1158 }
1159
1160 m_aListenerContainer.addInterface( cppu::UnoType<XUIConfigurationListener>::get(), xListener );
1161}
1162
1163void ImageManagerImpl::removeConfigurationListener( const uno::Reference< css::ui::XUIConfigurationListener >& xListener )
1164{
1165 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1166 m_aListenerContainer.removeInterface( cppu::UnoType<XUIConfigurationListener>::get(), xListener );
1167}
1168
1169void ImageManagerImpl::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
1170{
1171 ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer(
1172 cppu::UnoType<css::ui::XUIConfigurationListener>::get());
1173 if ( pContainer == nullptr )
1174 return;
1175
1176 ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
1177 while ( pIterator.hasMoreElements() )
1178 {
1179 try
1180 {
1181 switch ( eOp )
1182 {
1183 case NotifyOp_Replace:
1184 static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementReplaced( aEvent );
1185 break;
1186 case NotifyOp_Insert:
1187 static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementInserted( aEvent );
1188 break;
1189 case NotifyOp_Remove:
1190 static_cast< css::ui::XUIConfigurationListener*>(pIterator.next())->elementRemoved( aEvent );
1191 break;
1192 }
1193 }
1194 catch( const css::uno::RuntimeException& )
1195 {
1196 pIterator.remove();
1197 }
1198 }
1199}
1200void ImageManagerImpl::clear()
1201{
1202 SolarMutexGuard g;
1203
1204 for (auto & n : m_pUserImageList)
1205 {
1206 n.reset();
1207 }
1208}
1209} // namespace framework
1210
1211/* vim:set shiftwidth=4 softtabstop=4 expandtab: */