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

sw lok: route SwEditWin::MouseButtonDown to SidebarTextControl if necessary

LOK sends all mouse events to SwEditWin, so add initial hit testing in
its mouse handler to forward the mouse events to the right VCL widget.

Change-Id: I67e8e19f47156261fd7c7eafd4e63f743e0c4ce9
üst bb078ab8
...@@ -234,6 +234,8 @@ class SwPostItMgr: public SfxListener ...@@ -234,6 +234,8 @@ class SwPostItMgr: public SfxListener
Rectangle GetTopScrollRect(const unsigned long aPage) const; Rectangle GetTopScrollRect(const unsigned long aPage) const;
bool IsHit(const Point &aPointPixel); bool IsHit(const Point &aPointPixel);
/// Get the matching window that is responsible for handling mouse events of rPointLogic, if any.
vcl::Window* IsHitSidebarWindow(const Point& rPointLogic);
Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const; Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const;
sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pField) const; sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pField) const;
......
...@@ -178,6 +178,8 @@ class SwSidebarWin : public vcl::Window ...@@ -178,6 +178,8 @@ class SwSidebarWin : public vcl::Window
virtual void Draw(OutputDevice* pDev, const Point&, const Size&, DrawFlags) override; virtual void Draw(OutputDevice* pDev, const Point&, const Size&, DrawFlags) override;
void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect); 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);
protected: protected:
virtual void DataChanged( const DataChangedEvent& aEvent) override; virtual void DataChanged( const DataChangedEvent& aEvent) override;
......
...@@ -1706,6 +1706,37 @@ bool SwPostItMgr::IsHit(const Point &aPointPixel) ...@@ -1706,6 +1706,37 @@ bool SwPostItMgr::IsHit(const Point &aPointPixel)
} }
return false; return false;
} }
vcl::Window* SwPostItMgr::IsHitSidebarWindow(const Point& rPointLogic)
{
vcl::Window* pRet = 0;
if (HasNotes() && ShowNotes())
{
bool bEnableMapMode = !mpEditWin->IsMapModeEnabled();
if (bEnableMapMode)
mpEditWin->EnableMapMode();
for (SwSidebarItem* pItem : mvPostItFields)
{
SwSidebarWin* pPostIt = pItem->pPostIt;
if (!pPostIt)
continue;
if (vcl::Window* pWindow = pPostIt->IsHitWindow(rPointLogic))
{
pRet = pWindow;
break;
}
}
if (bEnableMapMode)
mpEditWin->EnableMapMode(false);
}
return pRet;
}
Rectangle SwPostItMgr::GetBottomScrollRect(const unsigned long aPage) const Rectangle SwPostItMgr::GetBottomScrollRect(const unsigned long aPage) const
{ {
SwRect aPageRect = mPages[aPage-1]->mPageRect; SwRect aPageRect = mPages[aPage-1]->mPageRect;
......
...@@ -279,6 +279,14 @@ void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const Rectangle ...@@ -279,6 +279,14 @@ void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const Rectangle
rRenderContext.Push(PushFlags::NONE); rRenderContext.Push(PushFlags::NONE);
} }
vcl::Window* SwSidebarWin::IsHitWindow(const Point& rPointLogic)
{
Rectangle aRectangleLogic(EditWin().PixelToLogic(GetPosPixel()), EditWin().PixelToLogic(GetSizePixel()));
if (aRectangleLogic.IsInside(rPointLogic))
return mpSidebarTextControl;
return 0;
}
void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, DrawFlags nInFlags) void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, DrawFlags nInFlags)
{ {
if (mpMetadataAuthor->IsVisible() ) if (mpMetadataAuthor->IsVisible() )
......
...@@ -2764,6 +2764,22 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) ...@@ -2764,6 +2764,22 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
if (m_rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel())) if (m_rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel()))
return; return;
if (comphelper::LibreOfficeKit::isActive())
{
if (vcl::Window* pWindow = m_rView.GetPostItMgr()->IsHitSidebarWindow(rMEvt.GetPosPixel()))
{
bool bDisableMapMode = pWindow->IsMapModeEnabled();
if (bDisableMapMode)
pWindow->EnableMapMode(false);
pWindow->MouseButtonDown(rMEvt);
if (bDisableMapMode)
pWindow->EnableMapMode();
return;
}
}
m_rView.GetPostItMgr()->SetActiveSidebarWin(nullptr); m_rView.GetPostItMgr()->SetActiveSidebarWin(nullptr);
GrabFocus(); GrabFocus();
......
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