svx/source/table/svdotable.cxx | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
New commits: commit 7eefd10324207c52fafc639e51e3d4eb32eb3024 Author: LuboÅ¡ LuÅák <l.lu...@collabora.com> Date: Tue Mar 25 11:27:51 2014 +0100 avoid repeated table layouting (fdo#75622) With the document from fdo#75622, this saves 3775 calls and leaves only 13. e586fe4585dc07e6f6dd061d09f6a7fb0b22948c removed avoiding the call to LayoutTable(), which made loading slow. I checked that the doc from that bugreport still works, so if very original code was correct in avoiding the call sometimes, this should be ok too. Change-Id: Ia80f974d4497e5cb04612331527eb87b579ddb76 diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 474d42d..823154f 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -244,8 +244,20 @@ public: virtual bool isInUse(); bool UpdateWritingMode(); +private: + static SdrTableObjImpl* lastLayoutTable; + static Rectangle lastLayoutRectangle; + static bool lastLayoutFitWidth; + static bool lastLayoutFitHeight; + static WritingMode lastLayoutMode; }; +SdrTableObjImpl* SdrTableObjImpl::lastLayoutTable = NULL; +Rectangle SdrTableObjImpl::lastLayoutRectangle; +bool SdrTableObjImpl::lastLayoutFitWidth; +bool SdrTableObjImpl::lastLayoutFitHeight; +WritingMode SdrTableObjImpl::lastLayoutMode; + // ----------------------------------------------------------------------------- SdrTableObjImpl::SdrTableObjImpl() @@ -259,6 +271,8 @@ SdrTableObjImpl::SdrTableObjImpl() SdrTableObjImpl::~SdrTableObjImpl() { + if( lastLayoutTable == this ) + lastLayoutTable = NULL; } // ----------------------------------------------------------------------------- @@ -681,8 +695,21 @@ void SdrTableObjImpl::LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHe { if( mpLayouter && mpTableObj->GetModel() ) { - TableModelNotifyGuard aGuard( mxTable.get() ); - mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight ); + // Optimization: SdrTableObj::SetChanged() can call this very often, repeatedly + // with the same settings, noticeably increasing load time. Skip if already done. + WritingMode writingMode = mpTableObj->GetWritingMode(); + if( lastLayoutTable != this || lastLayoutRectangle != rArea + || lastLayoutFitWidth != bFitWidth || lastLayoutFitHeight != bFitHeight + || lastLayoutMode != writingMode ) + { + lastLayoutTable = this; + lastLayoutRectangle = rArea; + lastLayoutFitWidth = bFitWidth; + lastLayoutFitHeight = bFitHeight; + lastLayoutMode = writingMode; + TableModelNotifyGuard aGuard( mxTable.get() ); + mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight ); + } } }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits