summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-01-10 13:58:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-01-10 14:59:31 +0100
commit8f453c674f19188360ba5895c2bd9bd80273a83b (patch)
treece569bb8caeaea0b110e1e23e845716cb841588f /sw
parentc5367ee0a60966b755e726de6d175dfcd1630741 (diff)
static_cast after dynamic_cast
Change-Id: I3792ddadad9582a7e6f4740829c081d9571ddaff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109049 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/frmedt/feshview.cxx8
-rw-r--r--sw/source/core/layout/fly.cxx4
-rw-r--r--sw/source/core/view/vdraw.cxx7
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx11
-rw-r--r--sw/source/filter/xml/xmltble.cxx5
-rw-r--r--sw/source/ui/dialog/docstdlg.cxx8
-rw-r--r--sw/source/uibase/app/apphdl.cxx8
-rw-r--r--sw/source/uibase/app/docsh.cxx12
-rw-r--r--sw/source/uibase/uiview/view.cxx4
9 files changed, 35 insertions, 32 deletions
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 4250a11f8684..691f60ca3592 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -3087,11 +3087,11 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
SetLineEnds(aAttr, *pObj, nSlotId);
pObj->SetMergedItemSet(aAttr);
}
- else if(auto pCationObj = dynamic_cast<SdrCaptionObj*>( pObj))
+ else if(auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj))
{
bool bVerticalText = ( SID_DRAW_TEXT_VERTICAL == nSlotId ||
SID_DRAW_CAPTION_VERTICAL == nSlotId );
- static_cast<SdrTextObj*>(pObj)->SetVerticalWriting(bVerticalText);
+ pCaptionObj->SetVerticalWriting(bVerticalText);
if(bVerticalText)
{
SfxItemSet aSet(pObj->GetMergedItemSet());
@@ -3100,8 +3100,8 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
pObj->SetMergedItemSet(aSet);
}
- pCationObj->SetLogicRect(aRect);
- pCationObj->SetTailPos(
+ pCaptionObj->SetLogicRect(aRect);
+ pCaptionObj->SetTailPos(
aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
}
else if(auto pText = dynamic_cast<SdrTextObj*>( pObj))
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 299932e8fa7c..9d79621c5d15 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -319,9 +319,9 @@ void SwFlyFrame::DeleteCnt()
while ( pFrame->GetDrawObjs() && pFrame->GetDrawObjs()->size() )
{
SwAnchoredObject *pAnchoredObj = (*pFrame->GetDrawObjs())[0];
- if ( dynamic_cast<const SwFlyFrame*>( pAnchoredObj) != nullptr )
+ if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pAnchoredObj) )
{
- SwFrame::DestroyFrame(static_cast<SwFlyFrame*>(pAnchoredObj));
+ SwFrame::DestroyFrame(pFlyFrame);
}
else if ( dynamic_cast<const SwAnchoredDrawObject*>( pAnchoredObj) != nullptr )
{
diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx
index c0a30276b251..94f2f2240655 100644
--- a/sw/source/core/view/vdraw.cxx
+++ b/sw/source/core/view/vdraw.cxx
@@ -223,10 +223,13 @@ void SwViewShellImp::NotifySizeChg( const Size &rNewSz )
// this function might be called by the InsertDocument, when
// a PageDesc-Attribute is set on a node. Then the SdrObject
// must not have an UserCall.
- if( !pCont || dynamic_cast<const SwDrawContact*>( pCont) == nullptr )
+ if( !pCont )
+ continue;
+ auto pDrawContact = dynamic_cast<const SwDrawContact*>( pCont);
+ if( !pDrawContact )
continue;
- const SwFrame *pAnchor = static_cast<const SwDrawContact*>(pCont)->GetAnchorFrame();
+ const SwFrame *pAnchor = pDrawContact->GetAnchorFrame();
if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->isFrameAreaDefinitionValid() ||
!pAnchor->GetUpper() || !pAnchor->FindPageFrame() ||
(RndStdIds::FLY_AS_CHAR == pCont->GetFormat()->GetAnchor().GetAnchorId()) )
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index c2efe73c3830..de8a1866ba36 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2200,11 +2200,12 @@ SdrObject* SwWW8ImplReader::CreateContactObject(SwFrameFormat* pFlyFormat)
SdrObject* pNewObject = m_bNewDoc ? nullptr : pFlyFormat->FindRealSdrObject();
if (!pNewObject)
pNewObject = pFlyFormat->FindSdrObject();
- if (!pNewObject && dynamic_cast< const SwFlyFrameFormat *>( pFlyFormat ) != nullptr)
- {
- SwFlyDrawContact* pContactObject(static_cast<SwFlyFrameFormat*>(pFlyFormat)->GetOrCreateContact());
- pNewObject = pContactObject->GetMaster();
- }
+ if (!pNewObject )
+ if (auto pFlyFrameFormat = dynamic_cast<SwFlyFrameFormat *>( pFlyFormat ))
+ {
+ SwFlyDrawContact* pContactObject = pFlyFrameFormat->GetOrCreateContact();
+ pNewObject = pContactObject->GetMaster();
+ }
return pNewObject;
}
return nullptr;
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index a681fc4cf38d..ad79a92e3732 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -1122,11 +1122,10 @@ void SwXMLExport::ExportTable( const SwTableNode& rTableNd )
SvXMLElementExport aElem(*this, *oPrefix, XML_TABLE, true, true);
// export DDE source (if this is a DDE table)
- if ( dynamic_cast<const SwDDETable*>( &rTable) != nullptr )
+ if ( auto pSwDdeTable = dynamic_cast<const SwDDETable*>( &rTable) )
{
// get DDE Field Type (contains the DDE connection)
- const SwDDEFieldType* pDDEFieldType =
- static_cast<const SwDDETable&>(rTable).GetDDEFieldType();
+ const SwDDEFieldType* pDDEFieldType = pSwDdeTable->GetDDEFieldType();
// connection name
AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME,
diff --git a/sw/source/ui/dialog/docstdlg.cxx b/sw/source/ui/dialog/docstdlg.cxx
index 7aacfd94cd5f..c9b362355c6e 100644
--- a/sw/source/ui/dialog/docstdlg.cxx
+++ b/sw/source/ui/dialog/docstdlg.cxx
@@ -95,10 +95,10 @@ void SwDocStatPage::Update()
{
SfxViewShell *pVSh = SfxViewShell::Current();
SwViewShell *pSh = nullptr;
- if ( dynamic_cast< const SwView *>( pVSh ) != nullptr )
- pSh = static_cast<SwView*>(pVSh)->GetWrtShellPtr();
- else if ( dynamic_cast< const SwPagePreview *>( pVSh ) != nullptr )
- pSh = static_cast<SwPagePreview*>(pVSh)->GetViewShell();
+ if ( auto pSwView = dynamic_cast<SwView *>( pVSh ) )
+ pSh = pSwView->GetWrtShellPtr();
+ else if ( auto pPagePreview = dynamic_cast<SwPagePreview *>( pVSh ) )
+ pSh = pPagePreview->GetViewShell();
OSL_ENSURE( pSh, "Shell not found" );
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index d4bcf37d4fca..3074d96f7bab 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -964,10 +964,10 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, Con
{
if(bAccessibility)
{
- if(dynamic_cast< const SwView *>( pViewShell ) != nullptr)
- static_cast<SwView*>(pViewShell)->ApplyAccessibilityOptions(*m_pAccessibilityOptions);
- else if(dynamic_cast< const SwPagePreview *>( pViewShell ) != nullptr)
- static_cast<SwPagePreview*>(pViewShell)->ApplyAccessibilityOptions(*m_pAccessibilityOptions);
+ if(auto pSwView = dynamic_cast<SwView *>( pViewShell ))
+ pSwView->ApplyAccessibilityOptions(*m_pAccessibilityOptions);
+ else if(auto pPagePreview = dynamic_cast<SwPagePreview *>( pViewShell ))
+ pPagePreview->ApplyAccessibilityOptions(*m_pAccessibilityOptions);
}
pViewShell->GetWindow()->Invalidate();
}
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 16b3a66d8460..b6937382ebe8 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -994,12 +994,12 @@ void SwDocShell::GetState(SfxItemSet& rSet)
SfxViewFrame *pTmpFrame = SfxViewFrame::GetFirst(this);
while (pTmpFrame) // Look for Preview
{
- if ( dynamic_cast<SwView*>( pTmpFrame->GetViewShell() ) &&
- static_cast<SwView*>(pTmpFrame->GetViewShell())->GetWrtShell().GetViewOptions()->getBrowseMode() )
- {
- bDisable = true;
- break;
- }
+ if ( auto pSwView = dynamic_cast<SwView*>( pTmpFrame->GetViewShell() ) )
+ if (pSwView->GetWrtShell().GetViewOptions()->getBrowseMode())
+ {
+ bDisable = true;
+ break;
+ }
pTmpFrame = SfxViewFrame::GetNext(*pTmpFrame, this);
}
}
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 0e12a868f88d..5f5fd34029af 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1613,9 +1613,9 @@ SwGlossaryHdl* SwView::GetGlosHdl()
void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
bool bCallBase = true;
- if(dynamic_cast<const FmDesignModeChangedHint*>(&rHint))
+ if(auto pChangedHint = dynamic_cast<const FmDesignModeChangedHint*>(&rHint))
{
- bool bDesignMode = static_cast<const FmDesignModeChangedHint&>(rHint).GetDesignMode();
+ bool bDesignMode = pChangedHint->GetDesignMode();
if (!bDesignMode && GetDrawFuncPtr())
{
GetDrawFuncPtr()->Deactivate();