Kaydet (Commit) 1ba9d7fd authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 49f45375
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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");
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment