From eea254dd5eb834b846ff9c55662d5704c266f438 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 19 Nov 2015 16:11:43 +0100 Subject: [PATCH 348/398] sw lok comments: optimize sidebar text control invalidation Instead of invalidating the whole area, invalidate the sub-widget when the whole area of the sub-widget would be invalidated. With this, a test comment with enough comment to have a scrollbar results in 3 paintTile() calls instead of 11 ones (70% save). (cherry picked from commit 9ece5c870a0ce39690109777bb8f76c1463a10c2) Change-Id: I2fe317549eefac9a63aaf50f5a9a242e15c4dc86 --- sw/source/uibase/docvw/SidebarTxtControl.cxx | 34 ++++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx index d6887a475312..4558c4071bfd 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.cxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx @@ -190,24 +190,28 @@ void SidebarTextControl::Paint(vcl::RenderContext& rRenderContext, const Rectang void SidebarTextControl::LogicInvalidate(const Rectangle* pRectangle) { - OString sRectangle; + Rectangle aRectangle; + if (!pRectangle) - sRectangle = "EMPTY"; - else { - // Convert from relative twips to absolute ones. - Rectangle aRectangle(*pRectangle); - vcl::Window& rParent = *mrSidebarWin.EditWin(); - Point aOffset(GetOutOffXPixel() - rParent.GetOutOffXPixel(), GetOutOffYPixel() - rParent.GetOutOffYPixel()); - rParent.Push(PushFlags::MAPMODE); - rParent.EnableMapMode(); - aOffset = rParent.PixelToLogic(aOffset); - rParent.Pop(); - aRectangle.Move(aOffset.getX(), aOffset.getY()); - - sRectangle = aRectangle.toString(); + Push(PushFlags::MAPMODE); + EnableMapMode(); + aRectangle = Rectangle(Point(0, 0), PixelToLogic(GetSizePixel())); + Pop(); } - + else + aRectangle = *pRectangle; + + // Convert from relative twips to absolute ones. + vcl::Window& rParent = *mrSidebarWin.EditWin(); + Point aOffset(GetOutOffXPixel() - rParent.GetOutOffXPixel(), GetOutOffYPixel() - rParent.GetOutOffYPixel()); + rParent.Push(PushFlags::MAPMODE); + rParent.EnableMapMode(); + aOffset = rParent.PixelToLogic(aOffset); + rParent.Pop(); + aRectangle.Move(aOffset.getX(), aOffset.getY()); + + OString sRectangle = aRectangle.toString(); SwWrtShell& rWrtShell = mrDocView.GetWrtShell(); rWrtShell.libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr()); } -- 2.12.0