1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_framework.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <imagemanagerimpl.hxx> 32*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx> 33*cdf0e10cSrcweir #include <xml/imagesconfiguration.hxx> 34*cdf0e10cSrcweir #include <uiconfiguration/graphicnameaccess.hxx> 35*cdf0e10cSrcweir #include <services.h> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include "properties.h" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 40*cdf0e10cSrcweir // interface includes 41*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 42*cdf0e10cSrcweir #include <com/sun/star/ui/UIElementType.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/ui/ConfigurationEvent.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/ui/ImageType.hpp> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 52*cdf0e10cSrcweir // other includes 53*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #include <vcl/svapp.hxx> 56*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 57*cdf0e10cSrcweir #include <osl/mutex.hxx> 58*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 59*cdf0e10cSrcweir #include <tools/urlobj.hxx> 60*cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 61*cdf0e10cSrcweir #include <vcl/pngread.hxx> 62*cdf0e10cSrcweir #include <vcl/pngwrite.hxx> 63*cdf0e10cSrcweir #include <rtl/logfile.hxx> 64*cdf0e10cSrcweir #include "svtools/miscopt.hxx" 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 67*cdf0e10cSrcweir // namespaces 68*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir using ::rtl::OUString; 71*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 72*cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 73*cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 74*cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 75*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 76*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 77*cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 78*cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphic; 79*cdf0e10cSrcweir using namespace ::com::sun::star; 80*cdf0e10cSrcweir using namespace ::com::sun::star::io; 81*cdf0e10cSrcweir using namespace ::com::sun::star::embed; 82*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 83*cdf0e10cSrcweir using namespace ::com::sun::star::container; 84*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 85*cdf0e10cSrcweir using namespace ::com::sun::star::ui; 86*cdf0e10cSrcweir using namespace ::cppu; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // Image sizes for our toolbars/menus 89*cdf0e10cSrcweir const sal_Int32 IMAGE_SIZE_NORMAL = 16; 90*cdf0e10cSrcweir const sal_Int32 IMAGE_SIZE_LARGE = 26; 91*cdf0e10cSrcweir const sal_Int16 MAX_IMAGETYPE_VALUE = ::com::sun::star::ui::ImageType::COLOR_HIGHCONTRAST| 92*cdf0e10cSrcweir ::com::sun::star::ui::ImageType::SIZE_LARGE; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir static const char IMAGE_FOLDER[] = "images"; 95*cdf0e10cSrcweir static const char BITMAPS_FOLDER[] = "Bitmaps"; 96*cdf0e10cSrcweir static const char IMAGE_EXTENSION[] = ".png"; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir static const char* IMAGELIST_XML_FILE[] = 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir "sc_imagelist.xml", 101*cdf0e10cSrcweir "lc_imagelist.xml", 102*cdf0e10cSrcweir "sch_imagelist.xml", 103*cdf0e10cSrcweir "lch_imagelist.xml" 104*cdf0e10cSrcweir }; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir static const char* BITMAP_FILE_NAMES[] = 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir "sc_userimages.png", 109*cdf0e10cSrcweir "lc_userimages.png", 110*cdf0e10cSrcweir "sch_userimages.png", 111*cdf0e10cSrcweir "lch_userimages.png" 112*cdf0e10cSrcweir }; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir namespace framework 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir static char ModuleImageList[] = "private:resource/images/moduleimages"; 117*cdf0e10cSrcweir static osl::Mutex* pImageListWrapperMutex = 0; 118*cdf0e10cSrcweir static GlobalImageList* pGlobalImageList = 0; 119*cdf0e10cSrcweir static const char* ImageType_Prefixes[ImageType_COUNT] = 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir "res/commandimagelist/sc_", 122*cdf0e10cSrcweir "res/commandimagelist/lc_", 123*cdf0e10cSrcweir "res/commandimagelist/sch_", 124*cdf0e10cSrcweir "res/commandimagelist/lch_" 125*cdf0e10cSrcweir }; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir typedef GraphicNameAccess CmdToXGraphicNameAccess; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir static osl::Mutex& getGlobalImageListMutex() 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir if ( pImageListWrapperMutex == 0 ) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 134*cdf0e10cSrcweir if ( pImageListWrapperMutex == 0 ) 135*cdf0e10cSrcweir pImageListWrapperMutex = new osl::Mutex; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir return *pImageListWrapperMutex; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir static GlobalImageList* getGlobalImageList( const uno::Reference< XMultiServiceFactory >& rServiceManager ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir osl::MutexGuard guard( getGlobalImageListMutex() ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir if ( pGlobalImageList == 0 ) 146*cdf0e10cSrcweir pGlobalImageList = new GlobalImageList( rServiceManager ); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir return pGlobalImageList; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir static rtl::OUString getCanonicalName( const rtl::OUString& rFileName ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir bool bRemoveSlash( true ); 154*cdf0e10cSrcweir sal_Int32 nLength = rFileName.getLength(); 155*cdf0e10cSrcweir const sal_Unicode* pString = rFileName.getStr(); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir rtl::OUStringBuffer aBuf( nLength ); 158*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nLength; i++ ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir const sal_Unicode c = pString[i]; 161*cdf0e10cSrcweir switch ( c ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir // map forbidden characters to escape 164*cdf0e10cSrcweir case '/' : if ( !bRemoveSlash ) 165*cdf0e10cSrcweir aBuf.appendAscii( "%2f" ); 166*cdf0e10cSrcweir break; 167*cdf0e10cSrcweir case '\\': aBuf.appendAscii( "%5c" ); bRemoveSlash = false; break; 168*cdf0e10cSrcweir case ':' : aBuf.appendAscii( "%3a" ); bRemoveSlash = false; break; 169*cdf0e10cSrcweir case '*' : aBuf.appendAscii( "%2a" ); bRemoveSlash = false; break; 170*cdf0e10cSrcweir case '?' : aBuf.appendAscii( "%3f" ); bRemoveSlash = false; break; 171*cdf0e10cSrcweir case '<' : aBuf.appendAscii( "%3c" ); bRemoveSlash = false; break; 172*cdf0e10cSrcweir case '>' : aBuf.appendAscii( "%3e" ); bRemoveSlash = false; break; 173*cdf0e10cSrcweir case '|' : aBuf.appendAscii( "%7c" ); bRemoveSlash = false; break; 174*cdf0e10cSrcweir default: aBuf.append( c ); bRemoveSlash = false; 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir return aBuf.makeStringAndClear(); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir CmdImageList::CmdImageList( const uno::Reference< XMultiServiceFactory >& rServiceManager, const rtl::OUString& aModuleIdentifier ) : 183*cdf0e10cSrcweir m_bVectorInit( sal_False ), 184*cdf0e10cSrcweir m_aModuleIdentifier( aModuleIdentifier ), 185*cdf0e10cSrcweir m_xServiceManager( rServiceManager ), 186*cdf0e10cSrcweir m_nSymbolsStyle( SvtMiscOptions().GetCurrentSymbolsStyle() ) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir for ( sal_Int32 n=0; n < ImageType_COUNT; n++ ) 189*cdf0e10cSrcweir m_pImageList[n] = 0; 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir CmdImageList::~CmdImageList() 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir for ( sal_Int32 n=0; n < ImageType_COUNT; n++ ) 195*cdf0e10cSrcweir delete m_pImageList[n]; 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir void CmdImageList::impl_fillCommandToImageNameMap() 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "framework: CmdImageList::impl_fillCommandToImageNameMap" ); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir if ( !m_bVectorInit ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir const rtl::OUString aCommandImageList( RTL_CONSTASCII_USTRINGPARAM( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST )); 205*cdf0e10cSrcweir Sequence< OUString > aCmdImageSeq; 206*cdf0e10cSrcweir uno::Reference< XNameAccess > xCmdDesc( m_xServiceManager->createInstance( 207*cdf0e10cSrcweir SERVICENAME_UICOMMANDDESCRIPTION ), 208*cdf0e10cSrcweir UNO_QUERY ); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir if ( m_aModuleIdentifier.getLength() > 0 ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir // If we have a module identifier - use to retrieve the command image name list from it. 213*cdf0e10cSrcweir // Otherwise we will use the global command image list 214*cdf0e10cSrcweir try 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir xCmdDesc->getByName( m_aModuleIdentifier ) >>= xCmdDesc; 217*cdf0e10cSrcweir if ( xCmdDesc.is() ) 218*cdf0e10cSrcweir xCmdDesc->getByName( aCommandImageList ) >>= aCmdImageSeq; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir catch ( NoSuchElementException& ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir // Module unknown we will work with an empty command image list! 223*cdf0e10cSrcweir return; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir if ( xCmdDesc.is() ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir try 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir xCmdDesc->getByName( aCommandImageList ) >>= aCmdImageSeq; 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir catch ( NoSuchElementException& ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir catch ( WrappedTargetException& ) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir // We have to map commands which uses special characters like '/',':','?','\','<'.'>','|' 242*cdf0e10cSrcweir String aExt = String::CreateFromAscii( IMAGE_EXTENSION ); 243*cdf0e10cSrcweir m_aImageCommandNameVector.resize(aCmdImageSeq.getLength() ); 244*cdf0e10cSrcweir m_aImageNameVector.resize( aCmdImageSeq.getLength() ); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir ::std::copy( aCmdImageSeq.getConstArray(), 247*cdf0e10cSrcweir aCmdImageSeq.getConstArray()+aCmdImageSeq.getLength(), 248*cdf0e10cSrcweir m_aImageCommandNameVector.begin() ); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir // Create a image name vector that must be provided to the vcl imagelist. We also need 251*cdf0e10cSrcweir // a command to image name map to speed up access time for image retrieval. 252*cdf0e10cSrcweir OUString aUNOString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" )); 253*cdf0e10cSrcweir String aEmptyString; 254*cdf0e10cSrcweir const sal_uInt32 nCount = m_aImageCommandNameVector.size(); 255*cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < nCount; i++ ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir OUString aCommandName( m_aImageCommandNameVector[i] ); 258*cdf0e10cSrcweir String aImageName; 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir if ( aCommandName.indexOf( aUNOString ) != 0 ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir INetURLObject aUrlObject( aCommandName, INetURLObject::ENCODE_ALL ); 263*cdf0e10cSrcweir aImageName = aUrlObject.GetURLPath(); 264*cdf0e10cSrcweir aImageName = getCanonicalName( aImageName ); // convert to valid filename 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir else 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir // just remove the schema 269*cdf0e10cSrcweir if ( aCommandName.getLength() > 5 ) 270*cdf0e10cSrcweir aImageName = aCommandName.copy( 5 ); 271*cdf0e10cSrcweir else 272*cdf0e10cSrcweir aImageName = aEmptyString; 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir // Search for query part. 275*cdf0e10cSrcweir sal_Int32 nIndex = aImageName.Search( '?' ); 276*cdf0e10cSrcweir if ( nIndex != STRING_NOTFOUND ) 277*cdf0e10cSrcweir aImageName = getCanonicalName( aImageName ); // convert to valid filename 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir // Image names are not case-dependent. Always use lower case characters to 280*cdf0e10cSrcweir // reflect this. 281*cdf0e10cSrcweir aImageName += aExt; 282*cdf0e10cSrcweir aImageName.ToLowerAscii(); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir m_aImageNameVector[i] = aImageName; 285*cdf0e10cSrcweir m_aCommandToImageNameMap.insert( CommandToImageNameMap::value_type( aCommandName, aImageName )); 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir m_bVectorInit = sal_True; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir ImageList* CmdImageList::impl_getImageList( sal_Int16 nImageType ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir SvtMiscOptions aMiscOptions; 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir sal_Int16 nSymbolsStyle = aMiscOptions.GetCurrentSymbolsStyle(); 297*cdf0e10cSrcweir if ( nSymbolsStyle != m_nSymbolsStyle ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir m_nSymbolsStyle = nSymbolsStyle; 300*cdf0e10cSrcweir for ( sal_Int32 n=0; n < ImageType_COUNT; n++ ) 301*cdf0e10cSrcweir delete m_pImageList[n], m_pImageList[n] = NULL; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir if ( !m_pImageList[nImageType] ) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir m_pImageList[nImageType] = new ImageList( m_aImageNameVector, 307*cdf0e10cSrcweir OUString::createFromAscii( ImageType_Prefixes[nImageType] ) ); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir return m_pImageList[nImageType]; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir std::vector< ::rtl::OUString >& CmdImageList::impl_getImageNameVector() 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir return m_aImageNameVector; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir std::vector< rtl::OUString >& CmdImageList::impl_getImageCommandNameVector() 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir return m_aImageCommandNameVector; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir Image CmdImageList::getImageFromCommandURL( sal_Int16 nImageType, const rtl::OUString& rCommandURL ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir impl_fillCommandToImageNameMap(); 326*cdf0e10cSrcweir CommandToImageNameMap::const_iterator pIter = m_aCommandToImageNameMap.find( rCommandURL ); 327*cdf0e10cSrcweir if ( pIter != m_aCommandToImageNameMap.end() ) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir ImageList* pImageList = impl_getImageList( nImageType ); 330*cdf0e10cSrcweir return pImageList->GetImage( pIter->second ); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir return Image(); 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir bool CmdImageList::hasImage( sal_Int16 /*nImageType*/, const rtl::OUString& rCommandURL ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir impl_fillCommandToImageNameMap(); 339*cdf0e10cSrcweir CommandToImageNameMap::const_iterator pIter = m_aCommandToImageNameMap.find( rCommandURL ); 340*cdf0e10cSrcweir if ( pIter != m_aCommandToImageNameMap.end() ) 341*cdf0e10cSrcweir return true; 342*cdf0e10cSrcweir else 343*cdf0e10cSrcweir return false; 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir ::std::vector< rtl::OUString >& CmdImageList::getImageNames() 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir return impl_getImageNameVector(); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir ::std::vector< rtl::OUString >& CmdImageList::getImageCommandNames() 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir return impl_getImageCommandNameVector(); 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir GlobalImageList::GlobalImageList( const uno::Reference< XMultiServiceFactory >& rServiceManager ) : 359*cdf0e10cSrcweir CmdImageList( rServiceManager, rtl::OUString() ), 360*cdf0e10cSrcweir m_nRefCount( 0 ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir GlobalImageList::~GlobalImageList() 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir Image GlobalImageList::getImageFromCommandURL( sal_Int16 nImageType, const rtl::OUString& rCommandURL ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir osl::MutexGuard guard( getGlobalImageListMutex() ); 371*cdf0e10cSrcweir return CmdImageList::getImageFromCommandURL( nImageType, rCommandURL ); 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir bool GlobalImageList::hasImage( sal_Int16 nImageType, const rtl::OUString& rCommandURL ) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir osl::MutexGuard guard( getGlobalImageListMutex() ); 377*cdf0e10cSrcweir return CmdImageList::hasImage( nImageType, rCommandURL ); 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir ::std::vector< rtl::OUString >& GlobalImageList::getImageNames() 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir osl::MutexGuard guard( getGlobalImageListMutex() ); 383*cdf0e10cSrcweir return impl_getImageNameVector(); 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir ::std::vector< rtl::OUString >& GlobalImageList::getImageCommandNames() 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir osl::MutexGuard guard( getGlobalImageListMutex() ); 389*cdf0e10cSrcweir return impl_getImageCommandNameVector(); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir oslInterlockedCount GlobalImageList::acquire() 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_nRefCount ); 395*cdf0e10cSrcweir return m_nRefCount; 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir oslInterlockedCount GlobalImageList::release() 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir osl::MutexGuard guard( getGlobalImageListMutex() ); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir if ( !osl_decrementInterlockedCount( &m_nRefCount )) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir oslInterlockedCount nCount( m_nRefCount ); 405*cdf0e10cSrcweir // remove global pointer as we destroy the object now 406*cdf0e10cSrcweir pGlobalImageList = 0; 407*cdf0e10cSrcweir delete this; 408*cdf0e10cSrcweir return nCount; 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir return m_nRefCount; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir static sal_Bool implts_checkAndScaleGraphic( uno::Reference< XGraphic >& rOutGraphic, const uno::Reference< XGraphic >& rInGraphic, sal_Int16 nImageType ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir static Size aNormSize( IMAGE_SIZE_NORMAL, IMAGE_SIZE_NORMAL ); 417*cdf0e10cSrcweir static Size aLargeSize( IMAGE_SIZE_LARGE, IMAGE_SIZE_LARGE ); 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir if ( !rInGraphic.is() ) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir rOutGraphic = Image().GetXGraphic(); 422*cdf0e10cSrcweir return sal_False; 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir // Check size and scale it 426*cdf0e10cSrcweir Image aImage( rInGraphic ); 427*cdf0e10cSrcweir Size aSize = aImage.GetSizePixel(); 428*cdf0e10cSrcweir bool bMustScale( false ); 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir if (( nImageType == ImageType_Color_Large ) || 431*cdf0e10cSrcweir ( nImageType == ImageType_HC_Large )) 432*cdf0e10cSrcweir bMustScale = ( aSize != aLargeSize ); 433*cdf0e10cSrcweir else 434*cdf0e10cSrcweir bMustScale = ( aSize != aNormSize ); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir if ( bMustScale ) 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir BitmapEx aBitmap = aImage.GetBitmapEx(); 439*cdf0e10cSrcweir aBitmap.Scale( aNormSize ); 440*cdf0e10cSrcweir aImage = Image( aBitmap ); 441*cdf0e10cSrcweir rOutGraphic = aImage.GetXGraphic(); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir else 444*cdf0e10cSrcweir rOutGraphic = rInGraphic; 445*cdf0e10cSrcweir return sal_True; 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir static sal_Int16 implts_convertImageTypeToIndex( sal_Int16 nImageType ) 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir sal_Int16 nIndex( 0 ); 451*cdf0e10cSrcweir if ( nImageType & ::com::sun::star::ui::ImageType::SIZE_LARGE ) 452*cdf0e10cSrcweir nIndex += 1; 453*cdf0e10cSrcweir if ( nImageType & ::com::sun::star::ui::ImageType::COLOR_HIGHCONTRAST ) 454*cdf0e10cSrcweir nIndex += 2; 455*cdf0e10cSrcweir return nIndex; 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir ImageList* ImageManagerImpl::implts_getUserImageList( ImageType nImageType ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 461*cdf0e10cSrcweir if ( !m_pUserImageList[nImageType] ) 462*cdf0e10cSrcweir implts_loadUserImages( nImageType, m_xUserImageStorage, m_xUserBitmapsStorage ); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir return m_pUserImageList[nImageType]; 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir void ImageManagerImpl::implts_initialize() 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir // Initialize the top-level structures with the storage data 470*cdf0e10cSrcweir if ( m_xUserConfigStorage.is() ) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir long nModes = m_bReadOnly ? ElementModes::READ : ElementModes::READWRITE; 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir try 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir m_xUserImageStorage = m_xUserConfigStorage->openStorageElement( OUString::createFromAscii( IMAGE_FOLDER ), 477*cdf0e10cSrcweir nModes ); 478*cdf0e10cSrcweir if ( m_xUserImageStorage.is() ) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir m_xUserBitmapsStorage = m_xUserImageStorage->openStorageElement( OUString::createFromAscii( BITMAPS_FOLDER ), 481*cdf0e10cSrcweir nModes ); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir catch ( com::sun::star::container::NoSuchElementException& ) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir catch ( ::com::sun::star::embed::InvalidStorageException& ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir catch ( ::com::sun::star::lang::IllegalArgumentException& ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir catch ( ::com::sun::star::io::IOException& ) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir catch ( ::com::sun::star::embed::StorageWrappedTargetException& ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir sal_Bool ImageManagerImpl::implts_loadUserImages( 503*cdf0e10cSrcweir ImageType nImageType, 504*cdf0e10cSrcweir const uno::Reference< XStorage >& xUserImageStorage, 505*cdf0e10cSrcweir const uno::Reference< XStorage >& xUserBitmapsStorage ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir if ( xUserImageStorage.is() && xUserBitmapsStorage.is() ) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir try 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir uno::Reference< XStream > xStream = xUserImageStorage->openStreamElement( rtl::OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ), 514*cdf0e10cSrcweir ElementModes::READ ); 515*cdf0e10cSrcweir uno::Reference< XInputStream > xInputStream = xStream->getInputStream(); 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir ImageListsDescriptor aUserImageListInfo; 518*cdf0e10cSrcweir ImagesConfiguration::LoadImages( m_xServiceManager, 519*cdf0e10cSrcweir xInputStream, 520*cdf0e10cSrcweir aUserImageListInfo ); 521*cdf0e10cSrcweir if (( aUserImageListInfo.pImageList != 0 ) && 522*cdf0e10cSrcweir ( aUserImageListInfo.pImageList->Count() > 0 )) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir ImageListItemDescriptor* pList = aUserImageListInfo.pImageList->GetObject(0); 525*cdf0e10cSrcweir sal_Int32 nCount = pList->pImageItemList->Count(); 526*cdf0e10cSrcweir std::vector< OUString > aUserImagesVector; 527*cdf0e10cSrcweir aUserImagesVector.reserve(nCount); 528*cdf0e10cSrcweir for ( sal_uInt16 i=0; i < nCount; i++ ) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir const ImageItemDescriptor* pItem = pList->pImageItemList->GetObject(i); 531*cdf0e10cSrcweir aUserImagesVector.push_back( pItem->aCommandURL ); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir uno::Reference< XStream > xBitmapStream = xUserBitmapsStorage->openStreamElement( 535*cdf0e10cSrcweir rtl::OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ), 536*cdf0e10cSrcweir ElementModes::READ ); 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir if ( xBitmapStream.is() ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir SvStream* pSvStream( 0 ); 541*cdf0e10cSrcweir BitmapEx aUserBitmap; 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir pSvStream = utl::UcbStreamHelper::CreateStream( xBitmapStream ); 544*cdf0e10cSrcweir vcl::PNGReader aPngReader( *pSvStream ); 545*cdf0e10cSrcweir aUserBitmap = aPngReader.Read(); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir delete pSvStream; 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir // Delete old image list and create a new one from the read bitmap 550*cdf0e10cSrcweir delete m_pUserImageList[nImageType]; 551*cdf0e10cSrcweir m_pUserImageList[nImageType] = new ImageList(); 552*cdf0e10cSrcweir m_pUserImageList[nImageType]->InsertFromHorizontalStrip 553*cdf0e10cSrcweir ( aUserBitmap, aUserImagesVector ); 554*cdf0e10cSrcweir return sal_True; 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir catch ( com::sun::star::container::NoSuchElementException& ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir } 561*cdf0e10cSrcweir catch ( ::com::sun::star::embed::InvalidStorageException& ) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir catch ( ::com::sun::star::lang::IllegalArgumentException& ) 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir } 567*cdf0e10cSrcweir catch ( ::com::sun::star::io::IOException& ) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir catch ( ::com::sun::star::embed::StorageWrappedTargetException& ) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir // Destroy old image list - create a new empty one 576*cdf0e10cSrcweir delete m_pUserImageList[nImageType]; 577*cdf0e10cSrcweir m_pUserImageList[nImageType] = new ImageList; 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir return sal_True; 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir sal_Bool ImageManagerImpl::implts_storeUserImages( 583*cdf0e10cSrcweir ImageType nImageType, 584*cdf0e10cSrcweir const uno::Reference< XStorage >& xUserImageStorage, 585*cdf0e10cSrcweir const uno::Reference< XStorage >& xUserBitmapsStorage ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir if ( m_bModified ) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir ImageList* pImageList = implts_getUserImageList( nImageType ); 592*cdf0e10cSrcweir if ( pImageList->GetImageCount() > 0 ) 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir ImageListsDescriptor aUserImageListInfo; 595*cdf0e10cSrcweir aUserImageListInfo.pImageList = new ImageListDescriptor; 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir ImageListItemDescriptor* pList = new ImageListItemDescriptor; 598*cdf0e10cSrcweir aUserImageListInfo.pImageList->Insert( pList, 0 ); 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir pList->pImageItemList = new ImageItemListDescriptor; 601*cdf0e10cSrcweir for ( sal_uInt16 i=0; i < pImageList->GetImageCount(); i++ ) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir ImageItemDescriptor* pItem = new ::framework::ImageItemDescriptor; 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir pItem->nIndex = i; 606*cdf0e10cSrcweir pItem->aCommandURL = pImageList->GetImageName( i ); 607*cdf0e10cSrcweir pList->pImageItemList->Insert( pItem, pList->pImageItemList->Count() ); 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir pList->aURL = String::CreateFromAscii("Bitmaps/"); 611*cdf0e10cSrcweir pList->aURL += String::CreateFromAscii( BITMAP_FILE_NAMES[nImageType] ); 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir uno::Reference< XTransactedObject > xTransaction; 614*cdf0e10cSrcweir uno::Reference< XOutputStream > xOutputStream; 615*cdf0e10cSrcweir uno::Reference< XStream > xStream = xUserImageStorage->openStreamElement( rtl::OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] ), 616*cdf0e10cSrcweir ElementModes::WRITE|ElementModes::TRUNCATE ); 617*cdf0e10cSrcweir if ( xStream.is() ) 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir uno::Reference< XStream > xBitmapStream = 620*cdf0e10cSrcweir xUserBitmapsStorage->openStreamElement( rtl::OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] ), 621*cdf0e10cSrcweir ElementModes::WRITE|ElementModes::TRUNCATE ); 622*cdf0e10cSrcweir if ( xBitmapStream.is() ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir SvStream* pSvStream = utl::UcbStreamHelper::CreateStream( xBitmapStream ); 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir vcl::PNGWriter aPngWriter( pImageList->GetAsHorizontalStrip() ); 627*cdf0e10cSrcweir aPngWriter.Write( *pSvStream ); 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir delete pSvStream; 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir // Commit user bitmaps storage 632*cdf0e10cSrcweir xTransaction = uno::Reference< XTransactedObject >( xUserBitmapsStorage, UNO_QUERY ); 633*cdf0e10cSrcweir if ( xTransaction.is() ) 634*cdf0e10cSrcweir xTransaction->commit(); 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir xOutputStream = xStream->getOutputStream(); 638*cdf0e10cSrcweir if ( xOutputStream.is() ) 639*cdf0e10cSrcweir ImagesConfiguration::StoreImages( m_xServiceManager, xOutputStream, aUserImageListInfo ); 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir // Commit user image storage 642*cdf0e10cSrcweir xTransaction = uno::Reference< XTransactedObject >( xUserImageStorage, UNO_QUERY ); 643*cdf0e10cSrcweir if ( xTransaction.is() ) 644*cdf0e10cSrcweir xTransaction->commit(); 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir return sal_True; 648*cdf0e10cSrcweir } 649*cdf0e10cSrcweir else 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir // Remove the streams from the storage, if we have no data. We have to catch 652*cdf0e10cSrcweir // the NoSuchElementException as it can be possible that there is no stream at all! 653*cdf0e10cSrcweir try 654*cdf0e10cSrcweir { 655*cdf0e10cSrcweir xUserImageStorage->removeElement( rtl::OUString::createFromAscii( IMAGELIST_XML_FILE[nImageType] )); 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir catch ( ::com::sun::star::container::NoSuchElementException& ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir try 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir xUserBitmapsStorage->removeElement( rtl::OUString::createFromAscii( BITMAP_FILE_NAMES[nImageType] )); 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir catch ( ::com::sun::star::container::NoSuchElementException& ) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir uno::Reference< XTransactedObject > xTransaction; 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir // Commit user image storage 672*cdf0e10cSrcweir xTransaction = uno::Reference< XTransactedObject >( xUserImageStorage, UNO_QUERY ); 673*cdf0e10cSrcweir if ( xTransaction.is() ) 674*cdf0e10cSrcweir xTransaction->commit(); 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir // Commit user bitmaps storage 677*cdf0e10cSrcweir xTransaction = uno::Reference< XTransactedObject >( xUserBitmapsStorage, UNO_QUERY ); 678*cdf0e10cSrcweir if ( xTransaction.is() ) 679*cdf0e10cSrcweir xTransaction->commit(); 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir return sal_True; 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir return sal_False; 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir const rtl::Reference< GlobalImageList >& ImageManagerImpl::implts_getGlobalImageList() 688*cdf0e10cSrcweir { 689*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir if ( !m_pGlobalImageList.is() ) 692*cdf0e10cSrcweir m_pGlobalImageList = getGlobalImageList( m_xServiceManager ); 693*cdf0e10cSrcweir return m_pGlobalImageList; 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir CmdImageList* ImageManagerImpl::implts_getDefaultImageList() 697*cdf0e10cSrcweir { 698*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir if ( !m_pDefaultImageList ) 701*cdf0e10cSrcweir m_pDefaultImageList = new CmdImageList( m_xServiceManager, m_aModuleIdentifier ); 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir return m_pDefaultImageList; 704*cdf0e10cSrcweir } 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir ImageManagerImpl::ImageManagerImpl( const uno::Reference< XMultiServiceFactory >& xServiceManager,const uno::Reference< XInterface >& _xOwner,bool _bUseGlobal ) : 707*cdf0e10cSrcweir ThreadHelpBase( &Application::GetSolarMutex() ) 708*cdf0e10cSrcweir , m_xServiceManager( xServiceManager ) 709*cdf0e10cSrcweir , m_xOwner(_xOwner) 710*cdf0e10cSrcweir , m_pDefaultImageList( 0 ) 711*cdf0e10cSrcweir , m_aXMLPostfix( RTL_CONSTASCII_USTRINGPARAM( ".xml" )) 712*cdf0e10cSrcweir , m_aResourceString( RTL_CONSTASCII_USTRINGPARAM( ModuleImageList )) 713*cdf0e10cSrcweir , m_aListenerContainer( m_aLock.getShareableOslMutex() ) 714*cdf0e10cSrcweir , m_bUseGlobal(_bUseGlobal) 715*cdf0e10cSrcweir , m_bReadOnly( true ) 716*cdf0e10cSrcweir , m_bInitialized( false ) 717*cdf0e10cSrcweir , m_bModified( false ) 718*cdf0e10cSrcweir , m_bConfigRead( false ) 719*cdf0e10cSrcweir , m_bDisposed( false ) 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir for ( sal_Int32 n=0; n < ImageType_COUNT; n++ ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir m_pUserImageList[n] = 0; 724*cdf0e10cSrcweir m_bUserImageListModified[n] = false; 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir ImageManagerImpl::~ImageManagerImpl() 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir clear(); 731*cdf0e10cSrcweir } 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir void ImageManagerImpl::dispose() 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir css::lang::EventObject aEvent( m_xOwner ); 736*cdf0e10cSrcweir m_aListenerContainer.disposeAndClear( aEvent ); 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 740*cdf0e10cSrcweir m_xUserConfigStorage.clear(); 741*cdf0e10cSrcweir m_xUserImageStorage.clear(); 742*cdf0e10cSrcweir m_xUserRootCommit.clear(); 743*cdf0e10cSrcweir m_bConfigRead = false; 744*cdf0e10cSrcweir m_bModified = false; 745*cdf0e10cSrcweir m_bDisposed = true; 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir // delete user and default image list on dispose 748*cdf0e10cSrcweir for ( sal_Int32 n=0; n < ImageType_COUNT; n++ ) 749*cdf0e10cSrcweir { 750*cdf0e10cSrcweir delete m_pUserImageList[n]; 751*cdf0e10cSrcweir m_pUserImageList[n] = 0; 752*cdf0e10cSrcweir } 753*cdf0e10cSrcweir delete m_pDefaultImageList; 754*cdf0e10cSrcweir m_pDefaultImageList = 0; 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir void ImageManagerImpl::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 759*cdf0e10cSrcweir { 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 764*cdf0e10cSrcweir if ( m_bDisposed ) 765*cdf0e10cSrcweir throw DisposedException(); 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir m_aListenerContainer.addInterface( ::getCppuType( ( const uno::Reference< XEventListener >* ) NULL ), xListener ); 769*cdf0e10cSrcweir } 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir void ImageManagerImpl::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 774*cdf0e10cSrcweir m_aListenerContainer.removeInterface( ::getCppuType( ( const uno::Reference< XEventListener >* ) NULL ), xListener ); 775*cdf0e10cSrcweir } 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir // XInitialization 778*cdf0e10cSrcweir void ImageManagerImpl::initialize( const Sequence< Any >& aArguments ) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir if ( !m_bInitialized ) 783*cdf0e10cSrcweir { 784*cdf0e10cSrcweir for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ ) 785*cdf0e10cSrcweir { 786*cdf0e10cSrcweir PropertyValue aPropValue; 787*cdf0e10cSrcweir if ( aArguments[n] >>= aPropValue ) 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir if ( aPropValue.Name.equalsAscii( "UserConfigStorage" )) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir aPropValue.Value >>= m_xUserConfigStorage; 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir else if ( aPropValue.Name.equalsAscii( "ModuleIdentifier" )) 794*cdf0e10cSrcweir { 795*cdf0e10cSrcweir aPropValue.Value >>= m_aModuleIdentifier; 796*cdf0e10cSrcweir } 797*cdf0e10cSrcweir else if ( aPropValue.Name.equalsAscii( "UserRootCommit" )) 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir aPropValue.Value >>= m_xUserRootCommit; 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir } 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir if ( m_xUserConfigStorage.is() ) 805*cdf0e10cSrcweir { 806*cdf0e10cSrcweir uno::Reference< XPropertySet > xPropSet( m_xUserConfigStorage, UNO_QUERY ); 807*cdf0e10cSrcweir if ( xPropSet.is() ) 808*cdf0e10cSrcweir { 809*cdf0e10cSrcweir long nOpenMode = 0; 810*cdf0e10cSrcweir if ( xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ))) >>= nOpenMode ) 811*cdf0e10cSrcweir m_bReadOnly = !( nOpenMode & ElementModes::WRITE ); 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir } 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir implts_initialize(); 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir m_bInitialized = true; 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir // XImageManagerImpl 822*cdf0e10cSrcweir void ImageManagerImpl::reset() 823*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 824*cdf0e10cSrcweir { 825*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 828*cdf0e10cSrcweir if ( m_bDisposed ) 829*cdf0e10cSrcweir throw DisposedException(); 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir std::vector< OUString > aUserImageNames; 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < ImageType_COUNT; i++ ) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir aUserImageNames.clear(); 836*cdf0e10cSrcweir ImageList* pImageList = implts_getUserImageList( ImageType(i)); 837*cdf0e10cSrcweir pImageList->GetImageNames( aUserImageNames ); 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir Sequence< rtl::OUString > aRemoveList( aUserImageNames.size() ); 840*cdf0e10cSrcweir const sal_uInt32 nCount = aUserImageNames.size(); 841*cdf0e10cSrcweir for ( sal_uInt32 j = 0; j < nCount; j++ ) 842*cdf0e10cSrcweir aRemoveList[j] = aUserImageNames[j]; 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir // Remove images 845*cdf0e10cSrcweir removeImages( sal_Int16( i ), aRemoveList ); 846*cdf0e10cSrcweir m_bUserImageListModified[i] = true; 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir m_bModified = sal_True; 850*cdf0e10cSrcweir } 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir Sequence< ::rtl::OUString > ImageManagerImpl::getAllImageNames( ::sal_Int16 nImageType ) 853*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 858*cdf0e10cSrcweir if ( m_bDisposed ) 859*cdf0e10cSrcweir throw DisposedException(); 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir ImageNameMap aImageCmdNameMap; 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType ); 864*cdf0e10cSrcweir 865*cdf0e10cSrcweir sal_uInt32 i( 0 ); 866*cdf0e10cSrcweir if ( m_bUseGlobal ) 867*cdf0e10cSrcweir { 868*cdf0e10cSrcweir rtl::Reference< GlobalImageList > rGlobalImageList = implts_getGlobalImageList(); 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir const std::vector< OUString >& rGlobalImageNameVector = rGlobalImageList->getImageCommandNames(); 871*cdf0e10cSrcweir const sal_uInt32 nGlobalCount = rGlobalImageNameVector.size(); 872*cdf0e10cSrcweir for ( i = 0; i < nGlobalCount; i++ ) 873*cdf0e10cSrcweir aImageCmdNameMap.insert( ImageNameMap::value_type( rGlobalImageNameVector[i], sal_True )); 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir const std::vector< OUString >& rModuleImageNameVector = implts_getDefaultImageList()->getImageCommandNames(); 876*cdf0e10cSrcweir const sal_uInt32 nModuleCount = rModuleImageNameVector.size(); 877*cdf0e10cSrcweir for ( i = 0; i < nModuleCount; i++ ) 878*cdf0e10cSrcweir aImageCmdNameMap.insert( ImageNameMap::value_type( rModuleImageNameVector[i], sal_True )); 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir ImageList* pImageList = implts_getUserImageList( ImageType( nIndex )); 882*cdf0e10cSrcweir std::vector< OUString > rUserImageNames; 883*cdf0e10cSrcweir pImageList->GetImageNames( rUserImageNames ); 884*cdf0e10cSrcweir const sal_uInt32 nUserCount = rUserImageNames.size(); 885*cdf0e10cSrcweir for ( i = 0; i < nUserCount; i++ ) 886*cdf0e10cSrcweir aImageCmdNameMap.insert( ImageNameMap::value_type( rUserImageNames[i], sal_True )); 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir Sequence< OUString > aImageNameSeq( aImageCmdNameMap.size() ); 889*cdf0e10cSrcweir ImageNameMap::const_iterator pIter; 890*cdf0e10cSrcweir i = 0; 891*cdf0e10cSrcweir for ( pIter = aImageCmdNameMap.begin(); pIter != aImageCmdNameMap.end(); pIter++ ) 892*cdf0e10cSrcweir aImageNameSeq[i++] = pIter->first; 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir return aImageNameSeq; 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir ::sal_Bool ImageManagerImpl::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL ) 898*cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 899*cdf0e10cSrcweir { 900*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 901*cdf0e10cSrcweir 902*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 903*cdf0e10cSrcweir if ( m_bDisposed ) 904*cdf0e10cSrcweir throw DisposedException(); 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir if (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE )) 907*cdf0e10cSrcweir throw IllegalArgumentException(); 908*cdf0e10cSrcweir 909*cdf0e10cSrcweir sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType ); 910*cdf0e10cSrcweir if ( m_bUseGlobal && implts_getGlobalImageList()->hasImage( nIndex, aCommandURL )) 911*cdf0e10cSrcweir return sal_True; 912*cdf0e10cSrcweir else 913*cdf0e10cSrcweir { 914*cdf0e10cSrcweir if ( m_bUseGlobal && implts_getDefaultImageList()->hasImage( nIndex, aCommandURL )) 915*cdf0e10cSrcweir return sal_True; 916*cdf0e10cSrcweir else 917*cdf0e10cSrcweir { 918*cdf0e10cSrcweir // User layer 919*cdf0e10cSrcweir ImageList* pImageList = implts_getUserImageList( ImageType( nIndex )); 920*cdf0e10cSrcweir if ( pImageList ) 921*cdf0e10cSrcweir return ( pImageList->GetImagePos( aCommandURL ) != IMAGELIST_IMAGE_NOTFOUND ); 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir return sal_False; 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir Sequence< uno::Reference< XGraphic > > ImageManagerImpl::getImages( 929*cdf0e10cSrcweir ::sal_Int16 nImageType, 930*cdf0e10cSrcweir const Sequence< ::rtl::OUString >& aCommandURLSequence ) 931*cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) 932*cdf0e10cSrcweir { 933*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 936*cdf0e10cSrcweir if ( m_bDisposed ) 937*cdf0e10cSrcweir throw DisposedException(); 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir if (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE )) 940*cdf0e10cSrcweir throw IllegalArgumentException(); 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir Sequence< uno::Reference< XGraphic > > aGraphSeq( aCommandURLSequence.getLength() ); 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir const rtl::OUString* aStrArray = aCommandURLSequence.getConstArray(); 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType ); 947*cdf0e10cSrcweir rtl::Reference< GlobalImageList > rGlobalImageList; 948*cdf0e10cSrcweir CmdImageList* pDefaultImageList = NULL; 949*cdf0e10cSrcweir if ( m_bUseGlobal ) 950*cdf0e10cSrcweir { 951*cdf0e10cSrcweir rGlobalImageList = implts_getGlobalImageList(); 952*cdf0e10cSrcweir pDefaultImageList = implts_getDefaultImageList(); 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir ImageList* pUserImageList = implts_getUserImageList( ImageType( nIndex )); 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir // We have to search our image list in the following order: 957*cdf0e10cSrcweir // 1. user image list (read/write) 958*cdf0e10cSrcweir // 2. module image list (read) 959*cdf0e10cSrcweir // 3. global image list (read) 960*cdf0e10cSrcweir for ( sal_Int32 n = 0; n < aCommandURLSequence.getLength(); n++ ) 961*cdf0e10cSrcweir { 962*cdf0e10cSrcweir Image aImage = pUserImageList->GetImage( aStrArray[n] ); 963*cdf0e10cSrcweir if ( !aImage && m_bUseGlobal ) 964*cdf0e10cSrcweir { 965*cdf0e10cSrcweir aImage = pDefaultImageList->getImageFromCommandURL( nIndex, aStrArray[n] ); 966*cdf0e10cSrcweir if ( !aImage ) 967*cdf0e10cSrcweir aImage = rGlobalImageList->getImageFromCommandURL( nIndex, aStrArray[n] ); 968*cdf0e10cSrcweir } 969*cdf0e10cSrcweir 970*cdf0e10cSrcweir aGraphSeq[n] = aImage.GetXGraphic(); 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir 973*cdf0e10cSrcweir return aGraphSeq; 974*cdf0e10cSrcweir } 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir void ImageManagerImpl::replaceImages( 977*cdf0e10cSrcweir ::sal_Int16 nImageType, 978*cdf0e10cSrcweir const Sequence< ::rtl::OUString >& aCommandURLSequence, 979*cdf0e10cSrcweir const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence ) 980*cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException, 981*cdf0e10cSrcweir ::com::sun::star::lang::IllegalAccessException, 982*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 983*cdf0e10cSrcweir { 984*cdf0e10cSrcweir CmdToXGraphicNameAccess* pInsertedImages( 0 ); 985*cdf0e10cSrcweir CmdToXGraphicNameAccess* pReplacedImages( 0 ); 986*cdf0e10cSrcweir 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 989*cdf0e10cSrcweir 990*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 991*cdf0e10cSrcweir if ( m_bDisposed ) 992*cdf0e10cSrcweir throw DisposedException(); 993*cdf0e10cSrcweir 994*cdf0e10cSrcweir if (( aCommandURLSequence.getLength() != aGraphicsSequence.getLength() ) || 995*cdf0e10cSrcweir (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE ))) 996*cdf0e10cSrcweir throw IllegalArgumentException(); 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir if ( m_bReadOnly ) 999*cdf0e10cSrcweir throw IllegalAccessException(); 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType ); 1002*cdf0e10cSrcweir ImageList* pImageList = implts_getUserImageList( ImageType( nIndex )); 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir uno::Reference< XGraphic > xGraphic; 1005*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < aCommandURLSequence.getLength(); i++ ) 1006*cdf0e10cSrcweir { 1007*cdf0e10cSrcweir // Check size and scale. If we don't have any graphics ignore it 1008*cdf0e10cSrcweir if ( !implts_checkAndScaleGraphic( xGraphic, aGraphicsSequence[i], nIndex )) 1009*cdf0e10cSrcweir continue; 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir sal_uInt16 nPos = pImageList->GetImagePos( aCommandURLSequence[i] ); 1012*cdf0e10cSrcweir if ( nPos == IMAGELIST_IMAGE_NOTFOUND ) 1013*cdf0e10cSrcweir { 1014*cdf0e10cSrcweir pImageList->AddImage( aCommandURLSequence[i], xGraphic ); 1015*cdf0e10cSrcweir if ( !pInsertedImages ) 1016*cdf0e10cSrcweir pInsertedImages = new CmdToXGraphicNameAccess(); 1017*cdf0e10cSrcweir pInsertedImages->addElement( aCommandURLSequence[i], xGraphic ); 1018*cdf0e10cSrcweir } 1019*cdf0e10cSrcweir else 1020*cdf0e10cSrcweir { 1021*cdf0e10cSrcweir pImageList->ReplaceImage( aCommandURLSequence[i], xGraphic ); 1022*cdf0e10cSrcweir if ( !pReplacedImages ) 1023*cdf0e10cSrcweir pReplacedImages = new CmdToXGraphicNameAccess(); 1024*cdf0e10cSrcweir pReplacedImages->addElement( aCommandURLSequence[i], xGraphic ); 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir if (( pInsertedImages != 0 ) || ( pReplacedImages != 0 )) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir m_bModified = sal_True; 1031*cdf0e10cSrcweir m_bUserImageListModified[nIndex] = true; 1032*cdf0e10cSrcweir } 1033*cdf0e10cSrcweir } 1034*cdf0e10cSrcweir 1035*cdf0e10cSrcweir // Notify listeners 1036*cdf0e10cSrcweir if ( pInsertedImages != 0 ) 1037*cdf0e10cSrcweir { 1038*cdf0e10cSrcweir ConfigurationEvent aInsertEvent; 1039*cdf0e10cSrcweir aInsertEvent.aInfo <<= nImageType; 1040*cdf0e10cSrcweir aInsertEvent.Accessor <<= m_xOwner; 1041*cdf0e10cSrcweir aInsertEvent.Source = m_xOwner; 1042*cdf0e10cSrcweir aInsertEvent.ResourceURL = m_aResourceString; 1043*cdf0e10cSrcweir aInsertEvent.Element = uno::makeAny( uno::Reference< XNameAccess >( 1044*cdf0e10cSrcweir static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY )); 1045*cdf0e10cSrcweir implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert ); 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir if ( pReplacedImages != 0 ) 1048*cdf0e10cSrcweir { 1049*cdf0e10cSrcweir ConfigurationEvent aReplaceEvent; 1050*cdf0e10cSrcweir aReplaceEvent.aInfo <<= nImageType; 1051*cdf0e10cSrcweir aReplaceEvent.Accessor <<= m_xOwner; 1052*cdf0e10cSrcweir aReplaceEvent.Source = m_xOwner; 1053*cdf0e10cSrcweir aReplaceEvent.ResourceURL = m_aResourceString; 1054*cdf0e10cSrcweir aReplaceEvent.ReplacedElement = Any(); 1055*cdf0e10cSrcweir aReplaceEvent.Element = uno::makeAny( uno::Reference< XNameAccess >( 1056*cdf0e10cSrcweir static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY )); 1057*cdf0e10cSrcweir implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace ); 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir void ImageManagerImpl::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence ) 1062*cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException, 1063*cdf0e10cSrcweir ::com::sun::star::lang::IllegalAccessException, 1064*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 1065*cdf0e10cSrcweir { 1066*cdf0e10cSrcweir CmdToXGraphicNameAccess* pRemovedImages( 0 ); 1067*cdf0e10cSrcweir CmdToXGraphicNameAccess* pReplacedImages( 0 ); 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir { 1070*cdf0e10cSrcweir ResetableGuard aLock( m_aLock ); 1071*cdf0e10cSrcweir 1072*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1073*cdf0e10cSrcweir if ( m_bDisposed ) 1074*cdf0e10cSrcweir throw DisposedException(); 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir if (( nImageType < 0 ) || ( nImageType > MAX_IMAGETYPE_VALUE )) 1077*cdf0e10cSrcweir throw IllegalArgumentException(); 1078*cdf0e10cSrcweir 1079*cdf0e10cSrcweir if ( m_bReadOnly ) 1080*cdf0e10cSrcweir throw IllegalAccessException(); 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweir sal_Int16 nIndex = implts_convertImageTypeToIndex( nImageType ); 1083*cdf0e10cSrcweir rtl::Reference< GlobalImageList > rGlobalImageList; 1084*cdf0e10cSrcweir CmdImageList* pDefaultImageList = NULL; 1085*cdf0e10cSrcweir if ( m_bUseGlobal ) 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir rGlobalImageList = implts_getGlobalImageList(); 1088*cdf0e10cSrcweir pDefaultImageList = implts_getDefaultImageList(); 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir ImageList* pImageList = implts_getUserImageList( ImageType( nIndex )); 1091*cdf0e10cSrcweir uno::Reference< XGraphic > xEmptyGraphic( Image().GetXGraphic() ); 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < aCommandURLSequence.getLength(); i++ ) 1094*cdf0e10cSrcweir { 1095*cdf0e10cSrcweir sal_uInt16 nPos = pImageList->GetImagePos( aCommandURLSequence[i] ); 1096*cdf0e10cSrcweir if ( nPos != IMAGELIST_IMAGE_NOTFOUND ) 1097*cdf0e10cSrcweir { 1098*cdf0e10cSrcweir Image aImage = pImageList->GetImage( nPos ); 1099*cdf0e10cSrcweir sal_uInt16 nId = pImageList->GetImageId( nPos ); 1100*cdf0e10cSrcweir pImageList->RemoveImage( nId ); 1101*cdf0e10cSrcweir 1102*cdf0e10cSrcweir if ( m_bUseGlobal ) 1103*cdf0e10cSrcweir { 1104*cdf0e10cSrcweir // Check, if we have a image in our module/global image list. If we find one => 1105*cdf0e10cSrcweir // this is a replace instead of a remove operation! 1106*cdf0e10cSrcweir Image aNewImage = pDefaultImageList->getImageFromCommandURL( nIndex, aCommandURLSequence[i] ); 1107*cdf0e10cSrcweir if ( !aNewImage ) 1108*cdf0e10cSrcweir aNewImage = rGlobalImageList->getImageFromCommandURL( nIndex, aCommandURLSequence[i] ); 1109*cdf0e10cSrcweir if ( !aNewImage ) 1110*cdf0e10cSrcweir { 1111*cdf0e10cSrcweir if ( !pRemovedImages ) 1112*cdf0e10cSrcweir pRemovedImages = new CmdToXGraphicNameAccess(); 1113*cdf0e10cSrcweir pRemovedImages->addElement( aCommandURLSequence[i], xEmptyGraphic ); 1114*cdf0e10cSrcweir } 1115*cdf0e10cSrcweir else 1116*cdf0e10cSrcweir { 1117*cdf0e10cSrcweir if ( !pReplacedImages ) 1118*cdf0e10cSrcweir pReplacedImages = new CmdToXGraphicNameAccess(); 1119*cdf0e10cSrcweir pReplacedImages->addElement( aCommandURLSequence[i], aNewImage.GetXGraphic() ); 1120*cdf0e10cSrcweir } 1121*cdf0e10cSrcweir } // if ( m_bUseGlobal ) 1122*cdf0e10cSrcweir else 1123*cdf0e10cSrcweir { 1124*cdf0e10cSrcweir if ( !pRemovedImages ) 1125*cdf0e10cSrcweir pRemovedImages = new CmdToXGraphicNameAccess(); 1126*cdf0e10cSrcweir pRemovedImages->addElement( aCommandURLSequence[i], xEmptyGraphic ); 1127*cdf0e10cSrcweir } 1128*cdf0e10cSrcweir } 1129*cdf0e10cSrcweir } 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir if (( pReplacedImages != 0 ) || ( pRemovedImages != 0 )) 1132*cdf0e10cSrcweir { 1133*cdf0e10cSrcweir m_bModified = sal_True; 1134*cdf0e10cSrcweir m_bUserImageListModified[nIndex] = true; 1135*cdf0e10cSrcweir } 1136*cdf0e10cSrcweir } 1137*cdf0e10cSrcweir 1138*cdf0e10cSrcweir // Notify listeners 1139*cdf0e10cSrcweir if ( pRemovedImages != 0 ) 1140*cdf0e10cSrcweir { 1141*cdf0e10cSrcweir ConfigurationEvent aRemoveEvent; 1142*cdf0e10cSrcweir aRemoveEvent.aInfo = uno::makeAny( nImageType ); 1143*cdf0e10cSrcweir aRemoveEvent.Accessor = uno::makeAny( m_xOwner ); 1144*cdf0e10cSrcweir aRemoveEvent.Source = m_xOwner; 1145*cdf0e10cSrcweir aRemoveEvent.ResourceURL = m_aResourceString; 1146*cdf0e10cSrcweir aRemoveEvent.Element = uno::makeAny( uno::Reference< XNameAccess >( 1147*cdf0e10cSrcweir static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY )); 1148*cdf0e10cSrcweir implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove ); 1149*cdf0e10cSrcweir } 1150*cdf0e10cSrcweir if ( pReplacedImages != 0 ) 1151*cdf0e10cSrcweir { 1152*cdf0e10cSrcweir ConfigurationEvent aReplaceEvent; 1153*cdf0e10cSrcweir aReplaceEvent.aInfo = uno::makeAny( nImageType ); 1154*cdf0e10cSrcweir aReplaceEvent.Accessor = uno::makeAny( m_xOwner ); 1155*cdf0e10cSrcweir aReplaceEvent.Source = m_xOwner; 1156*cdf0e10cSrcweir aReplaceEvent.ResourceURL = m_aResourceString; 1157*cdf0e10cSrcweir aReplaceEvent.ReplacedElement = Any(); 1158*cdf0e10cSrcweir aReplaceEvent.Element = uno::makeAny( uno::Reference< XNameAccess >( 1159*cdf0e10cSrcweir static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY )); 1160*cdf0e10cSrcweir implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace ); 1161*cdf0e10cSrcweir } 1162*cdf0e10cSrcweir } 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir void ImageManagerImpl::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence ) 1165*cdf0e10cSrcweir throw ( ::com::sun::star::container::ElementExistException, 1166*cdf0e10cSrcweir ::com::sun::star::lang::IllegalArgumentException, 1167*cdf0e10cSrcweir ::com::sun::star::lang::IllegalAccessException, 1168*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 1169*cdf0e10cSrcweir { 1170*cdf0e10cSrcweir replaceImages(nImageType,aCommandURLSequence,aGraphicSequence); 1171*cdf0e10cSrcweir } 1172*cdf0e10cSrcweir 1173*cdf0e10cSrcweir 1174*cdf0e10cSrcweir // XUIConfigurationPersistence 1175*cdf0e10cSrcweir void ImageManagerImpl::reload() 1176*cdf0e10cSrcweir throw ( ::com::sun::star::uno::Exception, 1177*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ) 1178*cdf0e10cSrcweir { 1179*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 1180*cdf0e10cSrcweir 1181*cdf0e10cSrcweir if ( m_bDisposed ) 1182*cdf0e10cSrcweir throw DisposedException(); 1183*cdf0e10cSrcweir 1184*cdf0e10cSrcweir CommandMap aOldUserCmdImageSet; 1185*cdf0e10cSrcweir std::vector< rtl::OUString > aNewUserCmdImageSet; 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir if ( m_bModified ) 1188*cdf0e10cSrcweir { 1189*cdf0e10cSrcweir for ( sal_Int16 i = 0; i < sal_Int16( ImageType_COUNT ); i++ ) 1190*cdf0e10cSrcweir { 1191*cdf0e10cSrcweir if ( !m_bDisposed && m_bUserImageListModified[i] ) 1192*cdf0e10cSrcweir { 1193*cdf0e10cSrcweir std::vector< rtl::OUString > aOldUserCmdImageVector; 1194*cdf0e10cSrcweir ImageList* pImageList = implts_getUserImageList( (ImageType)i ); 1195*cdf0e10cSrcweir pImageList->GetImageNames( aOldUserCmdImageVector ); 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir // Fill hash map to speed up search afterwards 1198*cdf0e10cSrcweir sal_uInt32 j( 0 ); 1199*cdf0e10cSrcweir const sal_uInt32 nOldCount = aOldUserCmdImageVector.size(); 1200*cdf0e10cSrcweir for ( j = 0; j < nOldCount; j++ ) 1201*cdf0e10cSrcweir aOldUserCmdImageSet.insert( CommandMap::value_type( aOldUserCmdImageVector[j], false )); 1202*cdf0e10cSrcweir 1203*cdf0e10cSrcweir // Attention: This can make the old image list pointer invalid! 1204*cdf0e10cSrcweir implts_loadUserImages( (ImageType)i, m_xUserImageStorage, m_xUserBitmapsStorage ); 1205*cdf0e10cSrcweir pImageList = implts_getUserImageList( (ImageType)i ); 1206*cdf0e10cSrcweir pImageList->GetImageNames( aNewUserCmdImageSet ); 1207*cdf0e10cSrcweir 1208*cdf0e10cSrcweir CmdToXGraphicNameAccess* pInsertedImages( 0 ); 1209*cdf0e10cSrcweir CmdToXGraphicNameAccess* pReplacedImages( 0 ); 1210*cdf0e10cSrcweir CmdToXGraphicNameAccess* pRemovedImages( 0 ); 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir const sal_uInt32 nNewCount = aNewUserCmdImageSet.size(); 1213*cdf0e10cSrcweir for ( j = 0; j < nNewCount; j++ ) 1214*cdf0e10cSrcweir { 1215*cdf0e10cSrcweir CommandMap::iterator pIter = aOldUserCmdImageSet.find( aNewUserCmdImageSet[j] ); 1216*cdf0e10cSrcweir if ( pIter != aOldUserCmdImageSet.end() ) 1217*cdf0e10cSrcweir { 1218*cdf0e10cSrcweir pIter->second = true; // mark entry as replaced 1219*cdf0e10cSrcweir if ( !pReplacedImages ) 1220*cdf0e10cSrcweir pReplacedImages = new CmdToXGraphicNameAccess(); 1221*cdf0e10cSrcweir pReplacedImages->addElement( aNewUserCmdImageSet[j], 1222*cdf0e10cSrcweir pImageList->GetImage( aNewUserCmdImageSet[j] ).GetXGraphic() ); 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir else 1225*cdf0e10cSrcweir { 1226*cdf0e10cSrcweir if ( !pInsertedImages ) 1227*cdf0e10cSrcweir pInsertedImages = new CmdToXGraphicNameAccess(); 1228*cdf0e10cSrcweir pInsertedImages->addElement( aNewUserCmdImageSet[j], 1229*cdf0e10cSrcweir pImageList->GetImage( aNewUserCmdImageSet[j] ).GetXGraphic() ); 1230*cdf0e10cSrcweir } 1231*cdf0e10cSrcweir } 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir // Search map for unmarked entries => they have been removed from the user list 1234*cdf0e10cSrcweir // through this reload operation. 1235*cdf0e10cSrcweir // We have to search the module and global image list! 1236*cdf0e10cSrcweir rtl::Reference< GlobalImageList > rGlobalImageList; 1237*cdf0e10cSrcweir CmdImageList* pDefaultImageList = NULL; 1238*cdf0e10cSrcweir if ( m_bUseGlobal ) 1239*cdf0e10cSrcweir { 1240*cdf0e10cSrcweir rGlobalImageList = implts_getGlobalImageList(); 1241*cdf0e10cSrcweir pDefaultImageList = implts_getDefaultImageList(); 1242*cdf0e10cSrcweir } 1243*cdf0e10cSrcweir uno::Reference< XGraphic > xEmptyGraphic( Image().GetXGraphic() ); 1244*cdf0e10cSrcweir CommandMap::const_iterator pIter = aOldUserCmdImageSet.begin(); 1245*cdf0e10cSrcweir while ( pIter != aOldUserCmdImageSet.end() ) 1246*cdf0e10cSrcweir { 1247*cdf0e10cSrcweir if ( !pIter->second ) 1248*cdf0e10cSrcweir { 1249*cdf0e10cSrcweir if ( m_bUseGlobal ) 1250*cdf0e10cSrcweir { 1251*cdf0e10cSrcweir Image aImage = pDefaultImageList->getImageFromCommandURL( i, pIter->first ); 1252*cdf0e10cSrcweir if ( !aImage ) 1253*cdf0e10cSrcweir aImage = rGlobalImageList->getImageFromCommandURL( i, pIter->first ); 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir if ( !aImage ) 1256*cdf0e10cSrcweir { 1257*cdf0e10cSrcweir // No image in the module/global image list => remove user image 1258*cdf0e10cSrcweir if ( !pRemovedImages ) 1259*cdf0e10cSrcweir pRemovedImages = new CmdToXGraphicNameAccess(); 1260*cdf0e10cSrcweir pRemovedImages->addElement( pIter->first, xEmptyGraphic ); 1261*cdf0e10cSrcweir } 1262*cdf0e10cSrcweir else 1263*cdf0e10cSrcweir { 1264*cdf0e10cSrcweir // Image has been found in the module/global image list => replace user image 1265*cdf0e10cSrcweir if ( !pReplacedImages ) 1266*cdf0e10cSrcweir pReplacedImages = new CmdToXGraphicNameAccess(); 1267*cdf0e10cSrcweir pReplacedImages->addElement( pIter->first, aImage.GetXGraphic() ); 1268*cdf0e10cSrcweir } 1269*cdf0e10cSrcweir } // if ( m_bUseGlobal ) 1270*cdf0e10cSrcweir else 1271*cdf0e10cSrcweir { 1272*cdf0e10cSrcweir // No image in the user image list => remove user image 1273*cdf0e10cSrcweir if ( !pRemovedImages ) 1274*cdf0e10cSrcweir pRemovedImages = new CmdToXGraphicNameAccess(); 1275*cdf0e10cSrcweir pRemovedImages->addElement( pIter->first, xEmptyGraphic ); 1276*cdf0e10cSrcweir } 1277*cdf0e10cSrcweir } 1278*cdf0e10cSrcweir ++pIter; 1279*cdf0e10cSrcweir } 1280*cdf0e10cSrcweir 1281*cdf0e10cSrcweir aGuard.unlock(); 1282*cdf0e10cSrcweir 1283*cdf0e10cSrcweir // Now notify our listeners. Unlock mutex to prevent deadlocks 1284*cdf0e10cSrcweir if ( pInsertedImages != 0 ) 1285*cdf0e10cSrcweir { 1286*cdf0e10cSrcweir ConfigurationEvent aInsertEvent; 1287*cdf0e10cSrcweir aInsertEvent.aInfo = uno::makeAny( i ); 1288*cdf0e10cSrcweir aInsertEvent.Accessor = uno::makeAny( m_xOwner ); 1289*cdf0e10cSrcweir aInsertEvent.Source = m_xOwner; 1290*cdf0e10cSrcweir aInsertEvent.ResourceURL = m_aResourceString; 1291*cdf0e10cSrcweir aInsertEvent.Element = uno::makeAny( uno::Reference< XNameAccess >( 1292*cdf0e10cSrcweir static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY )); 1293*cdf0e10cSrcweir implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert ); 1294*cdf0e10cSrcweir } 1295*cdf0e10cSrcweir if ( pReplacedImages != 0 ) 1296*cdf0e10cSrcweir { 1297*cdf0e10cSrcweir ConfigurationEvent aReplaceEvent; 1298*cdf0e10cSrcweir aReplaceEvent.aInfo = uno::makeAny( i ); 1299*cdf0e10cSrcweir aReplaceEvent.Accessor = uno::makeAny( m_xOwner ); 1300*cdf0e10cSrcweir aReplaceEvent.Source = m_xOwner; 1301*cdf0e10cSrcweir aReplaceEvent.ResourceURL = m_aResourceString; 1302*cdf0e10cSrcweir aReplaceEvent.ReplacedElement = Any(); 1303*cdf0e10cSrcweir aReplaceEvent.Element = uno::makeAny( uno::Reference< XNameAccess >( 1304*cdf0e10cSrcweir static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY )); 1305*cdf0e10cSrcweir implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace ); 1306*cdf0e10cSrcweir } 1307*cdf0e10cSrcweir if ( pRemovedImages != 0 ) 1308*cdf0e10cSrcweir { 1309*cdf0e10cSrcweir ConfigurationEvent aRemoveEvent; 1310*cdf0e10cSrcweir aRemoveEvent.aInfo = uno::makeAny( i ); 1311*cdf0e10cSrcweir aRemoveEvent.Accessor = uno::makeAny( m_xOwner ); 1312*cdf0e10cSrcweir aRemoveEvent.Source = m_xOwner; 1313*cdf0e10cSrcweir aRemoveEvent.ResourceURL = m_aResourceString; 1314*cdf0e10cSrcweir aRemoveEvent.Element = uno::makeAny( uno::Reference< XNameAccess >( 1315*cdf0e10cSrcweir static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY )); 1316*cdf0e10cSrcweir implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove ); 1317*cdf0e10cSrcweir } 1318*cdf0e10cSrcweir 1319*cdf0e10cSrcweir aGuard.lock(); 1320*cdf0e10cSrcweir } 1321*cdf0e10cSrcweir } 1322*cdf0e10cSrcweir } 1323*cdf0e10cSrcweir } 1324*cdf0e10cSrcweir 1325*cdf0e10cSrcweir void ImageManagerImpl::store() 1326*cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 1327*cdf0e10cSrcweir { 1328*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 1329*cdf0e10cSrcweir 1330*cdf0e10cSrcweir if ( m_bDisposed ) 1331*cdf0e10cSrcweir throw DisposedException(); 1332*cdf0e10cSrcweir 1333*cdf0e10cSrcweir if ( m_bModified ) 1334*cdf0e10cSrcweir { 1335*cdf0e10cSrcweir sal_Bool bWritten( sal_False ); 1336*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < ImageType_COUNT; i++ ) 1337*cdf0e10cSrcweir { 1338*cdf0e10cSrcweir sal_Bool bSuccess = implts_storeUserImages( ImageType(i), m_xUserImageStorage, m_xUserBitmapsStorage ); 1339*cdf0e10cSrcweir if ( bSuccess ) 1340*cdf0e10cSrcweir bWritten = sal_True; 1341*cdf0e10cSrcweir m_bUserImageListModified[i] = false; 1342*cdf0e10cSrcweir } 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir if ( bWritten && 1345*cdf0e10cSrcweir m_xUserConfigStorage.is() ) 1346*cdf0e10cSrcweir { 1347*cdf0e10cSrcweir uno::Reference< XTransactedObject > xUserConfigStorageCommit( m_xUserConfigStorage, UNO_QUERY ); 1348*cdf0e10cSrcweir if ( xUserConfigStorageCommit.is() ) 1349*cdf0e10cSrcweir xUserConfigStorageCommit->commit(); 1350*cdf0e10cSrcweir if ( m_xUserRootCommit.is() ) 1351*cdf0e10cSrcweir m_xUserRootCommit->commit(); 1352*cdf0e10cSrcweir } 1353*cdf0e10cSrcweir 1354*cdf0e10cSrcweir m_bModified = sal_False; 1355*cdf0e10cSrcweir } 1356*cdf0e10cSrcweir } 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir void ImageManagerImpl::storeToStorage( const uno::Reference< XStorage >& Storage ) 1359*cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 1360*cdf0e10cSrcweir { 1361*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 1362*cdf0e10cSrcweir 1363*cdf0e10cSrcweir if ( m_bDisposed ) 1364*cdf0e10cSrcweir throw DisposedException(); 1365*cdf0e10cSrcweir 1366*cdf0e10cSrcweir if ( m_bModified && Storage.is() ) 1367*cdf0e10cSrcweir { 1368*cdf0e10cSrcweir long nModes = ElementModes::READWRITE; 1369*cdf0e10cSrcweir 1370*cdf0e10cSrcweir uno::Reference< XStorage > xUserImageStorage = Storage->openStorageElement( OUString::createFromAscii( IMAGE_FOLDER ), 1371*cdf0e10cSrcweir nModes ); 1372*cdf0e10cSrcweir if ( xUserImageStorage.is() ) 1373*cdf0e10cSrcweir { 1374*cdf0e10cSrcweir uno::Reference< XStorage > xUserBitmapsStorage = xUserImageStorage->openStorageElement( OUString::createFromAscii( BITMAPS_FOLDER ), 1375*cdf0e10cSrcweir nModes ); 1376*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < ImageType_COUNT; i++ ) 1377*cdf0e10cSrcweir { 1378*cdf0e10cSrcweir implts_getUserImageList( (ImageType)i ); 1379*cdf0e10cSrcweir implts_storeUserImages( (ImageType)i, xUserImageStorage, xUserBitmapsStorage ); 1380*cdf0e10cSrcweir } 1381*cdf0e10cSrcweir 1382*cdf0e10cSrcweir uno::Reference< XTransactedObject > xTransaction( Storage, UNO_QUERY ); 1383*cdf0e10cSrcweir if ( xTransaction.is() ) 1384*cdf0e10cSrcweir xTransaction->commit(); 1385*cdf0e10cSrcweir } 1386*cdf0e10cSrcweir } 1387*cdf0e10cSrcweir } 1388*cdf0e10cSrcweir 1389*cdf0e10cSrcweir sal_Bool ImageManagerImpl::isModified() 1390*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 1391*cdf0e10cSrcweir { 1392*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 1393*cdf0e10cSrcweir return m_bModified; 1394*cdf0e10cSrcweir } 1395*cdf0e10cSrcweir 1396*cdf0e10cSrcweir sal_Bool ImageManagerImpl::isReadOnly() throw (::com::sun::star::uno::RuntimeException) 1397*cdf0e10cSrcweir { 1398*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 1399*cdf0e10cSrcweir return m_bReadOnly; 1400*cdf0e10cSrcweir } 1401*cdf0e10cSrcweir // XUIConfiguration 1402*cdf0e10cSrcweir void ImageManagerImpl::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 1403*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 1404*cdf0e10cSrcweir { 1405*cdf0e10cSrcweir { 1406*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 1407*cdf0e10cSrcweir 1408*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1409*cdf0e10cSrcweir if ( m_bDisposed ) 1410*cdf0e10cSrcweir throw DisposedException(); 1411*cdf0e10cSrcweir } 1412*cdf0e10cSrcweir 1413*cdf0e10cSrcweir m_aListenerContainer.addInterface( ::getCppuType( ( const uno::Reference< XUIConfigurationListener >* ) NULL ), xListener ); 1414*cdf0e10cSrcweir } 1415*cdf0e10cSrcweir 1416*cdf0e10cSrcweir void ImageManagerImpl::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 1417*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 1418*cdf0e10cSrcweir { 1419*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1420*cdf0e10cSrcweir m_aListenerContainer.removeInterface( ::getCppuType( ( const uno::Reference< XUIConfigurationListener >* ) NULL ), xListener ); 1421*cdf0e10cSrcweir } 1422*cdf0e10cSrcweir 1423*cdf0e10cSrcweir 1424*cdf0e10cSrcweir void ImageManagerImpl::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp ) 1425*cdf0e10cSrcweir { 1426*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( 1427*cdf0e10cSrcweir ::getCppuType( ( const css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >*) NULL ) ); 1428*cdf0e10cSrcweir if ( pContainer != NULL ) 1429*cdf0e10cSrcweir { 1430*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper pIterator( *pContainer ); 1431*cdf0e10cSrcweir while ( pIterator.hasMoreElements() ) 1432*cdf0e10cSrcweir { 1433*cdf0e10cSrcweir try 1434*cdf0e10cSrcweir { 1435*cdf0e10cSrcweir switch ( eOp ) 1436*cdf0e10cSrcweir { 1437*cdf0e10cSrcweir case NotifyOp_Replace: 1438*cdf0e10cSrcweir ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementReplaced( aEvent ); 1439*cdf0e10cSrcweir break; 1440*cdf0e10cSrcweir case NotifyOp_Insert: 1441*cdf0e10cSrcweir ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementInserted( aEvent ); 1442*cdf0e10cSrcweir break; 1443*cdf0e10cSrcweir case NotifyOp_Remove: 1444*cdf0e10cSrcweir ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementRemoved( aEvent ); 1445*cdf0e10cSrcweir break; 1446*cdf0e10cSrcweir } 1447*cdf0e10cSrcweir } 1448*cdf0e10cSrcweir catch( css::uno::RuntimeException& ) 1449*cdf0e10cSrcweir { 1450*cdf0e10cSrcweir pIterator.remove(); 1451*cdf0e10cSrcweir } 1452*cdf0e10cSrcweir } 1453*cdf0e10cSrcweir } 1454*cdf0e10cSrcweir } 1455*cdf0e10cSrcweir void ImageManagerImpl::clear() 1456*cdf0e10cSrcweir { 1457*cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 1458*cdf0e10cSrcweir for ( sal_Int32 n = 0; n < ImageType_COUNT; n++ ) 1459*cdf0e10cSrcweir { 1460*cdf0e10cSrcweir delete m_pUserImageList[n]; 1461*cdf0e10cSrcweir m_pUserImageList[n] = 0; 1462*cdf0e10cSrcweir } 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir } // namespace framework 1465