From f9fdb4feeaa51ef9c1e9a87209d4643cb98fa76a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 12 Nov 2015 16:56:45 +0100 Subject: [PATCH 314/398] 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. (cherry picked from commit 1ba9d7fd2a7a3e2b4f52ed0f5efdf7df867b9db3) Change-Id: I4489941512197880940e20cbaeb0b47a7a6f26fc --- 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 | 4 ++-- sw/source/uibase/docvw/SidebarWin.cxx | 6 ++++++ sw/source/uibase/docvw/edtwin.cxx | 11 +++++++++++ 7 files changed, 39 insertions(+), 2 deletions(-) diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index 4356f6daa416..06f7cc1f1925 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -34,6 +34,8 @@ #include #include #include +#define LOK_USE_UNSTABLE_API +#include class OutputDevice; class SwWrtShell; @@ -291,6 +293,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 1eaf982ebf07..c41352749c28 100644 --- a/sw/inc/SidebarWin.hxx +++ b/sw/inc/SidebarWin.hxx @@ -178,6 +178,7 @@ class SwSidebarWin : public vcl::Window virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE; virtual void Draw(OutputDevice* pDev, const Point&, const Size&, sal_uLong) 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 fad9dc3552db..963577fb1bd8 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -120,6 +120,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 eb5755e20cf9..703a433a44ee 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 1be8ab3b8b4a..4f47ef4a2177 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) SAL_OVERRIDE; - virtual void KeyInput( const KeyEvent& rKeyEvt ) SAL_OVERRIDE; virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE; @@ -60,7 +59,8 @@ class SidebarTextControl : public Control virtual ~SidebarTextControl(); virtual void dispose() SAL_OVERRIDE; - virtual void GetFocus() SAL_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 575be80c0ae0..a40c82de5470 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -356,6 +356,12 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, s } } +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 b4ed61becbfb..10cdc0dca561 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -145,6 +145,8 @@ #include #include +#include +#include #include #include @@ -1324,6 +1326,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 ) { -- 2.12.0