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_sfx2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <stdio.h> 32*cdf0e10cSrcweir #include <hash_map> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include "sfx2/imgmgr.hxx" 35*cdf0e10cSrcweir #include <sfx2/sfx.hrc> 36*cdf0e10cSrcweir #include <sfx2/app.hxx> 37*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 38*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 39*cdf0e10cSrcweir #include "statcach.hxx" 40*cdf0e10cSrcweir #include <sfx2/module.hxx> 41*cdf0e10cSrcweir #include <vcl/bitmap.hxx> 42*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <tools/rcid.h> 45*cdf0e10cSrcweir #include <tools/link.hxx> 46*cdf0e10cSrcweir #include <svtools/miscopt.hxx> 47*cdf0e10cSrcweir #include <vos/mutex.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #ifndef GCC 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX 53*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 54*cdf0e10cSrcweir #endif 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir const sal_uInt32 IMAGELIST_COUNT = 4; // small, small-hi, large, large-hi 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir struct ToolBoxInf_Impl 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir ToolBox* pToolBox; 61*cdf0e10cSrcweir sal_uInt16 nFlags; 62*cdf0e10cSrcweir }; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir class SfxImageManager_Impl 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir public: 67*cdf0e10cSrcweir sal_Int16 m_nSymbolsSize; 68*cdf0e10cSrcweir SvtMiscOptions m_aOpt; 69*cdf0e10cSrcweir std::vector< ToolBoxInf_Impl* > m_aToolBoxes; 70*cdf0e10cSrcweir ImageList* m_pImageList[IMAGELIST_COUNT]; 71*cdf0e10cSrcweir SfxModule* m_pModule; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir ImageList* GetImageList( sal_Bool bBig, sal_Bool bHiContrast ); 74*cdf0e10cSrcweir Image GetImage( sal_uInt16 nId, sal_Bool bBig, sal_Bool bHiContrast ); 75*cdf0e10cSrcweir void SetSymbolsSize_Impl( sal_Int16 ); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir DECL_LINK( OptionsChanged_Impl, void* ); 78*cdf0e10cSrcweir DECL_LINK( SettingsChanged_Impl, void* ); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir SfxImageManager_Impl( SfxModule* pModule ); 82*cdf0e10cSrcweir ~SfxImageManager_Impl(); 83*cdf0e10cSrcweir }; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir typedef std::hash_map< sal_Int64, sal_Int64 > SfxImageManagerMap; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // global image lists 88*cdf0e10cSrcweir static SfxImageManager_Impl* pGlobalImageManager = 0; 89*cdf0e10cSrcweir static SfxImageManagerMap m_ImageManager_ImplMap; 90*cdf0e10cSrcweir static SfxImageManagerMap m_ImageManagerMap; 91*cdf0e10cSrcweir static ImageList* pImageListSmall=0; 92*cdf0e10cSrcweir static ImageList* pImageListBig=0; 93*cdf0e10cSrcweir static ImageList* pImageListHiSmall=0; 94*cdf0e10cSrcweir static ImageList* pImageListHiBig=0; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir static SfxImageManager_Impl* GetImageManager( SfxModule* pModule ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir if ( pModule == 0 ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir if ( !pGlobalImageManager ) 103*cdf0e10cSrcweir pGlobalImageManager = new SfxImageManager_Impl( 0 ); 104*cdf0e10cSrcweir return pGlobalImageManager; 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir else 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir SfxImageManager_Impl* pImpl( 0 ); 109*cdf0e10cSrcweir SfxImageManagerMap::const_iterator pIter = m_ImageManager_ImplMap.find( sal::static_int_cast< sal_Int64>( reinterpret_cast< sal_IntPtr >( pModule ))); 110*cdf0e10cSrcweir if ( pIter != m_ImageManager_ImplMap.end() ) 111*cdf0e10cSrcweir pImpl = reinterpret_cast< SfxImageManager_Impl* >( sal::static_int_cast< sal_IntPtr >( pIter->second )); 112*cdf0e10cSrcweir else 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir pImpl = new SfxImageManager_Impl( pModule ); 115*cdf0e10cSrcweir m_ImageManager_ImplMap.insert( 116*cdf0e10cSrcweir SfxImageManagerMap::value_type( 117*cdf0e10cSrcweir sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pModule )), 118*cdf0e10cSrcweir sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pImpl )) )); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir return pImpl; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // Global image list 125*cdf0e10cSrcweir static ImageList* GetImageList( sal_Bool bBig, sal_Bool bHiContrast ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir // Has to be changed if we know how the IDs are named!!! 130*cdf0e10cSrcweir ImageList*& rpList = bBig ? ( bHiContrast ? pImageListHiBig : pImageListBig ) : 131*cdf0e10cSrcweir ( bHiContrast ? pImageListHiSmall : pImageListSmall ); 132*cdf0e10cSrcweir if ( !rpList ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir ResMgr *pResMgr = SfxApplication::GetOrCreate()->GetOffResManager_Impl(); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir ResId aResId( bBig ? ( bHiContrast ? RID_DEFAULTIMAGELIST_LCH : RID_DEFAULTIMAGELIST_LC ) : 137*cdf0e10cSrcweir ( bHiContrast ? RID_DEFAULTIMAGELIST_SCH : RID_DEFAULTIMAGELIST_SC ), *pResMgr); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir aResId.SetRT( RSC_IMAGELIST ); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir DBG_ASSERT( pResMgr->IsAvailable(aResId), "No default ImageList!" ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir if ( pResMgr->IsAvailable(aResId) ) 144*cdf0e10cSrcweir rpList = new ImageList( aResId ); 145*cdf0e10cSrcweir else 146*cdf0e10cSrcweir rpList = new ImageList(); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir return rpList; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir static sal_Int16 impl_convertBools( sal_Bool bLarge, sal_Bool bHiContrast ) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir sal_Int16 nIndex( 0 ); 155*cdf0e10cSrcweir if ( bLarge ) 156*cdf0e10cSrcweir nIndex += 1; 157*cdf0e10cSrcweir if ( bHiContrast ) 158*cdf0e10cSrcweir nIndex += 2; 159*cdf0e10cSrcweir return nIndex; 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir //========================================================================= 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir SfxImageManager_Impl::SfxImageManager_Impl( SfxModule* pModule ) : 165*cdf0e10cSrcweir m_nSymbolsSize( SvtMiscOptions().GetCurrentSymbolsSize() ), 166*cdf0e10cSrcweir m_pModule( pModule ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < IMAGELIST_COUNT; i++ ) 169*cdf0e10cSrcweir m_pImageList[i] = 0; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir m_aOpt.AddListenerLink( LINK( this, SfxImageManager_Impl, OptionsChanged_Impl ) ); 172*cdf0e10cSrcweir Application::AddEventListener( LINK( this, SfxImageManager_Impl, SettingsChanged_Impl ) ); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //------------------------------------------------------------------------- 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir SfxImageManager_Impl::~SfxImageManager_Impl() 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir m_aOpt.RemoveListenerLink( LINK( this, SfxImageManager_Impl, OptionsChanged_Impl ) ); 180*cdf0e10cSrcweir Application::RemoveEventListener( LINK( this, SfxImageManager_Impl, SettingsChanged_Impl ) ); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < m_aToolBoxes.size(); i++ ) 183*cdf0e10cSrcweir delete m_aToolBoxes[i]; 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir //------------------------------------------------------------------------- 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir ImageList* SfxImageManager_Impl::GetImageList( sal_Bool bBig, sal_Bool bHiContrast ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir sal_Int32 nIndex = impl_convertBools( bBig, bHiContrast ); 191*cdf0e10cSrcweir if ( !m_pImageList[nIndex] ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir if ( !m_pModule ) 194*cdf0e10cSrcweir m_pImageList[nIndex] = ::GetImageList( bBig, bHiContrast ); 195*cdf0e10cSrcweir else 196*cdf0e10cSrcweir m_pImageList[nIndex] = m_pModule->GetImageList_Impl( bBig, bHiContrast ); 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir return m_pImageList[nIndex]; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir //------------------------------------------------------------------------- 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir Image SfxImageManager_Impl::GetImage( sal_uInt16 nId, sal_Bool bBig, sal_Bool bHiContrast ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir ImageList* pImageList = GetImageList( bBig, bHiContrast ); 207*cdf0e10cSrcweir if ( pImageList ) 208*cdf0e10cSrcweir return pImageList->GetImage( nId ); 209*cdf0e10cSrcweir return Image(); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir //------------------------------------------------------------------------- 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir void SfxImageManager_Impl::SetSymbolsSize_Impl( sal_Int16 nNewSymbolsSize ) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir if ( nNewSymbolsSize != m_nSymbolsSize ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir m_nSymbolsSize = nNewSymbolsSize; 221*cdf0e10cSrcweir sal_Bool bLarge( m_nSymbolsSize == SFX_SYMBOLS_SIZE_LARGE ); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir for ( sal_uInt32 n=0; n < m_aToolBoxes.size(); n++ ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir ToolBoxInf_Impl *pInf = m_aToolBoxes[n]; 226*cdf0e10cSrcweir if ( pInf->nFlags & SFX_TOOLBOX_CHANGESYMBOLSET ) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir ToolBox *pBox = pInf->pToolBox; 229*cdf0e10cSrcweir sal_Bool bHiContrast = pBox->GetSettings().GetStyleSettings().GetHighContrastMode(); 230*cdf0e10cSrcweir sal_uInt16 nCount = pBox->GetItemCount(); 231*cdf0e10cSrcweir for ( sal_uInt16 nPos=0; nPos<nCount; nPos++ ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir sal_uInt16 nId = pBox->GetItemId( nPos ); 234*cdf0e10cSrcweir if ( pBox->GetItemType(nPos) == TOOLBOXITEM_BUTTON ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir pBox->SetItemImage( nId, GetImage( nId, bLarge, bHiContrast ) ); 237*cdf0e10cSrcweir SfxStateCache *pCache = SfxViewFrame::Current()->GetBindings().GetStateCache( nId ); 238*cdf0e10cSrcweir if ( pCache ) 239*cdf0e10cSrcweir pCache->SetCachedState(); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir if ( !pBox->IsFloatingMode() ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir Size aActSize( pBox->GetSizePixel() ); 246*cdf0e10cSrcweir Size aSize( pBox->CalcWindowSizePixel() ); 247*cdf0e10cSrcweir if ( pBox->IsHorizontal() ) 248*cdf0e10cSrcweir aSize.Width() = aActSize.Width(); 249*cdf0e10cSrcweir else 250*cdf0e10cSrcweir aSize.Height() = aActSize.Height(); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir pBox->SetSizePixel( aSize ); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir //------------------------------------------------------------------------- 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir IMPL_LINK( SfxImageManager_Impl, OptionsChanged_Impl, void*, EMPTYARG ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir SetSymbolsSize_Impl( SvtMiscOptions().GetCurrentSymbolsSize() ); 264*cdf0e10cSrcweir return 0L; 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir //------------------------------------------------------------------------- 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir IMPL_LINK( SfxImageManager_Impl, SettingsChanged_Impl, void*, EMPTYARG ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir // Check if toolbar button size have changed and we have to use system settings 272*cdf0e10cSrcweir sal_Int16 nSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize(); 273*cdf0e10cSrcweir if ( m_nSymbolsSize != nSymbolsSize ) 274*cdf0e10cSrcweir SetSymbolsSize_Impl( nSymbolsSize ); 275*cdf0e10cSrcweir return 0L; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir //------------------------------------------------------------------------- 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir //========================================================================= 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir SfxImageManager::SfxImageManager( SfxModule* pModule ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir pImp = ::GetImageManager( pModule ); 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir //------------------------------------------------------------------------- 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir SfxImageManager::~SfxImageManager() 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir //------------------------------------------------------------------------- 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir SfxImageManager* SfxImageManager::GetImageManager( SfxModule* pModule ) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir SfxImageManagerMap::const_iterator pIter = 300*cdf0e10cSrcweir m_ImageManagerMap.find( sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pModule ))); 301*cdf0e10cSrcweir if ( pIter != m_ImageManagerMap.end() ) 302*cdf0e10cSrcweir return reinterpret_cast< SfxImageManager* >( sal::static_int_cast< sal_IntPtr >( pIter->second )); 303*cdf0e10cSrcweir else 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir SfxImageManager* pSfxImageManager = new SfxImageManager( pModule ); 306*cdf0e10cSrcweir m_ImageManagerMap.insert( SfxImageManagerMap::value_type( 307*cdf0e10cSrcweir sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pModule )), 308*cdf0e10cSrcweir sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( pSfxImageManager )) )); 309*cdf0e10cSrcweir return pSfxImageManager; 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir //------------------------------------------------------------------------- 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir Image SfxImageManager::GetImage( sal_uInt16 nId, sal_Bool bBig, sal_Bool bHiContrast ) const 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir ImageList* pImageList = pImp->GetImageList( bBig, bHiContrast ); 318*cdf0e10cSrcweir if ( pImageList && pImageList->HasImageAtPos( nId ) ) 319*cdf0e10cSrcweir return pImageList->GetImage( nId ); 320*cdf0e10cSrcweir return Image(); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir //------------------------------------------------------------------------- 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir Image SfxImageManager::GetImage( sal_uInt16 nId, sal_Bool bHiContrast ) const 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir sal_Bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge(); 328*cdf0e10cSrcweir return GetImage( nId, bLarge, bHiContrast ); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir //------------------------------------------------------------------------- 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir Image SfxImageManager::SeekImage( sal_uInt16 nId, sal_Bool bBig, sal_Bool bHiContrast ) const 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir sal_Bool bGlobal = ( pImp->m_pModule == 0 ); 336*cdf0e10cSrcweir ImageList* pImageList = pImp->GetImageList( bBig, bHiContrast ); 337*cdf0e10cSrcweir if ( pImageList && pImageList->HasImageAtPos( nId ) ) 338*cdf0e10cSrcweir return pImageList->GetImage( nId ); 339*cdf0e10cSrcweir else if ( !bGlobal ) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir pImageList = ::GetImageManager( 0 )->GetImageList( bBig, bHiContrast ); 342*cdf0e10cSrcweir if ( pImageList ) 343*cdf0e10cSrcweir return pImageList->GetImage( nId ); 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir return Image(); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir //------------------------------------------------------------------------- 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir Image SfxImageManager::SeekImage( sal_uInt16 nId, sal_Bool bHiContrast ) const 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir sal_Bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge(); 353*cdf0e10cSrcweir return SeekImage( nId, bLarge, bHiContrast ); 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir //------------------------------------------------------------------------- 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir void SfxImageManager::RegisterToolBox( ToolBox *pBox, sal_uInt16 nFlags ) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir ToolBoxInf_Impl* pInf = new ToolBoxInf_Impl; 363*cdf0e10cSrcweir pInf->pToolBox = pBox; 364*cdf0e10cSrcweir pInf->nFlags = nFlags; 365*cdf0e10cSrcweir pImp->m_aToolBoxes.push_back( pInf ); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir //------------------------------------------------------------------------- 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir void SfxImageManager::ReleaseToolBox( ToolBox *pBox ) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir for ( sal_uInt32 n=0; n < pImp->m_aToolBoxes.size(); n++ ) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir if ((pImp->m_aToolBoxes[n])->pToolBox == pBox ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir delete pImp->m_aToolBoxes[n]; 379*cdf0e10cSrcweir pImp->m_aToolBoxes.erase( pImp->m_aToolBoxes.begin() + n ); 380*cdf0e10cSrcweir return; 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir //------------------------------------------------------------------------- 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir void SfxImageManager::SetImages( ToolBox& rToolBox, sal_Bool bHiContrast, sal_Bool bLarge ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir SetImagesForceSize( rToolBox, bLarge, bHiContrast ); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir //------------------------------------------------------------------------- 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir void SfxImageManager::SetImagesForceSize( ToolBox& rToolBox, sal_Bool bHiContrast, sal_Bool bLarge ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir ImageList* pImageList = pImp->GetImageList( bLarge, bHiContrast ); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir sal_uInt16 nCount = rToolBox.GetItemCount(); 399*cdf0e10cSrcweir for (sal_uInt16 n=0; n<nCount; n++) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir sal_uInt16 nId = rToolBox.GetItemId(n); 402*cdf0e10cSrcweir switch ( rToolBox.GetItemType(n) ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir case TOOLBOXITEM_BUTTON: 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir if ( pImageList && pImageList->HasImageAtPos( nId ) ) 407*cdf0e10cSrcweir rToolBox.SetItemImage( nId, pImageList->GetImage( nId )); 408*cdf0e10cSrcweir else 409*cdf0e10cSrcweir rToolBox.SetItemImage( nId, Image() ); 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir case TOOLBOXITEM_SEPARATOR: 413*cdf0e10cSrcweir case TOOLBOXITEM_SPACE: 414*cdf0e10cSrcweir case TOOLBOXITEM_BREAK: 415*cdf0e10cSrcweir default: 416*cdf0e10cSrcweir break; 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir void SfxImageManager::SetImages( ToolBox& rToolBox ) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir sal_Bool bLarge = ( pImp->m_nSymbolsSize == SFX_SYMBOLS_SIZE_LARGE ); 424*cdf0e10cSrcweir sal_Bool bHiContrast = rToolBox.GetSettings().GetStyleSettings().GetHighContrastMode(); 425*cdf0e10cSrcweir SetImagesForceSize( rToolBox, bHiContrast, bLarge ); 426*cdf0e10cSrcweir } 427