summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-09-08 13:33:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-08 14:38:15 +0200
commit3afb514362a2ce2701628256fa96d4a5324433d6 (patch)
tree914e6c3b6a37f66543db8515b1031ae65a230b63
parent73c8bd42650dafc38c87b5e6dc1ef222d4f6175c (diff)
simplify static_cast after dynamic_cast
Change-Id: I53ae7f18519fdd878730d1d0316ebc408271c66d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121811 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basic/source/classes/eventatt.cxx4
-rw-r--r--filter/source/msfilter/escherex.cxx5
-rw-r--r--sc/source/ui/drawfunc/fudraw.cxx5
-rw-r--r--sc/source/ui/view/tabvwsh5.cxx9
-rw-r--r--sd/source/ui/func/funavig.cxx109
-rw-r--r--sd/source/ui/func/fupoor.cxx55
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeEngine.cxx9
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeHandle.cxx14
-rw-r--r--svx/source/unodraw/unoshap4.cxx6
-rw-r--r--svx/source/unodraw/unoshape.cxx5
-rw-r--r--sw/source/core/doc/swserv.cxx16
-rw-r--r--sw/source/core/text/txtfly.cxx2
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx5
13 files changed, 120 insertions, 124 deletions
diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx
index 6fa48784212e..6489d88d8339 100644
--- a/basic/source/classes/eventatt.cxx
+++ b/basic/source/classes/eventatt.cxx
@@ -417,12 +417,12 @@ void RTL_Impl_CreateUnoDialog( SbxArray& rPar )
// Get dialog
SbxBaseRef pObj = rPar.Get(1)->GetObject();
- if( !(pObj.is() && dynamic_cast<const SbUnoObject*>( pObj.get() ) != nullptr) )
+ SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>(pObj.get());
+ if( !pUnoObj )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
return;
}
- SbUnoObject* pUnoObj = static_cast<SbUnoObject*>(pObj.get());
Any aAnyISP = pUnoObj->getUnoAny();
TypeClass eType = aAnyISP.getValueType().getTypeClass();
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 865df7c292b4..95b8b27c48d3 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -2582,12 +2582,13 @@ void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeT
if ( !aXPropSet.is() )
return;
- if(nullptr == dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(rXShape)))
+ SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(rXShape));
+ if(!pSdrObjCustomShape)
{
return;
}
- SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*SdrObject::getSdrObjectFromXShape(rXShape)));
+ SdrObjCustomShape& rSdrObjCustomShape = *pSdrObjCustomShape;
uno::Any aGeoPropSet = aXPropSet->getPropertyValue( "CustomShapeGeometry" );
uno::Sequence< beans::PropertyValue > aGeoPropSeq;
if ( !(aGeoPropSet >>= aGeoPropSeq) )
diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx
index 582a1ba77713..9306a5fd9556 100644
--- a/sc/source/ui/drawfunc/fudraw.cxx
+++ b/sc/source/ui/drawfunc/fudraw.cxx
@@ -241,9 +241,10 @@ bool FuDraw::KeyInput(const KeyEvent& rKEvt)
{
bool bOle = rViewShell.GetViewFrame()->GetFrame().IsInPlace();
SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
- if( dynamic_cast<const SdrOle2Obj*>( pObj) && !bOle )
+ auto pOleObj = dynamic_cast<SdrOle2Obj*>(pObj);
+ if( pOleObj && !bOle )
{
- rViewShell.ActivateObject(static_cast<SdrOle2Obj*>(pObj), css::embed::EmbedVerbs::MS_OLEVERB_PRIMARY);
+ rViewShell.ActivateObject(pOleObj, css::embed::EmbedVerbs::MS_OLEVERB_PRIMARY);
// consumed
bReturn = true;
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index 70d88753b752..62949eaaa472 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -106,15 +106,14 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
}
}
}
- else if (dynamic_cast<const ScTablesHint*>(&rHint)) // table insert / deleted
+ else if (auto pTablesHint = dynamic_cast<const ScTablesHint*>(&rHint)) // table insert / deleted
{
// first fetch current table (can be changed during DeleteTab on ViewData)
SCTAB nActiveTab = GetViewData().GetTabNo();
- const ScTablesHint& rTabHint = static_cast<const ScTablesHint&>(rHint);
- SCTAB nTab1 = rTabHint.GetTab1();
- SCTAB nTab2 = rTabHint.GetTab2();
- sal_uInt16 nId = rTabHint.GetTablesHintId();
+ SCTAB nTab1 = pTablesHint->GetTab1();
+ SCTAB nTab2 = pTablesHint->GetTab2();
+ sal_uInt16 nId = pTablesHint->GetTablesHintId();
switch (nId)
{
case SC_TAB_INSERTED:
diff --git a/sd/source/ui/func/funavig.cxx b/sd/source/ui/func/funavig.cxx
index e481562f0c47..bd0cdb7c3336 100644
--- a/sd/source/ui/func/funavig.cxx
+++ b/sd/source/ui/func/funavig.cxx
@@ -69,75 +69,74 @@ void FuNavigation::DoExecute( SfxRequest& rReq )
case SID_GO_TO_PREVIOUS_PAGE:
{
- if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bSlideShow)
- {
- // With no modifier pressed we move to the previous
- // slide.
- mpView->SdrEndTextEdit();
-
- // Previous page.
- SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
- sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
-
- if (nSdPage > 0)
+ if( !bSlideShow)
+ if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ) )
{
- // Switch the page and send events regarding
- // deactivation the old page and activating the new
- // one.
- TabControl& rPageTabControl =
- static_cast<DrawViewShell*>(mpViewShell)
- ->GetPageTabControl();
- if (rPageTabControl.IsReallyShown())
- rPageTabControl.SendDeactivatePageEvent ();
- static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage - 1);
- if (rPageTabControl.IsReallyShown())
- rPageTabControl.SendActivatePageEvent ();
+ // With no modifier pressed we move to the previous
+ // slide.
+ mpView->SdrEndTextEdit();
+
+ // Previous page.
+ SdPage* pPage = pDrawViewShell->GetActualPage();
+ sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
+
+ if (nSdPage > 0)
+ {
+ // Switch the page and send events regarding
+ // deactivation the old page and activating the new
+ // one.
+ TabControl& rPageTabControl =
+ static_cast<DrawViewShell*>(mpViewShell)
+ ->GetPageTabControl();
+ if (rPageTabControl.IsReallyShown())
+ rPageTabControl.SendDeactivatePageEvent ();
+ static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage - 1);
+ if (rPageTabControl.IsReallyShown())
+ rPageTabControl.SendActivatePageEvent ();
+ }
}
- }
}
break;
case SID_GO_TO_NEXT_PAGE:
{
- if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bSlideShow)
- {
- // With no modifier pressed we move to the next slide.
- mpView->SdrEndTextEdit();
-
- // Next page.
- SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
- sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
-
- if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) - 1)
+ if( !bSlideShow)
+ if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
{
- // Switch the page and send events regarding
- // deactivation the old page and activating the new
- // one.
- TabControl& rPageTabControl =
- static_cast<DrawViewShell*>(mpViewShell)->GetPageTabControl();
- if (rPageTabControl.IsReallyShown())
- rPageTabControl.SendDeactivatePageEvent ();
- static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage + 1);
- if (rPageTabControl.IsReallyShown())
- rPageTabControl.SendActivatePageEvent ();
+ // With no modifier pressed we move to the next slide.
+ mpView->SdrEndTextEdit();
+
+ // Next page.
+ SdPage* pPage = pDrawViewShell->GetActualPage();
+ sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
+
+ if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) - 1)
+ {
+ // Switch the page and send events regarding
+ // deactivation the old page and activating the new
+ // one.
+ TabControl& rPageTabControl =
+ static_cast<DrawViewShell*>(mpViewShell)->GetPageTabControl();
+ if (rPageTabControl.IsReallyShown())
+ rPageTabControl.SendDeactivatePageEvent ();
+ static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage + 1);
+ if (rPageTabControl.IsReallyShown())
+ rPageTabControl.SendActivatePageEvent ();
+ }
}
- }
}
break;
case SID_GO_TO_LAST_PAGE:
{
- if (!mpView->IsTextEdit()
- && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr
- && !bSlideShow)
- {
- // jump to last page
- SdPage* pPage =
- static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
- static_cast<DrawViewShell*>(mpViewShell)
- ->SwitchPage(mpDoc->GetSdPageCount(
- pPage->GetPageKind()) - 1);
- }
+ if (!mpView->IsTextEdit() && !bSlideShow)
+ if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
+ {
+ // jump to last page
+ SdPage* pPage = pDrawViewShell->GetActualPage();
+ pDrawViewShell->SwitchPage(mpDoc->GetSdPageCount(
+ pPage->GetPageKind()) - 1);
+ }
}
break;
}
diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx
index 817d0f8c6014..f9b9e0a61675 100644
--- a/sd/source/ui/func/fupoor.cxx
+++ b/sd/source/ui/func/fupoor.cxx
@@ -373,31 +373,27 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
case KEY_HOME:
{
- if (!mpView->IsTextEdit()
- && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr
- && !bSlideShow)
- {
- // jump to first page
- static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(0);
- bReturn = true;
- }
+ if (!mpView->IsTextEdit() && !bSlideShow)
+ if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
+ {
+ // jump to first page
+ pDrawViewShell->SwitchPage(0);
+ bReturn = true;
+ }
}
break;
case KEY_END:
{
- if (!mpView->IsTextEdit()
- && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr
- && !bSlideShow)
- {
- // jump to last page
- SdPage* pPage =
- static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
- static_cast<DrawViewShell*>(mpViewShell)
- ->SwitchPage(mpDoc->GetSdPageCount(
- pPage->GetPageKind()) - 1);
- bReturn = true;
- }
+ if (!mpView->IsTextEdit() && !bSlideShow)
+ if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
+ {
+ // jump to last page
+ SdPage* pPage = pDrawViewShell->GetActualPage();
+ pDrawViewShell->SwitchPage(mpDoc->GetSdPageCount(
+ pPage->GetPageKind()) - 1);
+ bReturn = true;
+ }
}
break;
@@ -405,8 +401,10 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
{
if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() )
break;
+ if( bSlideShow)
+ break;
- if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bSlideShow)
+ if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ) )
{
// The page-up key switches layers or pages depending on the
// modifier key.
@@ -418,7 +416,7 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
// Previous page.
bReturn = true;
- SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
+ SdPage* pPage = pDrawViewShell->GetActualPage();
sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
if (nSdPage > 0)
@@ -427,11 +425,10 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
// deactivation the old page and activating the new
// one.
TabControl& rPageTabControl =
- static_cast<DrawViewShell*>(mpViewShell)
- ->GetPageTabControl();
+ pDrawViewShell->GetPageTabControl();
if (rPageTabControl.IsReallyShown())
rPageTabControl.SendDeactivatePageEvent ();
- static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage - 1);
+ pDrawViewShell->SwitchPage(nSdPage - 1);
if (rPageTabControl.IsReallyShown())
rPageTabControl.SendActivatePageEvent ();
}
@@ -439,7 +436,7 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
else if (rKEvt.GetKeyCode().IsMod1())
{
// With the CONTROL modifier we switch layers.
- if (static_cast<DrawViewShell*>(mpViewShell)->IsLayerModeActive())
+ if (pDrawViewShell->IsLayerModeActive())
{
// Moves to the previous layer.
SwitchLayer (-1);
@@ -600,11 +597,11 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
bool bIsMoveOfConnectedHandle(false);
bool bOldSuppress = false;
SdrEdgeObj* pEdgeObj = nullptr;
+ if(pHdl)
+ pEdgeObj = dynamic_cast<SdrEdgeObj *>( pHdl->GetObj() );
- if(pHdl && dynamic_cast< const SdrEdgeObj *>( pHdl->GetObj() ) && 0 == pHdl->GetPolyNum())
+ if(pEdgeObj && 0 == pHdl->GetPolyNum())
{
- pEdgeObj = static_cast<SdrEdgeObj*>(pHdl->GetObj());
-
if(0 == pHdl->GetPointNum())
{
if(pEdgeObj->GetConnection(true).GetObject())
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index 86d2f9bfb00b..6f280f3d7304 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -195,14 +195,11 @@ std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForce
// get the text bounds and set at text object
tools::Rectangle aTextBounds(rSdrObjCustomShape.GetSnapRect());
- const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxShape)));
+ auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxShape));
- if(bIsSdrObjCustomShape)
+ if(pSdrObjCustomShape)
{
- SdrObjCustomShape& rSdrObjCustomShape2(
- static_cast< SdrObjCustomShape& >(
- *SdrObject::getSdrObjectFromXShape(mxShape)));
- EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape2);
+ EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
aTextBounds = aCustomShape2d.GetTextRect();
}
diff --git a/svx/source/customshapes/EnhancedCustomShapeHandle.cxx b/svx/source/customshapes/EnhancedCustomShapeHandle.cxx
index 2a9fd1f19991..d2d5c8df6b5b 100644
--- a/svx/source/customshapes/EnhancedCustomShapeHandle.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeHandle.cxx
@@ -49,16 +49,15 @@ void SAL_CALL EnhancedCustomShapeHandle::release() noexcept
// XCustomShapeHandle
css::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition()
{
- const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape)));
+ auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape));
- if(!bIsSdrObjCustomShape)
+ if(!pSdrObjCustomShape)
{
throw css::uno::RuntimeException();
}
- SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*SdrObject::getSdrObjectFromXShape(mxCustomShape)));
Point aPosition;
- EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
+ EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
if(!aCustomShape2d.GetHandlePosition(mnIndex, aPosition))
{
@@ -70,15 +69,14 @@ css::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition()
void SAL_CALL EnhancedCustomShapeHandle::setControllerPosition( const css::awt::Point& aPnt )
{
- const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape)));
+ auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape));
- if(!bIsSdrObjCustomShape)
+ if(!pSdrObjCustomShape)
{
throw css::uno::RuntimeException();
}
- SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*SdrObject::getSdrObjectFromXShape(mxCustomShape)));
- EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
+ EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
if(!aCustomShape2d.SetHandleControllerPosition(mnIndex, aPnt))
{
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index 9274a60a2e28..ea590892daaa 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -87,10 +87,12 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
// TODO/LATER: seems to make no sense for iconified object
awt::Rectangle aVisArea;
- if( (rValue >>= aVisArea) && dynamic_cast<const SdrOle2Obj* >(GetSdrObject()) != nullptr)
+ if( !(rValue >>= aVisArea))
+ break;
+ if( auto pOle2Obj = dynamic_cast<SdrOle2Obj* >(GetSdrObject()) )
{
Size aTmp( aVisArea.X + aVisArea.Width, aVisArea.Y + aVisArea.Height );
- uno::Reference < embed::XEmbeddedObject > xObj = static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef();
+ uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef();
if( xObj.is() )
{
try
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 46611422ff23..6445b81e06db 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -2693,8 +2693,9 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
case OWN_ATTR_MIRRORED:
{
bool bMirror = false;
- if( HasSdrObject() && dynamic_cast<const SdrGrafObj*>(GetSdrObject()) != nullptr )
- bMirror = static_cast<SdrGrafObj*>(GetSdrObject())->IsMirrored();
+ if( HasSdrObject() )
+ if (auto pGrafObj = dynamic_cast<SdrGrafObj*>(GetSdrObject()) )
+ bMirror = pGrafObj->IsMirrored();
rValue <<= bMirror;
break;
diff --git a/sw/source/core/doc/swserv.cxx b/sw/source/core/doc/swserv.cxx
index cc2d3fe5dbf5..2236938a5ad2 100644
--- a/sw/source/core/doc/swserv.cxx
+++ b/sw/source/core/doc/swserv.cxx
@@ -299,14 +299,14 @@ SwDataChanged::~SwDataChanged()
{
::sfx2::SvLinkSourceRef refObj( rpLinkSrc );
// Anyone else interested in the Object?
- if( refObj->HasDataLinks() && dynamic_cast<const SwServerObject*>( refObj.get() ) != nullptr)
- {
- SwServerObject& rObj = *static_cast<SwServerObject*>( refObj.get() );
- if( m_pPos )
- rObj.SendDataChanged( *m_pPos );
- else
- rObj.SendDataChanged( *m_pPam );
- }
+ if( refObj->HasDataLinks())
+ if (auto pServerObj = dynamic_cast<SwServerObject*>( refObj.get() ))
+ {
+ if( m_pPos )
+ pServerObj->SendDataChanged( *m_pPos );
+ else
+ pServerObj->SendDataChanged( *m_pPam );
+ }
// We shouldn't have a connection anymore
if( !refObj->HasDataLinks() )
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 2e8e58b533ab..92508cde9bc3 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -224,7 +224,7 @@ SwRect SwContourCache::ContourRect( const SwFormat* pFormat,
// the graphic to change its size, call ClrObject()
tools::PolyPolygon aPoly;
if( !pVirtFlyDrawObj->GetFlyFrame()->GetContour( aPoly ) )
- aPoly = tools::PolyPolygon( static_cast<const SwVirtFlyDrawObj*>(pObj)->
+ aPoly = tools::PolyPolygon( pVirtFlyDrawObj->
GetFlyFrame()->getFrameArea().SVRect() );
aPolyPolygon.clear();
aPolyPolygon.append(aPoly.getB2DPolyPolygon());
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index 7d2db3ecd141..804b50184af6 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -612,10 +612,11 @@ bool X11SalBitmap::Create( const SalBitmap& rSSalBmp )
{
Destroy();
- if( dynamic_cast<const X11SalBitmap*>( &rSSalBmp ) == nullptr )
+ auto pX11Bmp = dynamic_cast<const X11SalBitmap*>( &rSSalBmp );
+ if (!pX11Bmp)
return false;
- const X11SalBitmap& rSalBmp = static_cast<const X11SalBitmap&>( rSSalBmp );
+ const X11SalBitmap& rSalBmp = *pX11Bmp;
if( rSalBmp.mpDIB )
{