Blob Blame History Raw
From 08ca67b7742364ecdc8bf7928ce2ef058da0e37e Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Sat, 14 Nov 2015 10:04:38 +0100
Subject: [PATCH 327/398] sw lok comments: emit invalidation events in
 SidebarTextControl

With this, newly typed characters show up instantly in comments, not
only after changing the zoom level.

(cherry picked from commit 4cbbaf571d3982eccd7f7267df3185b3d321d0da)

Change-Id: I1470db1ec03cc415917375f1f95434cf0944e559
---
 sw/source/uibase/docvw/SidebarTxtControl.cxx | 26 ++++++++++++++++++++++++++
 sw/source/uibase/docvw/SidebarTxtControl.hxx |  2 ++
 2 files changed, 28 insertions(+)

diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx
index afda8b1952ad..d6887a475312 100644
--- a/sw/source/uibase/docvw/SidebarTxtControl.cxx
+++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx
@@ -23,6 +23,7 @@
 
 #include <SidebarWin.hxx>
 #include <PostItMgr.hxx>
+#include <edtwin.hxx>
 
 #include <cmdid.h>
 #include <docvw.hrc>
@@ -46,6 +47,7 @@
 #include <editeng/editeng.hxx>
 #include <editeng/editview.hxx>
 #include <editeng/flditem.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #include <uitool.hxx>
 #include <view.hxx>
@@ -186,6 +188,30 @@ void SidebarTextControl::Paint(vcl::RenderContext& rRenderContext, const Rectang
     }
 }
 
+void SidebarTextControl::LogicInvalidate(const Rectangle* pRectangle)
+{
+    OString sRectangle;
+    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();
+    }
+
+    SwWrtShell& rWrtShell = mrDocView.GetWrtShell();
+    rWrtShell.libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
+}
+
 void SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt )
 {
     const vcl::KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.hxx b/sw/source/uibase/docvw/SidebarTxtControl.hxx
index 43d6b98d82c1..f73b68c950ae 100644
--- a/sw/source/uibase/docvw/SidebarTxtControl.hxx
+++ b/sw/source/uibase/docvw/SidebarTxtControl.hxx
@@ -40,6 +40,8 @@ class SidebarTextControl : public Control
 
     protected:
         virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
+        /// @see OutputDevice::LogicInvalidate().
+        void LogicInvalidate(const Rectangle* pRectangle) override;
         virtual void    MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
         virtual void    MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
         virtual void    Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
-- 
2.12.0