new loplugin simplifydynamiccast

simplify dynamic_cast followed by static_cast

Change-Id: I965afcf05d1675094cfde53d3590a0fd00f26279
Reviewed-on: https://gerrit.libreoffice.org/44460
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2017-11-07 13:55:06 +02:00
parent ea4a47d7d4
commit 5ba447bdcd
49 changed files with 275 additions and 148 deletions

View File

@ -0,0 +1,116 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <cassert>
#include <string>
#include <iostream>
#include <fstream>
#include <set>
#include <clang/AST/CXXInheritance.h>
#include "compat.hxx"
#include "plugin.hxx"
namespace
{
class SimplifyDynamicCast : public RecursiveASTVisitor<SimplifyDynamicCast>, public loplugin::Plugin
{
public:
explicit SimplifyDynamicCast(loplugin::InstantiationData const& data)
: Plugin(data)
{
}
virtual void run() override
{
// StringRef fn( compiler.getSourceManager().getFileEntryForID(
// compiler.getSourceManager().getMainFileID())->getName() );
// if (loplugin::isSamePathname(fn, WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx"))
// return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
bool TraverseIfStmt(IfStmt*);
bool VisitCXXStaticCastExpr(CXXStaticCastExpr const*);
private:
std::vector<QualType> dynamicCastVec;
std::vector<Decl const*> dynamicCastSubExprVec;
std::vector<IfStmt const*> ifVec;
};
bool SimplifyDynamicCast::TraverseIfStmt(IfStmt* ifStmt)
{
auto condExpr = ifStmt->getCond()->IgnoreParenImpCasts();
auto dynamicCastExpr = dyn_cast<CXXDynamicCastExpr>(condExpr);
if (!dynamicCastExpr)
{
if (auto binaryOp = dyn_cast<BinaryOperator>(condExpr))
{
if (binaryOp->getOpcode() == BO_NE)
dynamicCastExpr
= dyn_cast<CXXDynamicCastExpr>(binaryOp->getLHS()->IgnoreParenImpCasts());
}
}
Decl const* subExprDecl = nullptr;
if (dynamicCastExpr)
{
auto subExprDeclRefExpr
= dyn_cast<DeclRefExpr>(dynamicCastExpr->getSubExpr()->IgnoreParenImpCasts());
if (!subExprDeclRefExpr)
dynamicCastExpr = nullptr;
else
subExprDecl = subExprDeclRefExpr->getDecl();
}
if (dynamicCastExpr)
{
auto qt = dynamicCastExpr->getTypeAsWritten();
dynamicCastVec.push_back(qt);
dynamicCastSubExprVec.push_back(subExprDecl);
ifVec.push_back(ifStmt);
}
bool ret = RecursiveASTVisitor::TraverseIfStmt(ifStmt);
if (dynamicCastExpr)
{
dynamicCastVec.pop_back();
dynamicCastSubExprVec.pop_back();
ifVec.pop_back();
}
return ret;
}
bool SimplifyDynamicCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const* staticCastExpr)
{
if (ignoreLocation(staticCastExpr))
return true;
if (dynamicCastVec.empty())
return true;
auto qt = staticCastExpr->getTypeAsWritten();
auto it = std::find(dynamicCastVec.begin(), dynamicCastVec.end(), qt);
if (it == dynamicCastVec.end())
return true;
int idx = it - dynamicCastVec.begin();
auto subExprDecl = dyn_cast<DeclRefExpr>(staticCastExpr->getSubExpr()->IgnoreParenImpCasts());
if (!subExprDecl)
return true;
if (dynamicCastSubExprVec[idx] != subExprDecl->getDecl())
return true;
report(DiagnosticsEngine::Warning, "simplify, use var in if", staticCastExpr->getLocStart())
<< staticCastExpr->getSourceRange();
auto ifStmt = ifVec[idx];
report(DiagnosticsEngine::Note, "if here", ifStmt->getLocStart()) << ifStmt->getSourceRange();
return true;
}
loplugin::Plugin::Registration<SimplifyDynamicCast> X("simplifydynamiccast", true);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
struct ClassA
{
virtual ~ClassA() {}
};
struct ClassB : public ClassA
{
void foo() {}
};
void f1(ClassA* p1)
{
if (dynamic_cast<ClassB*>(p1)) // expected-note {{if here [loplugin:simplifydynamiccast]}}
{
static_cast<ClassB*>(p1)
->foo(); // expected-error@-1 {{simplify, use var in if [loplugin:simplifydynamiccast]}}
}
if (dynamic_cast<ClassB*>(p1) != nullptr)
{ // expected-note@-1 {{if here [loplugin:simplifydynamiccast]}}
static_cast<ClassB*>(p1)
->foo(); // expected-error@-1 {{simplify, use var in if [loplugin:simplifydynamiccast]}}
}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

View File

@ -3496,10 +3496,10 @@ uno::Reference< datatransfer::XTransferable > ImpEditEngine::CreateTransferable(
{
const SvxFieldItem* pField = static_cast<const SvxFieldItem*>(pAttr->GetItem());
const SvxFieldData* pFld = pField->GetField();
if ( dynamic_cast<const SvxURLField* >(pFld) != nullptr )
if ( auto pUrlField = dynamic_cast<const SvxURLField* >(pFld) )
{
// Office-Bookmark
pDataObj->GetURL() = static_cast<const SvxURLField*>(pFld)->GetURL();
pDataObj->GetURL() = pUrlField->GetURL();
}
}
}

View File

@ -3617,7 +3617,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, tools::Rectangle aClipRect, Po
if( pFieldItem )
{
const SvxFieldData* pFieldData = pFieldItem->GetField();
if ( dynamic_cast< const SvxURLField* >( pFieldData ) != nullptr)
if ( auto pUrlField = dynamic_cast< const SvxURLField* >( pFieldData ) )
{
Point aTopLeft( aTmpPos );
aTopLeft.Y() -= pLine->GetMaxAscent();
@ -3625,7 +3625,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, tools::Rectangle aClipRect, Po
tools::Rectangle aRect( aTopLeft, rTextPortion.GetSize() );
vcl::PDFExtOutDevBookmarkEntry aBookmark;
aBookmark.nLinkId = pPDFExtOutDevData->CreateLink( aRect );
aBookmark.aBookmark = static_cast<const SvxURLField*>(pFieldData)->GetURL();
aBookmark.aBookmark = pUrlField->GetURL();
std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks();
rBookmarks.push_back( aBookmark );
}

View File

@ -917,13 +917,13 @@ long ToolbarLayoutManager::childWindowEvent( VclSimpleEvent const * pEvent )
// To enable toolbar controllers to change their image when a sub-toolbar function
// is activated, we need this mechanism. We have NO connection between these toolbars
// anymore!
if ( dynamic_cast< const VclWindowEvent* >(pEvent) != nullptr )
if ( auto pWindowEvent = dynamic_cast< const VclWindowEvent* >(pEvent) )
{
if ( pEvent->GetId() == VclEventId::ToolboxSelect )
{
OUString aToolbarName;
OUString aCommand;
ToolBox* pToolBox = getToolboxPtr( static_cast<VclWindowEvent const *>(pEvent)->GetWindow() );
ToolBox* pToolBox = getToolboxPtr( pWindowEvent->GetWindow() );
if ( pToolBox )
{

View File

@ -518,8 +518,8 @@ ScValidationDlg * ScTPValidationValue::GetValidationDlg()
{
if( vcl::Window *pParent = GetParent() )
do{
if ( dynamic_cast<ScValidationDlg*>( pParent ) )
return static_cast< ScValidationDlg * >( pParent );
if ( auto pValidationDlg = dynamic_cast<ScValidationDlg*>( pParent ) )
return pValidationDlg;
}while ( nullptr != ( pParent = pParent->GetParent() ) );
return nullptr;
}

View File

@ -530,14 +530,14 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, vcl::Window* pWin, ScDrawV
if( pReqArgs->HasItem( FN_PARAM_4, &pItem ) )
{
if ( dynamic_cast<const SfxUInt16Item*>( pItem) != nullptr )
nToTable = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
else if ( dynamic_cast<const SfxBoolItem*>( pItem) != nullptr )
if ( auto pUInt16Item = dynamic_cast<const SfxUInt16Item*>( pItem) )
nToTable = pUInt16Item->GetValue();
else if ( auto pBoolItem = dynamic_cast<const SfxBoolItem*>( pItem) )
{
// In IDL for Basic FN_PARAM_4 means SfxBoolItem
// -> if set new table, else current table
if ( static_cast<const SfxBoolItem*>(pItem)->GetValue() )
if ( pBoolItem->GetValue() )
nToTable = static_cast<sal_uInt16>(rScDoc.GetTableCount());
else
nToTable = static_cast<sal_uInt16>(rData.GetTabNo());

View File

@ -1068,10 +1068,10 @@ const ScAreaLink* ScContentTree::GetLink( sal_uLong nIndex )
for (sal_uInt16 i=0; i<nCount; i++)
{
::sfx2::SvBaseLink* pBase = rLinks[i].get();
if (dynamic_cast<const ScAreaLink*>( pBase) != nullptr)
if (auto pAreaLink = dynamic_cast<const ScAreaLink*>( pBase))
{
if (nFound == nIndex)
return static_cast<const ScAreaLink*>(pBase);
return pAreaLink;
++nFound;
}
}

View File

@ -247,18 +247,18 @@ void ScScenarioWindow::NotifyState( const SfxPoolItem* pState )
{
aLbScenario->Enable();
if ( dynamic_cast<const SfxStringItem*>( pState) != nullptr )
if ( auto pStringItem = dynamic_cast<const SfxStringItem*>( pState) )
{
OUString aNewEntry( static_cast<const SfxStringItem*>(pState)->GetValue() );
OUString aNewEntry( pStringItem->GetValue() );
if ( !aNewEntry.isEmpty() )
aLbScenario->SelectEntry( aNewEntry );
else
aLbScenario->SetNoSelection();
}
else if ( dynamic_cast<const SfxStringListItem*>( pState) != nullptr )
else if ( auto pStringListItem = dynamic_cast<const SfxStringListItem*>( pState) )
{
aLbScenario->UpdateEntries( static_cast<const SfxStringListItem*>(pState)->GetList() );
aLbScenario->UpdateEntries( pStringListItem->GetList() );
}
}
else

View File

@ -2616,11 +2616,11 @@ void ScViewFunc::MoveTable(
{ &aItem, &aTarget });
if ( pRetItem )
{
if ( dynamic_cast<const SfxObjectItem*>( pRetItem) != nullptr )
pDestShell = dynamic_cast<ScDocShell*>( static_cast<const SfxObjectItem*>(pRetItem)->GetShell() );
else if ( dynamic_cast<const SfxViewFrameItem*>( pRetItem) != nullptr )
if ( auto pObjectItem = dynamic_cast<const SfxObjectItem*>(pRetItem) )
pDestShell = dynamic_cast<ScDocShell*>( pObjectItem->GetShell() );
else if ( auto pViewFrameItem = dynamic_cast<const SfxViewFrameItem*>( pRetItem) )
{
SfxViewFrame* pFrm = static_cast<const SfxViewFrameItem*>(pRetItem)->GetFrame();
SfxViewFrame* pFrm = pViewFrameItem->GetFrame();
if (pFrm)
pDestShell = dynamic_cast<ScDocShell*>( pFrm->GetObjectShell() );
}

View File

@ -1046,9 +1046,8 @@ IMapObject* SdDrawDocument::GetHitIMapObject( SdrObject const * pObj,
bool bObjSupported = false;
// execute HitTest
if ( dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr ) // simple graphics object
if ( auto pGrafObj = dynamic_cast< const SdrGrafObj *>( pObj ) ) // simple graphics object
{
const SdrGrafObj* pGrafObj = static_cast<const SdrGrafObj*>(pObj);
const GeoStat& rGeo = pGrafObj->GetGeoStat();
SdrGrafObjGeoData* pGeoData = static_cast<SdrGrafObjGeoData*>( pGrafObj->GetGeoData() );

View File

@ -91,8 +91,8 @@ static SdPage* GetCurrentPage( sd::ViewShell const * pViewSh, EditFieldInfo cons
// first try to check if we are inside the outline view
sd::OutlineView* pSdView = nullptr;
if( dynamic_cast<const sd::OutlineViewShell* >(pViewSh) != nullptr )
pSdView = static_cast<sd::OutlineView*> (static_cast<sd::OutlineViewShell const *>(pViewSh)->GetView());
if( auto pOutlineViewShell = dynamic_cast<const sd::OutlineViewShell* >(pViewSh) )
pSdView = static_cast<sd::OutlineView*>(pOutlineViewShell->GetView());
if (pSdView != nullptr && (pOutliner == &pSdView->GetOutliner()))
{

View File

@ -78,9 +78,9 @@ void SdTemplateControl::StateChanged(
{
if( eState != SfxItemState::DEFAULT || pState->IsVoidItem() )
GetStatusBar().SetItemText( GetId(), OUString() );
else if ( dynamic_cast< const SfxStringItem *>( pState ) != nullptr )
else if ( auto pStringItem = dynamic_cast< const SfxStringItem *>( pState ) )
{
msTemplate = static_cast<const SfxStringItem*>(pState)->GetValue();
msTemplate = pStringItem->GetValue();
GetStatusBar().SetItemText( GetId(), msTemplate );
}
}

View File

@ -819,11 +819,11 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
case SID_DRAW_MEASURELINE:
{
if( dynamic_cast< SdrMeasureObj *>( pObj ) != nullptr)
if( auto pMeasureObj = dynamic_cast< SdrMeasureObj *>( pObj ) )
{
sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
static_cast<SdrMeasureObj*>(pObj)->SetPoint(Point(aStart.X(), nYMiddle), 0);
static_cast<SdrMeasureObj*>(pObj)->SetPoint(Point(aEnd.X(), nYMiddle), 1);
pMeasureObj->SetPoint(Point(aStart.X(), nYMiddle), 0);
pMeasureObj->SetPoint(Point(aEnd.X(), nYMiddle), 1);
}
else
{
@ -862,10 +862,10 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
case SID_CONNECTOR_LINES_CIRCLE_END:
case SID_CONNECTOR_LINES_CIRCLES:
{
if( dynamic_cast< SdrEdgeObj *>( pObj ) != nullptr)
if( auto pEdgeObj = dynamic_cast< SdrEdgeObj *>( pObj ) )
{
static_cast<SdrEdgeObj*>(pObj)->SetTailPoint(false, aStart);
static_cast<SdrEdgeObj*>(pObj)->SetTailPoint(true, aEnd);
pEdgeObj->SetTailPoint(false, aStart);
pEdgeObj->SetTailPoint(true, aEnd);
}
else
{
@ -877,7 +877,7 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
case SID_DRAW_CAPTION:
case SID_DRAW_CAPTION_VERTICAL:
{
if( dynamic_cast< SdrCaptionObj *>( pObj ) != nullptr)
if( auto pCaptionObj = dynamic_cast< SdrCaptionObj *>( pObj ) )
{
bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID);
@ -893,8 +893,8 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
// The default text is not inserted anymore.
static_cast<SdrCaptionObj*>(pObj)->SetLogicRect(aRect);
static_cast<SdrCaptionObj*>(pObj)->SetTailPos(
pCaptionObj->SetLogicRect(aRect);
pCaptionObj->SetTailPos(
aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
}
else

View File

@ -1313,9 +1313,8 @@ SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rect
if(pObj)
{
if( dynamic_cast< SdrTextObj *>( pObj ) != nullptr)
if( auto pText = dynamic_cast< SdrTextObj *>( pObj ) )
{
SdrTextObj* pText = static_cast<SdrTextObj*>(pObj);
pText->SetLogicRect(rRectangle);
bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID);

View File

@ -1414,8 +1414,8 @@ private:
rOutliner.SetControlWord( nCntrl );
// When in outline view then apply all pending changes to the model.
if( dynamic_cast< OutlineViewShell *>( pShell ) != nullptr)
static_cast<OutlineViewShell*>(pShell)->PrepareClose (false);
if( auto pOutlineViewShell = dynamic_cast< OutlineViewShell *>( pShell ) )
pOutlineViewShell->PrepareClose (false);
// Collect some frequently used data.
if (mpOptions->IsDate())

View File

@ -97,7 +97,6 @@ void DrawViewShell::ScannerEvent()
Point aPnt ( ( aPageSize.Width() - aBmpSize.Width() ) >> 1, ( aPageSize.Height() - aBmpSize.Height() ) >> 1 );
aPnt += Point( pPage->GetLeftBorder(), pPage->GetUpperBorder() );
::tools::Rectangle aRect( aPnt, aBmpSize );
SdrGrafObj* pGrafObj = nullptr;
bool bInsertNewObject = true;
if( GetView()->AreObjectsMarked() )
@ -109,10 +108,8 @@ void DrawViewShell::ScannerEvent()
SdrMark* pMark = rMarkList.GetMark(0);
SdrObject* pObj = pMark->GetMarkedSdrObj();
if( dynamic_cast< SdrGrafObj *>( pObj ) != nullptr )
if( auto pGrafObj = dynamic_cast< SdrGrafObj *>( pObj ) )
{
pGrafObj = static_cast< SdrGrafObj* >( pObj );
if( pGrafObj->IsEmptyPresObj() )
{
bInsertNewObject = false;
@ -126,7 +123,7 @@ void DrawViewShell::ScannerEvent()
if( bInsertNewObject )
{
pGrafObj = new SdrGrafObj( Graphic( aScanBmp ), aRect );
auto pGrafObj = new SdrGrafObj( Graphic( aScanBmp ), aRect );
SdrPageView* pPV = GetView()->GetSdrPageView();
GetView()->InsertObjectAtView( pGrafObj, *pPV, SdrInsertFlags::SETDEFLAYER );
}

View File

@ -96,11 +96,11 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
{
const SvxFieldData* pField = pFieldItem->GetField();
if( dynamic_cast< const SvxURLField *>( pField ) != nullptr)
if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
{
aHLinkItem.SetName(static_cast<const SvxURLField*>(pField)->GetRepresentation());
aHLinkItem.SetURL(static_cast<const SvxURLField*>(pField)->GetURL());
aHLinkItem.SetTargetFrame(static_cast<const SvxURLField*>(pField)->GetTargetFrame());
aHLinkItem.SetName(pUrlField->GetRepresentation());
aHLinkItem.SetURL(pUrlField->GetURL());
aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
bField = true;
}
}

View File

@ -362,11 +362,11 @@ void OutlineViewShell::GetCtrlState(SfxItemSet &rSet)
if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
{
const SvxFieldData* pField = pFieldItem->GetField();
if ( dynamic_cast< const SvxURLField *>( pField ) != nullptr )
if ( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
{
aHLinkItem.SetName(static_cast<const SvxURLField*>(pField)->GetRepresentation());
aHLinkItem.SetURL(static_cast<const SvxURLField*>(pField)->GetURL());
aHLinkItem.SetTargetFrame(static_cast<const SvxURLField*>(pField)->GetTargetFrame());
aHLinkItem.SetName(pUrlField->GetRepresentation());
aHLinkItem.SetURL(pUrlField->GetURL());
aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
}
}
}

View File

@ -1400,13 +1400,13 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
if ( rSet.GetItemState( SID_FILLFRAME, false, &pItem ) == SfxItemState::SET )
{
pValue[nActProp].Name = sFrame;
if ( dynamic_cast< const SfxUsrAnyItem *>( pItem ) != nullptr )
if ( auto pUsrAnyItem = dynamic_cast< const SfxUsrAnyItem *>( pItem ) )
{
OSL_FAIL( "TransformItems: transporting an XFrame via an SfxUsrAnyItem is not deprecated!" );
pValue[nActProp++].Value = static_cast< const SfxUsrAnyItem* >( pItem )->GetValue();
pValue[nActProp++].Value = pUsrAnyItem->GetValue();
}
else if ( dynamic_cast< const SfxUnoFrameItem *>( pItem ) != nullptr )
pValue[nActProp++].Value <<= static_cast< const SfxUnoFrameItem* >( pItem )->GetFrame();
else if ( auto pUnoFrameItem = dynamic_cast< const SfxUnoFrameItem *>( pItem ) )
pValue[nActProp++].Value <<= pUnoFrameItem->GetFrame();
else
OSL_FAIL( "TransformItems: invalid item type for SID_FILLFRAME!" );
}

View File

@ -1019,10 +1019,10 @@ void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell
SfxItemPool::IsWhich(nWhich) &&
pOldItem ) )
{
if ( dynamic_cast< const SfxBoolItem *>( pOldItem ) != nullptr )
if ( auto pOldBoolItem = dynamic_cast< const SfxBoolItem *>( pOldItem ) )
{
// we can toggle Bools
bool bOldValue = static_cast<const SfxBoolItem *>(pOldItem)->GetValue();
bool bOldValue = pOldBoolItem->GetValue();
SfxBoolItem *pNewItem = static_cast<SfxBoolItem*>(pOldItem->Clone());
pNewItem->SetValue( !bOldValue );
aReq.AppendItem( *pNewItem );

View File

@ -619,10 +619,10 @@ void SfxToolBoxControl::StateChanged
case SfxItemState::DEFAULT:
if ( pState )
{
if ( dynamic_cast< const SfxBoolItem* >(pState) != nullptr )
if ( auto pBoolItem = dynamic_cast< const SfxBoolItem* >(pState) )
{
// BoolItem for checking
if ( static_cast<const SfxBoolItem*>(pState)->GetValue() )
if ( pBoolItem->GetValue() )
eTri = TRISTATE_TRUE;
nItemBits |= ToolBoxItemBits::CHECKABLE;
}

View File

@ -39,6 +39,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
compilerplugins/clang/test/refcounting \
compilerplugins/clang/test/salbool \
compilerplugins/clang/test/salunicodeliteral \
compilerplugins/clang/test/simplifydynamiccast \
compilerplugins/clang/test/stringconstant \
compilerplugins/clang/test/unnecessarycatchthrow \
compilerplugins/clang/test/unnecessaryoverride \

View File

@ -377,7 +377,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
SfxItemSet aLocalSet(aSet);
drawing::FillStyle aLocalFillStyle(eFillStyle);
if ( dynamic_cast<const SdrPathObj*>( pNext) != nullptr )
if ( auto pPathObj = dynamic_cast<const SdrPathObj*>(pNext) )
{
const SfxItemSet& rSet = pNext->GetMergedItemSet();
bool bNeedToConvertToContour(false);
@ -453,7 +453,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
}
else
{
aPolyPoly = static_cast<const SdrPathObj*>(pNext)->GetPathPoly();
aPolyPoly = pPathObj->GetPathPoly();
}
}
else

View File

@ -415,9 +415,9 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom
basegfx::B2DPolyPolygon aPP;
const SdrObject* pNext = aIter.Next();
if ( dynamic_cast<const SdrPathObj*>( pNext) != nullptr )
if ( auto pPathObj = dynamic_cast<const SdrPathObj*>(pNext) )
{
aPP = static_cast<const SdrPathObj*>(pNext)->GetPathPoly();
aPP = pPathObj->GetPathPoly();
}
else
{

View File

@ -418,9 +418,9 @@ SdrModel* E3dView::GetMarkedObjModel() const
{
const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
if(dynamic_cast< const E3dScene* >( pSrcOb) != nullptr)
if(auto p3dscene = dynamic_cast< const E3dScene* >( pSrcOb))
{
pScene = const_cast<E3dScene*>(static_cast<const E3dScene*>(pSrcOb));
pScene = const_cast<E3dScene*>(p3dscene);
// delete all not intentionally cloned 3d objects
pScene->removeAllNonSelectedObjects();
@ -476,9 +476,9 @@ bool E3dView::Paste(
for(size_t nOb = 0; nOb < nObjCount; ++nOb)
{
const SdrObject* pSrcOb = pSrcPg->GetObj(nOb);
if(dynamic_cast< const E3dScene* >(pSrcOb) != nullptr)
if(auto p3dscene = dynamic_cast< const E3dScene* >(pSrcOb))
{
E3dScene* pSrcScene = const_cast<E3dScene*>(static_cast<const E3dScene*>(pSrcOb));
E3dScene* pSrcScene = const_cast<E3dScene*>(p3dscene);
ImpCloneAll3DObjectsToDestScene(pSrcScene, pDstScene, aDist);
}
}

View File

@ -299,24 +299,24 @@ void SvxPosSizeStatusBarControl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
SAL_WARN( "svx.stbcrtls","unknown slot id");
}
}
else if ( dynamic_cast<const SfxPointItem*>( pState) != nullptr )
else if ( auto pPointItem = dynamic_cast<const SfxPointItem*>( pState) )
{
// show position
pImpl->aPos = static_cast<const SfxPointItem*>(pState)->GetValue();
pImpl->aPos = pPointItem->GetValue();
pImpl->bPos = true;
pImpl->bTable = false;
}
else if ( dynamic_cast<const SvxSizeItem*>( pState) != nullptr )
else if ( auto pSizeItem = dynamic_cast<const SvxSizeItem*>( pState) )
{
// show size
pImpl->aSize = static_cast<const SvxSizeItem*>(pState)->GetSize();
pImpl->aSize = pSizeItem->GetSize();
pImpl->bSize = true;
pImpl->bTable = false;
}
else if ( dynamic_cast<const SfxStringItem*>( pState) != nullptr )
else if ( auto pStringItem = dynamic_cast<const SfxStringItem*>( pState) )
{
// show string (table cel or different)
pImpl->aStr = static_cast<const SfxStringItem*>(pState)->GetValue();
pImpl->aStr = pStringItem->GetValue();
pImpl->bTable = true;
pImpl->bPos = false;
pImpl->bSize = false;

View File

@ -71,9 +71,9 @@ void XmlSecStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState, cons
{
mpImpl->mnState = SignatureState::UNKNOWN;
}
else if( dynamic_cast< const SfxUInt16Item* >(pState) != nullptr )
else if( auto pUint16Item = dynamic_cast< const SfxUInt16Item* >(pState) )
{
mpImpl->mnState = static_cast<SignatureState>(static_cast<const SfxUInt16Item*>(pState)->GetValue());
mpImpl->mnState = static_cast<SignatureState>(pUint16Item->GetValue());
}
else
{

View File

@ -116,17 +116,16 @@ void SvxZoomStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState,
GetStatusBar().SetItemText( GetId(), "" );
nValueSet = SvxZoomEnableFlags::NONE;
}
else if ( dynamic_cast< const SfxUInt16Item* >(pState) != nullptr )
else if ( auto pItem = dynamic_cast< const SfxUInt16Item* >(pState) )
{
const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState);
nZoom = pItem->GetValue();
OUString aStr(unicode::formatPercent(nZoom, Application::GetSettings().GetUILanguageTag()));
GetStatusBar().SetItemText( GetId(), aStr );
if ( dynamic_cast<const SvxZoomItem*>( pState) != nullptr )
if ( auto pZoomItem = dynamic_cast<const SvxZoomItem*>(pState) )
{
nValueSet = static_cast<const SvxZoomItem*>(pState)->GetValueSet();
nValueSet = pZoomItem->GetValueSet();
}
else
{

View File

@ -642,11 +642,11 @@ bool SdrPageView::IsObjMarkable(SdrObject const * pObj) const
return false; // only visible are selectable
if (!pObj->IsInserted())
return false; // Obj deleted?
if (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr)
if (auto pObjGroup = dynamic_cast<const SdrObjGroup*>(pObj))
{
// If object is a Group object, visibility may depend on
// multiple layers. If one object is markable, Group is markable.
SdrObjList* pObjList = static_cast<SdrObjGroup const *>(pObj)->GetSubList();
SdrObjList* pObjList = pObjGroup->GetSubList();
if (pObjList && pObjList->GetObjCount())
{

View File

@ -59,9 +59,8 @@ bool SwAccessibleCell::IsSelected()
assert(GetMap());
const SwViewShell *pVSh = GetMap()->GetShell();
assert(pVSh);
if( dynamic_cast<const SwCursorShell*>( pVSh) != nullptr )
if( auto pCSh = dynamic_cast<const SwCursorShell*>(pVSh) )
{
const SwCursorShell *pCSh = static_cast< const SwCursorShell * >( pVSh );
if( pCSh->IsTableMode() )
{
const SwCellFrame *pCFrame =

View File

@ -50,9 +50,8 @@ bool SwAccessibleFrameBase::IsSelected()
assert(GetMap());
const SwViewShell *pVSh = GetMap()->GetShell();
assert(pVSh);
if( dynamic_cast<const SwFEShell*>( pVSh) != nullptr )
if( auto pFESh = dynamic_cast<const SwFEShell*>(pVSh) )
{
const SwFEShell *pFESh = static_cast< const SwFEShell * >( pVSh );
const SwFrame *pFlyFrame = pFESh->GetSelectedFlyFrame();
if( pFlyFrame == GetFrame() )
bRet = true;

View File

@ -2507,17 +2507,15 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrame *pFrame )
SwAccessibleChild aFrameOrObj( pFrame );
bool bShapeSelected = false;
const SwViewShell *pVSh = GetShell();
if( dynamic_cast<const SwCursorShell*>( pVSh) != nullptr )
if( auto pCSh = dynamic_cast<const SwCursorShell*>(pVSh) )
{
const SwCursorShell *pCSh = static_cast< const SwCursorShell * >( pVSh );
if( pCSh->IsTableMode() )
{
while( aFrameOrObj.GetSwFrame() && !aFrameOrObj.GetSwFrame()->IsCellFrame() )
aFrameOrObj = aFrameOrObj.GetSwFrame()->GetUpper();
}
else if( dynamic_cast<const SwFEShell*>( pVSh) != nullptr )
else if( auto pFESh = dynamic_cast<const SwFEShell*>(pVSh) )
{
const SwFEShell *pFESh = static_cast< const SwFEShell * >( pVSh );
const SwFrame *pFlyFrame = pFESh->GetSelectedFlyFrame();
if( pFlyFrame )
{

View File

@ -185,10 +185,8 @@ static void lcl_AdjustPositioningAttr( SwDrawFrameFormat* _pFrameFormat,
// to adjust the positioning attributes - see <SwDrawContact::Changed_(..)>.
{
const SwAnchoredObject* pAnchoredObj = pContact->GetAnchoredObj( &_rSdrObj );
if ( dynamic_cast<const SwAnchoredDrawObject*>( pAnchoredObj) != nullptr )
if ( auto pAnchoredDrawObj = dynamic_cast<const SwAnchoredDrawObject*>( pAnchoredObj) )
{
const SwAnchoredDrawObject* pAnchoredDrawObj =
static_cast<const SwAnchoredDrawObject*>(pAnchoredObj);
const SwRect aObjRect = _rSdrObj.GetSnapRect();
const_cast<SwAnchoredDrawObject*>(pAnchoredDrawObj)
->SetLastObjRect( aObjRect.SVRect() );

View File

@ -674,10 +674,10 @@ const SwPageDesc* SwNode::FindPageDesc( size_t* pPgDescNdIdx ) const
static_cast<const SwFormatPageDesc*>(pItem)->GetDefinedIn() )
{
const SwModify* pMod = static_cast<const SwFormatPageDesc*>(pItem)->GetDefinedIn();
if( dynamic_cast<const SwContentNode*>( pMod) != nullptr )
aInfo.CheckNode( *static_cast<const SwContentNode*>(pMod) );
else if( dynamic_cast<const SwFormat*>( pMod) != nullptr)
static_cast<const SwFormat*>(pMod)->GetInfo( aInfo );
if( auto pContentNode = dynamic_cast<const SwContentNode*>( pMod) )
aInfo.CheckNode( *pContentNode );
else if( auto pFormat = dynamic_cast<const SwFormat*>( pMod) )
pFormat->GetInfo( aInfo );
}
}

View File

@ -754,9 +754,9 @@ const SwAnchoredObject* SwDrawContact::GetAnchoredObj(const SdrObject* pSdrObj )
const SwAnchoredObject* pRetAnchoredObj = nullptr;
if (dynamic_cast<const SwDrawVirtObj*>(pSdrObj) != nullptr)
if (auto pVirtObj = dynamic_cast<const SwDrawVirtObj*>(pSdrObj))
{
pRetAnchoredObj = &(static_cast<const SwDrawVirtObj*>(pSdrObj)->GetAnchoredObj());
pRetAnchoredObj = &(pVirtObj->GetAnchoredObj());
}
else
{

View File

@ -821,9 +821,9 @@ void SwDrawView::CheckPossibilities()
{
const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
const SwFrame *pFrame = nullptr;
if ( dynamic_cast< const SwVirtFlyDrawObj *>( pObj ) != nullptr )
if ( auto pVirtFlyDrawObj = dynamic_cast< const SwVirtFlyDrawObj *>( pObj ) )
{
const SwFlyFrame *pFly = static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
const SwFlyFrame *pFly = pVirtFlyDrawObj->GetFlyFrame();
if ( pFly )
{
pFrame = pFly->GetAnchorFrame();

View File

@ -1426,10 +1426,10 @@ static bool lcl_IsControlGroup( const SdrObject *pObj )
bool bRet = false;
if(dynamic_cast<const SdrUnoObj*>( pObj) != nullptr)
bRet = true;
else if( dynamic_cast<const SdrObjGroup*>( pObj) != nullptr )
else if( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) )
{
bRet = true;
const SdrObjList *pLst = static_cast<const SdrObjGroup*>(pObj)->GetSubList();
const SdrObjList *pLst = pObjGroup->GetSubList();
for ( size_t i = 0; i < pLst->GetObjCount(); ++i )
if( !::lcl_IsControlGroup( pLst->GetObj( i ) ) )
return false;
@ -1493,8 +1493,8 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
if ( rMrkList.GetMarkCount() )
{
const SdrObject* pStartObj = rMrkList.GetMark(0)->GetMarkedSdrObj();
if( dynamic_cast<const SwVirtFlyDrawObj*>( pStartObj) != nullptr )
aPos = static_cast<const SwVirtFlyDrawObj*>(pStartObj)->GetFlyFrame()->getFrameArea().Pos();
if( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pStartObj) )
aPos = pVirtFlyDrawObj->GetFlyFrame()->getFrameArea().Pos();
else
aPos = pStartObj->GetSnapRect().TopLeft();
@ -2378,10 +2378,9 @@ bool SwFEShell::IsGroupAllowed() const
if ( bIsGroupAllowed )
{
const SwFrame* pAnchorFrame = nullptr;
if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
if ( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) )
{
const SwFlyFrame* pFlyFrame =
static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
const SwFlyFrame* pFlyFrame = pVirtFlyDrawObj->GetFlyFrame();
if ( pFlyFrame )
{
pAnchorFrame = pFlyFrame->GetAnchorFrame();

View File

@ -632,10 +632,10 @@ void SwFormatPageDesc::SwClientNotify( const SwModify& rModify, const SfxHint& r
const SwModify* pMod = GetDefinedIn();
if ( pMod )
{
if( dynamic_cast<const SwContentNode*>( pMod) != nullptr )
const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pMod))->SetAttr( aDfltDesc );
else if( dynamic_cast<const SwFormat*>( pMod) != nullptr)
const_cast<SwFormat*>(static_cast<const SwFormat*>(pMod))->SetFormatAttr( aDfltDesc );
if( auto pContentNode = dynamic_cast<const SwContentNode*>( pMod) )
const_cast<SwContentNode*>(pContentNode)->SetAttr( aDfltDesc );
else if( auto pFormat = dynamic_cast<const SwFormat*>( pMod) )
const_cast<SwFormat*>(pFormat)->SetFormatAttr( aDfltDesc );
else
{
OSL_FAIL( "What kind of SwModify is this?" );

View File

@ -309,9 +309,8 @@ sal_uInt8 SwFlowFrame::BwdMoveNecessary( const SwPageFrame *pPage, const SwRect
if( m_rThis.IsLayoutFrame() && //Fly Lower of This?
Is_Lower_Of( &m_rThis, pObj->GetDrawObj() ) )
continue;
if( dynamic_cast<const SwFlyFrame*>( pObj) != nullptr )
if( auto pFly = dynamic_cast<const SwFlyFrame*>(pObj) )
{
const SwFlyFrame *pFly = static_cast<const SwFlyFrame*>(pObj);
if ( pFly->IsAnLower( &m_rThis ) )//This Lower of Fly?
continue;
}

View File

@ -945,9 +945,9 @@ void SwPageFrame::PlaceFly( SwFlyFrame* pFly, SwFlyFrameFormat* pFormat )
bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove )
{
bool bRet = true;
if ( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) != nullptr )
if ( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>(pSdrObj) )
{
const SwFlyFrame* pFly = static_cast<const SwVirtFlyDrawObj*>(pSdrObj)->GetFlyFrame();
const SwFlyFrame* pFly = pVirtFlyDrawObj->GetFlyFrame();
const bool bFollowTextFlow = pFly->GetFormat()->GetFollowTextFlow().GetValue();
// #i28701#
const bool bConsiderWrapOnObjPos =

View File

@ -2823,9 +2823,9 @@ void Notify_Background( const SdrObject* pObj,
SwLayoutFrame* pArea;
SwFlyFrame *pFlyFrame = nullptr;
SwFrame* pAnchor;
if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
if( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) )
{
pFlyFrame = const_cast<SwVirtFlyDrawObj*>(static_cast<const SwVirtFlyDrawObj*>(pObj))->GetFlyFrame();
pFlyFrame = const_cast<SwVirtFlyDrawObj*>(pVirtFlyDrawObj)->GetFlyFrame();
pAnchor = pFlyFrame->AnchorFrame();
}
else

View File

@ -893,9 +893,8 @@ static const SwFrame *lcl_FindFirstInvaContent( const SwLayoutFrame *pLay, long
const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
for (SwAnchoredObject* pObj : rObjs)
{
if ( dynamic_cast< const SwFlyFrame *>( pObj ) != nullptr )
if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pObj ) )
{
const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pObj);
if ( pFly->IsFlyInContentFrame() )
{
if ( static_cast<const SwFlyInContentFrame*>(pFly)->IsInvalid() ||
@ -928,9 +927,8 @@ static const SwAnchoredObject* lcl_FindFirstInvaObj( const SwPageFrame* _pPage,
for (SwAnchoredObject* pObj : *_pPage->GetSortedObjs())
{
if ( dynamic_cast< const SwFlyFrame *>( pObj ) != nullptr )
if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pObj ) )
{
const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pObj);
if ( pFly->getFrameArea().Top() <= _nBottom )
{
if ( pFly->IsInvalid() || pFly->IsCompletePaint() )
@ -942,9 +940,9 @@ static const SwAnchoredObject* lcl_FindFirstInvaObj( const SwPageFrame* _pPage,
return pFly;
}
}
else if ( dynamic_cast< const SwAnchoredDrawObject *>( pObj ) != nullptr )
else if ( auto pDrawObject = dynamic_cast< const SwAnchoredDrawObject *>( pObj ) )
{
if ( !static_cast<const SwAnchoredDrawObject*>(pObj)->IsValidPos() )
if ( !pDrawObject->IsValidPos() )
{
return pObj;
}
@ -2018,9 +2016,8 @@ bool SwLayIdle::DoIdleJob( IdleJobType eJob, bool bVisAreaOnly )
i < pPage->GetSortedObjs()->size(); ++i )
{
const SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
if ( dynamic_cast< const SwFlyFrame *>( pObj ) != nullptr )
if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pObj ) )
{
const SwFlyFrame *pFly = static_cast<const SwFlyFrame*>(pObj);
const SwContentFrame *pC = pFly->ContainsContent();
while( pC )
{

View File

@ -7051,9 +7051,8 @@ void SwPageFrame::RefreshExtraData( const SwRect &rRect ) const
if ( bLineInFly && GetSortedObjs() )
for (SwAnchoredObject* pAnchoredObj : *GetSortedObjs())
{
if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) )
{
const SwFlyFrame *pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
if ( pFly->getFrameArea().Top() <= aRect.Bottom() &&
pFly->getFrameArea().Bottom() >= aRect.Top() )
pFly->RefreshExtraData( aRect );
@ -7085,9 +7084,8 @@ void SwLayoutFrame::RefreshExtraData( const SwRect &rRect ) const
if ( bLineInFly && pCnt->GetDrawObjs() )
for (SwAnchoredObject* pAnchoredObj : *pCnt->GetDrawObjs())
{
if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) )
{
const SwFlyFrame *pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
if ( pFly->IsFlyInContentFrame() &&
pFly->getFrameArea().Top() <= rRect.Bottom() &&
pFly->getFrameArea().Bottom() >= rRect.Top() )

View File

@ -5081,10 +5081,8 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
if ( bConsiderWrapOnObjPos || css::text::WrapTextMode_THROUGH != rSur.GetSurround() )
{
// frames, which the cell is a lower of, aren't relevant
if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) )
{
const SwFlyFrame *pFly =
static_cast<const SwFlyFrame*>(pAnchoredObj);
if ( pFly->IsAnLower( this ) )
continue;
}

View File

@ -220,12 +220,12 @@ const SwRect SwContourCache::ContourRect( const SwFormat* pFormat,
::basegfx::B2DPolyPolygon aPolyPolygon;
::basegfx::B2DPolyPolygon* pPolyPolygon = nullptr;
if ( dynamic_cast< const SwVirtFlyDrawObj *>( pObj ) != nullptr )
if ( auto pVirtFlyDrawObj = dynamic_cast< const SwVirtFlyDrawObj *>( pObj ) )
{
// GetContour() causes the graphic to be loaded, which may cause
// the graphic to change its size, call ClrObject()
tools::PolyPolygon aPoly;
if( !static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrame()->GetContour( aPoly ) )
if( !pVirtFlyDrawObj->GetFlyFrame()->GetContour( aPoly ) )
aPoly = tools::PolyPolygon( static_cast<const SwVirtFlyDrawObj*>(pObj)->
GetFlyFrame()->getFrameArea().SVRect() );
aPolyPolygon.clear();

View File

@ -1548,11 +1548,8 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
{
// see SwFEShell::SetFrameFormat( SwFrameFormat *pNewFormat, bool bKeepOrient, Point* pDocPos )
SwFlyFrame *pFly = nullptr;
{
const SwFrameFormat* pFormatXX = pFormat;
if (dynamic_cast<const SwFlyFrameFormat*>( pFormatXX) )
pFly = static_cast<const SwFlyFrameFormat*>(pFormatXX)->GetFrame();
}
if (auto pFlyFrameFormat = dynamic_cast<const SwFlyFrameFormat*>(pFormat) )
pFly = pFlyFrameFormat->GetFrame();
if ( pFly )
{
const ::SfxPoolItem* pItem;
@ -1933,8 +1930,8 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
{
// see SwFEShell::SetFlyFrameAttr( SfxItemSet& rSet )
SwFlyFrame *pFly = nullptr;
if (dynamic_cast<SwFlyFrameFormat*>( pFormat) )
pFly = static_cast<SwFlyFrameFormat*>(pFormat)->GetFrame();
if (auto pFrameFormat = dynamic_cast<SwFlyFrameFormat*>( pFormat) )
pFly = pFrameFormat->GetFrame();
if (pFly)
{
const ::SfxPoolItem* pItem;

View File

@ -974,9 +974,9 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, Con
const SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
while( pObjSh )
{
if( dynamic_cast<const SwDocShell*>(pObjSh) != nullptr )
if( auto pDocShell = dynamic_cast<const SwDocShell*>(pObjSh) )
{
SwDoc* pDoc = const_cast<SwDocShell*>(static_cast<const SwDocShell*>(pObjSh))->GetDoc();
SwDoc* pDoc = const_cast<SwDocShell*>(pDocShell)->GetDoc();
SwViewShell* pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
if ( pVSh )
pVSh->ChgNumberDigits();

View File

@ -1147,8 +1147,8 @@ void SwDocShell::LoadingFinished()
if(pVFrame)
{
SfxViewShell* pShell = pVFrame->GetViewShell();
if(dynamic_cast<SwSrcView*>( pShell) )
static_cast<SwSrcView*>(pShell)->Load(this);
if(auto pSrcView = dynamic_cast<SwSrcView*>( pShell) )
pSrcView->Load(this);
}
// #i38810#