f085233
From b5a90399a502498c28779706b3f518b4ea224b4d Mon Sep 17 00:00:00 2001
c1307e3
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
c1307e3
Date: Thu, 13 Nov 2014 13:32:35 +0000
f085233
Subject: [PATCH 1/2] table layout cache returns wrong rectangle
c1307e3
c1307e3
the layouter can modify its input rectangle to grow
c1307e3
it to the necessary size to contain the layout
c1307e3
c1307e3
but we're returning the input rectangle when the inputs are the same as the
c1307e3
last call, not returning the output rectangle.
c1307e3
c1307e3
cache the output rect for a given input and return that
c1307e3
c1307e3
so now insert->table in impress and tab so extra cells are added and
c1307e3
then select the table and the blue border contains the whole
c1307e3
table, not just the first two rows
c1307e3
c1307e3
Change-Id: I4f09594d82c1597204afbd059e175af9bf8e2527
c1307e3
(cherry picked from commit 98cd2671f0a215ced6203372ac673e2380031ac0)
c1307e3
---
c1307e3
 svx/source/table/svdotable.cxx | 15 +++++++++++----
c1307e3
 1 file changed, 11 insertions(+), 4 deletions(-)
c1307e3
c1307e3
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
f085233
index 45c6a30..e3a2a47 100644
c1307e3
--- a/svx/source/table/svdotable.cxx
c1307e3
+++ b/svx/source/table/svdotable.cxx
c1307e3
@@ -244,7 +244,8 @@ public:
f085233
     virtual bool isInUse();
c1307e3
 private:
c1307e3
     static SdrTableObjImpl* lastLayoutTable;
c1307e3
-    static Rectangle lastLayoutRectangle;
c1307e3
+    static Rectangle lastLayoutInputRectangle;
c1307e3
+    static Rectangle lastLayoutResultRectangle;
c1307e3
     static bool lastLayoutFitWidth;
c1307e3
     static bool lastLayoutFitHeight;
c1307e3
     static WritingMode lastLayoutMode;
c1307e3
@@ -253,7 +254,8 @@ private:
c1307e3
 };
c1307e3
 
c1307e3
 SdrTableObjImpl* SdrTableObjImpl::lastLayoutTable = NULL;
c1307e3
-Rectangle SdrTableObjImpl::lastLayoutRectangle;
c1307e3
+Rectangle SdrTableObjImpl::lastLayoutInputRectangle;
c1307e3
+Rectangle SdrTableObjImpl::lastLayoutResultRectangle;
c1307e3
 bool SdrTableObjImpl::lastLayoutFitWidth;
c1307e3
 bool SdrTableObjImpl::lastLayoutFitHeight;
c1307e3
 WritingMode SdrTableObjImpl::lastLayoutMode;
f085233
@@ -698,14 +700,14 @@ void SdrTableObjImpl::LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHe
c1307e3
         // Optimization: SdrTableObj::SetChanged() can call this very often, repeatedly
c1307e3
         // with the same settings, noticeably increasing load time. Skip if already done.
c1307e3
         WritingMode writingMode = mpTableObj->GetWritingMode();
c1307e3
-        if( lastLayoutTable != this || lastLayoutRectangle != rArea
c1307e3
+        if( lastLayoutTable != this || lastLayoutInputRectangle != rArea
c1307e3
             || lastLayoutFitWidth != bFitWidth || lastLayoutFitHeight != bFitHeight
c1307e3
             || lastLayoutMode != writingMode
c1307e3
             || lastRowCount != getRowCount()
c1307e3
             || lastColCount != getColumnCount() )
c1307e3
         {
c1307e3
             lastLayoutTable = this;
c1307e3
-            lastLayoutRectangle = rArea;
c1307e3
+            lastLayoutInputRectangle = rArea;
c1307e3
             lastLayoutFitWidth = bFitWidth;
c1307e3
             lastLayoutFitHeight = bFitHeight;
c1307e3
             lastLayoutMode = writingMode;
f085233
@@ -713,6 +715,11 @@ void SdrTableObjImpl::LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHe
c1307e3
             lastColCount = getColumnCount();
c1307e3
             TableModelNotifyGuard aGuard( mxTable.get() );
c1307e3
             mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight );
c1307e3
+            lastLayoutResultRectangle = rArea;
c1307e3
+        }
c1307e3
+        else
c1307e3
+        {
c1307e3
+            rArea = lastLayoutResultRectangle;
c1307e3
         }
c1307e3
     }
c1307e3
 }
c1307e3
-- 
c1307e3
1.9.3
c1307e3