summaryrefslogtreecommitdiff
path: root/sd
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 /sd
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 'sd')
-rw-r--r--sd/source/core/drawdoc4.cxx24
-rw-r--r--sd/source/core/sdpage.cxx23
-rw-r--r--sd/source/filter/ppt/pptinanimations.cxx6
-rw-r--r--sd/source/ui/accessibility/AccessibleOutlineView.cxx6
-rw-r--r--sd/source/ui/app/sdxfer.cxx10
-rw-r--r--sd/source/ui/dlg/sdtreelb.cxx5
6 files changed, 39 insertions, 35 deletions
diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx
index f8cb995a5941..48ad50b89ced 100644
--- a/sd/source/core/drawdoc4.cxx
+++ b/sd/source/core/drawdoc4.cxx
@@ -927,11 +927,10 @@ IMPL_LINK_NOARG(SdDrawDocument, OnlineSpellingHdl, Timer *, void)
{
SdrObject* pSubObj = aGroupIter.Next();
- if (pSubObj->GetOutlinerParaObject() && dynamic_cast< SdrTextObj *>( pSubObj ) != nullptr)
- {
- // Found a text object in a group object
- SpellObject(static_cast<SdrTextObj*>(pSubObj));
- }
+ if (pSubObj->GetOutlinerParaObject())
+ if (auto pTextObj = dynamic_cast< SdrTextObj *>( pSubObj ))
+ // Found a text object in a group object
+ SpellObject(pTextObj);
}
}
}
@@ -1050,13 +1049,14 @@ void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo const * pInfo, Sdr
// restart when add to dictionary takes place, too.
|| nCommand == SpellCallbackCommand::ADDTODICTIONARY)
{
- if(pOutl && dynamic_cast< const SdrTextObj *>( pObj ))
- {
- bool bModified(IsChanged());
- static_cast<SdrTextObj*>(pObj)->SetOutlinerParaObject(pOutl->CreateParaObject());
- SetChanged(bModified);
- pObj->BroadcastObjectChange();
- }
+ if(pOutl)
+ if (auto pTextObj = dynamic_cast<SdrTextObj *>( pObj ))
+ {
+ bool bModified(IsChanged());
+ pTextObj->SetOutlinerParaObject(pOutl->CreateParaObject());
+ SetChanged(bModified);
+ pObj->BroadcastObjectChange();
+ }
mpOnlineSearchItem.reset(new SvxSearchItem( SID_SEARCH_ITEM ) );
mpOnlineSearchItem->SetSearchString(pInfo->aWord);
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index bc876afdac0a..800b69808639 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -486,20 +486,21 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
}
OUString aString = GetPresObjText(eObjKind);
- if( (!aString.isEmpty() || bForceText) && dynamic_cast< const SdrTextObj *>( pSdrObj ) != nullptr )
- {
- SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
+ if(!aString.isEmpty() || bForceText)
+ if (auto pTextObj = dynamic_cast<SdrTextObj *>( pSdrObj ) )
+ {
+ SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
- OutlinerMode nOutlMode = pOutliner->GetMode();
- pOutliner->Init( OutlinerMode::TextObject );
- pOutliner->SetStyleSheet( 0, nullptr );
- pOutliner->SetVertical( bVertical );
+ OutlinerMode nOutlMode = pOutliner->GetMode();
+ pOutliner->Init( OutlinerMode::TextObject );
+ pOutliner->SetStyleSheet( 0, nullptr );
+ pOutliner->SetVertical( bVertical );
- SetObjText( static_cast<SdrTextObj*>(pSdrObj), pOutliner, eObjKind, aString );
+ SetObjText( pTextObj, pOutliner, eObjKind, aString );
- pOutliner->Init( nOutlMode );
- pOutliner->SetStyleSheet( 0, nullptr );
- }
+ pOutliner->Init( nOutlMode );
+ pOutliner->SetStyleSheet( 0, nullptr );
+ }
if( (eObjKind == PresObjKind::Header) || (eObjKind == PresObjKind::Footer) || (eObjKind == PresObjKind::SlideNumber) || (eObjKind == PresObjKind::DateTime) )
{
diff --git a/sd/source/filter/ppt/pptinanimations.cxx b/sd/source/filter/ppt/pptinanimations.cxx
index c833780473ac..02afa719863d 100644
--- a/sd/source/filter/ppt/pptinanimations.cxx
+++ b/sd/source/filter/ppt/pptinanimations.cxx
@@ -2488,10 +2488,12 @@ void AnimationImporter::importTargetElementContainer( const Atom* pAtom, Any& rT
case 8: rSubType = ShapeAnimationSubType::ONLY_TEXT; break;
case 2: // one paragraph
{
- if( ((begin == -1) && (end == -1)) || dynamic_cast< SdrTextObj *>( pSdrObject ) == nullptr )
+ if((begin == -1) && (end == -1))
break;
- SdrTextObj* pTextObj = static_cast< SdrTextObj* >( pSdrObject );
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pSdrObject );
+ if(!pTextObj)
+ break;
const OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
if( pOPO == nullptr )
diff --git a/sd/source/ui/accessibility/AccessibleOutlineView.cxx b/sd/source/ui/accessibility/AccessibleOutlineView.cxx
index 1da0c44bc14e..60edcdadf92e 100644
--- a/sd/source/ui/accessibility/AccessibleOutlineView.cxx
+++ b/sd/source/ui/accessibility/AccessibleOutlineView.cxx
@@ -58,11 +58,11 @@ AccessibleOutlineView::AccessibleOutlineView (
::sd::View* pView = pViewShell->GetView();
- if (dynamic_cast<const ::sd::OutlineView* >( pView ) == nullptr)
+ auto pShellView = dynamic_cast<::sd::OutlineView* >( pView );
+ if(!pShellView)
return;
- OutlinerView* pOutlineView = static_cast< ::sd::OutlineView*>(
- pView)->GetViewByWindow( pSdWindow );
+ OutlinerView* pOutlineView = pShellView->GetViewByWindow( pSdWindow );
SdrOutliner& rOutliner =
static_cast< ::sd::OutlineView*>(pView)->GetOutliner();
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 4752d85f16b0..1b8698d0f6a1 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -150,11 +150,11 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
mpBookmark.reset();
mpImageMap.reset();
- if( nullptr!= dynamic_cast< const SdrOle2Obj* >( pObj ) )
+ if( auto pOleObj = dynamic_cast< SdrOle2Obj* >( pObj ) )
{
try
{
- uno::Reference < embed::XEmbeddedObject > xObj = static_cast< SdrOle2Obj* >( pObj )->GetObjRef();
+ uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
if( xObj.is() && xPersist.is() && xPersist->hasEntry() )
{
@@ -162,7 +162,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
// TODO/LATER: the standalone handling of the graphic should not be used any more in future
// The EmbedDataHelper should bring the graphic in future
- const Graphic* pObjGr = static_cast< SdrOle2Obj* >( pObj )->GetGraphic();
+ const Graphic* pObjGr = pOleObj->GetGraphic();
if ( pObjGr )
mpGraphic.reset( new Graphic( *pObjGr ) );
}
@@ -204,11 +204,11 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
}
}
}
- else if( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr )
+ else if( auto pTextObj = dynamic_cast< SdrTextObj *>( pObj ) )
{
const OutlinerParaObject* pPara;
- if( (pPara = static_cast< SdrTextObj* >( pObj )->GetOutlinerParaObject()) != nullptr )
+ if( (pPara = pTextObj->GetOutlinerParaObject()) != nullptr )
{
const SvxFieldItem* pField;
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 332b5f646747..fadcd450b170 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -767,8 +767,9 @@ OUString SdPageObjsTLV::GetObjectName(
{
aRet = pObject->GetName();
- if (aRet.isEmpty() && dynamic_cast<const SdrOle2Obj* >(pObject) != nullptr)
- aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName();
+ if (aRet.isEmpty())
+ if (auto pOleObj = dynamic_cast<const SdrOle2Obj* >(pObject))
+ aRet = pOleObj->GetPersistName();
}
if (bCreate