starmath/inc/cursor.hxx | 1 - starmath/inc/view.hxx | 2 ++ starmath/source/cursor.cxx | 7 ------- starmath/source/edit.cxx | 5 +---- starmath/source/view.cxx | 28 +++++++++++----------------- 5 files changed, 14 insertions(+), 29 deletions(-)
New commits: commit beaea2e992912b4747d790070b26371f557b1f57 Author: Khaled Hosny <kha...@libreoffice.org> AuthorDate: Thu Sep 7 19:19:56 2023 +0300 Commit: خالد حسني <kha...@libreoffice.org> CommitDate: Thu Sep 7 23:54:46 2023 +0200 starmath: Properly update the state to copy/cut/paste buttons Invalidate the slots explicitly instead of implicitly by updating the edit window. Followup to: commit 065609f86f730d4eedc6b7ae28382dc7daea11ac Author: Khaled Hosny <kha...@libreoffice.org> Date: Mon Sep 4 13:22:04 2023 +0300 starmath: Make cut/copy/paste buttons work with inline editing Change-Id: If0648c249d6145475202e1a48364d7fe142a5e35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156674 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@libreoffice.org> diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx index 7e1f8ec83c53..0a8a35071f10 100644 --- a/starmath/inc/cursor.hxx +++ b/starmath/inc/cursor.hxx @@ -85,7 +85,6 @@ public: /** True, if the cursor has a selection */ bool HasSelection() const { return mpAnchor != mpPosition; } - const ESelection& GetSelection(); /** Move the position of this cursor */ void Move(OutputDevice* pDev, SmMovementDirection direction, bool bMoveAnchor = true); diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index 4a79b94e4f02..a896cd41bf2d 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -321,6 +321,8 @@ public: void SendCaretToLOK() const; + void InvalidateSlots(); + private: /// SfxInterface initializer. static void InitInterface_Impl(); diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index 41506dff3109..e8623517bcd7 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -1141,13 +1141,6 @@ SmNode* SmCursor::FindSelectedNode(SmNode* pNode){ return nullptr; } -const ESelection& SmCursor::GetSelection() { - const SmNode* pNode = FindSelectedNode(mpTree); - if (!pNode) - return mpTree->GetSelection(); - return pNode->GetSelection(); -} - void SmCursor::LineToList(SmStructureNode* pLine, SmNodeList& list){ for(auto pChild : *pLine) { diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index 90cb6cd5498a..77ab710fab69 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -160,10 +160,7 @@ void SmEditTextWindow::StartCursorMove() void SmEditWindow::InvalidateSlots() { - SfxBindings& rBind = GetView()->GetViewFrame().GetBindings(); - rBind.Invalidate(SID_COPY); - rBind.Invalidate(SID_CUT); - rBind.Invalidate(SID_DELETE); + GetView()->InvalidateSlots(); } SmViewShell * SmEditWindow::GetView() diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index eacab22901ad..2800e06ba387 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -371,10 +371,8 @@ bool SmGraphicWidget::MouseButtonDown(const MouseEvent& rMEvt) SmEditWindow* pEdit = GetView().GetEditWindow(); if (SmViewShell::IsInlineEditEnabled()) { - SmCursor& rCursor = GetCursor(); - rCursor.MoveTo(&rDevice, aPos, !rMEvt.IsShift()); - if (pEdit) - pEdit->SetSelection(rCursor.GetSelection()); + GetCursor().MoveTo(&rDevice, aPos, !rMEvt.IsShift()); + GetView().InvalidateSlots(); // 'on grab' window events are missing in lok, do it explicitly if (comphelper::LibreOfficeKit::isActive()) SetIsCursorVisible(true); @@ -715,7 +713,6 @@ bool SmGraphicWidget::KeyInput(const KeyEvent& rKEvt) return GetView().KeyInput(rKEvt); bool bConsumed = true; - bool bSetSelection = false; SmCursor& rCursor = GetCursor(); switch (rKEvt.GetKeyCode().GetFunction()) @@ -740,32 +737,24 @@ bool SmGraphicWidget::KeyInput(const KeyEvent& rKEvt) { case KEY_LEFT: rCursor.Move(&GetOutputDevice(), MoveLeft, !rKEvt.GetKeyCode().IsShift()); - bSetSelection = true; break; case KEY_RIGHT: rCursor.Move(&GetOutputDevice(), MoveRight, !rKEvt.GetKeyCode().IsShift()); - bSetSelection = true; break; case KEY_UP: rCursor.Move(&GetOutputDevice(), MoveUp, !rKEvt.GetKeyCode().IsShift()); - bSetSelection = true; break; case KEY_DOWN: rCursor.Move(&GetOutputDevice(), MoveDown, !rKEvt.GetKeyCode().IsShift()); - bSetSelection = true; break; case KEY_RETURN: if (!rKEvt.GetKeyCode().IsShift()) - { rCursor.InsertRow(); - bSetSelection = true; - } break; case KEY_DELETE: if (!rCursor.HasSelection()) { rCursor.Move(&GetOutputDevice(), MoveRight, false); - bSetSelection = true; if (rCursor.HasComplexSelection()) break; } @@ -773,7 +762,6 @@ bool SmGraphicWidget::KeyInput(const KeyEvent& rKEvt) break; case KEY_BACKSPACE: rCursor.DeletePrev(&GetOutputDevice()); - bSetSelection = true; break; default: if (!CharInput(rKEvt.GetCharCode(), rCursor, GetOutputDevice())) @@ -781,9 +769,7 @@ bool SmGraphicWidget::KeyInput(const KeyEvent& rKEvt) } } - SmEditWindow* pEdit = GetView().GetEditWindow(); - if (pEdit && bSetSelection) - pEdit->SetSelection(rCursor.GetSelection()); + GetView().InvalidateSlots(); CaretBlinkStop(); CaretBlinkStart(); SetIsCursorVisible(true); @@ -2511,4 +2497,12 @@ void SmViewShell::SendCaretToLOK() const } } +void SmViewShell::InvalidateSlots() +{ + auto& rBind = GetViewFrame().GetBindings(); + rBind.Invalidate(SID_COPY); + rBind.Invalidate(SID_CUT); + rBind.Invalidate(SID_DELETE); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */