From 049bbd95c190e0844da3a8dd88b1ce7a9ccf83b7 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 20 Jan 2024 15:04:43 +0900 Subject: editeng: change EditEngine getter to ref in {Imp}EditView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit {Imp}EditView always needs to have EditEngine set (or it would crash otherwise), so we can change the getter to return a referece instead of a pointer. This simplifies things a bit because we get rid of all the nullptr checks and makes the interface more clear. Also change direct access to mpEditEngine in {Imp}EditView to use getEditEngine() and getImpEditEngine() (returning a reference) instead. Change-Id: Ib8f9c565b8364144bb9c35c3093c4975af1970c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162333 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl --- starmath/source/edit.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'starmath') diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index bc1138a18d44..f36634a16b14 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -312,7 +312,7 @@ bool SmEditTextWindow::KeyInput(const KeyEvent& rKEvt) // as we don't support RTL in Math, we need to swap values from selection when they were done // in RTL form aSelection.Adjust(); - OUString selected = pEditView->GetEditEngine()->GetText(aSelection); + OUString selected = pEditView->getEditEngine().GetText(aSelection); // Check is auto close brackets/braces is disabled SmModule *pMod = SM_MOD(); @@ -322,7 +322,7 @@ bool SmEditTextWindow::KeyInput(const KeyEvent& rKEvt) autoClose = true; else if (selected.isEmpty() && !aSelection.HasRange()) { - selected = pEditView->GetEditEngine()->GetText(aSelection.nEndPara); + selected = pEditView->getEditEngine().GetText(aSelection.nEndPara); if (!selected.isEmpty()) { sal_Int32 index = selected.indexOf("\n", aSelection.nEndPos); @@ -543,7 +543,7 @@ void SmEditTextWindow::SetText(const OUString& rText) aModifyIdle.Start(); // Apply zoom to smeditwindow text - static_cast(pEditView->GetEditEngine())->executeZoom(pEditView); + static_cast(pEditView->getEditEngine()).executeZoom(pEditView); pEditView->SetSelection(eSelection); } @@ -780,7 +780,7 @@ void SmEditTextWindow::InsertText(const OUString& rText) // Note: Insertion of a space in front of commands is done here and // in SmEditWindow::InsertCommand. ESelection aSelection = pEditView->GetSelection(); - OUString aCurrentFormula = pEditView->GetEditEngine()->GetText(); + OUString aCurrentFormula = pEditView->getEditEngine().GetText(); sal_Int32 nStartIndex = 0; // get the start position (when we get a multi line formula) @@ -850,11 +850,9 @@ void SmEditWindow::DeleteEditView() { if (EditView* pEditView = GetEditView()) { - if (EditEngine* pEditEngine = pEditView->GetEditEngine()) - { - pEditEngine->SetStatusEventHdl( Link() ); - pEditEngine->RemoveView(pEditView); - } + EditEngine& rEditEngine = pEditView->getEditEngine(); + rEditEngine.SetStatusEventHdl( Link() ); + rEditEngine.RemoveView(pEditView); mxTextControlWin.reset(); mxTextControl.reset(); } -- cgit