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

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