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

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