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,9 +34,9 @@ class SFX2_DLLPUBLIC SfxImageManager
SfxImageManager_Impl* pImp;
public:
static SfxImageManager* GetImageManager( SfxModule* );
static SfxImageManager* GetImageManager(SfxModule&);
SfxImageManager( SfxModule* pModule = 0 );
SfxImageManager(SfxModule& rModule);
~SfxImageManager();
void RegisterToolBox( ToolBox *pBox, sal_uInt16 nFlags=0xFFFF);
......
......@@ -187,7 +187,7 @@ ScInputWindow::ScInputWindow( vcl::Window* pParent, SfxBindings* pBind ) :
mbIsMultiLine ( lcl_isExperimentalMode() )
{
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
// (also for GetInputHdl below)
......@@ -281,7 +281,7 @@ ScInputWindow::~ScInputWindow()
}
}
SfxImageManager::GetImageManager( SC_MOD() )->ReleaseToolBox( this );
SfxImageManager::GetImageManager( *SC_MOD() )->ReleaseToolBox( this );
}
void ScInputWindow::SetInputHandler( ScInputHandler* pNew )
......@@ -648,7 +648,7 @@ void ScInputWindow::SetOkCancelMode()
EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
ScModule* pScMod = SC_MOD();
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
if (!bIsOkCancelMode)
{
RemoveItem( 3 ); // Remove SID_INPUT_SUM and SID_INPUT_EQUAL
......@@ -670,7 +670,7 @@ void ScInputWindow::SetSumAssignMode()
EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
ScModule* pScMod = SC_MOD();
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
if (bIsOkCancelMode)
{
// Remove SID_INPUT_CANCEL, and SID_INPUT_OK
......@@ -783,7 +783,7 @@ void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
{
// update item images
ScModule* pScMod = SC_MOD();
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
// IMAGE macro uses pScMod, pImgMg
SetItemImage( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ) );
......
......@@ -55,7 +55,7 @@ public:
std::vector< ToolBoxInf_Impl* > m_aToolBoxes;
sal_Int16 m_nSymbolsSize;
ImageList* m_pImageList[IMAGELIST_COUNT];
SfxModule* m_pModule;
SfxModule& m_rModule;
bool m_bAppEventListener;
ImageList* GetImageList( bool bBig );
......@@ -65,8 +65,7 @@ public:
DECL_LINK( OptionsChanged_Impl, void* );
DECL_LINK( SettingsChanged_Impl, VclWindowEvent* );
SfxImageManager_Impl( SfxModule* pModule );
SfxImageManager_Impl(SfxModule& rModule);
~SfxImageManager_Impl();
};
......@@ -76,57 +75,25 @@ namespace
class 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;
if ( pModule == 0 )
{
return &theGlobalImageManager::get(NULL);
}
else
{
SfxImageManagerImplMap &rImageManager_ImplMap =
theImageManagerImplMap::get();
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
{
rImageManager_ImplMap[pModule].reset(new SfxImageManager_Impl(pModule));
rImageManager_ImplMap[pModule].reset(new SfxImageManager_Impl(rModule));
pImpl = rImageManager_ImplMap[pModule].get();
}
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 )
......@@ -137,10 +104,8 @@ static sal_Int16 impl_convertBools( bool bLarge )
return nIndex;
}
SfxImageManager_Impl::SfxImageManager_Impl( SfxModule* pModule )
: m_pModule(pModule)
SfxImageManager_Impl::SfxImageManager_Impl(SfxModule& rModule)
: m_rModule(rModule)
, m_bAppEventListener(false)
{
m_nSymbolsSize = m_aOpt.GetCurrentSymbolsSize();
......@@ -171,10 +136,7 @@ ImageList* SfxImageManager_Impl::GetImageList( bool bBig )
sal_Int32 nIndex = impl_convertBools( bBig );
if ( !m_pImageList[nIndex] )
{
if ( !m_pModule )
m_pImageList[nIndex] = ::GetImageList( bBig );
else
m_pImageList[nIndex] = m_pModule->GetImageList_Impl( bBig );
m_pImageList[nIndex] = m_rModule.GetImageList_Impl( bBig );
}
return m_pImageList[nIndex];
......@@ -274,23 +236,15 @@ IMPL_LINK( SfxImageManager_Impl, SettingsChanged_Impl, VclWindowEvent*, pEvent)
return 0L;
}
SfxImageManager::SfxImageManager( SfxModule* pModule )
SfxImageManager::SfxImageManager(SfxModule& rModule)
{
pImp = ::GetImageManager( pModule );
pImp = ::GetImageManager(rModule);
}
SfxImageManager::~SfxImageManager()
{
}
namespace
{
typedef boost::unordered_map< SfxModule*, boost::shared_ptr<SfxImageManager> > SfxImageManagerMap;
......@@ -299,26 +253,24 @@ namespace
public rtl::Static<SfxImageManagerMap, theImageManagerMap> {};
}
SfxImageManager* SfxImageManager::GetImageManager( SfxModule* pModule )
SfxImageManager* SfxImageManager::GetImageManager(SfxModule& rModule)
{
SolarMutexGuard aGuard;
SfxImageManager* pSfxImageManager(0);
SfxImageManagerMap &rImageManagerMap = theImageManagerMap::get();
SfxModule* pModule = &rModule;
SfxImageManagerMap::const_iterator pIter = rImageManagerMap.find(pModule);
if ( pIter != rImageManagerMap.end() )
pSfxImageManager = pIter->second.get();
else
{
rImageManagerMap[pModule].reset(new SfxImageManager(pModule));
rImageManagerMap[pModule].reset(new SfxImageManager(rModule));
pSfxImageManager = rImageManagerMap[pModule].get();
}
return pSfxImageManager;
}
Image SfxImageManager::GetImage( sal_uInt16 nId, bool bBig ) const
{
ImageList* pImageList = pImp->GetImageList( bBig );
......@@ -327,41 +279,26 @@ Image SfxImageManager::GetImage( sal_uInt16 nId, bool bBig ) const
return Image();
}
Image SfxImageManager::GetImage( sal_uInt16 nId ) const
{
bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge();
return GetImage( nId, bLarge );
}
Image SfxImageManager::SeekImage( sal_uInt16 nId, bool bBig ) const
{
bool bGlobal = ( pImp->m_pModule == 0 );
ImageList* pImageList = pImp->GetImageList( bBig );
if ( pImageList && pImageList->HasImageAtPos( nId ) )
return pImageList->GetImage( nId );
else if ( !bGlobal )
{
pImageList = ::GetImageManager( 0 )->GetImageList( bBig );
if ( pImageList )
if (pImageList && pImageList->HasImageAtPos(nId))
return pImageList->GetImage( nId );
}
return Image();
}
Image SfxImageManager::SeekImage( sal_uInt16 nId ) const
{
bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge();
return SeekImage( nId, bLarge );
}
void SfxImageManager::RegisterToolBox( ToolBox *pBox, sal_uInt16 nFlags )
{
SolarMutexGuard aGuard;
......
......@@ -229,7 +229,7 @@ SwTestAccountSettingsDialog::SwTestAccountSettingsDialog(SwMailConfigPage* pPare
m_sCompleted = m_pResult1->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_aCompletedImg = pManager->GetImage(FN_FORMULA_APPLY);
......
......@@ -77,7 +77,7 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind )
aEdit.SetSizePixel( aEdit.CalcMinimumSize() );
SfxImageManager* pManager = SfxImageManager::GetImageManager( SW_MOD() );
SfxImageManager* pManager = SfxImageManager::GetImageManager( *SW_MOD() );
pManager->RegisterToolBox(this);
pView = ::GetActiveView();
......@@ -127,7 +127,7 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind )
SwInputWindow::~SwInputWindow()
{
SfxImageManager::GetImageManager( SW_MOD() )->ReleaseToolBox(this);
SfxImageManager::GetImageManager( *SW_MOD() )->ReleaseToolBox(this);
// wake rulers
if(pView)
......@@ -165,7 +165,7 @@ void SwInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
{
// update item images
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_CANCEL, pImgMgr->GetImage(FN_FORMULA_CANCEL ));
SetItemImage( FN_FORMULA_APPLY, pImgMgr->GetImage(FN_FORMULA_APPLY ));
......
......@@ -813,7 +813,7 @@ SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings,
StartListening(*SfxGetpApp());
if ( pCreateView )
StartListening(*pCreateView);
SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
SfxImageManager* pImgMan = SfxImageManager::GetImageManager(*SW_MOD());
pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
......@@ -862,7 +862,7 @@ SwNavigationPI::~SwNavigationPI()
EndListening(*SfxGetpApp());
SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
SfxImageManager* pImgMan = SfxImageManager::GetImageManager(*SW_MOD());
pImgMan->ReleaseToolBox(&aContentToolBox);
pImgMan->ReleaseToolBox(&aGlobalToolBox);
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