summaryrefslogtreecommitdiff
path: root/framework/source/uiconfiguration/imagemanager.cxx
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-09-08 04:57:32 +0000
committerOliver Bolte <obo@openoffice.org>2009-09-08 04:57:32 +0000
commitca00697e3dae9a03573d11281fc8d9a4ee391d3d (patch)
treec390c65f02f6f32b6d6d9faa600f4688a8c81857 /framework/source/uiconfiguration/imagemanager.cxx
parent047473d4f1a12e867ab7154113f7f1c5422d5368 (diff)
CWS-TOOLING: integrate CWS oj18
2009-08-21 15:08:49 +0200 oj r275263 : wrong check 2009-08-21 08:56:01 +0200 oj r275215 : missing not 2009-08-20 07:27:13 +0200 oj r275164 : use new method from global 2009-08-19 10:22:35 +0200 oj r275138 : call GetLocale instead of pLocale 2009-08-18 10:39:32 +0200 oj r275082 : missing header include 2009-08-18 10:09:44 +0200 oj r275081 : new methods at global 2009-08-18 10:09:00 +0200 oj r275080 : unused var 2009-08-18 08:59:04 +0200 oj r275078 : move files from classes to xml 2009-08-17 14:58:16 +0200 oj r275056 : CWS-TOOLING: rebase CWS oj18 to trunk@275001 (milestone: DEV300:m55) 2009-08-17 13:29:44 +0200 oj r275047 : compile error 2009-08-17 13:27:47 +0200 oj r275045 : compile error 2009-08-17 11:44:54 +0200 oj r275040 : add dep 2009-07-22 14:26:05 +0200 oj r274240 : move unused services into fwl 2009-07-22 14:25:35 +0200 oj r274239 : move unused services into fwl 2009-07-22 13:47:45 +0200 oj r274233 : remove some unused code 2009-07-22 09:06:20 +0200 oj r274219 : export dbtoolsclient dbcharsethelper for sc 2009-07-22 08:48:58 +0200 oj r274218 : create NumberFormatter on demand 2009-07-22 08:39:23 +0200 oj r274217 : change char to sal_Char 2009-07-22 07:33:34 +0200 oj r274214 : export dbtoolsclient dbcharsethelper for sc 2009-07-22 07:30:04 +0200 oj r274213 : late init of numberformatter and breakiterator 2009-07-22 07:28:55 +0200 oj r274212 : export dbtoolsclient dbcharsethelper for sc 2009-07-21 13:43:28 +0200 oj r274196 : check if quick start is enbaled 2009-07-21 13:40:09 +0200 oj r274195 : check config entry for UiEventsLogger 2009-07-21 13:37:40 +0200 oj r274194 : code refactoring, remove of duplicate code and some late inits and removale of not needed files 2009-07-21 13:35:38 +0200 oj r274193 : code refactoring, remove of duplicate code and some late inits and removale of not needed files 2009-07-21 13:33:41 +0200 oj r274192 : doc meta data will now be created on demand 2009-07-21 13:13:40 +0200 oj r274187 : load ldap functions on demand 2009-07-21 13:03:17 +0200 oj r274183 : late init of TransliterationImpl 2009-07-21 12:36:10 +0200 oj r274180 : late init of charClass
Diffstat (limited to 'framework/source/uiconfiguration/imagemanager.cxx')
-rw-r--r--framework/source/uiconfiguration/imagemanager.cxx926
1 files changed, 25 insertions, 901 deletions
diff --git a/framework/source/uiconfiguration/imagemanager.cxx b/framework/source/uiconfiguration/imagemanager.cxx
index 3ec26805de71..6844b5cb6b43 100644
--- a/framework/source/uiconfiguration/imagemanager.cxx
+++ b/framework/source/uiconfiguration/imagemanager.cxx
@@ -35,6 +35,7 @@
#include <xml/imagesconfiguration.hxx>
#include <uiconfiguration/graphicnameaccess.hxx>
#include <services.h>
+#include "imagemanagerimpl.hxx"
#include "properties.h"
@@ -62,6 +63,7 @@
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/pngread.hxx>
#include <vcl/pngwrite.hxx>
+#include <rtl/logfile.hxx>
//_________________________________________________________________________________________________________________
// namespaces
@@ -90,55 +92,14 @@ const sal_Int32 IMAGE_SIZE_LARGE = 26;
const sal_Int16 MAX_IMAGETYPE_VALUE = ::com::sun::star::ui::ImageType::COLOR_HIGHCONTRAST|
::com::sun::star::ui::ImageType::SIZE_LARGE;
-static const char IMAGE_FOLDER[] = "images";
-static const char BITMAPS_FOLDER[] = "Bitmaps";
-static const char IMAGE_EXTENSION[] = ".png";
-
-static const char* IMAGELIST_XML_FILE[] =
-{
- "sc_imagelist.xml",
- "lc_imagelist.xml",
- "sch_imagelist.xml",
- "lch_imagelist.xml"
-};
-
-static const char* BITMAP_FILE_NAMES[] =
-{
- "sc_userimages.png",
- "lc_userimages.png",
- "sch_userimages.png",
- "lch_userimages.png"
-};
-
namespace framework
{
-static char ModuleImageList[] = "private:resource/images/moduleimages";
-
typedef GraphicNameAccess CmdToXGraphicNameAccess;
//*****************************************************************************************************************
// XInterface, XTypeProvider, XServiceInfo
//*****************************************************************************************************************
-DEFINE_XINTERFACE_6 ( ImageManager ,
- OWeakObject ,
- DIRECT_INTERFACE( css::lang::XTypeProvider ),
- DIRECT_INTERFACE( css::lang::XComponent ),
- DIRECT_INTERFACE( css::lang::XInitialization ),
- DIRECT_INTERFACE( ::com::sun::star::ui::XImageManager ),
- DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfiguration ),
- DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationPersistence )
- )
-
-DEFINE_XTYPEPROVIDER_6 ( ImageManager ,
- css::lang::XTypeProvider ,
- css::lang::XComponent ,
- css::lang::XInitialization ,
- ::com::sun::star::ui::XImageManager ,
- ::com::sun::star::ui::XUIConfiguration ,
- ::com::sun::star::ui::XUIConfigurationPersistence
- )
-
DEFINE_XSERVICEINFO_MULTISERVICE ( ImageManager ,
::cppu::OWeakObject ,
SERVICENAME_IMAGEMANAGER ,
@@ -147,471 +108,69 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( ImageManager
DEFINE_INIT_SERVICE ( ImageManager, {} )
-static sal_Bool implts_checkAndScaleGraphic( uno::Reference< XGraphic >& rOutGraphic, const uno::Reference< XGraphic >& rInGraphic, sal_Int16 nImageType )
-{
- static Size aNormSize( IMAGE_SIZE_NORMAL, IMAGE_SIZE_NORMAL );
- static Size aLargeSize( IMAGE_SIZE_LARGE, IMAGE_SIZE_LARGE );
-
- if ( !rInGraphic.is() )
- {
- rOutGraphic = Image().GetXGraphic();
- return sal_False;
- }
-
- // Check size and scale it
- Image aImage( rInGraphic );
- Size aSize = aImage.GetSizePixel();
- bool bMustScale( false );
-
- if (( nImageType == ImageType_Color_Large ) ||
- ( nImageType == ImageType_HC_Large ))
- bMustScale = ( aSize != aLargeSize );
- else
- bMustScale = ( aSize != aNormSize );
-
- if ( bMustScale )
- {
- BitmapEx aBitmap = aImage.GetBitmapEx();
- aBitmap.Scale( aNormSize );
- aImage = Image( aBitmap );
- rOutGraphic = aImage.GetXGraphic();
- }
- else
- rOutGraphic = rInGraphic;
- return sal_True;
-}
-
-static sal_Int16 implts_convertImageTypeToIndex( sal_Int16 nImageType )
-{
- sal_Int16 nIndex( 0 );
- if ( nImageType & ::com::sun::star::ui::ImageType::SIZE_LARGE )
- nIndex += 1;
- if ( nImageType & ::com::sun::star::ui::ImageType::COLOR_HIGHCONTRAST )
- nIndex += 2;
- return nIndex;
-}
-
-ImageList* ImageManager::implts_getUserImageList( ImageType nImageType )
-{
- ResetableGuard aGuard( m_aLock );
- if ( !m_pUserImageList[nImageType] )
- implts_loadUserImages( nImageType, m_xUserImageStorage, m_xUserBitmapsStorage );
-
- return m_pUserImageList[nImageType];
-}
-
-void ImageManager::implts_initialize()
-{
- // Initialize the top-level structures with the storage data
- if ( m_xUserConfigStorage.is() )
- {
- long nModes = m_bReadOnly ? ElementModes::READ : ElementModes::READWRITE;
-
- try
- {
- m_xUserImageStorage = m_xUserConfigStorage->openStorageElement( OUString::createFromAscii( IMAGE_FOLDER ),
- nModes );
- if ( m_xUserImageStorage.is() )
- {
- m_xUserBitmapsStorage = m_xUserImageStorage->openStorageElement( OUString::createFromAscii( BITMAPS_FOLDER ),
- nModes );
- }
- }
- catch ( com::sun::star::container::NoSuchElementException& )
- {
- }
- catch ( ::com::sun::star::embed::InvalidStorageException& )
- {
- }
- catch ( ::com::sun::star::lang::IllegalArgumentException& )
- {
- }
- catch ( ::com::sun::star::io::IOException& )
- {
- }
- catch ( ::com::sun::star::embed::StorageWrappedTargetException& )
- {
- }
- }
-}
-
-sal_Bool ImageManager::implts_loadUserImages(
- ImageType nImageType,
- const uno::Reference< XStorage >& xUserImageStorage,
- const uno::Reference< XStorage >& xUserBitmapsStorage )
-{
- ResetableGuard aGuard( m_aLock );
-
- if ( xUserImageStorage.is() && xUserBitmapsStorage.is() )
- {
- try
- {
- uno::Reference< XStream > xStream = xUserImageStorage->openStreamElement( rtl::OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ),
- ElementModes::READ );
- uno::Reference< XInputStream > xInputStream = xStream->getInputStream();
-
- ImageListsDescriptor aUserImageListInfo;
- ImagesConfiguration::LoadImages( m_xServiceManager,
- xInputStream,
- aUserImageListInfo );
- if (( aUserImageListInfo.pImageList != 0 ) &&
- ( aUserImageListInfo.pImageList->Count() > 0 ))
- {
- ImageListItemDescriptor* pList = aUserImageListInfo.pImageList->GetObject(0);
- sal_Int32 nCount = pList->pImageItemList->Count();
-
- std::vector< OUString > aUserImagesVector;
- for ( USHORT i=0; i < nCount; i++ )
- {
- const ImageItemDescriptor* pItem = pList->pImageItemList->GetObject(i);
- aUserImagesVector.push_back( pItem->aCommandURL );
- }
-
- uno::Reference< XStream > xBitmapStream = xUserBitmapsStorage->openStreamElement(
- rtl::OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ),
- ElementModes::READ );
-
- if ( xBitmapStream.is() )
- {
- SvStream* pSvStream( 0 );
- BitmapEx aUserBitmap;
- {
- pSvStream = utl::UcbStreamHelper::CreateStream( xBitmapStream );
- vcl::PNGReader aPngReader( *pSvStream );
- aUserBitmap = aPngReader.Read();
- }
- delete pSvStream;
-
- // Delete old image list and create a new one from the read bitmap
- delete m_pUserImageList[nImageType];
- m_pUserImageList[nImageType] = new ImageList();
- m_pUserImageList[nImageType]->InsertFromHorizontalStrip
- ( aUserBitmap, aUserImagesVector );
- return sal_True;
- }
- }
- }
- catch ( com::sun::star::container::NoSuchElementException& )
- {
- }
- catch ( ::com::sun::star::embed::InvalidStorageException& )
- {
- }
- catch ( ::com::sun::star::lang::IllegalArgumentException& )
- {
- }
- catch ( ::com::sun::star::io::IOException& )
- {
- }
- catch ( ::com::sun::star::embed::StorageWrappedTargetException& )
- {
- }
- }
-
- // Destroy old image list - create a new empty one
- delete m_pUserImageList[nImageType];
- m_pUserImageList[nImageType] = new ImageList;
-
- return sal_True;
-}
-
-sal_Bool ImageManager::implts_storeUserImages(
- ImageType nImageType,
- const uno::Reference< XStorage >& xUserImageStorage,
- const uno::Reference< XStorage >& xUserBitmapsStorage )
-{
- ResetableGuard aGuard( m_aLock );
-
- if ( m_bModified )
- {
- ImageList* pImageList = implts_getUserImageList( nImageType );
- if ( pImageList->GetImageCount() > 0 )
- {
- ImageListsDescriptor aUserImageListInfo;
- aUserImageListInfo.pImageList = new ImageListDescriptor;
-
- ImageListItemDescriptor* pList = new ImageListItemDescriptor;
- aUserImageListInfo.pImageList->Insert( pList, 0 );
-
- pList->pImageItemList = new ImageItemListDescriptor;
- for ( USHORT i=0; i < pImageList->GetImageCount(); i++ )
- {
- ImageItemDescriptor* pItem = new ::framework::ImageItemDescriptor;
-
- pItem->nIndex = i;
- pItem->aCommandURL = pImageList->GetImageName( i );
- pList->pImageItemList->Insert( pItem, pList->pImageItemList->Count() );
- }
-
- pList->aURL = String::CreateFromAscii("Bitmaps/");
- pList->aURL += String::CreateFromAscii( BITMAP_FILE_NAMES[nImageType] );
-
- uno::Reference< XTransactedObject > xTransaction;
- uno::Reference< XOutputStream > xOutputStream;
- uno::Reference< XStream > xStream = xUserImageStorage->openStreamElement( rtl::OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ),
- ElementModes::WRITE|ElementModes::TRUNCATE );
- if ( xStream.is() )
- {
- uno::Reference< XStream > xBitmapStream =
- xUserBitmapsStorage->openStreamElement( rtl::OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ),
- ElementModes::WRITE|ElementModes::TRUNCATE );
- if ( xBitmapStream.is() )
- {
- SvStream* pSvStream = utl::UcbStreamHelper::CreateStream( xBitmapStream );
- {
- vcl::PNGWriter aPngWriter( pImageList->GetAsHorizontalStrip() );
- aPngWriter.Write( *pSvStream );
- }
- delete pSvStream;
-
- // Commit user bitmaps storage
- xTransaction = uno::Reference< XTransactedObject >( xUserBitmapsStorage, UNO_QUERY );
- if ( xTransaction.is() )
- xTransaction->commit();
- }
-
- xOutputStream = xStream->getOutputStream();
- if ( xOutputStream.is() )
- ImagesConfiguration::StoreImages( m_xServiceManager, xOutputStream, aUserImageListInfo );
-
- // Commit user image storage
- xTransaction = uno::Reference< XTransactedObject >( xUserImageStorage, UNO_QUERY );
- if ( xTransaction.is() )
- xTransaction->commit();
- }
-
- return sal_True;
- }
- else
- {
- // Remove the streams from the storage, if we have no data. We have to catch
- // the NoSuchElementException as it can be possible that there is no stream at all!
- try
- {
- xUserImageStorage->removeElement( rtl::OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ));
- }
- catch ( ::com::sun::star::container::NoSuchElementException& )
- {
- }
-
- try
- {
- xUserBitmapsStorage->removeElement( rtl::OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ));
- }
- catch ( ::com::sun::star::container::NoSuchElementException& )
- {
- }
-
- uno::Reference< XTransactedObject > xTransaction;
-
- // Commit user image storage
- xTransaction = uno::Reference< XTransactedObject >( xUserImageStorage, UNO_QUERY );
- if ( xTransaction.is() )
- xTransaction->commit();
-
- // Commit user bitmaps storage
- xTransaction = uno::Reference< XTransactedObject >( xUserBitmapsStorage, UNO_QUERY );
- if ( xTransaction.is() )
- xTransaction->commit();
-
- return sal_True;
- }
- }
-
- return sal_False;
-}
-
ImageManager::ImageManager( uno::Reference< XMultiServiceFactory > xServiceManager ) :
ThreadHelpBase( &Application::GetSolarMutex() )
- , m_xUserConfigStorage( 0 )
- , m_xUserImageStorage( 0 )
- , m_xUserBitmapsStorage( 0 )
- , m_bReadOnly( true )
- , m_bInitialized( false )
- , m_bModified( false )
- , m_bConfigRead( false )
- , m_bDisposed( false )
- , m_aXMLPostfix( RTL_CONSTASCII_USTRINGPARAM( ".xml" ))
- , m_aResourceString( RTL_CONSTASCII_USTRINGPARAM( ModuleImageList ))
- , m_xServiceManager( xServiceManager )
- , m_aListenerContainer( m_aLock.getShareableOslMutex() )
+ , m_pImpl( new ImageManagerImpl(xServiceManager,static_cast< OWeakObject* >(this),false) )
{
- for ( sal_Int32 n=0; n < ImageType_COUNT; n++ )
- {
- m_pUserImageList[n] = 0;
- m_bUserImageListModified[n] = false;
- }
}
ImageManager::~ImageManager()
{
- ResetableGuard aGuard( m_aLock );
- for ( sal_Int32 n = 0; n < ImageType_COUNT; n++ )
- {
- delete m_pUserImageList[n];
- m_pUserImageList[n] = 0;
- }
+ m_pImpl->clear();
}
// XComponent
void SAL_CALL ImageManager::dispose() throw (::com::sun::star::uno::RuntimeException)
{
- uno::Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
-
- css::lang::EventObject aEvent( xThis );
- m_aListenerContainer.disposeAndClear( aEvent );
-
- {
- ResetableGuard aGuard( m_aLock );
- m_xUserConfigStorage.clear();
- m_xUserImageStorage.clear();
- m_bConfigRead = false;
- m_bModified = false;
- m_bDisposed = true;
- }
+ m_pImpl->dispose();
}
void SAL_CALL ImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
{
- {
- ResetableGuard aGuard( m_aLock );
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
- }
-
- m_aListenerContainer.addInterface( ::getCppuType( ( const uno::Reference< XEventListener >* ) NULL ), xListener );
+ m_pImpl->addEventListener(xListener);
}
void SAL_CALL ImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( ::getCppuType( ( const uno::Reference< XEventListener >* ) NULL ), xListener );
+ m_pImpl->removeEventListener(xListener);
}
// Non-UNO methods
void ImageManager::setStorage( const uno::Reference< XStorage >& Storage )
throw (::com::sun::star::uno::RuntimeException)
{
- ResetableGuard aLock( m_aLock );
+ ResetableGuard aLock( m_pImpl->m_aLock );
- m_xUserConfigStorage = Storage;
- implts_initialize();
+ m_pImpl->m_xUserConfigStorage = Storage;
+ m_pImpl->implts_initialize();
}
// XInitialization
void SAL_CALL ImageManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
{
- ResetableGuard aLock( m_aLock );
-
- if ( !m_bInitialized )
- {
- for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ )
- {
- PropertyValue aPropValue;
- if ( aArguments[n] >>= aPropValue )
- {
- if ( aPropValue.Name.equalsAscii( "UserConfigStorage" ))
- {
- aPropValue.Value >>= m_xUserConfigStorage;
- }
- else if ( aPropValue.Name.equalsAscii( "ModuleIdentifier" ))
- {
- aPropValue.Value >>= m_aModuleIdentifier;
- }
- }
- }
-
- if ( m_xUserConfigStorage.is() )
- {
- uno::Reference< XPropertySet > xPropSet( m_xUserConfigStorage, UNO_QUERY );
- if ( xPropSet.is() )
- {
- long nOpenMode = 0;
- Any a = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" )));
- if ( a >>= nOpenMode )
- m_bReadOnly = !( nOpenMode & ElementModes::WRITE );
- }
- }
-
- implts_initialize();
-
- m_bInitialized = true;
- }
+ m_pImpl->initialize(aArguments);
}
// XImageManager
void SAL_CALL ImageManager::reset()
throw (::com::sun::star::uno::RuntimeException)
{
- ResetableGuard aLock( m_aLock );
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
-
- std::vector< OUString > aUserImageNames;
-
- for ( sal_Int32 i = 0; i < ImageType_COUNT; i++ )
- {
- aUserImageNames.clear();
- ImageList* pImageList = implts_getUserImageList( ImageType(i));
- pImageList->GetImageNames( aUserImageNames );
-
- Sequence< rtl::OUString > aRemoveList( aUserImageNames.size() );
- for ( sal_uInt32 j = 0; j < aUserImageNames.size(); j++ )
- aRemoveList[j] = aUserImageNames[j];
-
- // Remove images
- removeImages( sal_Int16( i ), aRemoveList );
- m_bUserImageListModified[i] = true;
- }
-
- m_bModified = sal_True;
+ m_pImpl->reset();
}
Sequence< ::rtl::OUString > SAL_CALL ImageManager::getAllImageNames( ::sal_Int16 nImageType )
throw (::com::sun::star::uno::RuntimeException)
{
- ResetableGuard aLock( m_aLock );
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
-
- sal_uInt32 i( 0 );
- sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType );
- ImageList* pImageList = implts_getUserImageList( ImageType( nIndex ));
-
- std::vector< OUString > aUserImageNames;
- pImageList->GetImageNames( aUserImageNames );
-
- Sequence< OUString > aImageNameSeq( aUserImageNames.size() );
- for ( i = 0; i < aUserImageNames.size(); i++ )
- aImageNameSeq[i] = aUserImageNames[i];
-
- return aImageNameSeq;
+ return m_pImpl->getAllImageNames( nImageType );
}
::sal_Bool SAL_CALL ImageManager::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL )
throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
{
- ResetableGuard aLock( m_aLock );
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
-
- if (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE ))
- throw IllegalArgumentException();
-
- sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType );
- ImageList* pImageList = implts_getUserImageList( ImageType( nIndex ));
- if ( pImageList )
- return ( pImageList->GetImagePos( aCommandURL ) != IMAGELIST_IMAGE_NOTFOUND );
-
- return sal_False;
+ return m_pImpl->hasImage(nImageType,aCommandURL);
}
Sequence< uno::Reference< XGraphic > > SAL_CALL ImageManager::getImages(
@@ -619,28 +178,7 @@ Sequence< uno::Reference< XGraphic > > SAL_CALL ImageManager::getImages(
const Sequence< ::rtl::OUString >& aCommandURLSequence )
throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{
- ResetableGuard aLock( m_aLock );
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
-
- if (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE ))
- throw IllegalArgumentException();
-
- Sequence< uno::Reference< XGraphic > > aGraphSeq( aCommandURLSequence.getLength() );
-
- const rtl::OUString* aStrArray = aCommandURLSequence.getConstArray();
- sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType );
- ImageList* pUserImageList = implts_getUserImageList( ImageType( nIndex ));
-
- for ( sal_Int32 n = 0; n < aCommandURLSequence.getLength(); n++ )
- {
- Image aImage = pUserImageList->GetImage( aStrArray[n] );
- aGraphSeq[n] = aImage.GetXGraphic();
- }
-
- return aGraphSeq;
+ return m_pImpl->getImages(nImageType,aCommandURLSequence);
}
void SAL_CALL ImageManager::replaceImages(
@@ -651,84 +189,7 @@ throw ( ::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::lang::IllegalAccessException,
::com::sun::star::uno::RuntimeException)
{
- CmdToXGraphicNameAccess* pInsertedImages( 0 );
- CmdToXGraphicNameAccess* pReplacedImages( 0 );
-
- {
- ResetableGuard aLock( m_aLock );
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
-
- if (( aCommandURLSequence.getLength() != aGraphicsSequence.getLength() ) ||
- (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE )))
- throw IllegalArgumentException();
-
- if ( m_bReadOnly )
- throw IllegalAccessException();
-
- sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType );
- ImageList* pImageList = implts_getUserImageList( ImageType( nIndex ));
-
- uno::Reference< XGraphic > xGraphic;
- for ( sal_Int32 i = 0; i < aCommandURLSequence.getLength(); i++ )
- {
- // Check size and scale. If we don't have any graphics ignore it
- if ( !implts_checkAndScaleGraphic( xGraphic, aGraphicsSequence[i], nIndex ))
- continue;
-
- USHORT nPos = pImageList->GetImagePos( aCommandURLSequence[i] );
- if ( nPos == IMAGELIST_IMAGE_NOTFOUND )
- {
- pImageList->AddImage( aCommandURLSequence[i], xGraphic );
- if ( !pInsertedImages )
- pInsertedImages = new CmdToXGraphicNameAccess();
- pInsertedImages->addElement( aCommandURLSequence[i], xGraphic );
- }
- else
- {
- pImageList->ReplaceImage( aCommandURLSequence[i], xGraphic );
- if ( !pReplacedImages )
- pReplacedImages = new CmdToXGraphicNameAccess();
- pReplacedImages->addElement( aCommandURLSequence[i], xGraphic );
- }
- }
-
- if (( pInsertedImages != 0 ) || ( pReplacedImages != 0 ))
- {
- m_bModified = sal_True;
- m_bUserImageListModified[nIndex] = true;
- }
- }
-
- // Notify listeners
- uno::Reference< XImageManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- uno::Reference< XInterface > xIfac( xThis, UNO_QUERY );
-
- if ( pInsertedImages != 0 )
- {
- ConfigurationEvent aInsertEvent;
- aInsertEvent.aInfo = uno::makeAny( nImageType );
- aInsertEvent.Accessor = uno::makeAny( xThis );
- aInsertEvent.Source = xIfac;
- aInsertEvent.ResourceURL = m_aResourceString;
- aInsertEvent.Element = uno::makeAny( uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY ));
- implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert );
- }
- if ( pReplacedImages != 0 )
- {
- ConfigurationEvent aReplaceEvent;
- aReplaceEvent.aInfo = uno::makeAny( nImageType );
- aReplaceEvent.Accessor = uno::makeAny( xThis );
- aReplaceEvent.Source = xIfac;
- aReplaceEvent.ResourceURL = m_aResourceString;
- aReplaceEvent.ReplacedElement = Any();
- aReplaceEvent.Element = uno::makeAny( uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY ));
- implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace );
- }
+ m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence);
}
void SAL_CALL ImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence )
@@ -736,62 +197,7 @@ throw ( ::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::lang::IllegalAccessException,
::com::sun::star::uno::RuntimeException)
{
- CmdToXGraphicNameAccess* pRemovedImages( 0 );
-
- {
- ResetableGuard aLock( m_aLock );
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
-
- if (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE ))
- throw IllegalArgumentException();
-
- if ( m_bReadOnly )
- throw IllegalAccessException();
-
- sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType );
- ImageList* pImageList = implts_getUserImageList( ImageType( nIndex ));
- uno::Reference< XGraphic > xEmptyGraphic( Image().GetXGraphic() );
-
- for ( sal_Int32 i = 0; i < aCommandURLSequence.getLength(); i++ )
- {
- USHORT nPos = pImageList->GetImagePos( aCommandURLSequence[i] );
- if ( nPos != IMAGELIST_IMAGE_NOTFOUND )
- {
- Image aImage = pImageList->GetImage( nPos );
- USHORT nId = pImageList->GetImageId( nPos );
- pImageList->RemoveImage( nId );
-
- if ( !pRemovedImages )
- pRemovedImages = new CmdToXGraphicNameAccess();
- pRemovedImages->addElement( aCommandURLSequence[i], xEmptyGraphic );
- }
- }
-
- if ( pRemovedImages != 0 )
- {
- m_bModified = sal_True;
- m_bUserImageListModified[nIndex] = true;
- }
- }
-
- // Notify listeners
- uno::Reference< XImageManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- uno::Reference< XInterface > xIfac( xThis, UNO_QUERY );
-
- if ( pRemovedImages != 0 )
- {
- ConfigurationEvent aRemoveEvent;
- aRemoveEvent.aInfo = uno::makeAny( nImageType );
- aRemoveEvent.Accessor = uno::makeAny( xThis );
- aRemoveEvent.Source = xIfac;
- aRemoveEvent.ResourceURL = m_aResourceString;
- aRemoveEvent.Element = uno::makeAny( uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY ));
- implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove );
- }
+ m_pImpl->removeImages(nImageType,aCommandURLSequence);
}
void SAL_CALL ImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence )
@@ -800,105 +206,21 @@ throw ( ::com::sun::star::container::ElementExistException,
::com::sun::star::lang::IllegalAccessException,
::com::sun::star::uno::RuntimeException)
{
- CmdToXGraphicNameAccess* pInsertedImages( 0 );
- CmdToXGraphicNameAccess* pReplacedImages( 0 );
-
- {
- ResetableGuard aLock( m_aLock );
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
-
- if (( aCommandURLSequence.getLength() != aGraphicSequence.getLength() ) ||
- (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE )))
- throw IllegalArgumentException();
-
- if ( m_bReadOnly )
- throw IllegalAccessException();
-
- sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType );
- ImageList* pImageList = implts_getUserImageList( ImageType( nIndex ));
-
- uno::Reference< XGraphic > xGraphic;
- for ( sal_Int32 i = 0; i < aCommandURLSequence.getLength(); i++ )
- {
- if ( !implts_checkAndScaleGraphic( xGraphic, aGraphicSequence[i], nIndex ))
- continue;
-
- USHORT nPos = pImageList->GetImagePos( aCommandURLSequence[i] );
- if ( nPos == IMAGELIST_IMAGE_NOTFOUND )
- {
- pImageList->AddImage( aCommandURLSequence[i], xGraphic );
- if ( !pInsertedImages )
- pInsertedImages = new CmdToXGraphicNameAccess();
- pInsertedImages->addElement( aCommandURLSequence[i], xGraphic );
- }
- else
- {
- pImageList->ReplaceImage( aCommandURLSequence[i], xGraphic );
- if ( !pReplacedImages )
- pReplacedImages = new CmdToXGraphicNameAccess();
- pReplacedImages->addElement( aCommandURLSequence[i], xGraphic );
- }
- }
-
- if (( pInsertedImages != 0 ) || ( pReplacedImages != 0 ))
- {
- m_bModified = sal_True;
- m_bUserImageListModified[nIndex] = true;
- }
- }
-
- // Notify listeners
- uno::Reference< XImageManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- uno::Reference< XInterface > xIfac( xThis, UNO_QUERY );
-
- if ( pInsertedImages != 0 )
- {
- ConfigurationEvent aInsertEvent;
- aInsertEvent.aInfo = uno::makeAny( nImageType );
- aInsertEvent.Accessor = uno::makeAny( xThis );
- aInsertEvent.Source = xIfac;
- aInsertEvent.ResourceURL = m_aResourceString;
- aInsertEvent.Element = uno::makeAny( uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY ));
- implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert );
- }
- if ( pReplacedImages != 0 )
- {
- ConfigurationEvent aReplaceEvent;
- aReplaceEvent.aInfo = uno::makeAny( nImageType );
- aReplaceEvent.Accessor = uno::makeAny( xThis );
- aReplaceEvent.Source = xIfac;
- aReplaceEvent.ResourceURL = m_aResourceString;
- aReplaceEvent.ReplacedElement = Any();
- aReplaceEvent.Element = uno::makeAny( uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY ));
- implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace );
- }
+ m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence);
}
// XUIConfiguration
void SAL_CALL ImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
throw (::com::sun::star::uno::RuntimeException)
{
- {
- ResetableGuard aGuard( m_aLock );
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- if ( m_bDisposed )
- throw DisposedException();
- }
-
- m_aListenerContainer.addInterface( ::getCppuType( ( const uno::Reference< XUIConfigurationListener >* ) NULL ), xListener );
+ m_pImpl->addConfigurationListener(xListener);
}
void SAL_CALL ImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
throw (::com::sun::star::uno::RuntimeException)
{
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
- m_aListenerContainer.removeInterface( ::getCppuType( ( const uno::Reference< XUIConfigurationListener >* ) NULL ), xListener );
+ m_pImpl->removeConfigurationListener(xListener);
}
// XUIConfigurationPersistence
@@ -906,228 +228,30 @@ void SAL_CALL ImageManager::reload()
throw ( ::com::sun::star::uno::Exception,
::com::sun::star::uno::RuntimeException )
{
- ResetableGuard aGuard( m_aLock );
-
- uno::Reference< uno::XInterface > xRefThis( static_cast< OWeakObject* >( this ));
-
- if ( m_bDisposed )
- throw DisposedException();
-
- CommandMap aOldUserCmdImageSet;
- std::vector< rtl::OUString > aNewUserCmdImageSet;
-
- if ( m_bModified )
- {
- uno::Reference< XImageManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
- uno::Reference< XInterface > xIfac( xThis, UNO_QUERY );
-
- for ( sal_Int16 i = 0; i < sal_Int16( ImageType_COUNT ); i++ )
- {
- if ( !m_bDisposed && m_bUserImageListModified[i] )
- {
- std::vector< rtl::OUString > aOldUserCmdImageVector;
- ImageList* pImageList = implts_getUserImageList( (ImageType)i );
- pImageList->GetImageNames( aOldUserCmdImageVector );
-
- // Fill hash map to speed up search afterwards
- sal_uInt32 j( 0 );
- for ( j = 0; j < aOldUserCmdImageVector.size(); j++ )
- aOldUserCmdImageSet.insert( CommandMap::value_type( aOldUserCmdImageVector[j], false ));
-
- // Attention: This can make the old image list pointer invalid!
- implts_loadUserImages( (ImageType)i, m_xUserImageStorage, m_xUserBitmapsStorage );
- pImageList = implts_getUserImageList( (ImageType)i );
- pImageList->GetImageNames( aNewUserCmdImageSet );
-
- CmdToXGraphicNameAccess* pInsertedImages( 0 );
- CmdToXGraphicNameAccess* pReplacedImages( 0 );
- CmdToXGraphicNameAccess* pRemovedImages( 0 );
-
- for ( j = 0; j < aNewUserCmdImageSet.size(); j++ )
- {
- CommandMap::iterator pIter = aOldUserCmdImageSet.find( aNewUserCmdImageSet[j] );
- if ( pIter != aOldUserCmdImageSet.end() )
- {
- pIter->second = true; // mark entry as replaced
- if ( !pReplacedImages )
- pReplacedImages = new CmdToXGraphicNameAccess();
- pReplacedImages->addElement( aNewUserCmdImageSet[j],
- pImageList->GetImage( aNewUserCmdImageSet[j] ).GetXGraphic() );
- }
- else
- {
- if ( !pInsertedImages )
- pInsertedImages = new CmdToXGraphicNameAccess();
- pInsertedImages->addElement( aNewUserCmdImageSet[j],
- pImageList->GetImage( aNewUserCmdImageSet[j] ).GetXGraphic() );
- }
- }
-
- // Search map for unmarked entries => they have been removed from the user list
- // through this reload operation.
- uno::Reference< XGraphic > xEmptyGraphic( Image().GetXGraphic() );
- CommandMap::const_iterator pIter = aOldUserCmdImageSet.begin();
- while ( pIter != aOldUserCmdImageSet.end() )
- {
- if ( !pIter->second )
- {
- // No image in the user image list => remove user image
- if ( !pRemovedImages )
- pRemovedImages = new CmdToXGraphicNameAccess();
- pRemovedImages->addElement( pIter->first, xEmptyGraphic );
- }
- ++pIter;
- }
-
- aGuard.unlock();
-
- // Now notify our listeners. Unlock mutex to prevent deadlocks
- if ( pInsertedImages != 0 )
- {
- ConfigurationEvent aInsertEvent;
- aInsertEvent.aInfo = uno::makeAny( i );
- aInsertEvent.Accessor = uno::makeAny( xThis );
- aInsertEvent.Source = xIfac;
- aInsertEvent.ResourceURL = m_aResourceString;
- aInsertEvent.Element = uno::makeAny( uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY ));
- implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert );
- }
- if ( pReplacedImages != 0 )
- {
- ConfigurationEvent aReplaceEvent;
- aReplaceEvent.aInfo = uno::makeAny( i );
- aReplaceEvent.Accessor = uno::makeAny( xThis );
- aReplaceEvent.Source = xIfac;
- aReplaceEvent.ResourceURL = m_aResourceString;
- aReplaceEvent.ReplacedElement = Any();
- aReplaceEvent.Element = uno::makeAny( uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY ));
- implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace );
- }
- if ( pRemovedImages != 0 )
- {
- ConfigurationEvent aRemoveEvent;
- aRemoveEvent.aInfo = uno::makeAny( i );
- aRemoveEvent.Accessor = uno::makeAny( xThis );
- aRemoveEvent.Source = xIfac;
- aRemoveEvent.ResourceURL = m_aResourceString;
- aRemoveEvent.Element = uno::makeAny( uno::Reference< XNameAccess >(
- static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY ));
- implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove );
- }
-
- aGuard.lock();
- }
- }
- }
+ m_pImpl->reload();
}
void SAL_CALL ImageManager::store()
throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
{
- ResetableGuard aGuard( m_aLock );
-
- if ( m_bDisposed )
- throw DisposedException();
-
- if ( m_bModified )
- {
- sal_Bool bWritten( sal_False );
- for ( sal_Int32 i = 0; i < ImageType_COUNT; i++ )
- {
- sal_Bool bSuccess = implts_storeUserImages( ImageType(i), m_xUserImageStorage, m_xUserBitmapsStorage );
- if ( bSuccess )
- bWritten = sal_True;
- m_bUserImageListModified[i] = false;
- }
-
- if ( bWritten &&
- m_xUserConfigStorage.is())
- {
- uno::Reference< XTransactedObject > xUserConfigStorageCommit( m_xUserConfigStorage, UNO_QUERY );
- if ( xUserConfigStorageCommit.is() )
- xUserConfigStorageCommit->commit();
- }
-
- m_bModified = sal_False;
- }
+ m_pImpl->store();
}
void SAL_CALL ImageManager::storeToStorage( const uno::Reference< XStorage >& Storage )
throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
{
- ResetableGuard aGuard( m_aLock );
-
- if ( m_bDisposed )
- throw DisposedException();
-
- if ( m_bModified && Storage.is() )
- {
- long nModes = ElementModes::READWRITE;
-
- uno::Reference< XStorage > xUserImageStorage = Storage->openStorageElement( OUString::createFromAscii( IMAGE_FOLDER ),
- nModes );
- if ( xUserImageStorage.is() )
- {
- uno::Reference< XStorage > xUserBitmapsStorage = xUserImageStorage->openStorageElement( OUString::createFromAscii( BITMAPS_FOLDER ),
- nModes );
- for ( sal_Int32 i = 0; i < ImageType_COUNT; i++ )
- {
- implts_getUserImageList( (ImageType)i );
- implts_storeUserImages( (ImageType)i, xUserImageStorage, xUserBitmapsStorage );
- }
-
- uno::Reference< XTransactedObject > xTransaction( Storage, UNO_QUERY );
- if ( xTransaction.is() )
- xTransaction->commit();
- }
- }
+ m_pImpl->storeToStorage(Storage);
}
sal_Bool SAL_CALL ImageManager::isModified()
throw (::com::sun::star::uno::RuntimeException)
{
- ResetableGuard aGuard( m_aLock );
- return m_bModified;
+ return m_pImpl->isModified();
}
sal_Bool SAL_CALL ImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
{
- ResetableGuard aGuard( m_aLock );
- return m_bReadOnly;
-}
-
-void ImageManager::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
-{
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer(
- ::getCppuType( ( const css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >*) NULL ) );
- if ( pContainer != NULL )
- {
- ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
- while ( pIterator.hasMoreElements() )
- {
- try
- {
- switch ( eOp )
- {
- case NotifyOp_Replace:
- ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementReplaced( aEvent );
- break;
- case NotifyOp_Insert:
- ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementInserted( aEvent );
- break;
- case NotifyOp_Remove:
- ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementRemoved( aEvent );
- break;
- }
- }
- catch( css::uno::RuntimeException& )
- {
- pIterator.remove();
- }
- }
- }
+ return m_pImpl->isReadOnly();
}
} // namespace framework