summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-10-13 09:45:36 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-10-13 10:34:24 +0200
commitc93cdd4e2416c81ccc4b90fd96421d7e45cecd70 (patch)
tree7be3b0f61ffb1900ea3be238d1849be02fcb1bc6 /sc
parente360269e8e217359e131ca4ae33a5668a2efab78 (diff)
static_cast after dynamic_cast
Change-Id: If1194bd3364fef8b2d0c26c22854745d0fb7b412 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104223 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/sidebar/AlignmentPropertyPanel.cxx8
-rw-r--r--sc/source/ui/undo/areasave.cxx12
-rw-r--r--sc/source/ui/undo/undoblk.cxx63
-rw-r--r--sc/source/ui/undo/undoblk2.cxx4
-rw-r--r--sc/source/ui/undo/undoblk3.cxx42
-rw-r--r--sc/source/ui/undo/undocell.cxx20
6 files changed, 73 insertions, 76 deletions
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
index 6a6bee924459..90e72f5bf1f8 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
@@ -245,11 +245,9 @@ void AlignmentPropertyPanel::NotifyItemUpdate(
case SID_H_ALIGNCELL:
{
SvxCellHorJustify meHorAlignState = SvxCellHorJustify::Standard;
- if(eState >= SfxItemState::DEFAULT && dynamic_cast<const SvxHorJustifyItem*>( pState) )
- {
- const SvxHorJustifyItem* pItem = static_cast<const SvxHorJustifyItem*>(pState);
- meHorAlignState = pItem->GetValue();
- }
+ if(eState >= SfxItemState::DEFAULT)
+ if (auto pItem = dynamic_cast<const SvxHorJustifyItem*>( pState) )
+ meHorAlignState = pItem->GetValue();
if( meHorAlignState == SvxCellHorJustify::Repeat )
{
diff --git a/sc/source/ui/undo/areasave.cxx b/sc/source/ui/undo/areasave.cxx
index e250aac70e60..3d50fba4f826 100644
--- a/sc/source/ui/undo/areasave.cxx
+++ b/sc/source/ui/undo/areasave.cxx
@@ -92,9 +92,9 @@ bool ScAreaLinkSaveCollection::IsEqual( const ScDocument* pDoc ) const
for (sal_uInt16 i=0; i<nLinkCount; i++)
{
::sfx2::SvBaseLink* pBase = rLinks[i].get();
- if (dynamic_cast<const ScAreaLink*>( pBase) != nullptr)
+ if (auto pAreaLink = dynamic_cast<ScAreaLink*>( pBase))
{
- if ( nPos >= size() || !(*this)[nPos].IsEqual( *static_cast<ScAreaLink*>(pBase) ) )
+ if ( nPos >= size() || !(*this)[nPos].IsEqual( *pAreaLink ) )
return false;
++nPos;
@@ -113,11 +113,9 @@ static ScAreaLink* lcl_FindLink( const ::sfx2::SvBaseLinks& rLinks, const ScArea
for (sal_uInt16 i=0; i<nLinkCount; i++)
{
::sfx2::SvBaseLink* pBase = rLinks[i].get();
- if ( dynamic_cast<const ScAreaLink*>( pBase) != nullptr &&
- rSaver.IsEqualSource( *static_cast<ScAreaLink*>(pBase) ) )
- {
- return static_cast<ScAreaLink*>(pBase); // found
- }
+ if ( auto pAreaLink = dynamic_cast<ScAreaLink*>( pBase) )
+ if ( rSaver.IsEqualSource( *pAreaLink ) )
+ return pAreaLink; // found
}
return nullptr; // not found
}
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 36c016c0a8b5..be9e606b4915 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -107,20 +107,20 @@ bool ScUndoInsertCells::Merge( SfxUndoAction* pNextAction )
if ( pPasteUndo )
return pPasteUndo->Merge( pNextAction );
- if ( bPartOfPaste && dynamic_cast<const ScUndoWrapper*>( pNextAction) != nullptr )
- {
- ScUndoWrapper* pWrapper = static_cast<ScUndoWrapper*>(pNextAction);
- SfxUndoAction* pWrappedAction = pWrapper->GetWrappedUndo();
- if ( dynamic_cast<const ScUndoPaste*>( pWrappedAction) )
+ if ( bPartOfPaste )
+ if ( auto pWrapper = dynamic_cast<ScUndoWrapper*>( pNextAction) )
{
- // Store paste action if this is part of paste with inserting cells.
- // A list action isn't used because Repeat wouldn't work (insert wrong cells).
+ SfxUndoAction* pWrappedAction = pWrapper->GetWrappedUndo();
+ if ( dynamic_cast<const ScUndoPaste*>( pWrappedAction) )
+ {
+ // Store paste action if this is part of paste with inserting cells.
+ // A list action isn't used because Repeat wouldn't work (insert wrong cells).
- pPasteUndo.reset( pWrappedAction );
- pWrapper->ForgetWrappedUndo(); // pWrapper is deleted by UndoManager
- return true;
+ pPasteUndo.reset( pWrappedAction );
+ pWrapper->ForgetWrappedUndo(); // pWrapper is deleted by UndoManager
+ return true;
+ }
}
- }
// Call base class for detective handling
return ScMoveUndo::Merge( pNextAction );
@@ -627,8 +627,8 @@ void ScUndoDeleteCells::Redo()
void ScUndoDeleteCells::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->DeleteCells( eCmd );
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget) )
+ pViewTarget->GetViewShell()->DeleteCells( eCmd );
}
bool ScUndoDeleteCells::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -904,8 +904,8 @@ void ScUndoCut::Redo()
void ScUndoCut::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->CutToClip();
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->CutToClip();
}
bool ScUndoCut::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -1169,10 +1169,11 @@ void ScUndoPaste::Redo()
void ScUndoPaste::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) == nullptr)
+ auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget);
+ if (!pViewTarget)
return;
- ScTabViewShell* pViewSh = static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+ ScTabViewShell* pViewSh = pViewTarget->GetViewShell();
// keep a reference in case the clipboard is changed during PasteFromClip
const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(pViewSh->GetViewData().GetActiveWin()));
if (pOwnClip)
@@ -1758,18 +1759,18 @@ void ScUndoUseScenario::Redo()
void ScUndoUseScenario::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
OUString aTemp = aName;
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->UseScenario(aTemp);
+ pViewTarget->GetViewShell()->UseScenario(aTemp);
}
}
bool ScUndoUseScenario::CanRepeat(SfxRepeatTarget& rTarget) const
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
- ScViewData& rViewData = static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData();
+ ScViewData& rViewData = pViewTarget->GetViewShell()->GetViewData();
return !rViewData.GetDocument().IsScenario( rViewData.GetTabNo() );
}
return false;
@@ -2019,8 +2020,8 @@ void ScUndoIndent::Redo()
void ScUndoIndent::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->ChangeIndent( bIsIncrement );
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->ChangeIndent( bIsIncrement );
}
bool ScUndoIndent::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -2074,8 +2075,8 @@ void ScUndoTransliterate::Redo()
void ScUndoTransliterate::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->TransliterateText( nTransliterationType );
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->TransliterateText( nTransliterationType );
}
bool ScUndoTransliterate::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -2132,9 +2133,9 @@ void ScUndoClearItems::Redo()
void ScUndoClearItems::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
- ScViewData& rViewData = static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData();
+ ScViewData& rViewData = pViewTarget->GetViewShell()->GetViewData();
rViewData.GetDocFunc().ClearItems( rViewData.GetMarkData(), pWhich.get(), false );
}
}
@@ -2195,9 +2196,9 @@ void ScUndoRemoveBreaks::Redo()
void ScUndoRemoveBreaks::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
- ScTabViewShell& rViewShell = *static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+ ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
rViewShell.RemoveManualBreaks();
}
}
@@ -2325,8 +2326,8 @@ void ScUndoRemoveMerge::Redo()
void ScUndoRemoveMerge::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->RemoveMerge();
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->RemoveMerge();
}
bool ScUndoRemoveMerge::CanRepeat(SfxRepeatTarget& rTarget) const
diff --git a/sc/source/ui/undo/undoblk2.cxx b/sc/source/ui/undo/undoblk2.cxx
index 7e13a13ef25a..149da08b5be2 100644
--- a/sc/source/ui/undo/undoblk2.cxx
+++ b/sc/source/ui/undo/undoblk2.cxx
@@ -174,8 +174,8 @@ void ScUndoWidthOrHeight::Redo()
void ScUndoWidthOrHeight::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->SetMarkedWidthOrHeight( bWidth, eMode, nNewSize );
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->SetMarkedWidthOrHeight( bWidth, eMode, nNewSize );
}
bool ScUndoWidthOrHeight::CanRepeat(SfxRepeatTarget& rTarget) const
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 4c966c4ae890..ef0a5eff9738 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -190,8 +190,8 @@ void ScUndoDeleteContents::Redo()
void ScUndoDeleteContents::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->DeleteContents( nFlags );
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->DeleteContents( nFlags );
}
bool ScUndoDeleteContents::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -326,8 +326,8 @@ void ScUndoFillTable::Redo()
void ScUndoFillTable::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink );
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink );
}
bool ScUndoFillTable::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -462,9 +462,9 @@ void ScUndoSelectionAttr::Redo()
void ScUndoSelectionAttr::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
- ScTabViewShell& rViewShell = *static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+ ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
if (pLineOuter)
rViewShell.ApplyPatternLines(*pApplyPattern, *pLineOuter, pLineInner);
else
@@ -615,9 +615,9 @@ void ScUndoAutoFill::Redo()
void ScUndoAutoFill::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
- ScTabViewShell& rViewShell = *static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+ ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
if (eFillCmd==FILL_SIMPLE)
rViewShell.FillSimple( eFillDir );
else
@@ -748,9 +748,9 @@ void ScUndoMerge::Redo()
void ScUndoMerge::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
- ScTabViewShell& rViewShell = *static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+ ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
bool bCont = false;
rViewShell.MergeCells( false, bCont, false );
}
@@ -902,8 +902,8 @@ void ScUndoAutoFormat::Redo()
void ScUndoAutoFormat::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->AutoFormat( nFormatNo );
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->AutoFormat( nFormatNo );
}
bool ScUndoAutoFormat::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -1081,8 +1081,8 @@ void ScUndoReplace::Redo()
void ScUndoReplace::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->SearchAndReplace( pSearchItem.get(), true, false );
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->SearchAndReplace( pSearchItem.get(), true, false );
}
bool ScUndoReplace::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -1266,8 +1266,8 @@ void ScUndoConversion::Redo()
void ScUndoConversion::Repeat( SfxRepeatTarget& rTarget )
{
- if( dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr )
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->DoSheetConversion( maConvParam );
+ if( auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget) )
+ pViewTarget->GetViewShell()->DoSheetConversion( maConvParam );
}
bool ScUndoConversion::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -1352,8 +1352,8 @@ void ScUndoRefConversion::Redo()
void ScUndoRefConversion::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->DoRefConversion();
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->DoRefConversion();
}
bool ScUndoRefConversion::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -1471,9 +1471,9 @@ static ScAreaLink* lcl_FindAreaLink( const sfx2::LinkManager* pLinkManager, cons
for (sal_uInt16 i=0; i<nCount; i++)
{
::sfx2::SvBaseLink* pBase = rLinks[i].get();
- if (dynamic_cast<const ScAreaLink*>( pBase) != nullptr)
- if ( static_cast<ScAreaLink*>(pBase)->IsEqual( rDoc, rFlt, rOpt, rSrc, rDest ) )
- return static_cast<ScAreaLink*>(pBase);
+ if (auto pAreaLink = dynamic_cast<ScAreaLink*>( pBase))
+ if ( pAreaLink->IsEqual( rDoc, rFlt, rOpt, rSrc, rDest ) )
+ return pAreaLink;
}
OSL_FAIL("ScAreaLink not found");
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index b34426c8f4d9..2e82399c879e 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -145,8 +145,8 @@ void ScUndoCursorAttr::Redo()
void ScUndoCursorAttr::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->ApplySelectionPattern( *pApplyPattern );
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->ApplySelectionPattern( *pApplyPattern );
}
bool ScUndoCursorAttr::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -291,10 +291,10 @@ void ScUndoEnterData::Redo()
void ScUndoEnterData::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
OUString aTemp = maNewString;
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->EnterDataAtCursor( aTemp );
+ pViewTarget->GetViewShell()->EnterDataAtCursor( aTemp );
}
}
@@ -551,9 +551,9 @@ void ScUndoPageBreak::Redo()
void ScUndoPageBreak::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
- ScTabViewShell& rViewShell = *static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+ ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
if (bInsert)
rViewShell.InsertPageBreak(bColumn);
@@ -624,9 +624,9 @@ void ScUndoPrintZoom::Redo()
void ScUndoPrintZoom::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
- ScTabViewShell& rViewShell = *static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+ ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
ScViewData& rViewData = rViewShell.GetViewData();
rViewData.GetDocShell()->SetPrintZoom( rViewData.GetTabNo(), nNewScale, nNewPages );
}
@@ -709,8 +709,8 @@ void ScUndoThesaurus::Redo()
void ScUndoThesaurus::Repeat(SfxRepeatTarget& rTarget)
{
- if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr)
- static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->DoThesaurus();
+ if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+ pViewTarget->GetViewShell()->DoThesaurus();
}
bool ScUndoThesaurus::CanRepeat(SfxRepeatTarget& rTarget) const