[Libreoffice-commits] core.git: filter/source framework/source sc/source sd/source svx/source sw/source
Noel (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 8 06:40:46 UTC 2021
filter/source/msfilter/svdfppt.cxx | 4 -
framework/source/layoutmanager/toolbarlayoutmanager.cxx | 2
sc/source/ui/undo/areasave.cxx | 4 -
sd/source/core/drawdoc.cxx | 23 ++++-----
sd/source/core/sdpage.cxx | 6 +-
sd/source/ui/app/sdxfer.cxx | 2
sd/source/ui/func/fupoor.cxx | 8 +--
sd/source/ui/func/futext.cxx | 4 -
sd/source/ui/view/sdview2.cxx | 8 +--
svx/source/engine3d/view3d.cxx | 19 ++++---
svx/source/form/filtnav.cxx | 17 +++---
svx/source/gallery2/galmisc.cxx | 40 ++++++++--------
svx/source/toolbars/fontworkbar.cxx | 4 -
sw/source/core/frmedt/feshview.cxx | 4 -
sw/source/uibase/docvw/edtwin2.cxx | 2
15 files changed, 75 insertions(+), 72 deletions(-)
New commits:
commit c7b898df4d452746399621f6adc8e7da088f0f3a
Author: Noel <noel.grandin at collabora.co.uk>
AuthorDate: Sun Mar 7 18:41:56 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Mar 8 07:40:01 2021 +0100
clean up some more dynamic/static casting
using a hacked version of the staticdynamic plugin
and some judgement
Change-Id: I5e6668b19320025e419f84bebceade4239577729
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112137
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 462cefb3738b..c2c8b8b25070 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -778,12 +778,12 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
case PPT_PST_RecolorInfoAtom :
{
- if ( auto pSdrGrafObj = dynamic_cast<const SdrGrafObj* >(pRet) )
+ if ( auto pSdrGrafObj = dynamic_cast<SdrGrafObj* >(pRet) )
if ( pSdrGrafObj->HasGDIMetaFile() )
{
Graphic aGraphic( pSdrGrafObj->GetGraphic() );
RecolorGraphic( rSt, aClientDataHd.nRecLen, aGraphic );
- static_cast<SdrGrafObj*>(pRet)->SetGraphic( aGraphic );
+ pSdrGrafObj->SetGraphic( aGraphic );
}
}
break;
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index 36a91c9074f6..1f46f09e2274 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -965,7 +965,7 @@ void ToolbarLayoutManager::childWindowEvent( VclSimpleEvent const * pEvent )
{
if ( !implts_isToolbarCreationActive() )
{
- ToolBox* pToolBox = getToolboxPtr( static_cast<VclWindowEvent const *>(pEvent)->GetWindow() );
+ ToolBox* pToolBox = getToolboxPtr( pWindowEvent->GetWindow() );
if ( pToolBox )
{
OUString aToolbarName = retrieveToolbarNameFromHelpURL( pToolBox );
diff --git a/sc/source/ui/undo/areasave.cxx b/sc/source/ui/undo/areasave.cxx
index 3d50fba4f826..a46adae4017c 100644
--- a/sc/source/ui/undo/areasave.cxx
+++ b/sc/source/ui/undo/areasave.cxx
@@ -156,12 +156,12 @@ std::unique_ptr<ScAreaLinkSaveCollection> ScAreaLinkSaveCollection::CreateFromDo
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 (!pColl)
pColl.reset(new ScAreaLinkSaveCollection);
- pColl->push_back( ScAreaLinkSaver( *static_cast<ScAreaLink*>(pBase ) ) );
+ pColl->push_back( ScAreaLinkSaver( *pAreaLink ) );
}
}
}
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index c257fa909ae2..48769e0b88da 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -887,19 +887,20 @@ void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool
}
}
- if( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr && pObj->IsEmptyPresObj())
- {
- PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj);
- OUString aString( pPage->GetPresObjText(ePresObjKind) );
-
- if (!aString.isEmpty())
+ if( auto pTextObj = dynamic_cast<SdrTextObj *>( pObj ) )
+ if (pTextObj->IsEmptyPresObj())
{
- SdOutliner* pInternalOutl = GetInternalOutliner();
- pPage->SetObjText( static_cast<SdrTextObj*>(pObj), pInternalOutl, ePresObjKind, aString );
- pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), true );
- pInternalOutl->Clear();
+ PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj);
+ OUString aString( pPage->GetPresObjText(ePresObjKind) );
+
+ if (!aString.isEmpty())
+ {
+ SdOutliner* pInternalOutl = GetInternalOutliner();
+ pPage->SetObjText( pTextObj, pInternalOutl, ePresObjKind, aString );
+ pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), true );
+ pInternalOutl->Clear();
+ }
}
- }
}
}
}
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 5f8280dd8f51..2be8b854a23c 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -439,12 +439,12 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
InsertObject(pSdrObj);
- if ( dynamic_cast< const SdrTextObj *>( pSdrObj ) != nullptr )
+ if ( auto pTextObj = dynamic_cast<SdrTextObj *>( pSdrObj ) )
{
// Tell the object EARLY that it is vertical to have the
// defaults for AutoGrowWidth/Height reversed
if(bVertical)
- static_cast<SdrTextObj*>(pSdrObj)->SetVerticalWriting(true);
+ pTextObj->SetVerticalWriting(true);
SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
if( bVertical )
@@ -1543,7 +1543,7 @@ static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDe
if( pPersist )
{
uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
- GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
+ GetEmbeddedObject( pOle2->GetPersistName() );
// TODO CL->KA: Why is this not working anymore?
if( xObject.is() )
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 1b8698d0f6a1..6a5476f84886 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -158,7 +158,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
if( xObj.is() && xPersist.is() && xPersist->hasEntry() )
{
- mpOLEDataHelper.reset( new TransferableDataHelper( new SvEmbedTransferHelper( xObj, static_cast< SdrOle2Obj* >( pObj )->GetGraphic(), static_cast< SdrOle2Obj* >( pObj )->GetAspect() ) ) );
+ mpOLEDataHelper.reset( new TransferableDataHelper( new SvEmbedTransferHelper( xObj, pOleObj->GetGraphic(), pOleObj->GetAspect() ) ) );
// TODO/LATER: the standalone handling of the graphic should not be used any more in future
// The EmbedDataHelper should bring the graphic in future
diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx
index 7d1728be115e..817d0f8c6014 100644
--- a/sd/source/ui/func/fupoor.cxx
+++ b/sd/source/ui/func/fupoor.cxx
@@ -194,7 +194,7 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
{
SdrObject* pObj = aIter.Next();
- if(dynamic_cast< const SdrTextObj *>( pObj ))
+ if(auto pTextObj = dynamic_cast<SdrTextObj *>( pObj ))
{
SdrInventor nInv(pObj->GetObjInventor());
sal_uInt16 nKnd(pObj->GetObjIdentifier());
@@ -202,7 +202,7 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
if(SdrInventor::Default == nInv &&
(OBJ_TITLETEXT == nKnd || OBJ_OUTLINETEXT == nKnd || OBJ_TEXT == nKnd))
{
- pCandidate = static_cast<SdrTextObj*>(pObj);
+ pCandidate = pTextObj;
}
}
}
@@ -824,14 +824,14 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
{
SdrObject* pObj = aIter.Next();
- if(dynamic_cast< const SdrTextObj *>( pObj ))
+ if(auto pTextObj = dynamic_cast< SdrTextObj *>( pObj ))
{
SdrInventor nInv(pObj->GetObjInventor());
sal_uInt16 nKnd(pObj->GetObjIdentifier());
if(SdrInventor::Default == nInv && OBJ_TITLETEXT == nKnd)
{
- pCandidate = static_cast<SdrTextObj*>(pObj);
+ pCandidate = pTextObj;
}
}
}
diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx
index db565991a74c..be5a00c89c44 100644
--- a/sd/source/ui/func/futext.cxx
+++ b/sd/source/ui/func/futext.cxx
@@ -264,11 +264,11 @@ bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
{
const SvxFieldData* pField = pFieldItem->GetField();
- if (pField && dynamic_cast< const SvxURLField *>( pField ) != nullptr)
+ if (auto pURLField = dynamic_cast< const SvxURLField *>( pField ))
{
eHit = SdrHitKind::MarkedObject;
aVEvt.eEvent = SdrEventKind::ExecuteUrl;
- aVEvt.pURLField = static_cast<const SvxURLField*>(pField);
+ aVEvt.pURLField = pURLField;
}
}
}
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index f71246ea651e..5b7ba59e8e60 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -108,7 +108,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat
{
SdrObject* pObj = GetMarkedObjectByIndex(0);
- if( auto pOle2Obj = dynamic_cast< const SdrOle2Obj *>( pObj ) )
+ if( auto pOle2Obj = dynamic_cast<SdrOle2Obj *>( pObj ) )
if( pOle2Obj->GetObjRef() )
{
// If object has no persistence it must be copied as part of the document
@@ -116,7 +116,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat
{
uno::Reference< embed::XEmbedPersist > xPersObj( pOle2Obj->GetObjRef(), uno::UNO_QUERY );
if ( xPersObj.is() && xPersObj->hasEntry() )
- pSdrOleObj = static_cast<SdrOle2Obj*>(pObj);
+ pSdrOleObj = pOle2Obj;
}
catch( uno::Exception& )
{}
@@ -154,7 +154,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje
{
SdrObject* pObj = GetMarkedObjectByIndex( 0 );
- if( auto pOle2Obj = dynamic_cast< const SdrOle2Obj *>( pObj ) )
+ if( auto pOle2Obj = dynamic_cast<SdrOle2Obj *>( pObj ) )
if( pOle2Obj->GetObjRef() )
{
// If object has no persistence it must be copied as part of the document
@@ -162,7 +162,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje
{
uno::Reference< embed::XEmbedPersist > xPersObj( pOle2Obj->GetObjRef(), uno::UNO_QUERY );
if ( xPersObj.is() && xPersObj->hasEntry() )
- pSdrOleObj = static_cast<SdrOle2Obj*>(pObj);
+ pSdrOleObj = pOle2Obj;
}
catch( uno::Exception& )
{}
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index 4ab95d4b5ca2..decbf61b7b0c 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -324,17 +324,18 @@ std::unique_ptr<SdrModel> E3dView::CreateMarkedObjModel() const
{
const SdrObject* pObj = GetMarkedObjectByIndex(nObjs);
- if(!bSpecialHandling && dynamic_cast< const E3dCompoundObject*>(pObj))
- {
- // if the object is selected, but it's scene not,
- // we need special handling
- pScene = static_cast<const E3dCompoundObject*>(pObj)->getRootE3dSceneFromE3dObject();
-
- if(nullptr != pScene && !IsObjMarked(pScene))
+ if(!bSpecialHandling)
+ if(auto pCompoundObj = dynamic_cast< const E3dCompoundObject*>(pObj))
{
- bSpecialHandling = true;
+ // if the object is selected, but it's scene not,
+ // we need special handling
+ pScene = pCompoundObj->getRootE3dSceneFromE3dObject();
+
+ if(nullptr != pScene && !IsObjMarked(pScene))
+ {
+ bSpecialHandling = true;
+ }
}
- }
if(auto p3dObject = dynamic_cast< const E3dObject*>(pObj))
{
diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx
index cee9f5d3c71b..2e5ba4b0db38 100644
--- a/svx/source/form/filtnav.cxx
+++ b/svx/source/form/filtnav.cxx
@@ -696,7 +696,7 @@ void FmFilterModel::Remove(FmFilterData* pData)
DBG_ASSERT(i != rItems.end(), "FmFilterModel::Remove(): unknown Item");
// position within the parent
sal_Int32 nPos = i - rItems.begin();
- if (dynamic_cast<const FmFilterItems*>( pData) != nullptr)
+ if (auto pFilterItems = dynamic_cast<FmFilterItems*>( pData))
{
FmFormItem* pFormItem = static_cast<FmFormItem*>(pParent);
@@ -708,7 +708,7 @@ void FmFilterModel::Remove(FmFilterData* pData)
if ( bEmptyLastTerm )
{
// remove all children (by setting an empty predicate expression)
- ::std::vector< std::unique_ptr<FmFilterData> >& rChildren = static_cast<FmFilterItems*>(pData)->GetChildren();
+ ::std::vector< std::unique_ptr<FmFilterData> >& rChildren = pFilterItems->GetChildren();
while ( !rChildren.empty() )
{
auto removePos = rChildren.end() - 1;
@@ -1506,7 +1506,8 @@ IMPL_LINK(FmFilterNavigator, PopupMenuHdl, const CommandEvent&, rEvt, bool)
}
FmFilterData* pFilterEntry = reinterpret_cast<FmFilterData*>(m_xTreeView->get_id(*xClicked).toInt64());
- bool bEdit = dynamic_cast<FmFilterItem*>(pFilterEntry) != nullptr &&
+ auto pFilterItem = dynamic_cast<FmFilterItem*>(pFilterEntry);
+ bool bEdit = pFilterItem &&
m_xTreeView->is_selected(*xClicked) && m_xTreeView->count_selected_rows() == 1;
if (bNoDelete && !bEdit)
@@ -1531,18 +1532,16 @@ IMPL_LINK(FmFilterNavigator, PopupMenuHdl, const CommandEvent&, rEvt, bool)
{
OUString aErrorMsg;
OUString aText = "IS NULL";
- m_pModel->ValidateText(static_cast<FmFilterItem*>(pFilterEntry),
- aText, aErrorMsg);
- m_pModel->SetTextForItem(static_cast<FmFilterItem*>(pFilterEntry), aText);
+ m_pModel->ValidateText(pFilterItem, aText, aErrorMsg);
+ m_pModel->SetTextForItem(pFilterItem, aText);
}
else if (sIdent == "isnotnull")
{
OUString aErrorMsg;
OUString aText = "IS NOT NULL";
- m_pModel->ValidateText(static_cast<FmFilterItem*>(pFilterEntry),
- aText, aErrorMsg);
- m_pModel->SetTextForItem(static_cast<FmFilterItem*>(pFilterEntry), aText);
+ m_pModel->ValidateText(pFilterItem, aText, aErrorMsg);
+ m_pModel->SetTextForItem(pFilterItem, aText);
}
else if (sIdent == "delete")
{
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
index a3613424f041..eb90fd0895d4 100644
--- a/svx/source/gallery2/galmisc.cxx
+++ b/svx/source/gallery2/galmisc.cxx
@@ -118,30 +118,32 @@ bool GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel )
bool CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap )
{
+ if (! rModel.GetPageCount() )
+ return false;
+
+ const SdrPage* pPage = rModel.GetPage( 0 );
+ const SdrObject* pObj = pPage->GetObj( 0 );
+
+ if ( pPage->GetObjCount() != 1 )
+ return false;
+ auto pGrafObj = dynamic_cast<const SdrGrafObj*>( pObj);
+ if (!pGrafObj)
+ return false;
+
bool bRet = false;
+ const sal_uInt16 nCount = pObj->GetUserDataCount();
- if ( rModel.GetPageCount() )
+ // Exist in the user data an IMap information?
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
{
- const SdrPage* pPage = rModel.GetPage( 0 );
- const SdrObject* pObj = pPage->GetObj( 0 );
+ const SdrObjUserData* pUserData = pObj->GetUserData( i );
- if ( pPage->GetObjCount() == 1 && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr )
+ if ( ( pUserData->GetInventor() == SdrInventor::SgaImap ) && ( pUserData->GetId() == ID_IMAPINFO ) )
{
- const sal_uInt16 nCount = pObj->GetUserDataCount();
-
- // Exist in the user data an IMap information?
- for ( sal_uInt16 i = 0; i < nCount; i++ )
- {
- const SdrObjUserData* pUserData = pObj->GetUserData( i );
-
- if ( ( pUserData->GetInventor() == SdrInventor::SgaImap ) && ( pUserData->GetId() == ID_IMAPINFO ) )
- {
- rGraphic = static_cast<const SdrGrafObj*>( pObj )->GetGraphic();
- rImageMap = static_cast<const SgaIMapInfo*>( pUserData )->GetImageMap();
- bRet = true;
- break;
- }
- }
+ rGraphic = pGrafObj->GetGraphic();
+ rImageMap = static_cast<const SgaIMapInfo*>( pUserData )->GetImageMap();
+ bRet = true;
+ break;
}
}
diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx
index 36cd9652b2aa..3399b20d79ea 100644
--- a/svx/source/toolbars/fontworkbar.cxx
+++ b/svx/source/toolbars/fontworkbar.cxx
@@ -436,7 +436,7 @@ void FontworkBar::execute( SdrView& rSdrView, SfxRequest const & rReq, SfxBindin
for( size_t i = 0; i < nCount; ++i )
{
SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
- if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
+ if( auto pCustomShape = dynamic_cast<SdrObjCustomShape*>( pObj) )
{
const bool bUndo = rSdrView.IsUndoEnabled();
@@ -450,7 +450,7 @@ void FontworkBar::execute( SdrView& rSdrView, SfxRequest const & rReq, SfxBindin
GetGeometryForCustomShape( aGeometryItem, aCustomShape );
pObj->SetMergedItem( aGeometryItem );
- Reference< drawing::XShape > aXShape = GetXShapeForSdrObject( static_cast<SdrObjCustomShape*>(pObj) );
+ Reference< drawing::XShape > aXShape = GetXShapeForSdrObject( pCustomShape );
if ( aXShape.is() )
{
Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( aXShape, UNO_QUERY );
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index c4145ddde43d..af1a729eb446 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -2980,7 +2980,7 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
aAttr.Put(makeSdrCircEndAngleItem(0_deg100));
pObj->SetMergedItemSet(aAttr);
}
- else if(dynamic_cast<const SdrPathObj*>( pObj) != nullptr)
+ else if(auto pPathObj = dynamic_cast<SdrPathObj*>( pObj))
{
basegfx::B2DPolyPolygon aPoly;
@@ -3076,7 +3076,7 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
break;
}
- static_cast<SdrPathObj*>(pObj)->SetPathPoly(aPoly);
+ pPathObj->SetPathPoly(aPoly);
}
else if(auto pMeasureObj = dynamic_cast<SdrMeasureObj*>( pObj))
{
diff --git a/sw/source/uibase/docvw/edtwin2.cxx b/sw/source/uibase/docvw/edtwin2.cxx
index f3b975dfb546..645878cd855f 100644
--- a/sw/source/uibase/docvw/edtwin2.cxx
+++ b/sw/source/uibase/docvw/edtwin2.cxx
@@ -336,7 +336,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
}
else
{
- sText = static_cast<const SwGetRefField*>(pField)->GetSetRefName();
+ sText = pRefField->GetSetRefName();
}
}
break;
More information about the Libreoffice-commits
mailing list