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

sw lok comments: implement setTextSelection() API

So that it's possible to drag the text selection start/end handles in
comment text when there is an existing selection.

Change-Id: I3acc4770928d4f385f0ca09a2484a9e112409907
üst 4cbbaf57
......@@ -182,6 +182,8 @@ class SwSidebarWin : public vcl::Window
void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
/// Is there a matching sub-widget inside this sidebar widget for rPointLogic?
bool IsHitWindow(const Point& rPointLogic);
/// Allows adjusting the point or mark of the selection to a document coordinate.
void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
protected:
virtual void DataChanged( const DataChangedEvent& aEvent) override;
......
......@@ -82,6 +82,32 @@
#include <memory>
#include <comphelper/lok.hxx>
namespace
{
/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input.
void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* pMouseEvent)
{
// Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones.
Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
aOffset = rChild.PixelToLogic(aOffset);
MapMode aMapMode(rChild.GetMapMode());
aMapMode.SetOrigin(aOffset);
rChild.SetMapMode(aMapMode);
rChild.EnableMapMode(false);
if (pMouseEvent)
{
// Set event coordinates, so they contain relative coordinates instead of absolute ones.
Point aPos = pMouseEvent->GetPosPixel();
aPos.Move(-aOffset.getX(), -aOffset.getY());
MouseEvent aMouseEvent(aPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), pMouseEvent->GetButtons(), pMouseEvent->GetModifier());
*pMouseEvent = aMouseEvent;
}
}
}
namespace sw { namespace sidebarwindows {
#define METABUTTON_WIDTH 16
......@@ -289,6 +315,19 @@ bool SwSidebarWin::IsHitWindow(const Point& rPointLogic)
return aRectangleLogic.IsInside(rPointLogic);
}
void SwSidebarWin::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark)
{
mpSidebarTextControl->Push(PushFlags::MAPMODE);
MouseEvent aMouseEvent(rPosition);
lcl_translateTwips(EditWin(), *mpSidebarTextControl, &aMouseEvent);
Point aPosition(aMouseEvent.GetPosPixel());
EditView& rEditView = GetOutlinerView()->GetEditView();
rEditView.SetCursorLogicPosition(aPosition, bPoint, bClearMark);
mpSidebarTextControl->Pop();
}
void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, DrawFlags nInFlags)
{
if (mpMetadataAuthor->IsVisible() )
......@@ -357,27 +396,6 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, D
}
}
/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input.
static void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* pMouseEvent)
{
// Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones.
Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
aOffset = rChild.PixelToLogic(aOffset);
MapMode aMapMode(rChild.GetMapMode());
aMapMode.SetOrigin(aOffset);
rChild.SetMapMode(aMapMode);
rChild.EnableMapMode(false);
if (pMouseEvent)
{
// Set event coordinates, so they contain relative coordinates instead of absolute ones.
Point aPos = pMouseEvent->GetPosPixel();
aPos.Move(-aOffset.getX(), -aOffset.getY());
MouseEvent aMouseEvent(aPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), pMouseEvent->GetButtons(), pMouseEvent->GetModifier());
*pMouseEvent = aMouseEvent;
}
}
void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
{
if (mpSidebarTextControl)
......
......@@ -6331,6 +6331,16 @@ void SwEditWin::SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool
}
}
if (m_rView.GetPostItMgr())
{
if (sw::sidebarwindows::SwSidebarWin* pWin = m_rView.GetPostItMgr()->GetActiveSidebarWin())
{
// Editing postit text.
pWin->SetCursorLogicPosition(rPosition, bPoint, bClearMark);
return;
}
}
// Not an SwWrtShell, as that would make SwCrsrShell::GetCrsr() inaccessible.
SwEditShell& rShell = m_rView.GetWrtShell();
......
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