summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compilerplugins/clang/redundantcast.cxx37
-rw-r--r--compilerplugins/clang/test/redundantcast.cxx5
-rw-r--r--sc/source/ui/docshell/docsh.cxx2
-rw-r--r--sc/source/ui/docshell/docsh4.cxx4
-rw-r--r--sc/source/ui/unoobj/docuno.cxx2
-rw-r--r--sc/source/ui/view/cellsh1.cxx2
-rw-r--r--sc/source/ui/view/gridwin.cxx5
-rw-r--r--sd/qa/unit/misc-tests.cxx4
-rw-r--r--sd/source/core/sdpage.cxx1
-rw-r--r--sd/source/ui/animations/CustomAnimationPane.cxx2
-rw-r--r--sd/source/ui/presenter/PresenterPreviewCache.cxx2
-rw-r--r--sd/source/ui/view/drviewse.cxx2
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx2
-rw-r--r--svx/source/engine3d/scene3d.cxx1
-rw-r--r--svx/source/sdr/properties/attributeproperties.cxx8
-rw-r--r--svx/source/svdraw/svdedxv.cxx5
-rw-r--r--svx/source/svdraw/svditer.cxx4
-rw-r--r--svx/source/svdraw/svdmodel.cxx2
-rw-r--r--svx/source/table/svdotable.cxx4
-rw-r--r--sw/inc/postithelper.hxx2
-rw-r--r--sw/source/core/doc/docfmt.cxx6
-rw-r--r--sw/source/core/draw/dview.cxx2
-rw-r--r--sw/source/core/graphic/grfatr.cxx7
-rw-r--r--sw/source/core/layout/atrfrm.cxx2
-rw-r--r--sw/source/core/layout/paintfrm.cxx2
-rw-r--r--sw/source/core/unocore/unochart.cxx28
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx4
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx9
28 files changed, 91 insertions, 65 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index bdac3f3bcc56..afc1cb414681 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -800,16 +800,41 @@ bool RedundantCast::VisitCXXDynamicCastExpr(CXXDynamicCastExpr const * expr) {
if (ignoreLocation(expr)) {
return true;
}
- // so far this only deals with dynamic casting from T to T
auto const sub = compat::getSubExprAsWritten(expr);
auto const t1 = expr->getTypeAsWritten();
auto const t2 = sub->getType();
- if (t1.getCanonicalType() != t2.getCanonicalType())
+ QualType qt1 = t1.getCanonicalType();
+ QualType qt2 = t2.getCanonicalType();
+ if (qt1 == qt2)
+ {
+ report(
+ DiagnosticsEngine::Warning,
+ "redundant dynamic cast from %0 to %1", expr->getExprLoc())
+ << t2 << t1 << expr->getSourceRange();
return true;
- report(
- DiagnosticsEngine::Warning,
- "redundant dynamic cast from %0 to %1", expr->getExprLoc())
- << t2 << t1 << expr->getSourceRange();
+ }
+ if (qt1->isPointerType() && qt2->isPointerType())
+ {
+ // casting from 'T*' to 'const T*' is redundant, so compare without the qualifiers
+ qt1 = qt1->getPointeeType().getUnqualifiedType();
+ qt2 = qt2->getPointeeType().getUnqualifiedType();
+ if (qt1 == qt2)
+ {
+ report(
+ DiagnosticsEngine::Warning,
+ "redundant dynamic cast from %0 to %1", expr->getExprLoc())
+ << t2 << t1 << expr->getSourceRange();
+ return true;
+ }
+ if (qt1->getAsCXXRecordDecl() && qt2->getAsCXXRecordDecl()->isDerivedFrom(qt1->getAsCXXRecordDecl()))
+ {
+ report(
+ DiagnosticsEngine::Warning,
+ "redundant dynamic upcast from %0 to %1", expr->getExprLoc())
+ << t2 << t1 << expr->getSourceRange();
+ return true;
+ }
+ }
return true;
}
diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx
index 03ce47796d65..97f4e6f73777 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -340,11 +340,14 @@ void testDynamicCast() {
S1 * s1 = nullptr;
S2 * s2 = nullptr;
+ S3 * s3 = nullptr;
(void) dynamic_cast<S2 *>(s1);
- (void) dynamic_cast<S1 *>(s2);
+ (void) dynamic_cast<S1 *>(s2); // expected-error {{redundant dynamic upcast from 'S2 *' to 'S1 *' [loplugin:redundantcast]}}
(void) dynamic_cast<S2 *>(s2); // expected-error {{redundant dynamic cast from 'S2 *' to 'S2 *' [loplugin:redundantcast]}}
(void) dynamic_cast<S3 *>(s2);
+ (void) dynamic_cast<const S2 *>(s2); // expected-error {{redundant dynamic cast from 'S2 *' to 'const S2 *' [loplugin:redundantcast]}}
+ (void) dynamic_cast<S1 *>(s3); // expected-error {{redundant dynamic upcast from 'S3 *' to 'S1 *' [loplugin:redundantcast]}}
}
void overload(int);
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index feeecf885fe6..ec6b1a3b35e5 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -702,7 +702,7 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
if ( SwitchToShared( true, false ) )
{
ScViewData* pViewData = GetViewData();
- ScTabView* pTabView = ( pViewData ? dynamic_cast< ScTabView* >( pViewData->GetView() ) : nullptr );
+ ScTabView* pTabView = ( pViewData ? pViewData->GetView() : nullptr );
if ( pTabView )
{
pTabView->UpdateLayerLocks();
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 19ba7680a1fe..bc2edefd3115 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1004,7 +1004,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
InvalidateName();
GetUndoManager()->Clear();
- ScTabView* pTabView = dynamic_cast< ScTabView* >( pViewData->GetView() );
+ ScTabView* pTabView = pViewData->GetView();
if ( pTabView )
{
pTabView->UpdateLayerLocks();
@@ -1099,7 +1099,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
pBindings->ExecuteSynchron( SID_SAVEDOC );
}
- ScTabView* pTabView = dynamic_cast< ScTabView* >( pViewData->GetView() );
+ ScTabView* pTabView = pViewData->GetView();
if ( pTabView )
{
pTabView->UpdateLayerLocks();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 9eef212ee572..0f0807c325f1 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -571,7 +571,7 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
void ScModelObj::setPart( int nPart )
{
ScViewData* pViewData = ScDocShell::GetViewData();
- ScTabView* pTabView = dynamic_cast< ScTabView* >( pViewData->GetView() );
+ ScTabView* pTabView = pViewData->GetView();
if (pTabView)
pTabView->SelectTabPage(nPart + 1);
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 1613886bc6fb..8056fccb01f8 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2790,7 +2790,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
if(param3 && param4 && pInputHdl && pTabViewShell)
{
ScViewData& rData = pTabViewShell->GetViewData();
- ScTabView* pTabView = dynamic_cast< ScTabView* >( rData.GetView() );
+ ScTabView* pTabView = rData.GetView();
if (param1 && param2)
rData.SetRefStart(colStart, rowStart, table);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 37bc1ea211e6..34db171cd6d3 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2227,9 +2227,8 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
{
aPos = rMEvt.GetPosPixel();
mrViewData.GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
- auto pForTabView = dynamic_cast<const ScTabViewShell *>(pViewShell);
- OString aCursor = pForTabView->GetViewData().describeCellCursorAt(nPosX, nPosY);
- double fPPTX = pForTabView->GetViewData().GetPPTX();
+ OString aCursor = pViewShell->GetViewData().describeCellCursorAt(nPosX, nPosY);
+ double fPPTX = pViewShell->GetViewData().GetPPTX();
int mouseX = aPos.X() / fPPTX;
OString aMsg(aUrl.toUtf8() + " coordinates: " + aCursor + ", " + OString::number(mouseX));
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED, aMsg.getStr());
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index 078c9b19a19b..fca399a360a8 100644
--- a/sd/qa/unit/misc-tests.cxx
+++ b/sd/qa/unit/misc-tests.cxx
@@ -815,7 +815,7 @@ void SdMiscTest::testTdf130988()
//emulate command .uno:ConvertInto3DLathe
sd::ViewShell* pViewShell = xDocShRef->GetViewShell();
- E3dView* pView = dynamic_cast<E3dView*>(pViewShell->GetView());
+ E3dView* pView = pViewShell->GetView();
pView->MarkNextObj();
pView->ConvertMarkedObjTo3D(false, basegfx::B2DPoint(8000.0, -3000.0), basegfx::B2DPoint(3000.0, -8000.0));
E3dScene* pObj = dynamic_cast<E3dScene*>(pView->GetMarkedObjectByIndex(0));
@@ -839,7 +839,7 @@ void SdMiscTest::testTdf131033()
// It produces a rotation around a vertical axis, which is far away from the
// generating shape.
sd::ViewShell* pViewShell = xDocShRef->GetViewShell();
- E3dView* pView = dynamic_cast<E3dView*>(pViewShell->GetView());
+ E3dView* pView = pViewShell->GetView();
pView->MarkNextObj();
pView->ConvertMarkedObjTo3D(false, basegfx::B2DPoint(11000.0, -5000.0), basegfx::B2DPoint(11000.0, -9000.0));
E3dScene* pObj = dynamic_cast<E3dScene*>(pView->GetMarkedObjectByIndex(0));
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 800b69808639..5f8280dd8f51 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -2380,7 +2380,6 @@ void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eO
if ( !pObj )
return;
- DBG_ASSERT( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr, "SetObjText: No SdrTextObj!" );
::Outliner* pOutl = pOutliner;
if (!pOutliner)
diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx
index d9f86d628f6e..045522bc1ff4 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -160,7 +160,7 @@ CustomAnimationPane::CustomAnimationPane( Window* pParent, ViewShellBase& rBase,
void CustomAnimationPane::initialize()
{
mxLBAnimation->connect_changed(LINK(this, CustomAnimationPane, AnimationSelectHdl));
- mxCustomAnimationList->setController( dynamic_cast<ICustomAnimationListController*> ( this ) );
+ mxCustomAnimationList->setController( static_cast<ICustomAnimationListController*> ( this ) );
mxCustomAnimationList->set_size_request(mxCustomAnimationList->get_approximate_digit_width() * 15,
mxCustomAnimationList->get_height_rows(8));
diff --git a/sd/source/ui/presenter/PresenterPreviewCache.cxx b/sd/source/ui/presenter/PresenterPreviewCache.cxx
index c420cf5f9091..135fc45bf0f2 100644
--- a/sd/source/ui/presenter/PresenterPreviewCache.cxx
+++ b/sd/source/ui/presenter/PresenterPreviewCache.cxx
@@ -329,7 +329,7 @@ const SdrPage* PresenterPreviewCache::PresenterCacheContext::GetPage (
Reference<drawing::XDrawPage> xSlide (mxSlides->getByIndex(nSlideIndex), UNO_QUERY);
const SdPage* pPage = SdPage::getImplementation(xSlide);
- return dynamic_cast<const SdrPage*>(pPage);
+ return pPage;
}
void PresenterPreviewCache::PresenterCacheContext::CallListeners (
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index bd4c3775300d..d537dbdbb77e 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -267,7 +267,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
if(pDescriptorItem)
{
// get the form view
- FmFormView* pFormView = dynamic_cast<FmFormView*>( mpDrawView.get() );
+ FmFormView* pFormView = mpDrawView.get();
SdrPageView* pPageView = pFormView ? pFormView->GetSdrPageView() : nullptr;
if(pPageView)
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index e2e03e3219c3..2af18b6d7558 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -955,7 +955,7 @@ Reference<ui::XUIElement> SidebarController::CreateUIElement (
::comphelper::NamedValueCollection aCreationArguments;
aCreationArguments.put("Frame", makeAny(mxFrame));
aCreationArguments.put("ParentWindow", makeAny(rxWindow));
- SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow.get());
+ SidebarDockingWindow* pSfxDockingWindow = mpParentWindow.get();
if (pSfxDockingWindow != nullptr)
aCreationArguments.put("SfxBindings", makeAny(reinterpret_cast<sal_uInt64>(&pSfxDockingWindow->GetBindings())));
aCreationArguments.put("Theme", Theme::GetPropertySet());
diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx
index 0b6632a56a8a..788763536c81 100644
--- a/svx/source/engine3d/scene3d.cxx
+++ b/svx/source/engine3d/scene3d.cxx
@@ -679,7 +679,6 @@ bool E3dScene::IsBreakObjPossible()
while ( a3DIterator.IsMore() )
{
E3dObject* pObj = static_cast<E3dObject*>(a3DIterator.Next());
- DBG_ASSERT(dynamic_cast< const E3dObject*>(pObj), "only 3D objects are allowed in scenes!");
if(!pObj->IsBreakObjPossible())
return false;
}
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx
index 55dbf646210e..5ed41b9c4c99 100644
--- a/svx/source/sdr/properties/attributeproperties.cxx
+++ b/svx/source/sdr/properties/attributeproperties.cxx
@@ -99,7 +99,7 @@ namespace sdr::properties
void AttributeProperties::ImpRemoveStyleSheet()
{
// Check type since it is destroyed when the type is deleted
- if(GetStyleSheet() && dynamic_cast<const SfxStyleSheet *>(mpStyleSheet) != nullptr)
+ if(GetStyleSheet() && mpStyleSheet)
{
EndListening(*mpStyleSheet);
if (auto const pool = mpStyleSheet->GetPool()) { // TTTT
@@ -378,7 +378,7 @@ namespace sdr::properties
void AttributeProperties::ForceStyleToHardAttributes()
{
- if(!GetStyleSheet() || dynamic_cast<const SfxStyleSheet *>(mpStyleSheet) == nullptr)
+ if(!GetStyleSheet() || mpStyleSheet == nullptr)
return;
// guarantee SfxItemSet existence
@@ -457,10 +457,10 @@ namespace sdr::properties
// to register as listener to that new StyleSheet.
if(!rObj.IsInDestruction())
{
- if(dynamic_cast<const SfxStyleSheet *>(GetStyleSheet()) != nullptr)
+ if(SfxStyleSheet* pStyleSheet = GetStyleSheet())
{
pNewStSh = static_cast<SfxStyleSheet*>(rModel.GetStyleSheetPool()->Find(
- GetStyleSheet()->GetParent(), GetStyleSheet()->GetFamily()));
+ pStyleSheet->GetParent(), pStyleSheet->GetFamily()));
}
if(!pNewStSh)
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index a2fd9a692472..75190e09072c 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1528,8 +1528,7 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
pTEObj->EndTextEdit(*pTEOutliner);
- if ((pTEObj->GetRotateAngle() != 0_deg100)
- || (dynamic_cast<const SdrTextObj*>(pTEObj) != nullptr && pTEObj->IsFontwork()))
+ if ((pTEObj->GetRotateAngle() != 0_deg100) || (pTEObj && pTEObj->IsFontwork()))
{
pTEObj->ActionChanged();
}
@@ -1591,7 +1590,7 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
EndUndo(); // EndUndo after Remove, in case UndoStack is deleted immediately
// Switch on any TextAnimation again after TextEdit
- if (dynamic_cast<const SdrTextObj*>(pTEObj) != nullptr)
+ if (pTEObj)
{
pTEObj->SetTextAnimationAllowed(true);
}
diff --git a/svx/source/svdraw/svditer.cxx b/svx/source/svdraw/svditer.cxx
index 629438ac9842..8a7f5637517a 100644
--- a/svx/source/svdraw/svditer.cxx
+++ b/svx/source/svdraw/svditer.cxx
@@ -72,8 +72,8 @@ SdrObjListIter::SdrObjListIter(const SdrPage* pSdrPage, SdrIterMode eMode, bool
mbReverse(bReverse),
mbUseZOrder(true)
{
- if (const SdrObjList* pList = dynamic_cast<const SdrObjList*>(pSdrPage))
- ImpProcessObjectList(*pList, eMode);
+ if (pSdrPage)
+ ImpProcessObjectList(*pSdrPage, eMode);
Reset();
}
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 1e95644654aa..f6f2f8797d72 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -249,7 +249,7 @@ SdrModel::~SdrModel()
// the DrawingEngine may need it in its destructor
if( mxStyleSheetPool.is() )
{
- Reference< XComponent > xComponent( dynamic_cast< cppu::OWeakObject* >( mxStyleSheetPool.get() ), UNO_QUERY );
+ Reference< XComponent > xComponent( static_cast< cppu::OWeakObject* >( mxStyleSheetPool.get() ), UNO_QUERY );
if( xComponent.is() ) try
{
xComponent->dispose();
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 53e6133ac6de..23b3ab802859 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1309,7 +1309,7 @@ const Reference< XIndexAccess >& SdrTableObj::getTableStyle() const
/** returns the currently active text. */
SdrText* SdrTableObj::getActiveText() const
{
- return dynamic_cast< SdrText* >( getActiveCell().get() );
+ return getActiveCell().get();
}
@@ -1324,7 +1324,7 @@ SdrText* SdrTableObj::getText( sal_Int32 nIndex ) const
CellPos aPos( nIndex % nColCount, nIndex / nColCount );
CellRef xCell( mpImpl->getCell( aPos ) );
- return dynamic_cast< SdrText* >( xCell.get() );
+ return xCell.get();
}
}
return nullptr;
diff --git a/sw/inc/postithelper.hxx b/sw/inc/postithelper.hxx
index 356f42e114db..5b4f3319ca05 100644
--- a/sw/inc/postithelper.hxx
+++ b/sw/inc/postithelper.hxx
@@ -138,7 +138,7 @@ public:
}
virtual const SfxBroadcaster* GetBroadcaster() const override
{
- return dynamic_cast<const SfxBroadcaster *> (&mrFormatField);
+ return &mrFormatField;
}
virtual VclPtr<sw::annotation::SwAnnotationWin> GetSidebarWindow(
SwEditWin& rEditWin,
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index e3ecd4616fcb..7de2b60941d5 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -837,7 +837,7 @@ SwFormat *SwDoc::MakeFrameFormat_(const OUString &rFormatName,
{
SwFrameFormat *pFrameFormat = dynamic_cast<SwFrameFormat*>(pDerivedFrom);
pFrameFormat = MakeFrameFormat( rFormatName, pFrameFormat, bBroadcast, bAuto );
- return dynamic_cast<SwFormat*>(pFrameFormat);
+ return pFrameFormat;
}
SwCharFormat *SwDoc::MakeCharFormat( const OUString &rFormatName,
@@ -870,7 +870,7 @@ SwFormat *SwDoc::MakeCharFormat_(const OUString &rFormatName,
{
SwCharFormat *pCharFormat = dynamic_cast<SwCharFormat*>(pDerivedFrom);
pCharFormat = MakeCharFormat( rFormatName, pCharFormat, bBroadcast );
- return dynamic_cast<SwFormat*>(pCharFormat);
+ return pCharFormat;
}
/// Create the FormatCollections
@@ -904,7 +904,7 @@ SwFormat *SwDoc::MakeTextFormatColl_(const OUString &rFormatName,
{
SwTextFormatColl *pTextFormatColl = dynamic_cast<SwTextFormatColl*>(pDerivedFrom);
pTextFormatColl = MakeTextFormatColl( rFormatName, pTextFormatColl, bBroadcast );
- return dynamic_cast<SwFormat*>(pTextFormatColl);
+ return pTextFormatColl;
}
//FEATURE::CONDCOLL
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index 1d4a4d448120..4512543cadfb 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -987,7 +987,7 @@ SdrUndoManager* SwDrawView::getSdrUndoManagerForEnhancedTextEdit() const
{
SwDoc* pDoc = Imp().GetShell()->GetDoc();
- return pDoc ? dynamic_cast< SdrUndoManager* >(&(pDoc->GetUndoManager())) : nullptr;
+ return pDoc ? &(pDoc->GetUndoManager()) : nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/graphic/grfatr.cxx b/sw/source/core/graphic/grfatr.cxx
index b86ad78553c3..703a06d69d3d 100644
--- a/sw/source/core/graphic/grfatr.cxx
+++ b/sw/source/core/graphic/grfatr.cxx
@@ -23,6 +23,7 @@
#include <grfatr.hxx>
#include <swunohelper.hxx>
#include <osl/diagnose.h>
+#include <sal/log.hxx>
#include <unomid.h>
@@ -274,7 +275,8 @@ SwTransparencyGrf* SwTransparencyGrf::Clone( SfxItemPool * ) const
bool SwTransparencyGrf::QueryValue( uno::Any& rVal,
sal_uInt8 ) const
{
- OSL_ENSURE(dynamic_cast<const SfxByteItem*>( this ) != nullptr,"Put/QueryValue should be removed!");
+ //OSL_ENSURE(dynamic_cast<const SfxByteItem*>( this ) != nullptr,"Put/QueryValue should be removed!");
+ SAL_WARN("sw", "Put/QueryValue should be removed!");
sal_Int16 nRet = GetValue();
OSL_ENSURE( 0 <= nRet && nRet <= 100, "value out of range" );
rVal <<= nRet;
@@ -285,7 +287,8 @@ bool SwTransparencyGrf::PutValue( const uno::Any& rVal,
sal_uInt8 )
{
//temporary conversion until this is a SfxInt16Item!
- OSL_ENSURE(dynamic_cast<const SfxByteItem*>( this ) != nullptr,"Put/QueryValue should be removed!");
+ //OSL_ENSURE(dynamic_cast<const SfxByteItem*>( this ) != nullptr,"Put/QueryValue should be removed!");
+ SAL_WARN("sw", "Put/QueryValue should be removed!");
sal_Int16 nVal = 0;
if(!(rVal >>= nVal) || nVal < -100 || nVal > 100)
return false;
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 0ec7d5cd6362..cab6e41b341f 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3078,7 +3078,7 @@ SwAnchoredObject* SwFlyFrameFormat::GetAnchoredObj() const
SwFlyFrame* pFlyFrame( GetFrame() );
if ( pFlyFrame )
{
- return dynamic_cast<SwAnchoredObject*>(pFlyFrame);
+ return pFlyFrame;
}
else
{
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 4167950415e1..9779a81a736e 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3970,7 +3970,7 @@ void SwFlyFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect const&
if ( !bPaintCompleteBack &&
( bIsGraphicTransparent|| bContour ) )
{
- const SwFrameFormat* pSwFrameFormat = dynamic_cast< const SwFrameFormat* >(GetFormat());
+ const SwFlyFrameFormat* pSwFrameFormat = GetFormat();
if (pSwFrameFormat && pSwFrameFormat->supportsFullDrawingLayerFillAttributeSet())
{
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 927235b7e239..143f4e9eec61 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1377,7 +1377,7 @@ void SAL_CALL SwChartDataProvider::dispose( )
m_aDataSequences.clear();
// require listeners to release references to this object
- lang::EventObject aEvtObj( dynamic_cast< chart2::data::XDataProvider * >(this) );
+ lang::EventObject aEvtObj( static_cast< chart2::data::XDataProvider * >(this) );
m_aEventListeners.disposeAndClear( aEvtObj );
}
@@ -1792,9 +1792,9 @@ SwChartDataSequence::SwChartDataSequence(
const SwTable* pTable = SwTable::FindTable( &rTableFormat );
if (pTable)
{
- uno::Reference< chart2::data::XDataSequence > xRef( dynamic_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY );
+ uno::Reference< chart2::data::XDataSequence > xRef( static_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY );
m_xDataProvider->AddDataSequence( *pTable, xRef );
- m_xDataProvider->addEventListener( dynamic_cast< lang::XEventListener * >(this) );
+ m_xDataProvider->addEventListener( static_cast< lang::XEventListener * >(this) );
}
else {
OSL_FAIL( "table missing" );
@@ -1841,9 +1841,9 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) :
const SwTable* pTable = SwTable::FindTable( GetFrameFormat() );
if (pTable)
{
- uno::Reference< chart2::data::XDataSequence > xRef( dynamic_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY );
+ uno::Reference< chart2::data::XDataSequence > xRef( static_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY );
m_xDataProvider->AddDataSequence( *pTable, xRef );
- m_xDataProvider->addEventListener( dynamic_cast< lang::XEventListener * >(this) );
+ m_xDataProvider->addEventListener( static_cast< lang::XEventListener * >(this) );
}
else {
OSL_FAIL( "table missing" );
@@ -2198,7 +2198,7 @@ void SAL_CALL SwChartDataSequence::setModified(
throw lang::DisposedException();
if (bModified)
- LaunchModifiedEvent( m_aModifyListeners, dynamic_cast< XModifyBroadcaster * >(this) );
+ LaunchModifiedEvent( m_aModifyListeners, static_cast< XModifyBroadcaster * >(this) );
}
void SAL_CALL SwChartDataSequence::addModifyListener(
@@ -2245,7 +2245,7 @@ void SAL_CALL SwChartDataSequence::dispose( )
const SwTable* pTable = SwTable::FindTable( GetFrameFormat() );
if (pTable)
{
- uno::Reference< chart2::data::XDataSequence > xRef( dynamic_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY );
+ uno::Reference< chart2::data::XDataSequence > xRef( static_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY );
m_xDataProvider->RemoveDataSequence( *pTable, xRef );
}
else {
@@ -2277,7 +2277,7 @@ void SAL_CALL SwChartDataSequence::dispose( )
}
// require listeners to release references to this object
- lang::EventObject aEvtObj( dynamic_cast< chart2::data::XDataSequence * >(this) );
+ lang::EventObject aEvtObj( static_cast< chart2::data::XDataSequence * >(this) );
m_aModifyListeners.disposeAndClear( aEvtObj );
m_aEvtListeners.disposeAndClear( aEvtObj );
}
@@ -2538,8 +2538,8 @@ void SwChartLabeledDataSequence::SetDataSequence(
uno::Reference< chart2::data::XDataSequence >& rxDest,
const uno::Reference< chart2::data::XDataSequence >& rxSource)
{
- uno::Reference< util::XModifyListener > xML( dynamic_cast< util::XModifyListener* >(this), uno::UNO_QUERY );
- uno::Reference< lang::XEventListener > xEL( dynamic_cast< lang::XEventListener* >(this), uno::UNO_QUERY );
+ uno::Reference< util::XModifyListener > xML( static_cast< util::XModifyListener* >(this), uno::UNO_QUERY );
+ uno::Reference< lang::XEventListener > xEL( static_cast< lang::XEventListener* >(this), uno::UNO_QUERY );
// stop listening to old data-sequence
uno::Reference< util::XModifyBroadcaster > xMB( rxDest, uno::UNO_QUERY );
@@ -2571,7 +2571,7 @@ void SAL_CALL SwChartLabeledDataSequence::setValues(
{
SetDataSequence( m_xData, rxSequence );
// inform listeners of changes
- LaunchModifiedEvent( m_aModifyListeners, dynamic_cast< XModifyBroadcaster * >(this) );
+ LaunchModifiedEvent( m_aModifyListeners, static_cast< XModifyBroadcaster * >(this) );
}
}
@@ -2594,7 +2594,7 @@ void SAL_CALL SwChartLabeledDataSequence::setLabel(
{
SetDataSequence( m_xLabels, rxSequence );
// inform listeners of changes
- LaunchModifiedEvent( m_aModifyListeners, dynamic_cast< XModifyBroadcaster * >(this) );
+ LaunchModifiedEvent( m_aModifyListeners, static_cast< XModifyBroadcaster * >(this) );
}
}
@@ -2658,7 +2658,7 @@ void SAL_CALL SwChartLabeledDataSequence::modified(
{
if (rEvent.Source == m_xData || rEvent.Source == m_xLabels)
{
- LaunchModifiedEvent( m_aModifyListeners, dynamic_cast< XModifyBroadcaster * >(this) );
+ LaunchModifiedEvent( m_aModifyListeners, static_cast< XModifyBroadcaster * >(this) );
}
}
@@ -2692,7 +2692,7 @@ void SAL_CALL SwChartLabeledDataSequence::dispose( )
m_bDisposed = true;
// require listeners to release references to this object
- lang::EventObject aEvtObj( dynamic_cast< chart2::data::XLabeledDataSequence * >(this) );
+ lang::EventObject aEvtObj( static_cast< chart2::data::XLabeledDataSequence * >(this) );
m_aModifyListeners.disposeAndClear( aEvtObj );
m_aEventListeners.disposeAndClear( aEvtObj );
}
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 2575fe176f1c..daa679684cb3 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -1690,7 +1690,7 @@ css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
if (rServiceName == "com.sun.star.chart2.data.DataProvider")
{
return Reference<XInterface>(
- dynamic_cast<chart2::data::XDataProvider *>(
+ static_cast<chart2::data::XDataProvider *>(
m_pDocShell->getIDocumentChartDataProviderAccess().
GetChartDataProvider()));
}
@@ -3764,7 +3764,7 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
{
std::shared_ptr<SfxItemSet> pStyle = rStyles.back();
rStyles.pop_back();
- const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
+ const SfxItemSet *pSet = pStyle.get();
LanguageType nLang = LANGUAGE_DONTKNOW;
if (bLatin)
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index bfa345c7f3bc..7859c84018c2 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -178,15 +178,14 @@ uno::Reference< frame::XModel >
getCurrentDoc( const OUString& sKey )
{
uno::Reference< frame::XModel > xModel;
- SbxObject* pBasic = dynamic_cast< SbxObject* > ( SfxApplication::GetBasic() );
- SbxObject* basicChosen = pBasic ;
- if ( basicChosen == nullptr)
+ StarBASIC* pBasic = SfxApplication::GetBasic();
+ if (pBasic == nullptr)
{
SAL_INFO("vbahelper", "getModelFromBasic() StarBASIC* is NULL" );
return xModel;
}
- SbxObject* p = pBasic;
- SbxObject* pParent = p->GetParent();
+ SbxObject* basicChosen = pBasic;
+ SbxObject* pParent = pBasic->GetParent();
SbxObject* pParentParent = pParent ? pParent->GetParent() : nullptr;
if( pParentParent )