[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - svx/source

2014-03-25 Thread Luboš Luňák
 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


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - svx/source

2014-03-07 Thread Muthu Subramanian
 svx/source/svdraw/svdobj.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 5d033741b5e5d1b2c7eec91bc5fe24e5db18eb40
Author: Muthu Subramanian sumu...@collabora.com
Date:   Fri Mar 7 21:24:39 2014 +0530

Use GetData() instead of GetBuffer()

Change-Id: I82717c53b0ed1eb14ab6cc6cc037d991cce42984

diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index c3f3d42..c7297f9 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1796,7 +1796,7 @@ OString SdrObject::stringify() const
 SfxItemSet aSet(GetMergedItemSet());
 aSet.InvalidateDefaultItems();
 aSet.Store(aStream, true);
-aString.append((const char *)aStream.GetBuffer(), aStream.GetEndOfData());
+aString.append((const char *)aStream.GetData(), aStream.GetEndOfData());
 
 return aString.makeStringAndClear();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - svx/source vcl/source

2014-03-03 Thread Caolán McNamara
 svx/source/svdraw/sdrpaintwindow.cxx |   96 ---
 vcl/source/window/window.cxx |5 +
 2 files changed, 83 insertions(+), 18 deletions(-)

New commits:
commit fa3c550a8eeb4a7be3ec4afe0540c1320d321110
Author: Caolán McNamara caol...@redhat.com
Date:   Fri Feb 28 16:55:03 2014 +

Resolves: rhbz#1007697 Update on a Window triggering delete on window

Reviewed-on: https://gerrit.libreoffice.org/8396
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com
(cherry picked from commit 1ec2880679d88c89901ce00fe30dd78e584f6960)

Conflicts:
svx/source/svdraw/sdrpaintwindow.cxx
vcl/source/window/window.cxx

Change-Id: Ic6374ce45e3a3ba97217ae77e91f9143f46e277b

diff --git a/svx/source/svdraw/sdrpaintwindow.cxx 
b/svx/source/svdraw/sdrpaintwindow.cxx
index 6ab2b40..da94126 100644
--- a/svx/source/svdraw/sdrpaintwindow.cxx
+++ b/svx/source/svdraw/sdrpaintwindow.cxx
@@ -22,35 +22,95 @@
 #include svx/svdpntv.hxx
 #include vcl/gdimtf.hxx
 #include vcl/svapp.hxx
+#include set
+#include vector
+
+//rhbz#1007697 do this in two loops, one to collect the candidates
+//and another to update them because updating a candidate can
+//trigger the candidate to be deleted, so asking for its
+//sibling after that is going to fail hard
+class CandidateMgr
+{
+std::vectorWindow* m_aCandidates;
+std::setWindow* m_aDeletedCandidates;
+DECL_LINK(WindowEventListener, VclSimpleEvent*);
+public:
+void PaintTransparentChildren(Window  rWindow, Rectangle const 
rPixelRect);
+~CandidateMgr();
+};
+
+IMPL_LINK(CandidateMgr, WindowEventListener, VclSimpleEvent*, pEvent)
+{
+VclWindowEvent* pWinEvent = dynamic_cast VclWindowEvent* ( pEvent );
+if (pWinEvent)
+{
+Window* pWindow = pWinEvent-GetWindow();
+if (pWinEvent-GetId() == VCLEVENT_OBJECT_DYING)
+{
+m_aDeletedCandidates.insert(pWindow);
+}
+}
 
+return 0;
+}
+
+CandidateMgr::~CandidateMgr()
+{
+for (std::vectorWindow*::iterator aI = m_aCandidates.begin();
+ aI != m_aCandidates.end(); ++aI)
+{
+Window* pCandidate = *aI;
+if (m_aDeletedCandidates.find(pCandidate) != 
m_aDeletedCandidates.end())
+continue;
+pCandidate-RemoveEventListener(LINK(this, CandidateMgr, 
WindowEventListener));
+}
+}
 
 void PaintTransparentChildren(Window  rWindow, Rectangle const rPixelRect)
 {
-if (rWindow.IsChildTransparentModeEnabled())
+if (!rWindow.IsChildTransparentModeEnabled())
+return;
+
+CandidateMgr aManager;
+aManager.PaintTransparentChildren(rWindow, rPixelRect);
+}
+
+void CandidateMgr::PaintTransparentChildren(Window  rWindow, Rectangle const 
rPixelRect)
+{
+Window * pCandidate = rWindow.GetWindow( WINDOW_FIRSTCHILD );
+while (pCandidate)
 {
-Window * pCandidate = rWindow.GetWindow( WINDOW_FIRSTCHILD );
-while (pCandidate)
+if (pCandidate-IsPaintTransparent())
 {
-if (pCandidate-IsPaintTransparent())
+const Rectangle aCandidatePosSizePixel(
+pCandidate-GetPosPixel(),
+pCandidate-GetSizePixel());
+
+if (aCandidatePosSizePixel.IsOver(rPixelRect))
 {
-const Rectangle aCandidatePosSizePixel(
-pCandidate-GetPosPixel(),
-pCandidate-GetSizePixel());
-
-if (aCandidatePosSizePixel.IsOver(rPixelRect))
-{
-pCandidate-Invalidate(
-INVALIDATE_NOTRANSPARENT|INVALIDATE_CHILDREN );
-// important: actually paint the child here!
-pCandidate-Update();
-}
+m_aCandidates.push_back(pCandidate);
+pCandidate-AddEventListener(LINK(this, CandidateMgr, 
WindowEventListener));
 }
-pCandidate = pCandidate-GetWindow( WINDOW_NEXT );
 }
+pCandidate = pCandidate-GetWindow( WINDOW_NEXT );
 }
-}
 
-
+for (std::vectorWindow*::iterator aI = m_aCandidates.begin();
+ aI != m_aCandidates.end(); ++aI)
+{
+pCandidate = *aI;
+if (m_aDeletedCandidates.find(pCandidate) != 
m_aDeletedCandidates.end())
+continue;
+//rhbz#1007697 this can cause the window itself to be
+//deleted. So we are listening to see if that happens
+//and if so, then skip the update
+pCandidate-Invalidate(INVALIDATE_NOTRANSPARENT|INVALIDATE_CHILDREN);
+// important: actually paint the child here!
+if (m_aDeletedCandidates.find(pCandidate) != 
m_aDeletedCandidates.end())
+continue;
+pCandidate-Update();
+}
+}