summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx14
-rw-r--r--sw/source/uibase/inc/edtwin.hxx2
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx19
3 files changed, 35 insertions, 0 deletions
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 6666249466da..bb592175fde4 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6256,4 +6256,18 @@ void SwEditWin::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
MouseButtonUp(rMouseEvent);
}
+void SwEditWin::SetCursorLogicPosition(bool bPoint, const Point& rPosition)
+{
+ // Not an SwWrtShell, as that would make SwCrsrShell::GetCrsr() inaccessible.
+ SwEditShell& rShell = m_rView.GetWrtShell();
+ SwMvContext aMvContext(&rShell);
+ // If the mark is to be updated, then exchange the point and mark before
+ // and after, as we can't easily set the mark.
+ if (!bPoint)
+ rShell.GetCrsr()->Exchange();
+ rShell.SetCrsr(rPosition);
+ if (!bPoint)
+ rShell.GetCrsr()->Exchange();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index 5557321a5a1a..9af94460629c 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -305,6 +305,8 @@ public:
void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
/// Same as MouseButtonUp(), but coordinates are in logic unit.
void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
+ /// Allows adjusting the point or mark of the selection to a document coordinate.
+ void SetCursorLogicPosition(bool bPoint, const Point& rPosition);
};
#endif
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 70abbac57cbf..3a98cd955384 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3194,6 +3194,25 @@ void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
}
}
+void SwXTextDocument::setTextSelection(int nType, int nX, int nY)
+{
+ SolarMutexGuard aGuard;
+
+ SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
+ switch (nType)
+ {
+ case LOK_SETTEXTSELECTION_START:
+ rEditWin.SetCursorLogicPosition(/*bPoint=*/false, Point(nX, nY));
+ break;
+ case LOK_SETTEXTSELECTION_END:
+ rEditWin.SetCursorLogicPosition(/*bPoint=*/true, Point(nX, nY));
+ break;
+ default:
+ assert(false);
+ break;
+ }
+}
+
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
{
return SwXTextDocumentBaseClass::operator new(t);