[Libreoffice-commits] core.git: sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Nov 12 07:57:25 PST 2015


 sw/inc/PostItMgr.hxx                         |    4 ++++
 sw/inc/SidebarWin.hxx                        |    1 +
 sw/source/core/view/viewsh.cxx               |    2 ++
 sw/source/uibase/docvw/PostItMgr.cxx         |   13 +++++++++++++
 sw/source/uibase/docvw/SidebarTxtControl.hxx |    2 +-
 sw/source/uibase/docvw/SidebarWin.cxx        |    6 ++++++
 sw/source/uibase/docvw/edtwin.cxx            |   10 ++++++++++
 7 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 1ba9d7fd2a7a3e2b4f52ed0f5efdf7df867b9db3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Nov 12 16:56:45 2015 +0100

    sw lok: forward key events to annotation window if necessary
    
    And to allow proper reaction by the annotation windows, inform them when
    a LOK callback is registered.
    
    With this, it's possible to modify the contents of annotations via LOK.
    
    Change-Id: I4489941512197880940e20cbaeb0b47a7a6f26fc

diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index 7427c7a..3c8324e 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -34,6 +34,8 @@
 #include <SidebarWindowsTypes.hxx>
 #include <svl/lstner.hxx>
 #include <vcl/vclptr.hxx>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKitTypes.h>
 
 class OutputDevice;
 class SwWrtShell;
@@ -288,6 +290,8 @@ class SwPostItMgr: public SfxListener
 
         void DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage);
         void PaintTile(OutputDevice& rRenderContext, const Rectangle& rRect);
+        /// Informs already created annotations about a newly registered LOK callback.
+        void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData);
 };
 
 #endif
diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
index f42bcb3..9ddf149 100644
--- a/sw/inc/SidebarWin.hxx
+++ b/sw/inc/SidebarWin.hxx
@@ -177,6 +177,7 @@ class SwSidebarWin : public vcl::Window
         virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
 
         virtual void    Draw(OutputDevice* pDev, const Point&, const Size&, DrawFlags) override;
+        virtual void KeyInput(const KeyEvent& rKeyEvt) override;
         void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
         /// Get the matching sub-widget inside this sidebar widget for rPointLogic, if any.
         vcl::Window* IsHitWindow(const Point& rPointLogic);
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index c682566..226b123 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -119,6 +119,8 @@ void SwViewShell::ToggleHeaderFooterEdit()
 void SwViewShell::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData)
 {
     getIDocumentDrawModelAccess().GetDrawModel()->registerLibreOfficeKitCallback(pCallback, pData);
+    if (SwPostItMgr* pPostItMgr = GetPostItMgr())
+        pPostItMgr->registerLibreOfficeKitCallback(pCallback, pData);
 }
 
 void SwViewShell::libreOfficeKitCallback(int nType, const char* pPayload) const
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 9feb691..cba1999 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -881,6 +881,19 @@ void SwPostItMgr::PaintTile(OutputDevice& rRenderContext, const Rectangle& /*rRe
     }
 }
 
+void SwPostItMgr::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData)
+{
+    for (SwSidebarItem* pItem : mvPostItFields)
+    {
+        SwSidebarWin* pPostIt = pItem->pPostIt;
+        if (!pPostIt)
+            continue;
+
+        pPostIt->GetOutlinerView()->setTiledRendering(mpWrtShell->isTiledRendering());
+        pPostIt->GetOutlinerView()->registerLibreOfficeKitCallback(pCallback, pData);
+    }
+}
+
 void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage)
 {
     OSL_ENSURE((lScroll % GetScrollSize() )==0,"SwPostItMgr::Scroll: scrolling by wrong value");
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.hxx b/sw/source/uibase/docvw/SidebarTxtControl.hxx
index 51243ed..1258412 100644
--- a/sw/source/uibase/docvw/SidebarTxtControl.hxx
+++ b/sw/source/uibase/docvw/SidebarTxtControl.hxx
@@ -40,7 +40,6 @@ class SidebarTextControl : public Control
 
     protected:
         virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
-        virtual void    KeyInput( const KeyEvent& rKeyEvt ) override;
         virtual void    MouseMove( const MouseEvent& rMEvt ) override;
         virtual void    MouseButtonDown( const MouseEvent& rMEvt ) override;
         virtual void    MouseButtonUp( const MouseEvent& rMEvt ) override;
@@ -61,6 +60,7 @@ class SidebarTextControl : public Control
         virtual void dispose() override;
 
         virtual void GetFocus() override;
+        virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
 
         OutlinerView* GetTextView() const;
 
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index cdf6838..c2ffc06 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -355,6 +355,12 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, D
     }
 }
 
+void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
+{
+    if (mpSidebarTextControl)
+        mpSidebarTextControl->KeyInput(rKeyEvent);
+}
+
 void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight,
                                        const SwRect& aAnchorRect, const long aPageBorder)
 {
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index a33257c..3e90227 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -145,6 +145,7 @@
 #include <xmloff/odffields.hxx>
 
 #include <PostItMgr.hxx>
+#include <SidebarWin.hxx>
 #include <FrameControlsManager.hxx>
 
 #include <algorithm>
@@ -1332,6 +1333,15 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
 {
     SwWrtShell &rSh = m_rView.GetWrtShell();
 
+    if (comphelper::LibreOfficeKit::isActive() && m_rView.GetPostItMgr())
+    {
+        if (vcl::Window* pWindow = m_rView.GetPostItMgr()->GetActiveSidebarWin())
+        {
+            pWindow->KeyInput(rKEvt);
+            return;
+        }
+    }
+
     if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
         m_pApplyTempl && m_pApplyTempl->m_pFormatClipboard )
     {


More information about the Libreoffice-commits mailing list