summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-11-02 19:39:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-11-02 20:30:29 +0100
commit4d863fd8e38748607636d0033262baa62a3e9eb2 (patch)
treede15f5cd695199cfd56f1893bbb31cf06fc044d1 /svx/source
parent1a4151dcdf45a0fa946b6ddf5e1b5cca37d24619 (diff)
tdf#54857 elide more dynamic_cast
Change-Id: I42bef355eeef15e3733a5ee57b0569887cfa5e84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142183 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/accessibility/AccessibleShape.cxx2
-rw-r--r--svx/source/engine3d/view3d.cxx2
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrobj.cxx2
-rw-r--r--svx/source/sidebar/SelectionAnalyzer.cxx4
-rw-r--r--svx/source/sidebar/possize/PosSizePropertyPanel.cxx2
-rw-r--r--svx/source/svdraw/svddrgv.cxx2
-rw-r--r--svx/source/svdraw/svdedtv.cxx4
-rw-r--r--svx/source/svdraw/svdedtv1.cxx4
-rw-r--r--svx/source/svdraw/svdedtv2.cxx2
-rw-r--r--svx/source/svdraw/svdedxv.cxx4
-rw-r--r--svx/source/svdraw/svdetc.cxx2
-rw-r--r--svx/source/svdraw/svdfmtf.cxx4
-rw-r--r--svx/source/svdraw/svdmark.cxx4
-rw-r--r--svx/source/svdraw/svdmrkv.cxx6
-rw-r--r--svx/source/svdraw/svdobj.cxx11
-rw-r--r--svx/source/svdraw/svdotext.cxx4
-rw-r--r--svx/source/svdraw/svdotextdecomposition.cxx2
-rw-r--r--svx/source/svdraw/svdpdf.cxx4
-rw-r--r--svx/source/svdraw/svdundo.cxx6
-rw-r--r--svx/source/svdraw/svdview.cxx6
-rw-r--r--svx/source/unodraw/UnoGraphicExporter.cxx2
-rw-r--r--svx/source/unodraw/unoshape.cxx12
-rw-r--r--svx/source/unodraw/unoshtxt.cxx22
23 files changed, 61 insertions, 52 deletions
diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx
index 1c1f964f971a..e5d937094d17 100644
--- a/svx/source/accessibility/AccessibleShape.cxx
+++ b/svx/source/accessibility/AccessibleShape.cxx
@@ -152,7 +152,7 @@ void AccessibleShape::Init()
if( !pSdrObject )
return;
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( pSdrObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( pSdrObject );
const bool hasOutlinerParaObject = (pTextObj && pTextObj->CanCreateEditOutlinerParaObject()) || (pSdrObject->GetOutlinerParaObject() != nullptr);
// create AccessibleTextHelper to handle this shape's text
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index 86a1b15b64e4..18df6d5a6a98 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -632,7 +632,7 @@ void E3dView::ImpIsConvertTo3DPossible(SdrObject const * pObj, bool& rAny3D,
void E3dView::ImpChangeSomeAttributesFor3DConversion(SdrObject* pObj)
{
- if(dynamic_cast<const SdrTextObj*>( pObj) == nullptr)
+ if(DynCastSdrTextObj( pObj) == nullptr)
return;
const SfxItemSet& rSet = pObj->GetMergedItemSet();
diff --git a/svx/source/sdr/contact/viewcontactofsdrobj.cxx b/svx/source/sdr/contact/viewcontactofsdrobj.cxx
index 1483b57645f8..5f13af5cbe65 100644
--- a/svx/source/sdr/contact/viewcontactofsdrobj.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrobj.cxx
@@ -98,7 +98,7 @@ ViewContact* ViewContactOfSdrObj::GetParentContact() const
void ViewContactOfSdrObj::ActionChanged()
{
// look for own changes
- if (SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(&GetSdrObject()))
+ if (SdrTextObj* pTextObj = DynCastSdrTextObj(&GetSdrObject()))
{
// tdf#146860 no idea why, but calling this makes the text boxes render properly
pTextObj->GetTextAniKind();
diff --git a/svx/source/sidebar/SelectionAnalyzer.cxx b/svx/source/sidebar/SelectionAnalyzer.cxx
index 193b6b6b7d60..dc8073ec6c41 100644
--- a/svx/source/sidebar/SelectionAnalyzer.cxx
+++ b/svx/source/sidebar/SelectionAnalyzer.cxx
@@ -42,7 +42,7 @@ EnumContext::Context SelectionAnalyzer::GetContextForSelection_SC(const SdrMarkL
case 1:
{
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
- auto pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+ auto pTextObj = DynCastSdrTextObj(pObj);
if (pTextObj && pTextObj->IsInEditMode())
{
eContext = EnumContext::Context::DrawText;
@@ -125,7 +125,7 @@ EnumContext::Context SelectionAnalyzer::GetContextForSelection_SD(const SdrMarkL
case 1:
{
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
- auto pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+ auto pTextObj = DynCastSdrTextObj(pObj);
if (pTextObj && pTextObj->IsInEditMode())
{
if (pObj->GetObjIdentifier() == SdrObjKind::Table)
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index 100a7dcc8e16..5c04ce2706b6 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -188,7 +188,7 @@ namespace
if((pObj->GetObjInventor() == SdrInventor::Default) && (SdrObjKind::Text == eKind || SdrObjKind::TitleText == eKind || SdrObjKind::OutlineText == eKind))
{
- const SdrTextObj* pSdrTextObj = dynamic_cast< const SdrTextObj* >(pObj);
+ const SdrTextObj* pSdrTextObj = DynCastSdrTextObj(pObj);
if(pSdrTextObj && pSdrTextObj->HasText())
{
diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx
index 7c5d2c76f9e9..27b62dd17946 100644
--- a/svx/source/svdraw/svddrgv.cxx
+++ b/svx/source/svdraw/svddrgv.cxx
@@ -419,7 +419,7 @@ bool SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl
{
mpMarkedObj=GetMarkedObjectByIndex(0);
if ( mpMarkedObj &&
- dynamic_cast<const SdrTextObj*>( mpMarkedObj) != nullptr &&
+ DynCastSdrTextObj( mpMarkedObj) != nullptr &&
static_cast<SdrTextObj*>(mpMarkedObj)->IsTextFrame() )
bSingleTextObjMark = true;
}
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index 012b5153207f..58812d849403 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -1025,11 +1025,11 @@ void SdrEditView::ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrO
if(IsTextEdit())
{
#ifdef DBG_UTIL
- if(auto pTextObj = dynamic_cast< SdrTextObj* >(pOldObj))
+ if(auto pTextObj = DynCastSdrTextObj(pOldObj))
if (pTextObj->IsTextEditActive())
OSL_ENSURE(false, "OldObject is in TextEdit mode, this has to be ended before replacing it using SdrEndTextEdit (!)");
- if(auto pTextObj = dynamic_cast< SdrTextObj* >(pNewObj))
+ if(auto pTextObj = DynCastSdrTextObj(pNewObj))
if (pTextObj->IsTextEditActive())
OSL_ENSURE(false, "NewObject is in TextEdit mode, this has to be ended before replacing it using SdrEndTextEdit (!)");
#endif
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index 6d4fe7cfa181..2e4d218a3aee 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -1181,7 +1181,7 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll)
// multiple portions exist with multiple formats. If an OutlinerParaObject
// really exists and needs to be rescued is evaluated in the undo
// implementation itself.
- const bool bRescueText = dynamic_cast< SdrTextObj* >(pObj) != nullptr;
+ const bool bRescueText = DynCastSdrTextObj(pObj) != nullptr;
// add attribute undo
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj,false,bHasEEItems || bPossibleGeomChange || bRescueText));
@@ -1226,7 +1226,7 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll)
}
}
- if(auto pTextObj = dynamic_cast<SdrTextObj*>( pObj))
+ if(auto pTextObj = DynCastSdrTextObj( pObj))
{
if(!aCharWhichIds.empty())
{
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index caaeb93f1a00..38c07fbba1f0 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -1237,7 +1237,7 @@ void SdrEditView::CombineMarkedTextObjects()
while ( aIter.IsMore() )
{
SdrObject* pObj = aIter.Next();
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( pObj );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( pObj );
const OutlinerParaObject* pOPO = pTextObj ? pTextObj->GetOutlinerParaObject() : nullptr;
if ( pOPO && pTextObj->IsTextFrame()
&& pTextObj->GetObjIdentifier() == SdrObjKind::Text // not callouts (OBJ_CAPTION)
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 838876afa707..77b5f9cea719 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1232,7 +1232,7 @@ bool SdrObjEditView::SdrBeginTextEdit(SdrObject* pObj_, SdrPageView* pPV, vcl::W
// FIXME this encourages all sorts of bad habits and should be removed
SdrEndTextEdit();
- SdrTextObj* pObj = dynamic_cast<SdrTextObj*>(pObj_);
+ SdrTextObj* pObj = DynCastSdrTextObj(pObj_);
if (!pObj)
return false; // currently only possible with text objects
@@ -2963,7 +2963,7 @@ void SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet& rFormatSet, bool bNoChara
}
// now apply character and paragraph formatting to text, if the shape has any
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+ SdrTextObj* pTextObj = DynCastSdrTextObj(pObj);
if (pTextObj)
{
sal_Int32 nText = pTextObj->getTextCount();
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 203b566002b8..b642f8e69117 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -504,7 +504,7 @@ namespace
}
else
{
- SdrTextObj* pText = dynamic_cast< SdrTextObj * >(pObj);
+ SdrTextObj* pText = DynCastSdrTextObj(pObj);
// Exclude zero master page object (i.e. background shape) from color query
if(pText
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 587ca14a4637..eb1c9648b127 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -465,7 +465,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj1, bool bScale)
const SdrLayerID aOldLayer(pObj->GetLayer());
const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
const SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj.get());
- const SdrTextObj* pSdrTextObj = dynamic_cast< SdrTextObj* >(pObj.get());
+ const SdrTextObj* pSdrTextObj = DynCastSdrTextObj(pObj.get());
if(pSdrTextObj && pSdrTextObj->HasText())
{
@@ -611,7 +611,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj1, bool bScale)
if(!bVisible)
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj.get());
+ SdrTextObj* pTextObj = DynCastSdrTextObj(pObj.get());
if(pTextObj && pTextObj->HasText())
{
diff --git a/svx/source/svdraw/svdmark.cxx b/svx/source/svdraw/svdmark.cxx
index 58963a9f4ab8..9df4b8dc32f1 100644
--- a/svx/source/svdraw/svdmark.cxx
+++ b/svx/source/svdraw/svdmark.cxx
@@ -421,7 +421,7 @@ const OUString& SdrMarkList::GetMarkDescription() const
{
// if it's a single selection, cache only text frame
const SdrObject* pObj = GetMark(0)->GetMarkedSdrObj();
- const SdrTextObj* pTextObj = dynamic_cast<const SdrTextObj*>( pObj );
+ const SdrTextObj* pTextObj = DynCastSdrTextObj( pObj );
if(!pTextObj || !pTextObj->IsTextFrame())
{
@@ -511,7 +511,7 @@ const OUString& SdrMarkList::GetPointMarkDescription(bool bGlue) const
{
// if it's a single selection, cache only text frame
const SdrObject* pObj = GetMark(0)->GetMarkedSdrObj();
- const SdrTextObj* pTextObj = dynamic_cast<const SdrTextObj*>( pObj );
+ const SdrTextObj* pTextObj = DynCastSdrTextObj( pObj );
if(!pTextObj || !pTextObj->IsTextFrame())
{
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 90ebb72a7cc9..912135b0d1c0 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -1214,7 +1214,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
if(nullptr != mpMarkedObj)
{
bSingleTextObjMark =
- dynamic_cast<const SdrTextObj*>( mpMarkedObj) != nullptr &&
+ DynCastSdrTextObj( mpMarkedObj) != nullptr &&
static_cast<SdrTextObj*>(mpMarkedObj)->IsTextFrame();
// RotGrfFlyFrame: we may have limited rotation
@@ -1254,7 +1254,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
// Also formerly #122142#: Pretty much the same for SdrCaptionObj's in calc.
if(static_cast<SdrView*>(this)->IsTextEdit())
{
- const SdrTextObj* pSdrTextObj = dynamic_cast< const SdrTextObj* >(mpMarkedObj);
+ const SdrTextObj* pSdrTextObj = DynCastSdrTextObj(mpMarkedObj);
if (pSdrTextObj && pSdrTextObj->IsInEditMode())
{
@@ -2307,7 +2307,7 @@ SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nT
const bool bCheckIfMarkable(nOptions & SdrSearchOptions::TESTMARKABLE);
const bool bDeep(nOptions & SdrSearchOptions::DEEP);
const bool bOLE(dynamic_cast< const SdrOle2Obj* >(pObj) != nullptr);
- auto pTextObj = dynamic_cast<const SdrTextObj*>( pObj);
+ auto pTextObj = DynCastSdrTextObj( pObj);
const bool bTXT(pTextObj && pTextObj->IsTextFrame());
SdrObject* pRet=nullptr;
tools::Rectangle aRect(pObj->GetCurrentBoundRect());
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index becc4cd3cdbe..877744f4e273 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1107,7 +1107,7 @@ basegfx::B2DPolyPolygon SdrObject::TakeContour() const
if(pClone)
{
- const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(this);
+ const SdrTextObj* pTextObj = DynCastSdrTextObj(this);
if(pTextObj)
{
@@ -3209,6 +3209,15 @@ E3dObject* DynCastE3dObject(SdrObject* pObj)
return nullptr;
}
+SdrTextObj* DynCastSdrTextObj(SdrObject* pObj)
+{
+ // SdrTextObj has a lot of subclasses, with lots of SdrObjKind identifiers, so use a virtual method
+ // to be safer.
+ if( pObj && pObj->IsSdrTextObj() )
+ return static_cast<SdrTextObj*>(pObj);
+ return nullptr;
+}
+
rtl::Reference<SdrObject> SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier)
{
SdrObjCreatorParams aParams { nInventor, nObjIdentifier, rSdrModel };
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 53b32ddf28b2..8ca01ffd74b2 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1911,7 +1911,7 @@ static void ImpUpdateChainLinks(SdrTextObj *pTextObj, std::u16string_view aNextL
SdrPage *pPage(pTextObj->getSdrPageFromSdrObject());
assert(pPage);
- SdrTextObj *pNextTextObj = dynamic_cast< SdrTextObj * >
+ SdrTextObj *pNextTextObj = DynCastSdrTextObj
(ImpGetObjByName(pPage, aNextLinkName));
if (!pNextTextObj) {
SAL_INFO("svx.chaining", "[CHAINING] Can't find object as next link.");
@@ -2033,7 +2033,7 @@ bool SdrTextObj::GetPreventChainable() const
rtl::Reference<SdrObject> SdrTextObj::getFullDragClone() const
{
rtl::Reference<SdrObject> pClone = SdrAttrObj::getFullDragClone();
- SdrTextObj *pTextObjClone = dynamic_cast<SdrTextObj *>(pClone.get());
+ SdrTextObj *pTextObjClone = DynCastSdrTextObj(pClone.get());
if (pTextObjClone != nullptr) {
// Avoid transferring of text for chainable object during dragging
pTextObjClone->mbIsUnchainableClone = true;
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index 0c8928891231..90fddd223263 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -1498,7 +1498,7 @@ void SdrTextObj::impHandleChainingEventsDuringDecomposition(SdrOutliner &rOutlin
size_t nObjCount(getSdrPageFromSdrObject()->GetObjCount());
for (size_t i = 0; i < nObjCount; i++)
{
- SdrTextObj* pCurObj(dynamic_cast< SdrTextObj* >(getSdrPageFromSdrObject()->GetObj(i)));
+ SdrTextObj* pCurObj(DynCastSdrTextObj(getSdrPageFromSdrObject()->GetObj(i)));
if(pCurObj == this)
{
SAL_INFO("svx.chaining", "Working on TextBox " << i);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 16745d445e13..7509991ba346 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -416,7 +416,7 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj1, bool bScale)
const SdrLayerID aOldLayer(pObj->GetLayer());
const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
const SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(pObj.get());
- const SdrTextObj* pSdrTextObj = dynamic_cast<SdrTextObj*>(pObj.get());
+ const SdrTextObj* pSdrTextObj = DynCastSdrTextObj(pObj.get());
if (pSdrTextObj && pSdrTextObj->HasText())
{
@@ -561,7 +561,7 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj1, bool bScale)
if (!bVisible)
{
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj.get());
+ SdrTextObj* pTextObj = DynCastSdrTextObj(pObj.get());
if (pTextObj && pTextObj->HasText())
{
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index 0df375d266a6..20be7b878845 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -1023,7 +1023,7 @@ void SdrUndoObjSetText::AfterSetText()
void SdrUndoObjSetText::Undo()
{
// only works with SdrTextObj
- SdrTextObj* pTarget = dynamic_cast< SdrTextObj* >(mxObj.get());
+ SdrTextObj* pTarget = DynCastSdrTextObj(mxObj.get());
if(!pTarget)
{
@@ -1065,7 +1065,7 @@ void SdrUndoObjSetText::Undo()
void SdrUndoObjSetText::Redo()
{
// only works with SdrTextObj
- SdrTextObj* pTarget = dynamic_cast< SdrTextObj* >(mxObj.get());
+ SdrTextObj* pTarget = DynCastSdrTextObj(mxObj.get());
if(!pTarget)
{
@@ -1125,7 +1125,7 @@ void SdrUndoObjSetText::SdrRepeat(SdrView& rView)
for (size_t nm=0; nm<nCount; ++nm)
{
SdrObject* pObj2=rML.GetMark(nm)->GetMarkedSdrObj();
- SdrTextObj* pTextObj=dynamic_cast<SdrTextObj*>( pObj2 );
+ SdrTextObj* pTextObj=DynCastSdrTextObj( pObj2 );
if (pTextObj!=nullptr)
{
if( bUndo )
diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx
index 42399006bf47..e4e40a5ba2aa 100644
--- a/svx/source/svdraw/svdview.cxx
+++ b/svx/source/svdraw/svdview.cxx
@@ -438,7 +438,7 @@ SdrHitKind SdrView::PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) co
// check for URL field
if (eHit==SdrHitKind::UnmarkedObject)
{
- SdrTextObj* pTextObj=dynamic_cast<SdrTextObj*>( pHitObj );
+ SdrTextObj* pTextObj=DynCastSdrTextObj( pHitObj );
if (pTextObj!=nullptr && pTextObj->HasText())
{
// use the primitive-based HitTest which is more accurate anyways. It
@@ -518,7 +518,7 @@ SdrHitKind SdrView::PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) co
tools::Rectangle aBoundRect(pHitObj->GetCurrentBoundRect());
// Force to SnapRect when Fontwork
- if( auto pTextObj = dynamic_cast<const SdrTextObj*>(pHitObj) )
+ if( auto pTextObj = DynCastSdrTextObj(pHitObj) )
if( pTextObj->IsFontwork() )
aBoundRect = pHitObj->GetSnapRect();
@@ -1041,7 +1041,7 @@ PointerStyle SdrView::GetPreferredPointer(const Point& rMousePos, const OutputDe
case SdrHitKind::TextEdit :
case SdrHitKind::TextEditObj:
{
- SdrTextObj* pText = dynamic_cast< SdrTextObj* >(aVEvt.mpObj);
+ SdrTextObj* pText = DynCastSdrTextObj(aVEvt.mpObj);
if(pText && pText->HasText())
{
OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject();
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index b1ffa6449007..66af82d6baac 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -837,7 +837,7 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr
else if( rSettings.mbScrollText )
{
SdrObject* pObj = aShapes.front();
- auto pTextObj = dynamic_cast<SdrTextObj*>( pObj);
+ auto pTextObj = DynCastSdrTextObj( pObj);
if( pTextObj && pTextObj->HasText() )
{
tools::Rectangle aScrollRectangle;
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index a37e6ef4c65c..38d5ee335af5 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -175,7 +175,7 @@ protected:
/// Calculates what scaling factor will be used for autofit text scaling of this shape.
sal_Int16 GetTextFitToSizeScale(SdrObject* pObject)
{
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObject);
+ SdrTextObj* pTextObj = DynCastSdrTextObj(pObject);
if (!pTextObj)
{
return 0;
@@ -2436,7 +2436,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
case OWN_ATTR_TEXTCOLUMNS:
{
- if (auto pTextObj = dynamic_cast<SdrTextObj*>(pSdrObject.get()))
+ if (auto pTextObj = DynCastSdrTextObj(pSdrObject.get()))
{
css::uno::Reference<css::text::XTextColumns> xTextColumns;
if (rValue >>= xTextColumns)
@@ -2566,7 +2566,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
case OWN_ATTR_ISFONTWORK:
{
bool bIsFontwork = false;
- if (const SdrTextObj* pTextObj = dynamic_cast<const SdrTextObj*>(GetSdrObject()))
+ if (const SdrTextObj* pTextObj = DynCastSdrTextObj(GetSdrObject()))
bIsFontwork = pTextObj->IsFontwork();
rValue <<= bIsFontwork;
break;
@@ -2883,7 +2883,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
case OWN_ATTR_TEXTCOLUMNS:
{
- if (auto pTextObj = dynamic_cast<const SdrTextObj*>(GetSdrObject()))
+ if (auto pTextObj = DynCastSdrTextObj(GetSdrObject()))
{
if (pTextObj->HasTextColumnsNumber() || pTextObj->HasTextColumnsSpacing())
{
@@ -3888,7 +3888,7 @@ bool SvxShapeText::setPropertyValueImpl( const OUString& rName, const SfxItemPro
if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetSdrObject() );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( GetSdrObject() );
if( pTextObj )
{
css::text::WritingMode eMode;
@@ -3906,7 +3906,7 @@ bool SvxShapeText::getPropertyValueImpl( const OUString& rName, const SfxItemPro
{
if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetSdrObject() );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( GetSdrObject() );
if( pTextObj && pTextObj->IsVerticalWriting() )
rValue <<= css::text::WritingMode_TB_RL;
else
diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
index 9dc311f9c438..b1ca3ff0c65e 100644
--- a/svx/source/unodraw/unoshtxt.cxx
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -110,7 +110,7 @@ private:
{
if (!mbShapeIsEditMode)
return false;
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
return pTextObj && pTextObj->IsTextEditActive();
}
@@ -170,7 +170,7 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject* pObject, SdrText* pText
if( !mpText )
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
if( pTextObj )
mpText = pTextObj->getText( 0 );
}
@@ -201,7 +201,7 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText
{
if( !mpText )
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
if( pTextObj )
mpText = pTextObj->getText( 0 );
}
@@ -441,7 +441,7 @@ void SvxTextEditSourceImpl::SetupOutliner()
if( !(mpObject && mpOutliner) )
return;
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
if( pTextObj )
{
tools::Rectangle aPaintRect;
@@ -462,7 +462,7 @@ void SvxTextEditSourceImpl::UpdateOutliner()
if( !(mpObject && mpOutliner) )
return;
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
if( pTextObj )
{
tools::Rectangle aPaintRect;
@@ -486,7 +486,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
{
if( mpOutliner == nullptr )
{
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
OutlinerMode nOutlMode = OutlinerMode::TextObject;
if( pTextObj && pTextObj->IsTextFrame() && pTextObj->GetTextKind() == SdrObjKind::OutlineText )
nOutlMode = OutlinerMode::OutlineObject;
@@ -536,7 +536,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
mpTextForwarder->flushCache();
std::optional<OutlinerParaObject> pOutlinerParaObject;
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
if( pTextObj && pTextObj->getActiveText() == mpText )
pOutlinerParaObject = pTextObj->CreateEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
bool bOwnParaObj(false);
@@ -665,7 +665,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetTextForwarder()
{
assert(!mbForwarderIsEditMode); // because without a view there is no other option except !mbForwarderIsEditMode
bool bTextEditActive = false;
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(mpObject);
+ SdrTextObj* pTextObj = DynCastSdrTextObj(mpObject);
// similar to the GetBackgroundTextForwarder check, see if the text edit is active
if (pTextObj && pTextObj->getActiveText() == mpText && pTextObj->CanCreateEditOutlinerParaObject())
bTextEditActive = true; // text edit active
@@ -685,7 +685,7 @@ std::unique_ptr<SvxDrawOutlinerViewForwarder> SvxTextEditSourceImpl::CreateViewF
mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
mbNotifyEditOutlinerSet = true;
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
if( pTextObj )
{
tools::Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
@@ -736,7 +736,7 @@ SvxEditViewForwarder* SvxTextEditSourceImpl::GetEditViewForwarder( bool bCreate
if(mpView->SdrBeginTextEdit(mpObject))
{
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
if (pTextObj && pTextObj->IsTextEditActive())
{
// create new view forwarder
@@ -773,7 +773,7 @@ void SvxTextEditSourceImpl::UpdateData()
{
if( mpOutliner && mpObject && mpText )
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
+ SdrTextObj* pTextObj = DynCastSdrTextObj( mpObject );
if( pTextObj )
{
if( (mpOutliner->GetParagraphCount() == 1 && mpOutliner->GetEditEngine().GetTextLen( 0 ) == 0 )