Blame SOURCES/0358-sw-lok-comments-fix-missing-invalidations-from-the-s.patch

135360
From 2c28091ad868b3d4f3512600a46b51f4ab57fc03 Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Tue, 24 Nov 2015 11:58:09 +0100
135360
Subject: [PATCH 358/398] sw lok comments: fix missing invalidations from the
135360
 scrollbar
135360
135360
If a comment had a scrollbar, and the user clicked on the down arrow of
135360
it, then the button remained in the "pushed" state, as the scrollbar
135360
invalidations were not routed to the LOK client.
135360
135360
With this, the button gets back to its non-pushed state after the mouse
135360
button is released.
135360
135360
Change-Id: Ie4ba5d0ec07229b0cfc08532e8e91ae25f7a4c9e
135360
(cherry picked from commit 55040ea13426e337418143dcfe226dd2a395f041)
135360
---
135360
 sw/Library_sw.mk                            |  1 +
135360
 sw/source/uibase/docvw/SidebarScrollBar.cxx | 72 +++++++++++++++++++++++++++++
135360
 sw/source/uibase/docvw/SidebarScrollBar.hxx | 43 +++++++++++++++++
135360
 sw/source/uibase/docvw/SidebarWin.cxx       |  3 +-
135360
 4 files changed, 118 insertions(+), 1 deletion(-)
135360
 create mode 100644 sw/source/uibase/docvw/SidebarScrollBar.cxx
135360
 create mode 100644 sw/source/uibase/docvw/SidebarScrollBar.hxx
135360
135360
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
135360
index ea8368719f7b..1297a85b874d 100644
135360
--- a/sw/Library_sw.mk
135360
+++ b/sw/Library_sw.mk
135360
@@ -600,6 +600,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
135360
     sw/source/uibase/docvw/OverlayRanges \
135360
     sw/source/uibase/docvw/PostItMgr \
135360
     sw/source/uibase/docvw/ShadowOverlayObject \
135360
+    sw/source/uibase/docvw/SidebarScrollBar \
135360
     sw/source/uibase/docvw/SidebarTxtControl \
135360
     sw/source/uibase/docvw/SidebarTxtControlAcc \
135360
     sw/source/uibase/docvw/SidebarWin \
