include/svx/svdobj.hxx | 3 + svx/source/svdraw/svdobj.cxx | 5 ++ sw/inc/textboxhelper.hxx | 2 - sw/source/core/doc/textboxhelper.cxx | 21 ++++-------- sw/source/core/draw/dflyobj.cxx | 6 +++ sw/source/core/inc/dflyobj.hxx | 2 + sw/source/core/objectpositioning/anchoredobjectposition.cxx | 2 - 7 files changed, 25 insertions(+), 16 deletions(-)
New commits: commit e2b76eb07f03fdd6552cdbd8627fa88109f9c4d6 Author: Tor Lillqvist <t...@collabora.com> Date: Mon Dec 18 17:49:59 2017 +0200 Get rid of a dynamic_cast Add a virtual member function instead. This improves performance. The time to load a specific pathological customer document dropped from 1min 16s to 1min 8s on my machine. Not hugely, but clearly. Change-Id: I1e59d601e9d0e14b6a756c6e0ad29ce2a1fce66d Reviewed-on: https://gerrit.libreoffice.org/46735 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 3e75235abc9d..304f403cdfd4 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -948,6 +948,9 @@ public: virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const; + /// Is this a textbox of a drawinglayer shape? + virtual bool IsTextBox() const; + protected: /// Sets a new UNO shape /// diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index daaf8f0c37e6..09e0a3486fa7 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -3108,6 +3108,11 @@ bool SdrObject::HasText() const return false; } +bool SdrObject::IsTextBox() const +{ + return false; +} + SdrObjFactory::SdrObjFactory(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pNewPage, SdrModel* pNewModel) { nInventor=nInvent; diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index 32fc2167c72a..a9a35f35aa35 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -86,8 +86,6 @@ public: * Valid types are RES_DRAWFRMFMT and RES_FLYFRMFMT. */ static bool isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType); - /// Is pObject a textbox of a drawinglayer shape? - static bool isTextBox(const SdrObject* pObject); /// Count number of shapes in the document, excluding TextBoxes. static sal_Int32 getCount(const SwDoc* pDoc); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 23033eaeea38..a642de0c1299 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -148,20 +148,13 @@ bool SwTextBoxHelper::isTextBox(const SwFrameFormat* pShape, sal_uInt16 nType) return true; } -bool SwTextBoxHelper::isTextBox(const SdrObject* pObject) -{ - const SwVirtFlyDrawObj* pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>(pObject); - if (!pVirtFlyDrawObj) - return false; - return isTextBox(pVirtFlyDrawObj->GetFormat(), RES_FLYFRMFMT); -} - sal_Int32 SwTextBoxHelper::getCount(SdrPage* pPage) { sal_Int32 nRet = 0; for (std::size_t i = 0; i < pPage->GetObjCount(); ++i) { - if (isTextBox(pPage->GetObj(i))) + SdrObject* p = pPage->GetObj(i); + if (p && p->IsTextBox()) continue; ++nRet; } @@ -189,11 +182,12 @@ uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex) throw(lan sal_Int32 nCount = 0; // Current logical index. for (std::size_t i = 0; i < pPage->GetObjCount(); ++i) { - if (isTextBox(pPage->GetObj(i))) + SdrObject* p = pPage->GetObj(i); + if (p && p->IsTextBox()) continue; if (nCount == nIndex) { - pRet = pPage->GetObj(i); + pRet = p; break; } ++nCount; @@ -212,9 +206,10 @@ sal_Int32 SwTextBoxHelper::getOrdNum(const SdrObject* pObject) sal_Int32 nOrder = 0; // Current logical order. for (std::size_t i = 0; i < pPage->GetObjCount(); ++i) { - if (isTextBox(pPage->GetObj(i))) + SdrObject* p = pPage->GetObj(i); + if (p && p->IsTextBox()) continue; - if (pPage->GetObj(i) == pObject) + if (p == pObject) return nOrder; ++nOrder; } diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 19d0372b92e2..dafd5b1bfdc3 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -47,6 +47,7 @@ #include "grfatr.hxx" #include "pagefrm.hxx" #include "rootfrm.hxx" +#include "textboxhelper.hxx" #include "wrtsh.hxx" #include <ndgrf.hxx> #include <frmmgr.hxx> @@ -1135,4 +1136,9 @@ SdrObject* SwVirtFlyDrawObj::CheckMacroHit( const SdrObjMacroHitRec& rRec ) cons return SdrObject::CheckMacroHit( rRec ); } +bool SwVirtFlyDrawObj::IsTextBox() const +{ + return SwTextBoxHelper::isTextBox(GetFormat(), RES_FLYFRMFMT); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx index 77befafe37bf..80425ac03b15 100644 --- a/sw/source/core/inc/dflyobj.hxx +++ b/sw/source/core/inc/dflyobj.hxx @@ -132,6 +132,8 @@ public: // RotGrfFlyFrame: If true, this SdrObject supports only limited rotation. virtual bool HasLimitedRotation() const override; + + virtual bool IsTextBox() const override; }; #endif diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx index 2f387808b11e..ef243c301aa7 100644 --- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx @@ -494,7 +494,7 @@ SwTwips SwAnchoredObjectPosition::ImplAdjustVertRelPos( const SwTwips nTopOfAnch && nAdjustedRelPosY < nProposedRelPosY ) { const SwFrameFormat* pFormat = &(GetFrameFormat()); - if ( SwTextBoxHelper::isTextBox(&GetObject()) ) + if ( GetObject().IsTextBox() ) { // shrink textboxes to extend beyond the page bottom SwFrameFormat* pFrameFormat = ::FindFrameFormat(&GetObject()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits