1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "imagemanagerimpl.hxx"
21 #include <xml/imagesconfiguration.hxx>
22 #include <uiconfiguration/graphicnameaccess.hxx>
25 #include "properties.h"
27 #include <com/sun/star/frame/theUICommandDescription.hpp>
28 #include <com/sun/star/ui/UIElementType.hpp>
29 #include <com/sun/star/ui/ConfigurationEvent.hpp>
30 #include <com/sun/star/lang/DisposedException.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/io/XStream.hpp>
35 #include <com/sun/star/ui/ImageType.hpp>
37 #include <vcl/svapp.hxx>
38 #include <rtl/ustrbuf.hxx>
39 #include <osl/mutex.hxx>
40 #include <comphelper/sequence.hxx>
41 #include <tools/urlobj.hxx>
42 #include <unotools/ucbstreamhelper.hxx>
43 #include <vcl/pngread.hxx>
44 #include <vcl/pngwrite.hxx>
45 #include <rtl/instance.hxx>
46 #include <svtools/miscopt.hxx>
47 #include <boost/scoped_ptr.hpp>
49 using ::com::sun::star::uno::Sequence
;
50 using ::com::sun::star::uno::XInterface
;
51 using ::com::sun::star::uno::Exception
;
52 using ::com::sun::star::uno::RuntimeException
;
53 using ::com::sun::star::uno::UNO_QUERY
;
54 using ::com::sun::star::uno::Any
;
55 using ::com::sun::star::uno::makeAny
;
56 using ::com::sun::star::graphic::XGraphic
;
57 using namespace ::com::sun::star
;
58 using namespace ::com::sun::star::io
;
59 using namespace ::com::sun::star::embed
;
60 using namespace ::com::sun::star::lang
;
61 using namespace ::com::sun::star::container
;
62 using namespace ::com::sun::star::beans
;
63 using namespace ::com::sun::star::ui
;
64 using namespace ::cppu
;
66 // Image sizes for our toolbars/menus
67 const sal_Int32 IMAGE_SIZE_NORMAL
= 16;
68 const sal_Int32 IMAGE_SIZE_LARGE
= 26;
69 const sal_Int16 MAX_IMAGETYPE_VALUE
= ::com::sun::star::ui::ImageType::SIZE_LARGE
;
71 static const char IMAGE_FOLDER
[] = "images";
72 static const char BITMAPS_FOLDER
[] = "Bitmaps";
74 static const char ModuleImageList
[] = "private:resource/images/moduleimages";
76 static const char* IMAGELIST_XML_FILE
[] =
82 static const char* BITMAP_FILE_NAMES
[] =
90 static GlobalImageList
* pGlobalImageList
= 0;
91 static const char* ImageType_Prefixes
[ImageType_COUNT
] =
97 typedef GraphicNameAccess CmdToXGraphicNameAccess
;
101 class theGlobalImageListMutex
102 : public rtl::Static
<osl::Mutex
, theGlobalImageListMutex
> {};
105 static osl::Mutex
& getGlobalImageListMutex()
107 return theGlobalImageListMutex::get();
110 static GlobalImageList
* getGlobalImageList( const uno::Reference
< uno::XComponentContext
>& rxContext
)
112 osl::MutexGuard
guard( getGlobalImageListMutex() );
114 if ( pGlobalImageList
== 0 )
115 pGlobalImageList
= new GlobalImageList( rxContext
);
117 return pGlobalImageList
;
120 static OUString
getCanonicalName( const OUString
& rFileName
)
122 bool bRemoveSlash( true );
123 sal_Int32 nLength
= rFileName
.getLength();
124 const sal_Unicode
* pString
= rFileName
.getStr();
126 OUStringBuffer
aBuf( nLength
);
127 for ( sal_Int32 i
= 0; i
< nLength
; i
++ )
129 const sal_Unicode c
= pString
[i
];
132 // map forbidden characters to escape
133 case '/' : if ( !bRemoveSlash
)
134 aBuf
.appendAscii( "%2f" );
136 case '\\': aBuf
.appendAscii( "%5c" ); bRemoveSlash
= false; break;
137 case ':' : aBuf
.appendAscii( "%3a" ); bRemoveSlash
= false; break;
138 case '*' : aBuf
.appendAscii( "%2a" ); bRemoveSlash
= false; break;
139 case '?' : aBuf
.appendAscii( "%3f" ); bRemoveSlash
= false; break;
140 case '<' : aBuf
.appendAscii( "%3c" ); bRemoveSlash
= false; break;
141 case '>' : aBuf
.appendAscii( "%3e" ); bRemoveSlash
= false; break;
142 case '|' : aBuf
.appendAscii( "%7c" ); bRemoveSlash
= false; break;
143 default: aBuf
.append( c
); bRemoveSlash
= false;
146 return aBuf
.makeStringAndClear();
149 CmdImageList::CmdImageList( const uno::Reference
< uno::XComponentContext
>& rxContext
, const OUString
& aModuleIdentifier
) :
150 m_bVectorInit( false ),
151 m_aModuleIdentifier( aModuleIdentifier
),
152 m_xContext( rxContext
),
153 m_sIconTheme( SvtMiscOptions().GetIconTheme() )
155 for ( sal_Int32 n
=0; n
< ImageType_COUNT
; n
++ )
159 CmdImageList::~CmdImageList()
161 for ( sal_Int32 n
=0; n
< ImageType_COUNT
; n
++ )
162 delete m_pImageList
[n
];
165 void CmdImageList::impl_fillCommandToImageNameMap()
167 SAL_INFO( "fwk", "framework: CmdImageList::impl_fillCommandToImageNameMap" );
169 if ( !m_bVectorInit
)
171 const OUString
aCommandImageList( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST
);
172 Sequence
< OUString
> aCmdImageSeq
;
173 uno::Reference
< XNameAccess
> xCmdDesc
= frame::theUICommandDescription::get( m_xContext
);
175 if ( !m_aModuleIdentifier
.isEmpty() )
177 // If we have a module identifier - use to retrieve the command image name list from it.
178 // Otherwise we will use the global command image list
181 xCmdDesc
->getByName( m_aModuleIdentifier
) >>= xCmdDesc
;
183 xCmdDesc
->getByName( aCommandImageList
) >>= aCmdImageSeq
;
185 catch ( const NoSuchElementException
& )
187 // Module unknown we will work with an empty command image list!
196 xCmdDesc
->getByName( aCommandImageList
) >>= aCmdImageSeq
;
198 catch ( const NoSuchElementException
& )
201 catch ( const WrappedTargetException
& )
206 // We have to map commands which uses special characters like '/',':','?','\','<'.'>','|'
207 OUString aExt
= ".png";
208 m_aImageCommandNameVector
.resize(aCmdImageSeq
.getLength() );
209 m_aImageNameVector
.resize( aCmdImageSeq
.getLength() );
211 ::std::copy( aCmdImageSeq
.getConstArray(),
212 aCmdImageSeq
.getConstArray()+aCmdImageSeq
.getLength(),
213 m_aImageCommandNameVector
.begin() );
215 // Create a image name vector that must be provided to the vcl imagelist. We also need
216 // a command to image name map to speed up access time for image retrieval.
217 OUString
aUNOString( ".uno:" );
218 OUString aEmptyString
;
219 const sal_uInt32 nCount
= m_aImageCommandNameVector
.size();
220 for ( sal_uInt32 i
= 0; i
< nCount
; i
++ )
222 OUString
aCommandName( m_aImageCommandNameVector
[i
] );
225 if ( aCommandName
.indexOf( aUNOString
) != 0 )
227 INetURLObject
aUrlObject( aCommandName
, INetURLObject::ENCODE_ALL
);
228 aImageName
= aUrlObject
.GetURLPath();
229 aImageName
= getCanonicalName( aImageName
); // convert to valid filename
233 // just remove the schema
234 if ( aCommandName
.getLength() > 5 )
235 aImageName
= aCommandName
.copy( 5 );
237 aImageName
= aEmptyString
;
239 // Search for query part.
240 if ( aImageName
.indexOf('?') != -1 )
241 aImageName
= getCanonicalName( aImageName
); // convert to valid filename
243 // Image names are not case-dependent. Always use lower case characters to
246 aImageName
= aImageName
.toAsciiLowerCase();
248 m_aImageNameVector
[i
] = aImageName
;
249 m_aCommandToImageNameMap
.insert( CommandToImageNameMap::value_type( aCommandName
, aImageName
));
252 m_bVectorInit
= true;
256 ImageList
* CmdImageList::impl_getImageList( sal_Int16 nImageType
)
258 SvtMiscOptions aMiscOptions
;
260 const OUString
& rIconTheme
= aMiscOptions
.GetIconTheme();
261 if ( rIconTheme
!= m_sIconTheme
)
263 m_sIconTheme
= rIconTheme
;
264 for ( sal_Int32 n
=0; n
< ImageType_COUNT
; n
++ )
265 delete m_pImageList
[n
], m_pImageList
[n
] = NULL
;
268 if ( !m_pImageList
[nImageType
] )
270 m_pImageList
[nImageType
] = new ImageList( m_aImageNameVector
,
271 OUString::createFromAscii( ImageType_Prefixes
[nImageType
] ) );
274 return m_pImageList
[nImageType
];
279 Image
CmdImageList::getImageFromCommandURL( sal_Int16 nImageType
, const OUString
& rCommandURL
)
281 impl_fillCommandToImageNameMap();
282 CommandToImageNameMap::const_iterator pIter
= m_aCommandToImageNameMap
.find( rCommandURL
);
283 if ( pIter
!= m_aCommandToImageNameMap
.end() )
285 ImageList
* pImageList
= impl_getImageList( nImageType
);
286 return pImageList
->GetImage( pIter
->second
);
292 bool CmdImageList::hasImage( sal_Int16
/*nImageType*/, const OUString
& rCommandURL
)
294 impl_fillCommandToImageNameMap();
295 CommandToImageNameMap::const_iterator pIter
= m_aCommandToImageNameMap
.find( rCommandURL
);
296 if ( pIter
!= m_aCommandToImageNameMap
.end() )
302 ::std::vector
< OUString
>& CmdImageList::getImageNames()
304 return impl_getImageNameVector();
307 ::std::vector
< OUString
>& CmdImageList::getImageCommandNames()
309 return impl_getImageCommandNameVector();
312 GlobalImageList::GlobalImageList( const uno::Reference
< uno::XComponentContext
>& rxContext
) :
313 CmdImageList( rxContext
, OUString() )
317 GlobalImageList::~GlobalImageList()
319 osl::MutexGuard
guard( getGlobalImageListMutex() );
320 // remove global pointer as we destroy the object now
321 pGlobalImageList
= 0;
324 Image
GlobalImageList::getImageFromCommandURL( sal_Int16 nImageType
, const OUString
& rCommandURL
)
326 osl::MutexGuard
guard( getGlobalImageListMutex() );
327 return CmdImageList::getImageFromCommandURL( nImageType
, rCommandURL
);
330 bool GlobalImageList::hasImage( sal_Int16 nImageType
, const OUString
& rCommandURL
)
332 osl::MutexGuard
guard( getGlobalImageListMutex() );
333 return CmdImageList::hasImage( nImageType
, rCommandURL
);
336 ::std::vector
< OUString
>& GlobalImageList::getImageNames()
338 osl::MutexGuard
guard( getGlobalImageListMutex() );
339 return impl_getImageNameVector();
342 ::std::vector
< OUString
>& GlobalImageList::getImageCommandNames()
344 osl::MutexGuard
guard( getGlobalImageListMutex() );
345 return impl_getImageCommandNameVector();
348 static bool implts_checkAndScaleGraphic( uno::Reference
< XGraphic
>& rOutGraphic
, const uno::Reference
< XGraphic
>& rInGraphic
, sal_Int16 nImageType
)
350 static Size
aNormSize( IMAGE_SIZE_NORMAL
, IMAGE_SIZE_NORMAL
);
351 static Size
aLargeSize( IMAGE_SIZE_LARGE
, IMAGE_SIZE_LARGE
);
353 if ( !rInGraphic
.is() )
355 rOutGraphic
= Image().GetXGraphic();
359 // Check size and scale it
360 Image
aImage( rInGraphic
);
361 Size aSize
= aImage
.GetSizePixel();
362 bool bMustScale( false );
364 if ( nImageType
== ImageType_Color_Large
)
365 bMustScale
= ( aSize
!= aLargeSize
);
367 bMustScale
= ( aSize
!= aNormSize
);
371 BitmapEx aBitmap
= aImage
.GetBitmapEx();
372 aBitmap
.Scale( aNormSize
);
373 aImage
= Image( aBitmap
);
374 rOutGraphic
= aImage
.GetXGraphic();
377 rOutGraphic
= rInGraphic
;
381 static sal_Int16
implts_convertImageTypeToIndex( sal_Int16 nImageType
)
383 sal_Int16
nIndex( 0 );
384 if ( nImageType
& ::com::sun::star::ui::ImageType::SIZE_LARGE
)
389 ImageList
* ImageManagerImpl::implts_getUserImageList( ImageType nImageType
)
392 if ( !m_pUserImageList
[nImageType
] )
393 implts_loadUserImages( nImageType
, m_xUserImageStorage
, m_xUserBitmapsStorage
);
395 return m_pUserImageList
[nImageType
];
398 void ImageManagerImpl::implts_initialize()
400 // Initialize the top-level structures with the storage data
401 if ( m_xUserConfigStorage
.is() )
403 long nModes
= m_bReadOnly
? ElementModes::READ
: ElementModes::READWRITE
;
407 m_xUserImageStorage
= m_xUserConfigStorage
->openStorageElement( OUString(IMAGE_FOLDER
),
409 if ( m_xUserImageStorage
.is() )
411 m_xUserBitmapsStorage
= m_xUserImageStorage
->openStorageElement( OUString(BITMAPS_FOLDER
),
415 catch ( const ::com::sun::star::container::NoSuchElementException
& )
418 catch ( const ::com::sun::star::embed::InvalidStorageException
& )
421 catch ( const ::com::sun::star::lang::IllegalArgumentException
& )
424 catch ( const ::com::sun::star::io::IOException
& )
427 catch ( const ::com::sun::star::embed::StorageWrappedTargetException
& )
433 bool ImageManagerImpl::implts_loadUserImages(
434 ImageType nImageType
,
435 const uno::Reference
< XStorage
>& xUserImageStorage
,
436 const uno::Reference
< XStorage
>& xUserBitmapsStorage
)
440 if ( xUserImageStorage
.is() && xUserBitmapsStorage
.is() )
444 uno::Reference
< XStream
> xStream
= xUserImageStorage
->openStreamElement( OUString::createFromAscii( IMAGELIST_XML_FILE
[nImageType
] ),
445 ElementModes::READ
);
446 uno::Reference
< XInputStream
> xInputStream
= xStream
->getInputStream();
448 ImageListsDescriptor aUserImageListInfo
;
449 ImagesConfiguration::LoadImages( m_xContext
,
451 aUserImageListInfo
);
452 if (( aUserImageListInfo
.pImageList
!= 0 ) &&
453 ( !aUserImageListInfo
.pImageList
->empty() ))
455 ImageListItemDescriptor
* pList
= &aUserImageListInfo
.pImageList
->front();
456 sal_Int32 nCount
= pList
->pImageItemList
->size();
457 std::vector
< OUString
> aUserImagesVector
;
458 aUserImagesVector
.reserve(nCount
);
459 for ( sal_uInt16 i
=0; i
< nCount
; i
++ )
461 const ImageItemDescriptor
* pItem
= &(*pList
->pImageItemList
)[i
];
462 aUserImagesVector
.push_back( pItem
->aCommandURL
);
465 uno::Reference
< XStream
> xBitmapStream
= xUserBitmapsStorage
->openStreamElement(
466 OUString::createFromAscii( BITMAP_FILE_NAMES
[nImageType
] ),
467 ElementModes::READ
);
469 if ( xBitmapStream
.is() )
471 BitmapEx aUserBitmap
;
473 boost::scoped_ptr
<SvStream
> pSvStream(utl::UcbStreamHelper::CreateStream( xBitmapStream
));
474 vcl::PNGReader
aPngReader( *pSvStream
);
475 aUserBitmap
= aPngReader
.Read();
478 // Delete old image list and create a new one from the read bitmap
479 delete m_pUserImageList
[nImageType
];
480 m_pUserImageList
[nImageType
] = new ImageList();
481 m_pUserImageList
[nImageType
]->InsertFromHorizontalStrip
482 ( aUserBitmap
, aUserImagesVector
);
487 catch ( const ::com::sun::star::container::NoSuchElementException
& )
490 catch ( const ::com::sun::star::embed::InvalidStorageException
& )
493 catch ( const ::com::sun::star::lang::IllegalArgumentException
& )
496 catch ( const ::com::sun::star::io::IOException
& )
499 catch ( const ::com::sun::star::embed::StorageWrappedTargetException
& )
504 // Destroy old image list - create a new empty one
505 delete m_pUserImageList
[nImageType
];
506 m_pUserImageList
[nImageType
] = new ImageList
;
511 bool ImageManagerImpl::implts_storeUserImages(
512 ImageType nImageType
,
513 const uno::Reference
< XStorage
>& xUserImageStorage
,
514 const uno::Reference
< XStorage
>& xUserBitmapsStorage
)
520 ImageList
* pImageList
= implts_getUserImageList( nImageType
);
521 if ( pImageList
->GetImageCount() > 0 )
523 ImageListsDescriptor aUserImageListInfo
;
524 aUserImageListInfo
.pImageList
= new ImageListDescriptor
;
526 ImageListItemDescriptor
* pList
= new ImageListItemDescriptor
;
527 aUserImageListInfo
.pImageList
->push_back( pList
);
529 pList
->pImageItemList
= new ImageItemListDescriptor
;
530 for ( sal_uInt16 i
=0; i
< pImageList
->GetImageCount(); i
++ )
532 ImageItemDescriptor
* pItem
= new ::framework::ImageItemDescriptor
;
535 pItem
->aCommandURL
= pImageList
->GetImageName( i
);
536 pList
->pImageItemList
->push_back( pItem
);
539 pList
->aURL
= "Bitmaps/" + OUString::createFromAscii(BITMAP_FILE_NAMES
[nImageType
]);
541 uno::Reference
< XTransactedObject
> xTransaction
;
542 uno::Reference
< XOutputStream
> xOutputStream
;
543 uno::Reference
< XStream
> xStream
= xUserImageStorage
->openStreamElement( OUString::createFromAscii( IMAGELIST_XML_FILE
[nImageType
] ),
544 ElementModes::WRITE
|ElementModes::TRUNCATE
);
547 uno::Reference
< XStream
> xBitmapStream
=
548 xUserBitmapsStorage
->openStreamElement( OUString::createFromAscii( BITMAP_FILE_NAMES
[nImageType
] ),
549 ElementModes::WRITE
|ElementModes::TRUNCATE
);
550 if ( xBitmapStream
.is() )
553 boost::scoped_ptr
<SvStream
> pSvStream(utl::UcbStreamHelper::CreateStream( xBitmapStream
));
554 vcl::PNGWriter
aPngWriter( pImageList
->GetAsHorizontalStrip() );
555 aPngWriter
.Write( *pSvStream
);
558 // Commit user bitmaps storage
559 xTransaction
= uno::Reference
< XTransactedObject
>( xUserBitmapsStorage
, UNO_QUERY
);
560 if ( xTransaction
.is() )
561 xTransaction
->commit();
564 xOutputStream
= xStream
->getOutputStream();
565 if ( xOutputStream
.is() )
566 ImagesConfiguration::StoreImages( m_xContext
, xOutputStream
, aUserImageListInfo
);
568 // Commit user image storage
569 xTransaction
= uno::Reference
< XTransactedObject
>( xUserImageStorage
, UNO_QUERY
);
570 if ( xTransaction
.is() )
571 xTransaction
->commit();
578 // Remove the streams from the storage, if we have no data. We have to catch
579 // the NoSuchElementException as it can be possible that there is no stream at all!
582 xUserImageStorage
->removeElement( OUString::createFromAscii( IMAGELIST_XML_FILE
[nImageType
] ));
584 catch ( const ::com::sun::star::container::NoSuchElementException
& )
590 xUserBitmapsStorage
->removeElement( OUString::createFromAscii( BITMAP_FILE_NAMES
[nImageType
] ));
592 catch ( const ::com::sun::star::container::NoSuchElementException
& )
596 uno::Reference
< XTransactedObject
> xTransaction
;
598 // Commit user image storage
599 xTransaction
= uno::Reference
< XTransactedObject
>( xUserImageStorage
, UNO_QUERY
);
600 if ( xTransaction
.is() )
601 xTransaction
->commit();
603 // Commit user bitmaps storage
604 xTransaction
= uno::Reference
< XTransactedObject
>( xUserBitmapsStorage
, UNO_QUERY
);
605 if ( xTransaction
.is() )
606 xTransaction
->commit();
615 const rtl::Reference
< GlobalImageList
>& ImageManagerImpl::implts_getGlobalImageList()
619 if ( !m_pGlobalImageList
.is() )
620 m_pGlobalImageList
= getGlobalImageList( m_xContext
);
621 return m_pGlobalImageList
;
624 CmdImageList
* ImageManagerImpl::implts_getDefaultImageList()
628 if ( !m_pDefaultImageList
)
629 m_pDefaultImageList
= new CmdImageList( m_xContext
, m_aModuleIdentifier
);
631 return m_pDefaultImageList
;
634 ImageManagerImpl::ImageManagerImpl( const uno::Reference
< uno::XComponentContext
>& rxContext
,::cppu::OWeakObject
* pOwner
,bool _bUseGlobal
) :
635 m_xContext( rxContext
)
637 , m_pDefaultImageList( 0 )
638 , m_aXMLPostfix( ".xml" )
639 , m_aResourceString( ModuleImageList
)
640 , m_aListenerContainer( m_mutex
)
641 , m_bUseGlobal(_bUseGlobal
)
642 , m_bReadOnly( true )
643 , m_bInitialized( false )
644 , m_bModified( false )
645 , m_bConfigRead( false )
646 , m_bDisposed( false )
648 for ( sal_Int32 n
=0; n
< ImageType_COUNT
; n
++ )
650 m_pUserImageList
[n
] = 0;
651 m_bUserImageListModified
[n
] = false;
655 ImageManagerImpl::~ImageManagerImpl()
660 void ImageManagerImpl::dispose()
662 uno::Reference
< uno::XInterface
> xOwner(static_cast< OWeakObject
* >(m_pOwner
));
663 css::lang::EventObject
aEvent( xOwner
);
664 m_aListenerContainer
.disposeAndClear( aEvent
);
668 m_xUserConfigStorage
.clear();
669 m_xUserImageStorage
.clear();
670 m_xUserRootCommit
.clear();
671 m_bConfigRead
= false;
675 // delete user and default image list on dispose
676 for ( sal_Int32 n
=0; n
< ImageType_COUNT
; n
++ )
678 delete m_pUserImageList
[n
];
679 m_pUserImageList
[n
] = 0;
681 delete m_pDefaultImageList
;
682 m_pDefaultImageList
= 0;
686 void ImageManagerImpl::addEventListener( const uno::Reference
< XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
)
691 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
693 throw DisposedException();
696 m_aListenerContainer
.addInterface( cppu::UnoType
<XEventListener
>::get(), xListener
);
699 void ImageManagerImpl::removeEventListener( const uno::Reference
< XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
)
701 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
702 m_aListenerContainer
.removeInterface( cppu::UnoType
<XEventListener
>::get(), xListener
);
706 void ImageManagerImpl::initialize( const Sequence
< Any
>& aArguments
)
710 if ( !m_bInitialized
)
712 for ( sal_Int32 n
= 0; n
< aArguments
.getLength(); n
++ )
714 PropertyValue aPropValue
;
715 if ( aArguments
[n
] >>= aPropValue
)
717 if ( aPropValue
.Name
== "UserConfigStorage" )
719 aPropValue
.Value
>>= m_xUserConfigStorage
;
721 else if ( aPropValue
.Name
== "ModuleIdentifier" )
723 aPropValue
.Value
>>= m_aModuleIdentifier
;
725 else if ( aPropValue
.Name
== "UserRootCommit" )
727 aPropValue
.Value
>>= m_xUserRootCommit
;
732 if ( m_xUserConfigStorage
.is() )
734 uno::Reference
< XPropertySet
> xPropSet( m_xUserConfigStorage
, UNO_QUERY
);
738 if ( xPropSet
->getPropertyValue("OpenMode") >>= nOpenMode
)
739 m_bReadOnly
= !( nOpenMode
& ElementModes::WRITE
);
745 m_bInitialized
= true;
750 void ImageManagerImpl::reset()
751 throw (::com::sun::star::uno::RuntimeException
, lang::IllegalAccessException
)
755 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
757 throw DisposedException();
759 std::vector
< OUString
> aUserImageNames
;
761 for ( sal_Int32 i
= 0; i
< ImageType_COUNT
; i
++ )
763 aUserImageNames
.clear();
764 ImageList
* pImageList
= implts_getUserImageList( ImageType(i
));
765 pImageList
->GetImageNames( aUserImageNames
);
767 Sequence
< OUString
> aRemoveList( aUserImageNames
.size() );
768 const sal_uInt32 nCount
= aUserImageNames
.size();
769 for ( sal_uInt32 j
= 0; j
< nCount
; j
++ )
770 aRemoveList
[j
] = aUserImageNames
[j
];
773 removeImages( sal_Int16( i
), aRemoveList
);
774 m_bUserImageListModified
[i
] = true;
780 Sequence
< OUString
> ImageManagerImpl::getAllImageNames( ::sal_Int16 nImageType
)
781 throw (::com::sun::star::uno::RuntimeException
)
785 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
787 throw DisposedException();
789 ImageNameMap aImageCmdNameMap
;
791 sal_Int16 nIndex
= implts_convertImageTypeToIndex( nImageType
);
796 rtl::Reference
< GlobalImageList
> rGlobalImageList
= implts_getGlobalImageList();
798 const std::vector
< OUString
>& rGlobalImageNameVector
= rGlobalImageList
->getImageCommandNames();
799 const sal_uInt32 nGlobalCount
= rGlobalImageNameVector
.size();
800 for ( i
= 0; i
< nGlobalCount
; i
++ )
801 aImageCmdNameMap
.insert( ImageNameMap::value_type( rGlobalImageNameVector
[i
], sal_True
));
803 const std::vector
< OUString
>& rModuleImageNameVector
= implts_getDefaultImageList()->getImageCommandNames();
804 const sal_uInt32 nModuleCount
= rModuleImageNameVector
.size();
805 for ( i
= 0; i
< nModuleCount
; i
++ )
806 aImageCmdNameMap
.insert( ImageNameMap::value_type( rModuleImageNameVector
[i
], sal_True
));
809 ImageList
* pImageList
= implts_getUserImageList( ImageType( nIndex
));
810 std::vector
< OUString
> rUserImageNames
;
811 pImageList
->GetImageNames( rUserImageNames
);
812 const sal_uInt32 nUserCount
= rUserImageNames
.size();
813 for ( i
= 0; i
< nUserCount
; i
++ )
814 aImageCmdNameMap
.insert( ImageNameMap::value_type( rUserImageNames
[i
], sal_True
));
816 Sequence
< OUString
> aImageNameSeq( aImageCmdNameMap
.size() );
817 ImageNameMap::const_iterator pIter
;
819 for ( pIter
= aImageCmdNameMap
.begin(); pIter
!= aImageCmdNameMap
.end(); ++pIter
)
820 aImageNameSeq
[i
++] = pIter
->first
;
822 return aImageNameSeq
;
825 bool ImageManagerImpl::hasImage( ::sal_Int16 nImageType
, const OUString
& aCommandURL
)
826 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
830 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
832 throw DisposedException();
834 if (( nImageType
< 0 ) || ( nImageType
> MAX_IMAGETYPE_VALUE
))
835 throw IllegalArgumentException();
837 sal_Int16 nIndex
= implts_convertImageTypeToIndex( nImageType
);
838 if ( m_bUseGlobal
&& implts_getGlobalImageList()->hasImage( nIndex
, aCommandURL
))
842 if ( m_bUseGlobal
&& implts_getDefaultImageList()->hasImage( nIndex
, aCommandURL
))
847 ImageList
* pImageList
= implts_getUserImageList( ImageType( nIndex
));
849 return ( pImageList
->GetImagePos( aCommandURL
) != IMAGELIST_IMAGE_NOTFOUND
);
856 Sequence
< uno::Reference
< XGraphic
> > ImageManagerImpl::getImages(
857 ::sal_Int16 nImageType
,
858 const Sequence
< OUString
>& aCommandURLSequence
)
859 throw ( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
863 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
865 throw DisposedException();
867 if (( nImageType
< 0 ) || ( nImageType
> MAX_IMAGETYPE_VALUE
))
868 throw IllegalArgumentException();
870 Sequence
< uno::Reference
< XGraphic
> > aGraphSeq( aCommandURLSequence
.getLength() );
872 const OUString
* aStrArray
= aCommandURLSequence
.getConstArray();
874 sal_Int16 nIndex
= implts_convertImageTypeToIndex( nImageType
);
875 rtl::Reference
< GlobalImageList
> rGlobalImageList
;
876 CmdImageList
* pDefaultImageList
= NULL
;
879 rGlobalImageList
= implts_getGlobalImageList();
880 pDefaultImageList
= implts_getDefaultImageList();
882 ImageList
* pUserImageList
= implts_getUserImageList( ImageType( nIndex
));
884 // We have to search our image list in the following order:
885 // 1. user image list (read/write)
886 // 2. module image list (read)
887 // 3. global image list (read)
888 for ( sal_Int32 n
= 0; n
< aCommandURLSequence
.getLength(); n
++ )
890 Image aImage
= pUserImageList
->GetImage( aStrArray
[n
] );
891 if ( !aImage
&& m_bUseGlobal
)
893 aImage
= pDefaultImageList
->getImageFromCommandURL( nIndex
, aStrArray
[n
] );
895 aImage
= rGlobalImageList
->getImageFromCommandURL( nIndex
, aStrArray
[n
] );
898 aGraphSeq
[n
] = aImage
.GetXGraphic();
904 void ImageManagerImpl::replaceImages(
905 ::sal_Int16 nImageType
,
906 const Sequence
< OUString
>& aCommandURLSequence
,
907 const Sequence
< uno::Reference
< XGraphic
> >& aGraphicsSequence
)
908 throw (css::lang::IllegalArgumentException
,
909 css::lang::IllegalAccessException
,
910 css::uno::RuntimeException
,
913 CmdToXGraphicNameAccess
* pInsertedImages( 0 );
914 CmdToXGraphicNameAccess
* pReplacedImages( 0 );
919 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
921 throw DisposedException();
923 if (( aCommandURLSequence
.getLength() != aGraphicsSequence
.getLength() ) ||
924 (( nImageType
< 0 ) || ( nImageType
> MAX_IMAGETYPE_VALUE
)))
925 throw IllegalArgumentException();
928 throw IllegalAccessException();
930 sal_Int16 nIndex
= implts_convertImageTypeToIndex( nImageType
);
931 ImageList
* pImageList
= implts_getUserImageList( ImageType( nIndex
));
933 uno::Reference
< XGraphic
> xGraphic
;
934 for ( sal_Int32 i
= 0; i
< aCommandURLSequence
.getLength(); i
++ )
936 // Check size and scale. If we don't have any graphics ignore it
937 if ( !implts_checkAndScaleGraphic( xGraphic
, aGraphicsSequence
[i
], nIndex
))
940 sal_uInt16 nPos
= pImageList
->GetImagePos( aCommandURLSequence
[i
] );
941 if ( nPos
== IMAGELIST_IMAGE_NOTFOUND
)
943 pImageList
->AddImage(aCommandURLSequence
[i
], Image(xGraphic
));
944 if ( !pInsertedImages
)
945 pInsertedImages
= new CmdToXGraphicNameAccess();
946 pInsertedImages
->addElement( aCommandURLSequence
[i
], xGraphic
);
950 pImageList
->ReplaceImage(aCommandURLSequence
[i
], Image(xGraphic
));
951 if ( !pReplacedImages
)
952 pReplacedImages
= new CmdToXGraphicNameAccess();
953 pReplacedImages
->addElement( aCommandURLSequence
[i
], xGraphic
);
957 if (( pInsertedImages
!= 0 ) || ( pReplacedImages
!= 0 ))
960 m_bUserImageListModified
[nIndex
] = true;
964 uno::Reference
< uno::XInterface
> xOwner(static_cast< OWeakObject
* >(m_pOwner
));
966 if ( pInsertedImages
!= 0 )
968 ConfigurationEvent aInsertEvent
;
969 aInsertEvent
.aInfo
<<= nImageType
;
970 aInsertEvent
.Accessor
<<= xOwner
;
971 aInsertEvent
.Source
= xOwner
;
972 aInsertEvent
.ResourceURL
= m_aResourceString
;
973 aInsertEvent
.Element
= uno::makeAny( uno::Reference
< XNameAccess
>(
974 static_cast< OWeakObject
*>( pInsertedImages
), UNO_QUERY
));
975 implts_notifyContainerListener( aInsertEvent
, NotifyOp_Insert
);
977 if ( pReplacedImages
!= 0 )
979 ConfigurationEvent aReplaceEvent
;
980 aReplaceEvent
.aInfo
<<= nImageType
;
981 aReplaceEvent
.Accessor
<<= xOwner
;
982 aReplaceEvent
.Source
= xOwner
;
983 aReplaceEvent
.ResourceURL
= m_aResourceString
;
984 aReplaceEvent
.ReplacedElement
= Any();
985 aReplaceEvent
.Element
= uno::makeAny( uno::Reference
< XNameAccess
>(
986 static_cast< OWeakObject
*>( pReplacedImages
), UNO_QUERY
));
987 implts_notifyContainerListener( aReplaceEvent
, NotifyOp_Replace
);
991 void ImageManagerImpl::removeImages( ::sal_Int16 nImageType
, const Sequence
< OUString
>& aCommandURLSequence
)
992 throw ( ::com::sun::star::lang::IllegalArgumentException
,
993 ::com::sun::star::lang::IllegalAccessException
,
994 ::com::sun::star::uno::RuntimeException
)
996 CmdToXGraphicNameAccess
* pRemovedImages( 0 );
997 CmdToXGraphicNameAccess
* pReplacedImages( 0 );
1002 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1004 throw DisposedException();
1006 if (( nImageType
< 0 ) || ( nImageType
> MAX_IMAGETYPE_VALUE
))
1007 throw IllegalArgumentException();
1010 throw IllegalAccessException();
1012 sal_Int16 nIndex
= implts_convertImageTypeToIndex( nImageType
);
1013 rtl::Reference
< GlobalImageList
> rGlobalImageList
;
1014 CmdImageList
* pDefaultImageList
= NULL
;
1017 rGlobalImageList
= implts_getGlobalImageList();
1018 pDefaultImageList
= implts_getDefaultImageList();
1020 ImageList
* pImageList
= implts_getUserImageList( ImageType( nIndex
));
1021 uno::Reference
< XGraphic
> xEmptyGraphic( Image().GetXGraphic() );
1023 for ( sal_Int32 i
= 0; i
< aCommandURLSequence
.getLength(); i
++ )
1025 sal_uInt16 nPos
= pImageList
->GetImagePos( aCommandURLSequence
[i
] );
1026 if ( nPos
!= IMAGELIST_IMAGE_NOTFOUND
)
1028 Image aImage
= pImageList
->GetImage( nPos
);
1029 sal_uInt16 nId
= pImageList
->GetImageId( nPos
);
1030 pImageList
->RemoveImage( nId
);
1034 // Check, if we have a image in our module/global image list. If we find one =>
1035 // this is a replace instead of a remove operation!
1036 Image aNewImage
= pDefaultImageList
->getImageFromCommandURL( nIndex
, aCommandURLSequence
[i
] );
1038 aNewImage
= rGlobalImageList
->getImageFromCommandURL( nIndex
, aCommandURLSequence
[i
] );
1041 if ( !pRemovedImages
)
1042 pRemovedImages
= new CmdToXGraphicNameAccess();
1043 pRemovedImages
->addElement( aCommandURLSequence
[i
], xEmptyGraphic
);
1047 if ( !pReplacedImages
)
1048 pReplacedImages
= new CmdToXGraphicNameAccess();
1049 pReplacedImages
->addElement( aCommandURLSequence
[i
], aNewImage
.GetXGraphic() );
1051 } // if ( m_bUseGlobal )
1054 if ( !pRemovedImages
)
1055 pRemovedImages
= new CmdToXGraphicNameAccess();
1056 pRemovedImages
->addElement( aCommandURLSequence
[i
], xEmptyGraphic
);
1061 if (( pReplacedImages
!= 0 ) || ( pRemovedImages
!= 0 ))
1064 m_bUserImageListModified
[nIndex
] = true;
1069 uno::Reference
< uno::XInterface
> xOwner(static_cast< OWeakObject
* >(m_pOwner
));
1070 if ( pRemovedImages
!= 0 )
1072 ConfigurationEvent aRemoveEvent
;
1073 aRemoveEvent
.aInfo
= uno::makeAny( nImageType
);
1074 aRemoveEvent
.Accessor
= uno::makeAny( xOwner
);
1075 aRemoveEvent
.Source
= xOwner
;
1076 aRemoveEvent
.ResourceURL
= m_aResourceString
;
1077 aRemoveEvent
.Element
= uno::makeAny( uno::Reference
< XNameAccess
>(
1078 static_cast< OWeakObject
*>( pRemovedImages
), UNO_QUERY
));
1079 implts_notifyContainerListener( aRemoveEvent
, NotifyOp_Remove
);
1081 if ( pReplacedImages
!= 0 )
1083 ConfigurationEvent aReplaceEvent
;
1084 aReplaceEvent
.aInfo
= uno::makeAny( nImageType
);
1085 aReplaceEvent
.Accessor
= uno::makeAny( xOwner
);
1086 aReplaceEvent
.Source
= xOwner
;
1087 aReplaceEvent
.ResourceURL
= m_aResourceString
;
1088 aReplaceEvent
.ReplacedElement
= Any();
1089 aReplaceEvent
.Element
= uno::makeAny( uno::Reference
< XNameAccess
>(
1090 static_cast< OWeakObject
*>( pReplacedImages
), UNO_QUERY
));
1091 implts_notifyContainerListener( aReplaceEvent
, NotifyOp_Replace
);
1095 void ImageManagerImpl::insertImages( ::sal_Int16 nImageType
, const Sequence
< OUString
>& aCommandURLSequence
, const Sequence
< uno::Reference
< XGraphic
> >& aGraphicSequence
)
1096 throw ( ::com::sun::star::container::ElementExistException
,
1097 ::com::sun::star::lang::IllegalArgumentException
,
1098 ::com::sun::star::lang::IllegalAccessException
,
1099 ::com::sun::star::uno::RuntimeException
)
1101 replaceImages(nImageType
,aCommandURLSequence
,aGraphicSequence
);
1104 // XUIConfigurationPersistence
1105 void ImageManagerImpl::reload()
1106 throw (css::uno::Exception
,
1107 css::uno::RuntimeException
,
1110 SolarMutexClearableGuard aGuard
;
1113 throw DisposedException();
1115 CommandMap aOldUserCmdImageSet
;
1116 std::vector
< OUString
> aNewUserCmdImageSet
;
1120 for ( sal_Int16 i
= 0; i
< sal_Int16( ImageType_COUNT
); i
++ )
1122 if ( !m_bDisposed
&& m_bUserImageListModified
[i
] )
1124 std::vector
< OUString
> aOldUserCmdImageVector
;
1125 ImageList
* pImageList
= implts_getUserImageList( (ImageType
)i
);
1126 pImageList
->GetImageNames( aOldUserCmdImageVector
);
1128 // Fill hash map to speed up search afterwards
1130 const sal_uInt32 nOldCount
= aOldUserCmdImageVector
.size();
1131 for ( j
= 0; j
< nOldCount
; j
++ )
1132 aOldUserCmdImageSet
.insert( CommandMap::value_type( aOldUserCmdImageVector
[j
], false ));
1134 // Attention: This can make the old image list pointer invalid!
1135 implts_loadUserImages( (ImageType
)i
, m_xUserImageStorage
, m_xUserBitmapsStorage
);
1136 pImageList
= implts_getUserImageList( (ImageType
)i
);
1137 pImageList
->GetImageNames( aNewUserCmdImageSet
);
1139 CmdToXGraphicNameAccess
* pInsertedImages( 0 );
1140 CmdToXGraphicNameAccess
* pReplacedImages( 0 );
1141 CmdToXGraphicNameAccess
* pRemovedImages( 0 );
1143 const sal_uInt32 nNewCount
= aNewUserCmdImageSet
.size();
1144 for ( j
= 0; j
< nNewCount
; j
++ )
1146 CommandMap::iterator pIter
= aOldUserCmdImageSet
.find( aNewUserCmdImageSet
[j
] );
1147 if ( pIter
!= aOldUserCmdImageSet
.end() )
1149 pIter
->second
= true; // mark entry as replaced
1150 if ( !pReplacedImages
)
1151 pReplacedImages
= new CmdToXGraphicNameAccess();
1152 pReplacedImages
->addElement( aNewUserCmdImageSet
[j
],
1153 pImageList
->GetImage( aNewUserCmdImageSet
[j
] ).GetXGraphic() );
1157 if ( !pInsertedImages
)
1158 pInsertedImages
= new CmdToXGraphicNameAccess();
1159 pInsertedImages
->addElement( aNewUserCmdImageSet
[j
],
1160 pImageList
->GetImage( aNewUserCmdImageSet
[j
] ).GetXGraphic() );
1164 // Search map for unmarked entries => they have been removed from the user list
1165 // through this reload operation.
1166 // We have to search the module and global image list!
1167 rtl::Reference
< GlobalImageList
> rGlobalImageList
;
1168 CmdImageList
* pDefaultImageList
= NULL
;
1171 rGlobalImageList
= implts_getGlobalImageList();
1172 pDefaultImageList
= implts_getDefaultImageList();
1174 uno::Reference
< XGraphic
> xEmptyGraphic( Image().GetXGraphic() );
1175 CommandMap::const_iterator pIter
= aOldUserCmdImageSet
.begin();
1176 while ( pIter
!= aOldUserCmdImageSet
.end() )
1178 if ( !pIter
->second
)
1182 Image aImage
= pDefaultImageList
->getImageFromCommandURL( i
, pIter
->first
);
1184 aImage
= rGlobalImageList
->getImageFromCommandURL( i
, pIter
->first
);
1188 // No image in the module/global image list => remove user image
1189 if ( !pRemovedImages
)
1190 pRemovedImages
= new CmdToXGraphicNameAccess();
1191 pRemovedImages
->addElement( pIter
->first
, xEmptyGraphic
);
1195 // Image has been found in the module/global image list => replace user image
1196 if ( !pReplacedImages
)
1197 pReplacedImages
= new CmdToXGraphicNameAccess();
1198 pReplacedImages
->addElement( pIter
->first
, aImage
.GetXGraphic() );
1200 } // if ( m_bUseGlobal )
1203 // No image in the user image list => remove user image
1204 if ( !pRemovedImages
)
1205 pRemovedImages
= new CmdToXGraphicNameAccess();
1206 pRemovedImages
->addElement( pIter
->first
, xEmptyGraphic
);
1214 // Now notify our listeners. Unlock mutex to prevent deadlocks
1215 uno::Reference
< uno::XInterface
> xOwner(static_cast< OWeakObject
* >(m_pOwner
));
1216 if ( pInsertedImages
!= 0 )
1218 ConfigurationEvent aInsertEvent
;
1219 aInsertEvent
.aInfo
= uno::makeAny( i
);
1220 aInsertEvent
.Accessor
= uno::makeAny( xOwner
);
1221 aInsertEvent
.Source
= xOwner
;
1222 aInsertEvent
.ResourceURL
= m_aResourceString
;
1223 aInsertEvent
.Element
= uno::makeAny( uno::Reference
< XNameAccess
>(
1224 static_cast< OWeakObject
*>( pInsertedImages
), UNO_QUERY
));
1225 implts_notifyContainerListener( aInsertEvent
, NotifyOp_Insert
);
1227 if ( pReplacedImages
!= 0 )
1229 ConfigurationEvent aReplaceEvent
;
1230 aReplaceEvent
.aInfo
= uno::makeAny( i
);
1231 aReplaceEvent
.Accessor
= uno::makeAny( xOwner
);
1232 aReplaceEvent
.Source
= xOwner
;
1233 aReplaceEvent
.ResourceURL
= m_aResourceString
;
1234 aReplaceEvent
.ReplacedElement
= Any();
1235 aReplaceEvent
.Element
= uno::makeAny( uno::Reference
< XNameAccess
>(
1236 static_cast< OWeakObject
*>( pReplacedImages
), UNO_QUERY
));
1237 implts_notifyContainerListener( aReplaceEvent
, NotifyOp_Replace
);
1239 if ( pRemovedImages
!= 0 )
1241 ConfigurationEvent aRemoveEvent
;
1242 aRemoveEvent
.aInfo
= uno::makeAny( i
);
1243 aRemoveEvent
.Accessor
= uno::makeAny( xOwner
);
1244 aRemoveEvent
.Source
= xOwner
;
1245 aRemoveEvent
.ResourceURL
= m_aResourceString
;
1246 aRemoveEvent
.Element
= uno::makeAny( uno::Reference
< XNameAccess
>(
1247 static_cast< OWeakObject
*>( pRemovedImages
), UNO_QUERY
));
1248 implts_notifyContainerListener( aRemoveEvent
, NotifyOp_Remove
);
1257 void ImageManagerImpl::store()
1258 throw (::com::sun::star::uno::Exception
,
1259 ::com::sun::star::uno::RuntimeException
,
1265 throw DisposedException();
1269 bool bWritten( false );
1270 for ( sal_Int32 i
= 0; i
< ImageType_COUNT
; i
++ )
1272 bool bSuccess
= implts_storeUserImages( ImageType(i
), m_xUserImageStorage
, m_xUserBitmapsStorage
);
1275 m_bUserImageListModified
[i
] = false;
1279 m_xUserConfigStorage
.is() )
1281 uno::Reference
< XTransactedObject
> xUserConfigStorageCommit( m_xUserConfigStorage
, UNO_QUERY
);
1282 if ( xUserConfigStorageCommit
.is() )
1283 xUserConfigStorageCommit
->commit();
1284 if ( m_xUserRootCommit
.is() )
1285 m_xUserRootCommit
->commit();
1288 m_bModified
= false;
1292 void ImageManagerImpl::storeToStorage( const uno::Reference
< XStorage
>& Storage
)
1293 throw (::com::sun::star::uno::Exception
,
1294 ::com::sun::star::uno::RuntimeException
,
1300 throw DisposedException();
1302 if ( m_bModified
&& Storage
.is() )
1304 long nModes
= ElementModes::READWRITE
;
1306 uno::Reference
< XStorage
> xUserImageStorage
= Storage
->openStorageElement( OUString(IMAGE_FOLDER
),
1308 if ( xUserImageStorage
.is() )
1310 uno::Reference
< XStorage
> xUserBitmapsStorage
= xUserImageStorage
->openStorageElement( OUString(BITMAPS_FOLDER
),
1312 for ( sal_Int32 i
= 0; i
< ImageType_COUNT
; i
++ )
1314 implts_getUserImageList( (ImageType
)i
);
1315 implts_storeUserImages( (ImageType
)i
, xUserImageStorage
, xUserBitmapsStorage
);
1318 uno::Reference
< XTransactedObject
> xTransaction( Storage
, UNO_QUERY
);
1319 if ( xTransaction
.is() )
1320 xTransaction
->commit();
1325 bool ImageManagerImpl::isModified()
1326 throw (::com::sun::star::uno::RuntimeException
)
1332 bool ImageManagerImpl::isReadOnly() throw (::com::sun::star::uno::RuntimeException
)
1338 void ImageManagerImpl::addConfigurationListener( const uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& xListener
)
1339 throw (::com::sun::star::uno::RuntimeException
)
1344 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1346 throw DisposedException();
1349 m_aListenerContainer
.addInterface( cppu::UnoType
<XUIConfigurationListener
>::get(), xListener
);
1352 void ImageManagerImpl::removeConfigurationListener( const uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& xListener
)
1353 throw (::com::sun::star::uno::RuntimeException
)
1355 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1356 m_aListenerContainer
.removeInterface( cppu::UnoType
<XUIConfigurationListener
>::get(), xListener
);
1359 void ImageManagerImpl::implts_notifyContainerListener( const ConfigurationEvent
& aEvent
, NotifyOp eOp
)
1361 ::cppu::OInterfaceContainerHelper
* pContainer
= m_aListenerContainer
.getContainer(
1362 cppu::UnoType
<com::sun::star::ui::XUIConfigurationListener
>::get());
1363 if ( pContainer
!= NULL
)
1365 ::cppu::OInterfaceIteratorHelper
pIterator( *pContainer
);
1366 while ( pIterator
.hasMoreElements() )
1372 case NotifyOp_Replace
:
1373 static_cast< ::com::sun::star::ui::XUIConfigurationListener
*>(pIterator
.next())->elementReplaced( aEvent
);
1375 case NotifyOp_Insert
:
1376 static_cast< ::com::sun::star::ui::XUIConfigurationListener
*>(pIterator
.next())->elementInserted( aEvent
);
1378 case NotifyOp_Remove
:
1379 static_cast< ::com::sun::star::ui::XUIConfigurationListener
*>(pIterator
.next())->elementRemoved( aEvent
);
1383 catch( const css::uno::RuntimeException
& )
1390 void ImageManagerImpl::clear()
1394 for ( sal_Int32 n
= 0; n
< ImageType_COUNT
; n
++ )
1396 delete m_pUserImageList
[n
];
1397 m_pUserImageList
[n
] = 0;
1400 } // namespace framework
1402 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */