Blob Blame History Raw
From 2c28091ad868b3d4f3512600a46b51f4ab57fc03 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Tue, 24 Nov 2015 11:58:09 +0100
Subject: [PATCH 358/398] sw lok comments: fix missing invalidations from the
 scrollbar

If a comment had a scrollbar, and the user clicked on the down arrow of
it, then the button remained in the "pushed" state, as the scrollbar
invalidations were not routed to the LOK client.

With this, the button gets back to its non-pushed state after the mouse
button is released.

Change-Id: Ie4ba5d0ec07229b0cfc08532e8e91ae25f7a4c9e
(cherry picked from commit 55040ea13426e337418143dcfe226dd2a395f041)
---
 sw/Library_sw.mk                            |  1 +
 sw/source/uibase/docvw/SidebarScrollBar.cxx | 72 +++++++++++++++++++++++++++++
 sw/source/uibase/docvw/SidebarScrollBar.hxx | 43 +++++++++++++++++
 sw/source/uibase/docvw/SidebarWin.cxx       |  3 +-
 4 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100644 sw/source/uibase/docvw/SidebarScrollBar.cxx
 create mode 100644 sw/source/uibase/docvw/SidebarScrollBar.hxx

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index ea8368719f7b..1297a85b874d 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -600,6 +600,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/uibase/docvw/OverlayRanges \
     sw/source/uibase/docvw/PostItMgr \
     sw/source/uibase/docvw/ShadowOverlayObject \
+    sw/source/uibase/docvw/SidebarScrollBar \
     sw/source/uibase/docvw/SidebarTxtControl \
     sw/source/uibase/docvw/SidebarTxtControlAcc \
     sw/source/uibase/docvw/SidebarWin \
diff --git a/sw/source/uibase/docvw/SidebarScrollBar.cxx b/sw/source/uibase/docvw/SidebarScrollBar.cxx
new file mode 100644
index 000000000000..909aa763dba1
--- /dev/null
+++ b/sw/source/uibase/docvw/SidebarScrollBar.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <SidebarScrollBar.hxx>
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
+#include <SidebarWin.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <edtwin.hxx>
+
+namespace sw
+{
+namespace sidebarwindows
+{
+
+SidebarScrollBar::SidebarScrollBar(SwSidebarWin& rSidebarWin, WinBits nStyle, SwView& rView)
+    : ScrollBar(&rSidebarWin, nStyle),
+      m_rSidebarWin(rSidebarWin),
+      m_rView(rView)
+{
+}
+
+void SidebarScrollBar::LogicInvalidate(const Rectangle* pRectangle)
+{
+    Rectangle aRectangle;
+
+    if (!pRectangle)
+    {
+        Push(PushFlags::MAPMODE);
+        EnableMapMode();
+        MapMode aMapMode = GetMapMode();
+        aMapMode.SetMapUnit(MAP_TWIP);
+        SetMapMode(aMapMode);
+        aRectangle = Rectangle(Point(0, 0), PixelToLogic(GetSizePixel()));
+        Pop();
+    }
+    else
+        aRectangle = *pRectangle;
+
+    // Convert from relative twips to absolute ones.
+    vcl::Window& rParent = m_rSidebarWin.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 = m_rView.GetWrtShell();
+    rWrtShell.libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
+}
+
+
+SidebarScrollBar::~SidebarScrollBar()
+{
+    disposeOnce();
+}
+
+}
+} // end of namespace sw::sidebarwindows
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/docvw/SidebarScrollBar.hxx b/sw/source/uibase/docvw/SidebarScrollBar.hxx
new file mode 100644
index 000000000000..9543205387df
--- /dev/null
+++ b/sw/source/uibase/docvw/SidebarScrollBar.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UIBASE_DOCVW_SIDEBARSCROLLBAR_HXX
+#define INCLUDED_SW_SOURCE_UIBASE_DOCVW_SIDEBARSCROLLBAR_HXX
+
+#include <vcl/scrbar.hxx>
+
+class SwView;
+
+namespace sw
+{
+namespace sidebarwindows
+{
+
+class SwSidebarWin;
+
+/// Similar to the VCL scrollbar, but instrumented with Writer-specific details for LOK.
+class SidebarScrollBar : public ScrollBar
+{
+    SwSidebarWin& m_rSidebarWin;
+    SwView& m_rView;
+
+protected:
+    /// @see OutputDevice::LogicInvalidate().
+    void LogicInvalidate(const Rectangle* pRectangle) override;
+public:
+    SidebarScrollBar(SwSidebarWin& rSidebarWin, WinBits nStyle, SwView& rView);
+    virtual ~SidebarScrollBar();
+};
+
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index c95a8909de54..1bfab323e833 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -26,6 +26,7 @@
 #include <PostItMgr.hxx>
 
 #include <SidebarTxtControl.hxx>
+#include <SidebarScrollBar.hxx>
 #include <AnchorOverlayObject.hxx>
 #include <ShadowOverlayObject.hxx>
 #include <OverlayRanges.hxx>
@@ -623,7 +624,7 @@ void SwSidebarWin::InitControls()
     }
 
     //create Scrollbars
-    mpVScrollbar = VclPtr<ScrollBar>::Create(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
+    mpVScrollbar = VclPtr<SidebarScrollBar>::Create(*this, WB_3DLOOK |WB_VSCROLL|WB_DRAG, mrView);
     mpVScrollbar->EnableNativeWidget(false);
     mpVScrollbar->EnableRTL( false );
     mpVScrollbar->SetScrollHdl(LINK(this, SwSidebarWin, ScrollHdl));
-- 
2.12.0