From e7aa44b38ce78573f4b232d612d2411d8ecbb479 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <l.lunak@collabora.com>
Date: Tue, 25 Mar 2014 11:27:51 +0100
Subject: [PATCH] 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
---
svx/source/table/svdotable.cxx | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 9c5e64a..db2a6ad 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -242,9 +242,19 @@ public:
void connectTableStyle();
void disconnectTableStyle();
virtual bool isInUse();
+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()
: mpTableObj( 0 )
@@ -257,6 +267,8 @@ SdrTableObjImpl::SdrTableObjImpl()
SdrTableObjImpl::~SdrTableObjImpl()
{
+ if( lastLayoutTable == this )
+ lastLayoutTable = NULL;
}
// -----------------------------------------------------------------------------
@@ -677,8 +689,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 );
+ }
}
}
--
1.9.0