summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-03-25 11:27:51 +0100
committerAndras Timar <andras.timar@collabora.com>2014-03-25 10:52:25 +0000
commitf74991af12c78b25292641605ce1f2c55c44b33f (patch)
tree9317bf6e91c51d572a27e1bcfb90c8561feda2d6 /svx
parent572fdb94ecf3dfea6a6f787398efa4e4c54b4718 (diff)
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. Conflicts: svx/source/table/svdotable.cxx Change-Id: Ia80f974d4497e5cb04612331527eb87b579ddb76 Reviewed-on: https://gerrit.libreoffice.org/8738 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/table/svdotable.cxx31
1 files changed, 29 insertions, 2 deletions
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 9c5e64ae677a..d59c166ad70f 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -242,8 +242,20 @@ 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()
@@ -257,6 +269,8 @@ SdrTableObjImpl::SdrTableObjImpl()
SdrTableObjImpl::~SdrTableObjImpl()
{
+ if( lastLayoutTable == this )
+ lastLayoutTable = NULL;
}
// -----------------------------------------------------------------------------
@@ -677,8 +691,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 );
+ }
}
}