diff options
author | Khaled Hosny <khaled@libreoffice.org> | 2023-09-05 20:24:13 +0300 |
---|---|---|
committer | خالد حسني <khaled@libreoffice.org> | 2023-09-05 20:28:34 +0200 |
commit | ee187f6ed7873f3ebc1f845a4384a84713be1e9c (patch) | |
tree | 263663df8a2debf9ebeb71aacfac58569154465d /starmath | |
parent | 15e0dfe709636b517bc1876caa3853606d9b499c (diff) |
starmath: Always insert using SmCursor when inline editing is enabled
Choosing which code path based on which widget has focus is not a very
good idea, and leads to unreliable UI tests as each code path inserts
the text slightly differently (one code path inserts plain text then
parses the whole equation again, while the other parses the new text
then inserts the parsed node directly).
Change-Id: Ib2ca942c537e466f6ff100be7f95adaead99f1d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156578
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/view.hxx | 14 | ||||
-rw-r--r-- | starmath/source/edit.cxx | 4 | ||||
-rw-r--r-- | starmath/source/view.cxx | 29 |
3 files changed, 13 insertions, 34 deletions
diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index dc42dde2fdc9..4a79b94e4f02 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -249,11 +249,6 @@ class SmViewShell final : public SfxViewShell SmGraphicController maGraphicController; OUString maStatusText; bool mbPasteState; - /** Used to determine whether insertions using SID_INSERTSPECIAL and SID_INSERTCOMMANDTEXT - * should be inserted into SmEditWindow or directly into the SmDocShell as done if the - * visual editor was last to have focus. - */ - bool mbInsertIntoEditWindow; DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper*, void ); virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; @@ -337,15 +332,6 @@ public: void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions, tools::Rectangle aOutRect ); - /** Set bInsertIntoEditWindow so we know where to insert - * - * This method is called whenever SmGraphicWidget or SmEditWindow gets focus, - * so that when text is inserted from catalog or elsewhere we know whether to - * insert for the visual editor, or the text editor. - */ - void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast){ - mbInsertIntoEditWindow = bEditWindowHadFocusLast; - } static bool IsInlineEditEnabled(); // Opens the main help page for the Math module diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index 4cb4f6532f64..90cb6cd5498a 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -556,10 +556,6 @@ void SmEditTextWindow::GetFocus() EditEngine *pEditEngine = GetEditEngine(); if (pEditEngine) pEditEngine->SetStatusEventHdl(LINK(this, SmEditTextWindow, EditStatusHdl)); - - //Let SmViewShell know we got focus - if (mrEditWindow.GetView() && SmViewShell::IsInlineEditEnabled()) - mrEditWindow.GetView()->SetInsertIntoEditWindow(true); } void SmEditTextWindow::LoseFocus() diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 22ca4e575d3b..eacab22901ad 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -424,8 +424,6 @@ void SmGraphicWidget::GetFocus() return; if (SmEditWindow* pEdit = GetView().GetEditWindow()) pEdit->Flush(); - //Let view shell know what insertions should be done in visual editor - GetView().SetInsertIntoEditWindow(false); SetIsCursorVisible(true); ShowLine(true); CaretBlinkStart(); @@ -1784,7 +1782,7 @@ void SmViewShell::Execute(SfxRequest& rReq) case SID_CUT: - if (IsInlineEditEnabled() && !mbInsertIntoEditWindow) + if (IsInlineEditEnabled()) { GetDoc()->GetCursor().Cut(); GetGraphicWidget().GrabFocus(); @@ -1794,7 +1792,7 @@ void SmViewShell::Execute(SfxRequest& rReq) break; case SID_COPY: - if (IsInlineEditEnabled() && !mbInsertIntoEditWindow) + if (IsInlineEditEnabled()) { GetDoc()->GetCursor().Copy(); GetGraphicWidget().GrabFocus(); @@ -1814,7 +1812,7 @@ void SmViewShell::Execute(SfxRequest& rReq) case SID_PASTE: { - if (IsInlineEditEnabled() && !mbInsertIntoEditWindow) + if (IsInlineEditEnabled()) { GetDoc()->GetCursor().Paste(); GetGraphicWidget().GrabFocus(); @@ -1847,7 +1845,7 @@ void SmViewShell::Execute(SfxRequest& rReq) break; case SID_DELETE: - if (IsInlineEditEnabled() && !mbInsertIntoEditWindow) + if (IsInlineEditEnabled()) { if (!GetDoc()->GetCursor().HasSelection()) { @@ -1872,15 +1870,15 @@ void SmViewShell::Execute(SfxRequest& rReq) { const SfxStringItem& rItem = rReq.GetArgs()->Get(SID_INSERTCOMMANDTEXT); - if (pWin && (mbInsertIntoEditWindow || !IsInlineEditEnabled())) - { - pWin->InsertText(rItem.GetValue()); - } - if (IsInlineEditEnabled() && (GetDoc() && !mbInsertIntoEditWindow)) + if (IsInlineEditEnabled()) { GetDoc()->GetCursor().InsertCommandText(rItem.GetValue()); GetGraphicWidget().GrabFocus(); } + else if (pWin) + { + pWin->InsertText(rItem.GetValue()); + } break; } @@ -1889,10 +1887,10 @@ void SmViewShell::Execute(SfxRequest& rReq) { const SfxStringItem& rItem = rReq.GetArgs()->Get(SID_INSERTSPECIAL); - if (pWin && (mbInsertIntoEditWindow || !IsInlineEditEnabled())) - pWin->InsertText(rItem.GetValue()); - if (IsInlineEditEnabled() && (GetDoc() && !mbInsertIntoEditWindow)) + if (IsInlineEditEnabled()) GetDoc()->GetCursor().InsertSpecial(rItem.GetValue()); + else if (pWin) + pWin->InsertText(rItem.GetValue()); break; } @@ -2142,7 +2140,7 @@ void SmViewShell::GetState(SfxItemSet &rSet) case SID_CUT: case SID_COPY: case SID_DELETE: - if (IsInlineEditEnabled() && !mbInsertIntoEditWindow) + if (IsInlineEditEnabled()) { if (!GetDoc()->GetCursor().HasSelection()) rSet.DisableItem(nWh); @@ -2308,7 +2306,6 @@ SmViewShell::SmViewShell(SfxViewFrame& rFrame_, SfxViewShell *) , mxGraphicWindow(VclPtr<SmGraphicWindow>::Create(*this)) , maGraphicController(mxGraphicWindow->GetGraphicWidget(), SID_GRAPHIC_SM, rFrame_.GetBindings()) , mbPasteState(false) - , mbInsertIntoEditWindow(false) { SetStatusText(OUString()); SetWindow(mxGraphicWindow.get()); |