135360
diff --git a/sw/source/uibase/docvw/SidebarScrollBar.cxx b/sw/source/uibase/docvw/SidebarScrollBar.cxx
135360
new file mode 100644
135360
index 000000000000..909aa763dba1
135360
--- /dev/null
135360
+++ b/sw/source/uibase/docvw/SidebarScrollBar.cxx
135360
@@ -0,0 +1,72 @@
135360
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
135360
+/*
135360
+ * This file is part of the LibreOffice project.
135360
+ *
135360
+ * This Source Code Form is subject to the terms of the Mozilla Public
135360
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
135360
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
135360
+ */
135360
+
135360
+#include <SidebarScrollBar.hxx>
135360
+
135360
+#define LOK_USE_UNSTABLE_API
135360
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
135360
+
135360
+#include <SidebarWin.hxx>
135360
+#include <view.hxx>
135360
+#include <wrtsh.hxx>
135360
+#include <edtwin.hxx>
135360
+
135360
+namespace sw
135360
+{
135360
+namespace sidebarwindows
135360
+{
135360
+
135360
+SidebarScrollBar::SidebarScrollBar(SwSidebarWin& rSidebarWin, WinBits nStyle, SwView& rView)
135360
+    : ScrollBar(&rSidebarWin, nStyle),
135360
+      m_rSidebarWin(rSidebarWin),
135360
+      m_rView(rView)
135360
+{
135360
+}
135360
+
135360
+void SidebarScrollBar::LogicInvalidate(const Rectangle* pRectangle)
135360
+{
135360
+    Rectangle aRectangle;
135360
+
135360
+    if (!pRectangle)
135360
+    {
135360
+        Push(PushFlags::MAPMODE);
135360
+        EnableMapMode();
135360
+        MapMode aMapMode = GetMapMode();
135360
+        aMapMode.SetMapUnit(MAP_TWIP);
135360
+        SetMapMode(aMapMode);
135360
+        aRectangle = Rectangle(Point(0, 0), PixelToLogic(GetSizePixel()));
135360
+        Pop();
135360
+    }
135360
+    else
135360
+        aRectangle = *pRectangle;
135360
+
135360
+    // Convert from relative twips to absolute ones.
135360
+    vcl::Window& rParent = m_rSidebarWin.EditWin();
135360
+    Point aOffset(GetOutOffXPixel() - rParent.GetOutOffXPixel(), GetOutOffYPixel() - rParent.GetOutOffYPixel());
135360
+    rParent.Push(PushFlags::MAPMODE);
135360
+    rParent.EnableMapMode();
135360
+    aOffset = rParent.PixelToLogic(aOffset);
135360
+    rParent.Pop();
135360
+    aRectangle.Move(aOffset.getX(), aOffset.getY());
135360
+
135360
+    OString sRectangle = aRectangle.toString();
135360
+    SwWrtShell& rWrtShell = m_rView.GetWrtShell();
135360
+    rWrtShell.libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
135360
+}
135360
+
135360
+
135360
+SidebarScrollBar::~SidebarScrollBar()
135360
+{
135360
+    disposeOnce();
135360
+}
135360
+
135360
+}
135360
+} // end of namespace sw::sidebarwindows
135360
+
135360
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
135360
diff --git a/sw/source/uibase/docvw/SidebarScrollBar.hxx b/sw/source/uibase/docvw/SidebarScrollBar.hxx
135360
new file mode 100644
135360
index 000000000000..9543205387df
135360
--- /dev/null
135360
+++ b/sw/source/uibase/docvw/SidebarScrollBar.hxx
135360
@@ -0,0 +1,43 @@
135360
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
135360
+/*
135360
+ * This file is part of the LibreOffice project.
135360
+ *
135360
+ * This Source Code Form is subject to the terms of the Mozilla Public
135360
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
135360
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
135360
+ */
135360
+
135360
+#ifndef INCLUDED_SW_SOURCE_UIBASE_DOCVW_SIDEBARSCROLLBAR_HXX
135360
+#define INCLUDED_SW_SOURCE_UIBASE_DOCVW_SIDEBARSCROLLBAR_HXX
135360
+
135360
+#include <vcl/scrbar.hxx>
135360
+
135360
+class SwView;
135360
+
135360
+namespace sw
135360
+{
135360
+namespace sidebarwindows
135360
+{
135360
+
135360
+class SwSidebarWin;
135360
+
135360
+/// Similar to the VCL scrollbar, but instrumented with Writer-specific details for LOK.
135360
+class SidebarScrollBar : public ScrollBar
135360
+{
135360
+    SwSidebarWin& m_rSidebarWin;
135360
+    SwView& m_rView;
135360
+
135360
+protected:
135360
+    /// @see OutputDevice::LogicInvalidate().
135360
+    void LogicInvalidate(const Rectangle* pRectangle) override;
135360
+public:
135360
+    SidebarScrollBar(SwSidebarWin& rSidebarWin, WinBits nStyle, SwView& rView);
135360
+    virtual ~SidebarScrollBar();
135360
+};
135360
+
135360
+}
135360
+}
135360
+
135360
+#endif
135360
+
135360
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
135360
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
135360
index c95a8909de54..1bfab323e833 100644
135360
--- a/sw/source/uibase/docvw/SidebarWin.cxx
135360
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
135360
@@ -26,6 +26,7 @@
135360
 #include <PostItMgr.hxx>
135360
 
135360
 #include <SidebarTxtControl.hxx>
135360
+#include <SidebarScrollBar.hxx>
135360
 #include <AnchorOverlayObject.hxx>
135360
 #include <ShadowOverlayObject.hxx>
135360
 #include <OverlayRanges.hxx>
135360
@@ -623,7 +624,7 @@ void SwSidebarWin::InitControls()
135360
     }
135360
 
135360
     //create Scrollbars
135360
-    mpVScrollbar = VclPtr<ScrollBar>::Create(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
135360
+    mpVScrollbar = VclPtr<SidebarScrollBar>::Create(*this, WB_3DLOOK |WB_VSCROLL|WB_DRAG, mrView);
135360
     mpVScrollbar->EnableNativeWidget(false);
135360
     mpVScrollbar->EnableRTL( false );
135360
     mpVScrollbar->SetScrollHdl(LINK(this, SwSidebarWin, ScrollHdl));
135360
-- 
135360
2.12.0
135360