Kaydet (Commit) 49bbd886 authored tarafından Caolán McNamara's avatar Caolán McNamara

show that GetImageManager never has a NULL module

and remove resulting dead branches

Change-Id: I969c943b9ff7e56d22efb4eff5bee644f9792676
üst 80a60371
...@@ -34,10 +34,10 @@ class SFX2_DLLPUBLIC SfxImageManager ...@@ -34,10 +34,10 @@ class SFX2_DLLPUBLIC SfxImageManager
SfxImageManager_Impl* pImp; SfxImageManager_Impl* pImp;
public: public:
static SfxImageManager* GetImageManager( SfxModule* ); static SfxImageManager* GetImageManager(SfxModule&);
SfxImageManager( SfxModule* pModule = 0 ); SfxImageManager(SfxModule& rModule);
~SfxImageManager(); ~SfxImageManager();
void RegisterToolBox( ToolBox *pBox, sal_uInt16 nFlags=0xFFFF); void RegisterToolBox( ToolBox *pBox, sal_uInt16 nFlags=0xFFFF);
void ReleaseToolBox( ToolBox *pBox ); void ReleaseToolBox( ToolBox *pBox );
......
...@@ -187,7 +187,7 @@ ScInputWindow::ScInputWindow( vcl::Window* pParent, SfxBindings* pBind ) : ...@@ -187,7 +187,7 @@ ScInputWindow::ScInputWindow( vcl::Window* pParent, SfxBindings* pBind ) :
mbIsMultiLine ( lcl_isExperimentalMode() ) mbIsMultiLine ( lcl_isExperimentalMode() )
{ {
ScModule* pScMod = SC_MOD(); ScModule* pScMod = SC_MOD();
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod ); SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
// #i73615# don't rely on SfxViewShell::Current while constructing the input line // #i73615# don't rely on SfxViewShell::Current while constructing the input line
// (also for GetInputHdl below) // (also for GetInputHdl below)
...@@ -281,7 +281,7 @@ ScInputWindow::~ScInputWindow() ...@@ -281,7 +281,7 @@ ScInputWindow::~ScInputWindow()
} }
} }
SfxImageManager::GetImageManager( SC_MOD() )->ReleaseToolBox( this ); SfxImageManager::GetImageManager( *SC_MOD() )->ReleaseToolBox( this );
} }
void ScInputWindow::SetInputHandler( ScInputHandler* pNew ) void ScInputWindow::SetInputHandler( ScInputHandler* pNew )
...@@ -648,7 +648,7 @@ void ScInputWindow::SetOkCancelMode() ...@@ -648,7 +648,7 @@ void ScInputWindow::SetOkCancelMode()
EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ); EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
ScModule* pScMod = SC_MOD(); ScModule* pScMod = SC_MOD();
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod ); SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
if (!bIsOkCancelMode) if (!bIsOkCancelMode)
{ {
RemoveItem( 3 ); // Remove SID_INPUT_SUM and SID_INPUT_EQUAL RemoveItem( 3 ); // Remove SID_INPUT_SUM and SID_INPUT_EQUAL
...@@ -670,7 +670,7 @@ void ScInputWindow::SetSumAssignMode() ...@@ -670,7 +670,7 @@ void ScInputWindow::SetSumAssignMode()
EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ); EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
ScModule* pScMod = SC_MOD(); ScModule* pScMod = SC_MOD();
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod ); SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
if (bIsOkCancelMode) if (bIsOkCancelMode)
{ {
// Remove SID_INPUT_CANCEL, and SID_INPUT_OK // Remove SID_INPUT_CANCEL, and SID_INPUT_OK
...@@ -783,7 +783,7 @@ void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt ) ...@@ -783,7 +783,7 @@ void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
{ {
// update item images // update item images
ScModule* pScMod = SC_MOD(); ScModule* pScMod = SC_MOD();
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod ); SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
// IMAGE macro uses pScMod, pImgMg // IMAGE macro uses pScMod, pImgMg
SetItemImage( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ) ); SetItemImage( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ) );
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
std::vector< ToolBoxInf_Impl* > m_aToolBoxes; std::vector< ToolBoxInf_Impl* > m_aToolBoxes;
sal_Int16 m_nSymbolsSize; sal_Int16 m_nSymbolsSize;
ImageList* m_pImageList[IMAGELIST_COUNT]; ImageList* m_pImageList[IMAGELIST_COUNT];
SfxModule* m_pModule; SfxModule& m_rModule;
bool m_bAppEventListener; bool m_bAppEventListener;
ImageList* GetImageList( bool bBig ); ImageList* GetImageList( bool bBig );
...@@ -65,8 +65,7 @@ public: ...@@ -65,8 +65,7 @@ public:
DECL_LINK( OptionsChanged_Impl, void* ); DECL_LINK( OptionsChanged_Impl, void* );
DECL_LINK( SettingsChanged_Impl, VclWindowEvent* ); DECL_LINK( SettingsChanged_Impl, VclWindowEvent* );
SfxImageManager_Impl(SfxModule& rModule);
SfxImageManager_Impl( SfxModule* pModule );
~SfxImageManager_Impl(); ~SfxImageManager_Impl();
}; };
...@@ -76,57 +75,25 @@ namespace ...@@ -76,57 +75,25 @@ namespace
class theImageManagerImplMap : class theImageManagerImplMap :
public rtl::Static<SfxImageManagerImplMap, theImageManagerImplMap> {}; public rtl::Static<SfxImageManagerImplMap, theImageManagerImplMap> {};
class theGlobalImageManager :
public rtl::StaticWithArg<SfxImageManager_Impl, SfxModule*,
theGlobalImageManager> {};
} }
static SfxImageManager_Impl* GetImageManager( SfxModule* pModule ) static SfxImageManager_Impl* GetImageManager(SfxModule& rModule)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
if ( pModule == 0 ) SfxImageManagerImplMap &rImageManager_ImplMap =
{ theImageManagerImplMap::get();
return &theGlobalImageManager::get(NULL); SfxImageManager_Impl* pImpl( 0 );
} SfxModule* pModule(&rModule);
SfxImageManagerImplMap::const_iterator pIter = rImageManager_ImplMap.find(pModule);
if ( pIter != rImageManager_ImplMap.end() )
pImpl = pIter->second.get();
else else
{ {
SfxImageManagerImplMap &rImageManager_ImplMap = rImageManager_ImplMap[pModule].reset(new SfxImageManager_Impl(rModule));
theImageManagerImplMap::get(); pImpl = rImageManager_ImplMap[pModule].get();
SfxImageManager_Impl* pImpl( 0 );
SfxImageManagerImplMap::const_iterator pIter = rImageManager_ImplMap.find(pModule);
if ( pIter != rImageManager_ImplMap.end() )
pImpl = pIter->second.get();
else
{
rImageManager_ImplMap[pModule].reset(new SfxImageManager_Impl(pModule));
pImpl = rImageManager_ImplMap[pModule].get();
}
return pImpl;
} }
} return pImpl;
// Global image list
static ImageList* GetImageList( bool bBig )
{
SolarMutexGuard aGuard;
ImageList* rpList = NULL;
ResMgr *pResMgr = SfxApplication::GetOrCreate()->GetOffResManager_Impl();
ResId aResId( bBig ? ( RID_DEFAULTIMAGELIST_LC ) : ( RID_DEFAULTIMAGELIST_SC ), *pResMgr);
aResId.SetRT( RSC_IMAGELIST );
DBG_ASSERT( pResMgr->IsAvailable(aResId), "No default ImageList!" );
if ( pResMgr->IsAvailable(aResId) )
rpList = new ImageList( aResId );
else
rpList = new ImageList();
return rpList;
} }
static sal_Int16 impl_convertBools( bool bLarge ) static sal_Int16 impl_convertBools( bool bLarge )
...@@ -137,10 +104,8 @@ static sal_Int16 impl_convertBools( bool bLarge ) ...@@ -137,10 +104,8 @@ static sal_Int16 impl_convertBools( bool bLarge )
return nIndex; return nIndex;
} }
SfxImageManager_Impl::SfxImageManager_Impl(SfxModule& rModule)
: m_rModule(rModule)
SfxImageManager_Impl::SfxImageManager_Impl( SfxModule* pModule )
: m_pModule(pModule)
, m_bAppEventListener(false) , m_bAppEventListener(false)
{ {
m_nSymbolsSize = m_aOpt.GetCurrentSymbolsSize(); m_nSymbolsSize = m_aOpt.GetCurrentSymbolsSize();
...@@ -171,10 +136,7 @@ ImageList* SfxImageManager_Impl::GetImageList( bool bBig ) ...@@ -171,10 +136,7 @@ ImageList* SfxImageManager_Impl::GetImageList( bool bBig )
sal_Int32 nIndex = impl_convertBools( bBig ); sal_Int32 nIndex = impl_convertBools( bBig );
if ( !m_pImageList[nIndex] ) if ( !m_pImageList[nIndex] )
{ {
if ( !m_pModule ) m_pImageList[nIndex] = m_rModule.GetImageList_Impl( bBig );
m_pImageList[nIndex] = ::GetImageList( bBig );
else
m_pImageList[nIndex] = m_pModule->GetImageList_Impl( bBig );
} }
return m_pImageList[nIndex]; return m_pImageList[nIndex];
...@@ -274,23 +236,15 @@ IMPL_LINK( SfxImageManager_Impl, SettingsChanged_Impl, VclWindowEvent*, pEvent) ...@@ -274,23 +236,15 @@ IMPL_LINK( SfxImageManager_Impl, SettingsChanged_Impl, VclWindowEvent*, pEvent)
return 0L; return 0L;
} }
SfxImageManager::SfxImageManager(SfxModule& rModule)
SfxImageManager::SfxImageManager( SfxModule* pModule )
{ {
pImp = ::GetImageManager( pModule ); pImp = ::GetImageManager(rModule);
} }
SfxImageManager::~SfxImageManager() SfxImageManager::~SfxImageManager()
{ {
} }
namespace namespace
{ {
typedef boost::unordered_map< SfxModule*, boost::shared_ptr<SfxImageManager> > SfxImageManagerMap; typedef boost::unordered_map< SfxModule*, boost::shared_ptr<SfxImageManager> > SfxImageManagerMap;
...@@ -299,26 +253,24 @@ namespace ...@@ -299,26 +253,24 @@ namespace
public rtl::Static<SfxImageManagerMap, theImageManagerMap> {}; public rtl::Static<SfxImageManagerMap, theImageManagerMap> {};
} }
SfxImageManager* SfxImageManager::GetImageManager( SfxModule* pModule ) SfxImageManager* SfxImageManager::GetImageManager(SfxModule& rModule)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
SfxImageManager* pSfxImageManager(0); SfxImageManager* pSfxImageManager(0);
SfxImageManagerMap &rImageManagerMap = theImageManagerMap::get(); SfxImageManagerMap &rImageManagerMap = theImageManagerMap::get();
SfxModule* pModule = &rModule;
SfxImageManagerMap::const_iterator pIter = rImageManagerMap.find(pModule); SfxImageManagerMap::const_iterator pIter = rImageManagerMap.find(pModule);
if ( pIter != rImageManagerMap.end() ) if ( pIter != rImageManagerMap.end() )
pSfxImageManager = pIter->second.get(); pSfxImageManager = pIter->second.get();
else else
{ {
rImageManagerMap[pModule].reset(new SfxImageManager(pModule)); rImageManagerMap[pModule].reset(new SfxImageManager(rModule));
pSfxImageManager = rImageManagerMap[pModule].get(); pSfxImageManager = rImageManagerMap[pModule].get();
} }
return pSfxImageManager; return pSfxImageManager;
} }
Image SfxImageManager::GetImage( sal_uInt16 nId, bool bBig ) const Image SfxImageManager::GetImage( sal_uInt16 nId, bool bBig ) const
{ {
ImageList* pImageList = pImp->GetImageList( bBig ); ImageList* pImageList = pImp->GetImageList( bBig );
...@@ -327,41 +279,26 @@ Image SfxImageManager::GetImage( sal_uInt16 nId, bool bBig ) const ...@@ -327,41 +279,26 @@ Image SfxImageManager::GetImage( sal_uInt16 nId, bool bBig ) const
return Image(); return Image();
} }
Image SfxImageManager::GetImage( sal_uInt16 nId ) const Image SfxImageManager::GetImage( sal_uInt16 nId ) const
{ {
bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge(); bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge();
return GetImage( nId, bLarge ); return GetImage( nId, bLarge );
} }
Image SfxImageManager::SeekImage( sal_uInt16 nId, bool bBig ) const Image SfxImageManager::SeekImage( sal_uInt16 nId, bool bBig ) const
{ {
bool bGlobal = ( pImp->m_pModule == 0 );
ImageList* pImageList = pImp->GetImageList( bBig ); ImageList* pImageList = pImp->GetImageList( bBig );
if ( pImageList && pImageList->HasImageAtPos( nId ) ) if (pImageList && pImageList->HasImageAtPos(nId))
return pImageList->GetImage( nId ); return pImageList->GetImage( nId );
else if ( !bGlobal )
{
pImageList = ::GetImageManager( 0 )->GetImageList( bBig );
if ( pImageList )
return pImageList->GetImage( nId );
}
return Image(); return Image();
} }
Image SfxImageManager::SeekImage( sal_uInt16 nId ) const Image SfxImageManager::SeekImage( sal_uInt16 nId ) const
{ {
bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge(); bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge();
return SeekImage( nId, bLarge ); return SeekImage( nId, bLarge );
} }
void SfxImageManager::RegisterToolBox( ToolBox *pBox, sal_uInt16 nFlags ) void SfxImageManager::RegisterToolBox( ToolBox *pBox, sal_uInt16 nFlags )
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
......
...@@ -229,7 +229,7 @@ SwTestAccountSettingsDialog::SwTestAccountSettingsDialog(SwMailConfigPage* pPare ...@@ -229,7 +229,7 @@ SwTestAccountSettingsDialog::SwTestAccountSettingsDialog(SwMailConfigPage* pPare
m_sCompleted = m_pResult1->GetText(); m_sCompleted = m_pResult1->GetText();
m_sFailed = m_pResult2->GetText(); m_sFailed = m_pResult2->GetText();
SfxImageManager* pManager = SfxImageManager::GetImageManager( SW_MOD() ); SfxImageManager* pManager = SfxImageManager::GetImageManager(*SW_MOD());
m_aFailedImg = pManager->GetImage(FN_FORMULA_CANCEL); m_aFailedImg = pManager->GetImage(FN_FORMULA_CANCEL);
m_aCompletedImg = pManager->GetImage(FN_FORMULA_APPLY); m_aCompletedImg = pManager->GetImage(FN_FORMULA_APPLY);
......
...@@ -77,7 +77,7 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind ) ...@@ -77,7 +77,7 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind )
aEdit.SetSizePixel( aEdit.CalcMinimumSize() ); aEdit.SetSizePixel( aEdit.CalcMinimumSize() );
SfxImageManager* pManager = SfxImageManager::GetImageManager( SW_MOD() ); SfxImageManager* pManager = SfxImageManager::GetImageManager( *SW_MOD() );
pManager->RegisterToolBox(this); pManager->RegisterToolBox(this);
pView = ::GetActiveView(); pView = ::GetActiveView();
...@@ -127,7 +127,7 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind ) ...@@ -127,7 +127,7 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind )
SwInputWindow::~SwInputWindow() SwInputWindow::~SwInputWindow()
{ {
SfxImageManager::GetImageManager( SW_MOD() )->ReleaseToolBox(this); SfxImageManager::GetImageManager( *SW_MOD() )->ReleaseToolBox(this);
// wake rulers // wake rulers
if(pView) if(pView)
...@@ -165,7 +165,7 @@ void SwInputWindow::DataChanged( const DataChangedEvent& rDCEvt ) ...@@ -165,7 +165,7 @@ void SwInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
{ {
// update item images // update item images
SwModule *pMod = SW_MOD(); SwModule *pMod = SW_MOD();
SfxImageManager *pImgMgr = SfxImageManager::GetImageManager( pMod ); SfxImageManager *pImgMgr = SfxImageManager::GetImageManager(*pMod);
SetItemImage( FN_FORMULA_CALC, pImgMgr->GetImage(FN_FORMULA_CALC )); SetItemImage( FN_FORMULA_CALC, pImgMgr->GetImage(FN_FORMULA_CALC ));
SetItemImage( FN_FORMULA_CANCEL, pImgMgr->GetImage(FN_FORMULA_CANCEL )); SetItemImage( FN_FORMULA_CANCEL, pImgMgr->GetImage(FN_FORMULA_CANCEL ));
SetItemImage( FN_FORMULA_APPLY, pImgMgr->GetImage(FN_FORMULA_APPLY )); SetItemImage( FN_FORMULA_APPLY, pImgMgr->GetImage(FN_FORMULA_APPLY ));
......
...@@ -813,7 +813,7 @@ SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings, ...@@ -813,7 +813,7 @@ SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings,
StartListening(*SfxGetpApp()); StartListening(*SfxGetpApp());
if ( pCreateView ) if ( pCreateView )
StartListening(*pCreateView); StartListening(*pCreateView);
SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() ); SfxImageManager* pImgMan = SfxImageManager::GetImageManager(*SW_MOD());
pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE); pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE); pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
...@@ -862,7 +862,7 @@ SwNavigationPI::~SwNavigationPI() ...@@ -862,7 +862,7 @@ SwNavigationPI::~SwNavigationPI()
EndListening(*SfxGetpApp()); EndListening(*SfxGetpApp());
SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() ); SfxImageManager* pImgMan = SfxImageManager::GetImageManager(*SW_MOD());
pImgMan->ReleaseToolBox(&aContentToolBox); pImgMan->ReleaseToolBox(&aContentToolBox);
pImgMan->ReleaseToolBox(&aGlobalToolBox); pImgMan->ReleaseToolBox(&aGlobalToolBox);
delete aContentToolBox.GetItemWindow(FN_PAGENUMBER); delete aContentToolBox.GetItemWindow(FN_PAGENUMBER);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment