include/svx/svdobj.hxx | 1 + sw/source/core/draw/dflyobj.cxx | 7 +++++++ sw/source/core/inc/dflyobj.hxx | 6 ++++++ sw/source/core/layout/frmtool.cxx | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-)
New commits: commit 409b8284f4f0a875406ed6c574089ea1cc10c053 Author: Noel Grandin <[email protected]> AuthorDate: Wed Feb 4 12:48:02 2026 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Feb 6 09:12:29 2026 +0100 tdf#170595 reduce dynamic_cast overhead when performing layout, we cast often, so use our DynCast* strategy for SdrObject's. Change-Id: I2b1b40cd2e70adac7651328398359358d826c4b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198721 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 471f96490053..80a9df9642cc 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -763,6 +763,7 @@ public: virtual bool IsSdrTextObj() const { return false; } virtual bool IsSdrOle2Obj() const { return false; } virtual bool IsTextPath() const { return false ; } + virtual bool IsSwVirtFlyDrawObj() const { return false ; } /// Whether the aspect ratio should be kept by default when resizing. virtual bool shouldKeepAspectRatio() const { return false; } diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 9b6ffb4b2939..79a6d0f18a0f 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -454,6 +454,13 @@ SwFrameFormat *SwVirtFlyDrawObj::GetFormat() return GetFlyFrame()->GetFormat(); } +SwVirtFlyDrawObj* DynCastSwVirtFlyDrawObj(SdrObject* pObj) +{ + if( pObj && pObj->IsSwVirtFlyDrawObj() ) + return static_cast<SwVirtFlyDrawObj*>(pObj); + return nullptr; +} + // --> OD #i102707# namespace { diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx index ae302806406c..7cc9ac472821 100644 --- a/sw/source/core/inc/dflyobj.hxx +++ b/sw/source/core/inc/dflyobj.hxx @@ -148,8 +148,14 @@ public: virtual bool IsTextBox() const override; void dumpAsXml(xmlTextWriterPtr pWriter) const override; + + virtual bool IsSwVirtFlyDrawObj() const override { return true; } }; +// this serves a similar function to the DynCast* functions in include/svx/svdobj.hxx +SwVirtFlyDrawObj* DynCastSwVirtFlyDrawObj(SdrObject*); +inline const SwVirtFlyDrawObj* DynCastSwVirtFlyDrawObj(const SdrObject* p) { return DynCastSwVirtFlyDrawObj(const_cast<SdrObject*>(p)); } + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 64b937cba693..eca2e8e1829c 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -2781,7 +2781,7 @@ const SdrObject *SwOrderIter::Next() for (SwAnchoredObject* i : *pObjs) { const SdrObject* pObj = i->GetDrawObj(); - if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr ) + if ( DynCastSwVirtFlyDrawObj( pObj) == nullptr ) continue; sal_uInt32 nTmp = pObj->GetOrdNumDirect(); if ( nTmp > nCurOrd && nTmp < nOrd )
