summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-10-06 10:50:12 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-10-06 15:10:51 +0100
commit31ee230b6efac9a6a60ceb5c2367ae9a5cf98929 (patch)
treec7ff6f56f5295caa88bda7ceb2036691e3db5c36 /sc/source/ui/docshell
parent5a242f651c8ae8d53ac67f5059f64629303848ab (diff)
Related: tdf#94814 some cleanup of static_cast following dynamic_cast
to the same type Change-Id: I197e88acbc30f8e8bb9e7f2d54803971df6062af
Diffstat (limited to 'sc/source/ui/docshell')
-rw-r--r--sc/source/ui/docshell/docfunc.cxx4
-rw-r--r--sc/source/ui/docshell/docsh3.cxx3
-rw-r--r--sc/source/ui/docshell/docsh4.cxx57
-rw-r--r--sc/source/ui/docshell/docsh6.cxx6
-rw-r--r--sc/source/ui/docshell/servobj.cxx8
5 files changed, 43 insertions, 35 deletions
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index b554dd29060b..52a8c7186ba5 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5220,8 +5220,8 @@ bool ScDocFunc::InsertAreaLink( const OUString& rFile, const OUString& rFilter,
while (nLinkPos<nLinkCount)
{
::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[nLinkPos];
- if ( dynamic_cast< const ScAreaLink *>( pBase ) != nullptr &&
- static_cast<ScAreaLink*>(pBase)->GetDestArea().aStart == rDestRange.aStart )
+ ScAreaLink* pLink = dynamic_cast<ScAreaLink*>(pBase);
+ if (pLink && pLink->GetDestArea().aStart == rDestRange.aStart)
{
if ( bUndo )
{
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index a1135db48cbb..4ac965f4edf9 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -480,9 +480,8 @@ sal_uInt16 ScDocShell::SetPrinter( SfxPrinter* pNewPrinter, SfxPrinterChangeFlag
while (pFrame)
{
SfxViewShell* pSh = pFrame->GetViewShell();
- if (pSh && dynamic_cast<const ScTabViewShell*>( pSh) != nullptr)
+ if (ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(pSh))
{
- ScTabViewShell* pViewSh = static_cast<ScTabViewShell*>(pSh);
ScInputHandler* pInputHdl = pScMod->GetInputHdl(pViewSh);
if (pInputHdl)
pInputHdl->UpdateRefDevice();
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 79cabb134d8c..d923654d4ebd 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -674,31 +674,39 @@ void ScDocShell::Execute( SfxRequest& rReq )
}
SfxApplication* pApp = SfxGetpApp();
const SfxPoolItem* pItem;
+ const SfxStringItem* pStringItem(nullptr);
SfxMedium* pMed = NULL;
- if ( pReqArgs &&
- pReqArgs->GetItemState( SID_FILE_NAME, true, &pItem ) == SfxItemState::SET &&
- dynamic_cast<const SfxStringItem*>( pItem) != nullptr )
+ if (pReqArgs && pReqArgs->GetItemState(SID_FILE_NAME, true, &pItem) == SfxItemState::SET)
{
- OUString aFileName =
- static_cast<const SfxStringItem*>(pItem)->GetValue();
+ pStringItem = dynamic_cast<const SfxStringItem*>(pItem);
+ }
+ if (pStringItem)
+ {
+ OUString aFileName = pStringItem->GetValue();
OUString aFilterName;
- if ( pReqArgs->GetItemState( SID_FILTER_NAME, true, &pItem ) == SfxItemState::SET &&
- dynamic_cast<const SfxStringItem*>( pItem) != nullptr )
+ pStringItem = nullptr;
+ if (pReqArgs->GetItemState(SID_FILTER_NAME, true, &pItem) == SfxItemState::SET)
+ pStringItem = dynamic_cast<const SfxStringItem*>(pItem);
+ if (pStringItem)
{
- aFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ aFilterName = pStringItem->GetValue();
}
OUString aOptions;
- if ( pReqArgs->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) == SfxItemState::SET &&
- dynamic_cast<const SfxStringItem*>( pItem) != nullptr )
+ pStringItem = nullptr;
+ if (pReqArgs->GetItemState(SID_FILE_FILTEROPTIONS, true, &pItem) == SfxItemState::SET)
+ pStringItem = dynamic_cast<const SfxStringItem*>(pItem);
+ if (pStringItem)
{
- aOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ aOptions = pStringItem->GetValue();
}
short nVersion = 0;
- if ( pReqArgs->GetItemState( SID_VERSION, true, &pItem ) == SfxItemState::SET &&
- dynamic_cast<const SfxInt16Item*>( pItem) != nullptr )
+ const SfxInt16Item* pInt16Item(nullptr);
+ if (pReqArgs->GetItemState(SID_VERSION, true, &pItem) == SfxItemState::SET)
+ pInt16Item = dynamic_cast<const SfxInt16Item*>(pItem);
+ if (pInt16Item)
{
- nVersion = static_cast<const SfxInt16Item*>(pItem)->GetValue();
+ nVersion = pInt16Item->GetValue();
}
// kein Filter angegeben -> Detection
@@ -817,9 +825,9 @@ void ScDocShell::Execute( SfxRequest& rReq )
const SfxPoolItem* pItem;
if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
{
- if ( dynamic_cast<const SfxStringItem*>( pItem) != nullptr )
+ if (const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>(pItem))
{
- OUString aName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ OUString aName = pStringItem->GetValue();
SCTAB nTab;
if (aDocument.GetTable( aName, nTab ))
{
@@ -845,9 +853,9 @@ void ScDocShell::Execute( SfxRequest& rReq )
const SfxPoolItem* pItem;
if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
{
- if ( dynamic_cast<const SfxStringItem*>( pItem) != nullptr )
+ if (const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>(pItem))
{
- OUString aName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ OUString aName = pStringItem->GetValue();
SCTAB nTab;
if (aDocument.GetTable( aName, nTab ))
{
@@ -893,9 +901,9 @@ void ScDocShell::Execute( SfxRequest& rReq )
const SfxPoolItem* pItem;
if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
{
- if ( dynamic_cast<const SfxUInt16Item*>( pItem) != nullptr )
+ if (const SfxUInt16Item* pInt16Item = dynamic_cast<const SfxUInt16Item*>(pItem))
{
- sal_uInt16 nY2k = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ sal_uInt16 nY2k = pInt16Item->GetValue();
// immer an den DocOptions setzen, damit das auch fuer SO50
// gespeichert wird (und alle Abfragen bisher auch darauf laufen).
// SetDocOptions propagiert das an den NumberFormatter
@@ -2292,10 +2300,13 @@ IMPL_LINK_TYPED( ScDocShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg
pImpl->pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
}
const SfxPoolItem* pItem = NULL;
+ const SfxInt16Item* pInt16Item(nullptr);
SfxItemSet* pSet = pMed->GetItemSet();
- if ( pSet &&
- pSet->GetItemState( SID_VERSION, true, &pItem ) == SfxItemState::SET &&
- dynamic_cast<const SfxInt16Item*>( pItem) != nullptr )
+ if (pSet && pSet->GetItemState(SID_VERSION, true, &pItem) == SfxItemState::SET)
+ {
+ pInt16Item = dynamic_cast<const SfxInt16Item*>(pItem);
+ }
+ if (pInt16Item)
{
pImpl->pRequest->AppendItem( *pItem );
}
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index 737423695da7..0a012928f572 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -354,9 +354,8 @@ void ScDocShell::UpdateLinks()
{
--k;
::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[k];
- if (dynamic_cast<const ScTableLink*>( pBase) != nullptr)
+ if (ScTableLink* pTabLink = dynamic_cast<ScTableLink*>(pBase))
{
- ScTableLink* pTabLink = static_cast<ScTableLink*>(pBase);
if (pTabLink->IsUsed())
aNames.insert(pTabLink->GetFileName());
else // nicht mehr benutzt -> loeschen
@@ -418,9 +417,8 @@ bool ScDocShell::ReloadTabLinks()
for (size_t i=0; i<nCount; i++ )
{
::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
- if (dynamic_cast<const ScTableLink*>( pBase) != nullptr)
+ if (ScTableLink* pTabLink = dynamic_cast<ScTableLink*>(pBase))
{
- ScTableLink* pTabLink = static_cast<ScTableLink*>(pBase);
// pTabLink->SetAddUndo(sal_False); //! Undo's zusammenfassen
// Painting only after Update() makes no sense:
diff --git a/sc/source/ui/docshell/servobj.cxx b/sc/source/ui/docshell/servobj.cxx
index e090bd26724b..4e2d7a32baeb 100644
--- a/sc/source/ui/docshell/servobj.cxx
+++ b/sc/source/ui/docshell/servobj.cxx
@@ -228,18 +228,18 @@ void ScServerObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
const ScHint* pScHint = dynamic_cast<const ScHint*>( &rHint );
if (pScHint && (pScHint->GetId() & SC_HINT_DATACHANGED))
bDataChanged = true;
- else if ( dynamic_cast<const ScAreaChangedHint*>(&rHint) ) // position of broadcaster changed
+ else if (const ScAreaChangedHint *pChgHint = dynamic_cast<const ScAreaChangedHint*>(&rHint)) // position of broadcaster changed
{
- ScRange aNewRange = static_cast<const ScAreaChangedHint&>(rHint).GetRange();
+ ScRange aNewRange = pChgHint->GetRange();
if ( aRange != aNewRange )
{
bRefreshListener = true;
bDataChanged = true;
}
}
- else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
+ else if (const SfxSimpleHint *pSplHint = dynamic_cast<const SfxSimpleHint*>(&rHint))
{
- sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
+ sal_uLong nId = pSplHint->GetId();
if (nId == SFX_HINT_DYING)
{
// If the range is being deleted, listening must be restarted