Blame SOURCES/0314-sw-lok-forward-key-events-to-annotation-window-if-ne.patch

135360
From f9fdb4feeaa51ef9c1e9a87209d4643cb98fa76a Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Thu, 12 Nov 2015 16:56:45 +0100
135360
Subject: [PATCH 314/398] sw lok: forward key events to annotation window if
135360
 necessary
135360
135360
And to allow proper reaction by the annotation windows, inform them when
135360
a LOK callback is registered.
135360
135360
With this, it's possible to modify the contents of annotations via LOK.
135360
135360
(cherry picked from commit 1ba9d7fd2a7a3e2b4f52ed0f5efdf7df867b9db3)
135360
135360
Change-Id: I4489941512197880940e20cbaeb0b47a7a6f26fc
135360
---
135360
 sw/inc/PostItMgr.hxx                         |  4 ++++
135360
 sw/inc/SidebarWin.hxx                        |  1 +
135360
 sw/source/core/view/viewsh.cxx               |  2 ++
135360
 sw/source/uibase/docvw/PostItMgr.cxx         | 13 +++++++++++++
135360
 sw/source/uibase/docvw/SidebarTxtControl.hxx |  4 ++--
135360
 sw/source/uibase/docvw/SidebarWin.cxx        |  6 ++++++
135360
 sw/source/uibase/docvw/edtwin.cxx            | 11 +++++++++++
135360
 7 files changed, 39 insertions(+), 2 deletions(-)
135360
135360
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
135360
index 4356f6daa416..06f7cc1f1925 100644
135360
--- a/sw/inc/PostItMgr.hxx
135360
+++ b/sw/inc/PostItMgr.hxx
135360
@@ -34,6 +34,8 @@
135360
 #include <SidebarWindowsTypes.hxx>
135360
 #include <svl/lstner.hxx>
135360
 #include <vcl/vclptr.hxx>
135360
+#define LOK_USE_UNSTABLE_API
135360
+#include <LibreOfficeKit/LibreOfficeKitTypes.h>
135360
 
135360
 class OutputDevice;
135360
 class SwWrtShell;
135360
@@ -291,6 +293,8 @@ class SwPostItMgr: public SfxListener
135360
 
135360
         void DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage);
135360
         void PaintTile(OutputDevice& rRenderContext, const Rectangle& rRect);
135360
+        /// Informs already created annotations about a newly registered LOK callback.
135360
+        void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData);
135360
 };
135360
 
135360
 #endif
135360
diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
135360
index 1eaf982ebf07..c41352749c28 100644
135360
--- a/sw/inc/SidebarWin.hxx
135360
+++ b/sw/inc/SidebarWin.hxx
135360
@@ -178,6 +178,7 @@ class SwSidebarWin : public vcl::Window
135360
         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
135360
 
135360
         virtual void    Draw(OutputDevice* pDev, const Point&, const Size&, sal_uLong) override;
135360
+        virtual void KeyInput(const KeyEvent& rKeyEvt) override;
135360
         void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
135360
         /// Get the matching sub-widget inside this sidebar widget for rPointLogic, if any.
135360
         vcl::Window* IsHitWindow(const Point& rPointLogic);
135360
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
135360
index fad9dc3552db..963577fb1bd8 100644
135360
--- a/sw/source/core/view/viewsh.cxx
135360
+++ b/sw/source/core/view/viewsh.cxx
135360
@@ -120,6 +120,8 @@ void SwViewShell::ToggleHeaderFooterEdit()
135360
 void SwViewShell::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData)
135360
 {
135360
     getIDocumentDrawModelAccess()->GetDrawModel()->registerLibreOfficeKitCallback(pCallback, pData);
135360
+    if (SwPostItMgr* pPostItMgr = GetPostItMgr())
135360
+        pPostItMgr->registerLibreOfficeKitCallback(pCallback, pData);
135360
 }
135360
 
135360
 void SwViewShell::libreOfficeKitCallback(int nType, const char* pPayload) const
