include/LibreOfficeKit/LibreOfficeKit.h | 4 +++- libreofficekit/source/gtk/lokdocview.c | 3 +-- sw/source/uibase/docvw/edtwin.cxx | 4 +++- sw/source/uibase/inc/edtwin.hxx | 2 +- sw/source/uibase/uno/unotxdoc.cxx | 7 +++++-- 5 files changed, 13 insertions(+), 7 deletions(-)
New commits: commit 50da60dbe4fd8f0829676e0ef5a3acacf55802bb Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Feb 11 09:19:06 2015 +0100 LOK: add LOK_SETTEXTSELECTION_RESET So clients can perform a single method call to adjust the cursor position (when it's not a range), instead of sending two mouse clicks. This is mostly to be consistent, so that adjusting the cursor's middle and start/end handles all result in a setTextSelection() LOK call. Change-Id: I09eb0811887d173ea9ad7d125a2afb2c9e5c918c diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index eccf19b..9c5cca5 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -122,7 +122,9 @@ typedef enum /// The start of selection is to be adjusted. LOK_SETTEXTSELECTION_START, /// The end of selection is to be adjusted. - LOK_SETTEXTSELECTION_END + LOK_SETTEXTSELECTION_END, + /// Both the start and the end of selection is to be adjusted. + LOK_SETTEXTSELECTION_RESET } LibreOfficeKitSetTextSelectionType; diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c index 61d107c..132b2d4 100644 --- a/libreofficekit/source/gtk/lokdocview.c +++ b/libreofficekit/source/gtk/lokdocview.c @@ -74,8 +74,7 @@ gboolean lcl_signalMotion(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocVi { g_info("lcl_signalMotion: dragging the middle handle"); lcl_getDragPoint(&pDocView->m_aHandleMiddleRect, pEvent, &aPoint); - pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y), 1); - pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y), 1); + pDocView->pDocument->pClass->setTextSelection(pDocView->pDocument, LOK_SETTEXTSELECTION_RESET, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y)); } else if (pDocView->m_bInDragStartHandle) { diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index bb59217..53a1abb 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -6256,11 +6256,13 @@ void SwEditWin::LogicMouseButtonUp(const MouseEvent& rMouseEvent) MouseButtonUp(rMouseEvent); } -void SwEditWin::SetCursorLogicPosition(bool bPoint, const Point& rPosition) +void SwEditWin::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark) { // Not an SwWrtShell, as that would make SwCrsrShell::GetCrsr() inaccessible. SwEditShell& rShell = m_rView.GetWrtShell(); SwMvContext aMvContext(&rShell); + if (bClearMark) + rShell.ClearMark(); // 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) diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx index 9af9446..4e8ff48 100644 --- a/sw/source/uibase/inc/edtwin.hxx +++ b/sw/source/uibase/inc/edtwin.hxx @@ -306,7 +306,7 @@ public: /// 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); + void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark); }; #endif diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 3a98cd9..88320e8 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3202,10 +3202,13 @@ void SwXTextDocument::setTextSelection(int nType, int nX, int nY) switch (nType) { case LOK_SETTEXTSELECTION_START: - rEditWin.SetCursorLogicPosition(/*bPoint=*/false, Point(nX, nY)); + rEditWin.SetCursorLogicPosition(Point(nX, nY), /*bPoint=*/false, /*bClearMark=*/false); break; case LOK_SETTEXTSELECTION_END: - rEditWin.SetCursorLogicPosition(/*bPoint=*/true, Point(nX, nY)); + rEditWin.SetCursorLogicPosition(Point(nX, nY), /*bPoint=*/true, /*bClearMark=*/false); + break; + case LOK_SETTEXTSELECTION_RESET: + rEditWin.SetCursorLogicPosition(Point(nX, nY), /*bPoint=*/true, /*bClearMark=*/true); break; default: assert(false); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits