summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-11-14 10:37:45 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-11-14 13:40:35 +0100
commite320d070bb0d4dd0ceb696f2c7cc5afb7c4273c3 (patch)
tree78056467ec81db0d23f46f3418ae6a4ac6d3dfa9
parent4cbbaf571d3982eccd7f7267df3185b3d321d0da (diff)
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
-rw-r--r--sw/inc/SidebarWin.hxx2
-rw-r--r--sw/source/uibase/docvw/SidebarWin.cxx60
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx10
3 files changed, 51 insertions, 21 deletions
diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
index cb4914021e20..bda077bb8a62 100644
--- a/sw/inc/SidebarWin.hxx
+++ b/sw/inc/SidebarWin.hxx
@@ -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;
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index 1877e702549b..d1901f60b2dd 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -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)
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 676a55663f55..98aac5139f8b 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -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();