135360
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
135360
index eb5755e20cf9..703a433a44ee 100644
135360
--- a/sw/source/uibase/docvw/PostItMgr.cxx
135360
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
135360
@@ -881,6 +881,19 @@ void SwPostItMgr::PaintTile(OutputDevice& rRenderContext, const Rectangle& /*rRe
135360
     }
135360
 }
135360
 
135360
+void SwPostItMgr::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData)
135360
+{
135360
+    for (SwSidebarItem* pItem : mvPostItFields)
135360
+    {
135360
+        SwSidebarWin* pPostIt = pItem->pPostIt;
135360
+        if (!pPostIt)
135360
+            continue;
135360
+
135360
+        pPostIt->GetOutlinerView()->setTiledRendering(mpWrtShell->isTiledRendering());
135360
+        pPostIt->GetOutlinerView()->registerLibreOfficeKitCallback(pCallback, pData);
135360
+    }
135360
+}
135360
+
135360
 void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage)
135360
 {
135360
     OSL_ENSURE((lScroll % GetScrollSize() )==0,"SwPostItMgr::Scroll: scrolling by wrong value");
135360
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.hxx b/sw/source/uibase/docvw/SidebarTxtControl.hxx
135360
index 1be8ab3b8b4a..4f47ef4a2177 100644
135360
--- a/sw/source/uibase/docvw/SidebarTxtControl.hxx
135360
+++ b/sw/source/uibase/docvw/SidebarTxtControl.hxx
135360
@@ -40,7 +40,6 @@ class SidebarTextControl : public Control
135360
 
135360
     protected:
135360
         virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
135360
-        virtual void    KeyInput( const KeyEvent& rKeyEvt ) SAL_OVERRIDE;
135360
         virtual void    MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
135360
         virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
135360
         virtual void    MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
135360
@@ -60,7 +59,8 @@ class SidebarTextControl : public Control
135360
         virtual ~SidebarTextControl();
135360
         virtual void dispose() SAL_OVERRIDE;
135360
 
135360
-        virtual void GetFocus() SAL_OVERRIDE;
135360
+        virtual void GetFocus() override;
135360
+        virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
135360
 
135360
         OutlinerView* GetTextView() const;
135360
 
135360
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
135360
index 575be80c0ae0..a40c82de5470 100644
135360
--- a/sw/source/uibase/docvw/SidebarWin.cxx
135360
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
135360
@@ -356,6 +356,12 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, s
135360
     }
135360
 }
135360
 
135360
+void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
135360
+{
135360
+    if (mpSidebarTextControl)
135360
+        mpSidebarTextControl->KeyInput(rKeyEvent);
135360
+}
135360
+
135360
 void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight,
135360
                                        const SwRect& aAnchorRect, const long aPageBorder)
135360
 {
135360
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
135360
index b4ed61becbfb..10cdc0dca561 100644
135360
--- a/sw/source/uibase/docvw/edtwin.cxx
135360
+++ b/sw/source/uibase/docvw/edtwin.cxx
135360
@@ -145,6 +145,8 @@
135360
 #include <xmloff/odffields.hxx>
135360
 
135360
 #include <PostItMgr.hxx>
135360
+#include <SidebarWin.hxx>
135360
+#include <FrameControlsManager.hxx>
135360
 
135360
 #include <algorithm>
135360
 #include <vector>
135360
@@ -1324,6 +1326,15 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
135360
 {
135360
     SwWrtShell &rSh = m_rView.GetWrtShell();
135360
 
135360
+    if (comphelper::LibreOfficeKit::isActive() && m_rView.GetPostItMgr())
135360
+    {
135360
+        if (vcl::Window* pWindow = m_rView.GetPostItMgr()->GetActiveSidebarWin())
135360
+        {
135360
+            pWindow->KeyInput(rKEvt);
135360
+            return;
135360
+        }
135360
+    }
135360
+
135360
     if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
135360
         m_pApplyTempl && m_pApplyTempl->m_pFormatClipboard )
135360
     {
135360
-- 
135360
2.12.0
135360