summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-01-20 15:04:43 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-01-21 00:54:54 +0100
commit049bbd95c190e0844da3a8dd88b1ce7a9ccf83b7 (patch)
treebd19faddc850498494539d1899c6a7b9e848ad3a /sc
parent06aea80b0482c03e8f0a5f735d3a31ec816a07fe (diff)
editeng: change EditEngine getter to ref in {Imp}EditView
{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 <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx4
-rw-r--r--sc/source/ui/Accessibility/AccessibleEditObject.cxx4
-rw-r--r--sc/source/ui/Accessibility/AccessibleText.cxx17
-rw-r--r--sc/source/ui/app/inputhdl.cxx53
-rw-r--r--sc/source/ui/app/inputwin.cxx14
-rw-r--r--sc/source/ui/docshell/docsh4.cxx2
-rw-r--r--sc/source/ui/view/cellsh3.cxx2
-rw-r--r--sc/source/ui/view/editsh.cxx58
-rw-r--r--sc/source/ui/view/gridwin.cxx10
-rw-r--r--sc/source/ui/view/gridwin4.cxx13
-rw-r--r--sc/source/ui/view/spelldialog.cxx2
-rw-r--r--sc/source/ui/view/tabview3.cxx3
-rw-r--r--sc/source/ui/view/viewdata.cxx31
13 files changed, 104 insertions, 109 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index c309f1b1fe66..e8010b387393 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -1495,8 +1495,8 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
if (mpViewShell->GetViewData().GetEditActivePart() == meSplitPos)
{
ScViewData& rViewData = mpViewShell->GetViewData();
- const EditEngine* pEditEng = rViewData.GetEditView(meSplitPos)->GetEditEngine();
- if (pEditEng && pEditEng->IsUpdateLayout())
+ EditEngine const& rEditEng = rViewData.GetEditView(meSplitPos)->getEditEngine();
+ if (rEditEng.IsUpdateLayout())
{
mpTempAccEdit = new ScAccessibleEditObject(this, rViewData.GetEditView(meSplitPos),
mpViewShell->GetWindowByPos(meSplitPos), GetCurrentCellName(),
diff --git a/sc/source/ui/Accessibility/AccessibleEditObject.cxx b/sc/source/ui/Accessibility/AccessibleEditObject.cxx
index 7e58af04ef66..3b1eaf532d7a 100644
--- a/sc/source/ui/Accessibility/AccessibleEditObject.cxx
+++ b/sc/source/ui/Accessibility/AccessibleEditObject.cxx
@@ -191,9 +191,9 @@ AbsoluteScreenPixelRectangle ScAccessibleEditObject::GetBoundingBoxOnScreen() co
{
if ( meObjectType == CellInEditMode )
{
- if ( mpEditView && mpEditView->GetEditEngine() )
+ if (mpEditView)
{
- MapMode aMapMode( mpEditView->GetEditEngine()->GetRefMapMode() );
+ MapMode aMapMode(mpEditView->getEditEngine().GetRefMapMode());
tools::Rectangle aScreenBoundsLog = mpWindow->LogicToPixel( mpEditView->GetOutputArea(), aMapMode );
Point aCellLoc = aScreenBoundsLog.TopLeft();
AbsoluteScreenPixelRectangle aWindowRect = mpWindow->GetWindowExtentsAbsolute();
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx
index 52d5257af8cc..413cf831467b 100644
--- a/sc/source/ui/Accessibility/AccessibleText.cxx
+++ b/sc/source/ui/Accessibility/AccessibleText.cxx
@@ -658,10 +658,9 @@ ScDocShell* ScAccessibleCellTextData::GetDocShell(ScTabViewShell* pViewShell)
}
ScAccessibleEditObjectTextData::ScAccessibleEditObjectTextData(EditView* pEditView, OutputDevice* pWin, bool isClone)
- :
- mpEditView(pEditView),
- mpEditEngine(pEditView ? pEditView->GetEditEngine() : nullptr),
- mpWindow(pWin)
+ : mpEditView(pEditView)
+ , mpEditEngine(pEditView ? &pEditView->getEditEngine() : nullptr)
+ , mpWindow(pWin)
{
// If the object is cloned, do NOT add notify hdl.
mbIsCloned = isClone;
@@ -706,7 +705,7 @@ SvxTextForwarder* ScAccessibleEditObjectTextData::GetTextForwarder()
if ((!mpForwarder && mpEditView) || (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet()))
{
if (!mpEditEngine)
- mpEditEngine = mpEditView->GetEditEngine();
+ mpEditEngine = &mpEditView->getEditEngine();
// If the object is cloned, do NOT add notify hdl.
if (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet()&&!mbIsCloned)
mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
@@ -769,12 +768,12 @@ ScAccessibleEditLineTextData::~ScAccessibleEditLineTextData()
delete mpEditEngine;
mpEditEngine = nullptr; // don't access in ScAccessibleEditObjectTextData dtor!
}
- else if (mpTxtWnd && mpTxtWnd->HasEditView() && mpTxtWnd->GetEditView()->GetEditEngine())
+ else if (mpTxtWnd && mpTxtWnd->HasEditView())
{
// the NotifyHdl also has to be removed from the ScTextWnd's EditEngine
// (it's set in ScAccessibleEditLineTextData::GetTextForwarder, and mpEditEngine
// is reset there)
- mpTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link<EENotify&,void>());
+ mpTxtWnd->GetEditView()->getEditEngine().SetNotifyHdl(Link<EENotify&,void>());
}
}
@@ -868,8 +867,8 @@ void ScAccessibleEditLineTextData::ResetEditMode()
{
if (mbEditEngineCreated && mpEditEngine)
delete mpEditEngine;
- else if (mpTxtWnd && mpTxtWnd->HasEditView() && mpTxtWnd->GetEditView()->GetEditEngine())
- mpTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link<EENotify&,void>());
+ else if (mpTxtWnd && mpTxtWnd->HasEditView())
+ mpTxtWnd->GetEditView()->getEditEngine().SetNotifyHdl(Link<EENotify&,void>());
mpEditEngine = nullptr;
mpForwarder.reset();
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index bec8a2cbe6da..af4e01fec9ec 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -635,15 +635,15 @@ static void lcl_Replace( EditView* pView, const OUString& rNewStr, const ESelect
pView->SetSelection( ESelection( aOldSel.nEndPara, aOldSel.nEndPos,
aOldSel.nEndPara, aOldSel.nEndPos ) );
- EditEngine* pEngine = pView->GetEditEngine();
- pEngine->QuickInsertText( rNewStr, rOldSel );
+ EditEngine& rEngine = pView->getEditEngine();
+ rEngine.QuickInsertText( rNewStr, rOldSel );
// Dummy InsertText for Update and Paint
// To do that we need to cancel the selection from above (before QuickInsertText)
pView->InsertText( OUString() );
- const sal_Int32 nPara = pEngine->GetParagraphCount() - 1;
- const sal_Int32 nLen = pEngine->GetTextLen(nPara);
+ const sal_Int32 nPara = rEngine.GetParagraphCount() - 1;
+ const sal_Int32 nLen = rEngine.GetTextLen(nPara);
ESelection aSel( nPara, nLen, nPara, nLen );
pView->SetSelection( aSel ); // Set cursor to the end
}
@@ -1640,7 +1640,7 @@ void completeFunction( EditView* pView, const OUString& rInsert, bool& rParInser
ESelection aSel = pView->GetSelection();
bool bNoInitialLetter = false;
- OUString aOld = pView->GetEditEngine()->GetText(0);
+ OUString aOld = pView->getEditEngine().GetText(0);
// in case we want just insert a function and not completing
if ( comphelper::LibreOfficeKit::isActive() )
{
@@ -1775,10 +1775,9 @@ void ScInputHandler::LOKPasteFunctionData(const OUString& rFunctionName)
bool bEdit = false;
OUString aFormula;
- const EditEngine* pEditEngine = pEditView->GetEditEngine();
- if (pEditEngine)
+ EditEngine const& rEditEngine = pEditView->getEditEngine();
{
- aFormula = pEditEngine->GetText(0);
+ aFormula = rEditEngine.GetText(0);
/* TODO: LOK: are you sure you want '+' and '-' let start formulas with
* function names? That was meant for "data typist" numeric keyboard
* input. */
@@ -2661,22 +2660,22 @@ static void lcl_SetTopSelection( EditView* pEditView, ESelection& rSel )
{
OSL_ENSURE( rSel.nStartPara==0 && rSel.nEndPara==0, "SetTopSelection: Para != 0" );
- EditEngine* pEngine = pEditView->GetEditEngine();
- sal_Int32 nCount = pEngine->GetParagraphCount();
+ EditEngine& rEngine = pEditView->getEditEngine();
+ sal_Int32 nCount = rEngine.GetParagraphCount();
if (nCount > 1)
{
- sal_Int32 nParLen = pEngine->GetTextLen(rSel.nStartPara);
+ sal_Int32 nParLen = rEngine.GetTextLen(rSel.nStartPara);
while (rSel.nStartPos > nParLen && rSel.nStartPara+1 < nCount)
{
rSel.nStartPos -= nParLen + 1; // Including space from line break
- nParLen = pEngine->GetTextLen(++rSel.nStartPara);
+ nParLen = rEngine.GetTextLen(++rSel.nStartPara);
}
- nParLen = pEngine->GetTextLen(rSel.nEndPara);
+ nParLen = rEngine.GetTextLen(rSel.nEndPara);
while (rSel.nEndPos > nParLen && rSel.nEndPara+1 < nCount)
{
rSel.nEndPos -= nParLen + 1; // Including space from line break
- nParLen = pEngine->GetTextLen(++rSel.nEndPara);
+ nParLen = rEngine.GetTextLen(++rSel.nEndPara);
}
}
@@ -2753,7 +2752,7 @@ void ScInputHandler::DataChanged( bool bFromTopNotify, bool bSetModified )
{
// table EditEngine is formatted below, input line needs formatting after paste
// #i20282# not when called from the input line's modify handler
- pTopView->GetEditEngine()->QuickFormatDoc( true );
+ pTopView->getEditEngine().QuickFormatDoc( true );
// #i23720# QuickFormatDoc hides the cursor, but can't show it again because it
// can't safely access the EditEngine's current view, so the cursor has to be
@@ -3085,11 +3084,11 @@ static void lcl_SelectionToEnd( EditView* pView )
{
if ( pView )
{
- EditEngine* pEngine = pView->GetEditEngine();
- sal_Int32 nParCnt = pEngine->GetParagraphCount();
+ EditEngine& rEngine = pView->getEditEngine();
+ sal_Int32 nParCnt = rEngine.GetParagraphCount();
if ( nParCnt == 0 )
nParCnt = 1;
- ESelection aSel( nParCnt-1, pEngine->GetTextLen(nParCnt-1) ); // empty selection, cursor at the end
+ ESelection aSel( nParCnt-1, rEngine.GetTextLen(nParCnt-1) ); // empty selection, cursor at the end
pView->SetSelection( aSel );
}
}
@@ -3762,12 +3761,12 @@ void ScInputHandler::ClearText()
if (pTableView)
{
- pTableView->GetEditEngine()->SetText( "" );
+ pTableView->getEditEngine().SetText( "" );
pTableView->SetSelection( ESelection(0,0, 0,0) );
}
if (pTopView)
{
- pTopView->GetEditEngine()->SetText( "" );
+ pTopView->getEditEngine().SetText( "" );
pTopView->SetSelection( ESelection(0,0, 0,0) );
}
@@ -3957,7 +3956,7 @@ bool ScInputHandler::KeyInput( const KeyEvent& rKEvt, bool bStartEdit /* = false
if (pTableView)
{
- pTableView->GetEditEngine()->SetText( aStrLoP );
+ pTableView->getEditEngine().SetText( aStrLoP );
if ( !aStrLoP.isEmpty() )
pTableView->SetSelection( ESelection(0,0, 0,0) ); // before the '%'
@@ -3966,7 +3965,7 @@ bool ScInputHandler::KeyInput( const KeyEvent& rKEvt, bool bStartEdit /* = false
}
if (pTopView)
{
- pTopView->GetEditEngine()->SetText( aStrLoP );
+ pTopView->getEditEngine().SetText( aStrLoP );
if ( !aStrLoP.isEmpty() )
pTopView->SetSelection( ESelection(0,0, 0,0) ); // before the '%'
}
@@ -4181,12 +4180,12 @@ void ScInputHandler::InputCommand( const CommandEvent& rCEvt )
{
if (pTableView)
{
- pTableView->GetEditEngine()->SetText( "" );
+ pTableView->getEditEngine().SetText( "" );
pTableView->SetSelection( ESelection(0,0, 0,0) );
}
if (pTopView)
{
- pTopView->GetEditEngine()->SetText( "" );
+ pTopView->getEditEngine().SetText( "" );
pTopView->SetSelection( ESelection(0,0, 0,0) );
}
}
@@ -4524,7 +4523,7 @@ void ScInputHandler::InputChanged( const EditView* pView, bool bFromNotify )
bool bFromTopNotify = ( bFromNotify && pView == pTopView );
bool bNewView = DataChanging(); //FIXME: Is this at all possible?
- aCurrentText = pView->GetEditEngine()->GetText(); // Also remember the string
+ aCurrentText = pView->getEditEngine().GetText(); // Also remember the string
mpEditEngine->SetTextCurrentDefaults( aCurrentText );
DataChanged( bFromTopNotify );
bTextValid = true; // Is set to false in DataChanged
@@ -4625,7 +4624,7 @@ EditView* ScInputHandler::GetFuncEditView()
SetMode( SC_INPUT_TABLE );
bCreatingFuncView = false;
if ( pTableView )
- pTableView->GetEditEngine()->SetText( OUString() );
+ pTableView->getEditEngine().SetText( OUString() );
}
pView = pTableView;
}
@@ -4677,7 +4676,7 @@ void ScInputHandler::InputReplaceSelection( std::u16string_view aStr )
if (pView)
{
pView->SetEditEngineUpdateLayout( false );
- pView->GetEditEngine()->SetText( aFormText );
+ pView->getEditEngine().SetText( aFormText );
pView->SetSelection( ESelection(0,nFormSelStart, 0,nFormSelEnd) );
pView->SetEditEngineUpdateLayout( true );
}
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7f0cf742b05d..3aa9a36c5af0 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -428,9 +428,9 @@ void ScInputWindow::StartFormula()
TextGrabFocus();
if (pViewSh && !pViewSh->isLOKDesktop())
{
- nStartPara = nEndPara = pView->GetEditEngine()->GetParagraphCount() ?
- (pView->GetEditEngine()->GetParagraphCount() - 1) : 0;
- nStartPos = nEndPos = pView->GetEditEngine()->GetTextLen(nStartPara);
+ nStartPara = nEndPara = pView->getEditEngine().GetParagraphCount() ?
+ (pView->getEditEngine().GetParagraphCount() - 1) : 0;
+ nStartPos = nEndPos = pView->getEditEngine().GetTextLen(nStartPara);
}
}
pView->SetSelection(ESelection(nStartPara, nStartPos, nEndPara, nEndPos));
@@ -675,8 +675,8 @@ void ScInputWindow::SwitchToTextWin()
EditView* pView = mxTextWindow->GetEditView();
if (pView)
{
- sal_Int32 nPara = pView->GetEditEngine()->GetParagraphCount() ? ( pView->GetEditEngine()->GetParagraphCount() - 1 ) : 0;
- sal_Int32 nLen = pView->GetEditEngine()->GetTextLen( nPara );
+ sal_Int32 nPara = pView->getEditEngine().GetParagraphCount() ? ( pView->getEditEngine().GetParagraphCount() - 1 ) : 0;
+ sal_Int32 nLen = pView->getEditEngine().GetTextLen( nPara );
ESelection aSel( nPara, nLen, nPara, nLen );
pView->SetSelection( aSel ); // set cursor to end of text
}
@@ -1406,7 +1406,7 @@ void ScTextWnd::Resize()
int ScTextWnd::GetEditEngTxtHeight() const
{
- return m_xEditView ? m_xEditView->GetEditEngine()->GetTextHeight() : 0;
+ return m_xEditView ? m_xEditView->getEditEngine().GetTextHeight() : 0;
}
void ScTextWnd::SetScrollBarRange()
@@ -1524,7 +1524,7 @@ static void lcl_ModifyRTLDefaults( SfxItemSet& rSet )
static void lcl_ModifyRTLVisArea( EditView* pEditView )
{
tools::Rectangle aVisArea = pEditView->GetVisArea();
- Size aPaper = pEditView->GetEditEngine()->GetPaperSize();
+ Size aPaper = pEditView->getEditEngine().GetPaperSize();
tools::Long nDiff = aPaper.Width() - aVisArea.Right();
aVisArea.AdjustLeft(nDiff );
aVisArea.AdjustRight(nDiff );
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index bfe14b6aa138..e6fa6417dacb 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1331,7 +1331,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
const LanguageType nLangToUse = SvtLanguageTable::GetLanguageType( aLangText );
SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
- SfxItemSet aAttrs = pEditView->GetEditEngine()->GetEmptyItemSet();
+ SfxItemSet aAttrs = pEditView->getEditEngine().GetEmptyItemSet();
if (nScriptType == SvtScriptType::LATIN)
aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
if (nScriptType == SvtScriptType::COMPLEX)
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index b7bd2daa4450..7032a1094dad 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -300,7 +300,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
EditView* pTableView = pHdl->GetActiveView();
pHdl->DataChanging();
if (pTableView)
- pTableView->GetEditEngine()->SetText(aStr);
+ pTableView->getEditEngine().SetText(aStr);
pHdl->DataChanged();
SC_MOD()->SetInputMode(SC_INPUT_NONE);
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index c392f111e203..f9e3fededd5a 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -100,8 +100,8 @@ ScEditShell::ScEditShell(EditView* pView, ScViewData& rData) :
bPastePossible (false),
bIsInsertMode (true)
{
- SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() );
- SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() );
+ SetPool( pEditView->getEditEngine().GetEmptyItemSet().GetPool() );
+ SetUndoManager( &pEditView->getEditEngine().GetUndoManager() );
SetName("EditCell");
SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::EditCell));
}
@@ -127,13 +127,13 @@ void ScEditShell::SetEditView(EditView* pView)
{
pEditView = pView;
pEditView->SetInsertMode( bIsInsertMode );
- SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() );
- SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() );
+ SetPool( pEditView->getEditEngine().GetEmptyItemSet().GetPool() );
+ SetUndoManager( &pEditView->getEditEngine().GetUndoManager() );
}
static void lcl_RemoveAttribs( EditView& rEditView )
{
- ScEditEngineDefaulter* pEngine = static_cast<ScEditEngineDefaulter*>(rEditView.GetEditEngine());
+ ScEditEngineDefaulter* pEngine = static_cast<ScEditEngineDefaulter*>(&rEditView.getEditEngine());
bool bOld = pEngine->SetUpdateLayout(false);
@@ -182,7 +182,7 @@ void ScEditShell::Execute( SfxRequest& rReq )
if (!pTableView)
return;
- EditEngine* pEngine = pTableView->GetEditEngine();
+ EditEngine& rEngine = pTableView->getEditEngine();
pHdl->DataChanging();
bool bSetSelIsRef = false;
@@ -320,10 +320,10 @@ void ScEditShell::Execute( SfxRequest& rReq )
case SID_SELECTALL:
{
- sal_Int32 nPar = pEngine->GetParagraphCount();
+ sal_Int32 nPar = rEngine.GetParagraphCount();
if (nPar)
{
- sal_Int32 nLen = pEngine->GetTextLen(nPar-1);
+ sal_Int32 nLen = rEngine.GetTextLen(nPar-1);
pTableView->SetSelection(ESelection(0,0,nPar-1,nLen));
if (pTopView)
pTopView->SetSelection(ESelection(0,0,nPar-1,nLen));
@@ -346,7 +346,7 @@ void ScEditShell::Execute( SfxRequest& rReq )
EditView* pActiveView = pHdl->GetActiveView();
if( pActiveView )
{
- OUString sInput = pEngine->GetText();
+ OUString sInput = rEngine.GetText();
ESelection aSel( pActiveView->GetSelection() );
if( aSel.HasRange() )
sInput = pActiveView->GetSelected();
@@ -447,7 +447,7 @@ void ScEditShell::Execute( SfxRequest& rReq )
aSet.Put( aSetItem.GetItemSet(), false );
// SetAttribs on the View selects a word, when nothing is selected
- pTableView->GetEditEngine()->QuickSetAttribs( aSet, pTableView->GetSelection() );
+ pTableView->getEditEngine().QuickSetAttribs( aSet, pTableView->GetSelection() );
pTableView->InsertText(aString);
if (pTopView)
pTopView->InsertText(aString);
@@ -533,9 +533,9 @@ void ScEditShell::Execute( SfxRequest& rReq )
case SID_TOGGLE_REL:
{
/* TODO: MLFORMULA: this should work also with multi-line formulas. */
- if (pEngine->GetParagraphCount() == 1)
+ if (rEngine.GetParagraphCount() == 1)
{
- OUString aText = pEngine->GetText();
+ OUString aText = rEngine.GetText();
ESelection aSel = pEditView->GetSelection(); // current View
ScDocument& rDoc = rViewData.GetDocument();
@@ -545,11 +545,11 @@ void ScEditShell::Execute( SfxRequest& rReq )
{
const OUString& aNew = aFinder.GetText();
ESelection aNewSel( 0,aFinder.GetSelStart(), 0,aFinder.GetSelEnd() );
- pEngine->SetText( aNew );
+ rEngine.SetText( aNew );
pTableView->SetSelection( aNewSel );
if ( pTopView )
{
- pTopView->GetEditEngine()->SetText( aNew );
+ pTopView->getEditEngine().SetText( aNew );
pTopView->SetSelection( aNewSel );
}
@@ -620,10 +620,10 @@ void ScEditShell::Execute( SfxRequest& rReq )
{
if (bCellLinksOnly)
{
- sal_Int32 nPar = pEngine->GetParagraphCount();
+ sal_Int32 nPar = rEngine.GetParagraphCount();
if (nPar)
{
- sal_Int32 nLen = pEngine->GetTextLen(nPar - 1);
+ sal_Int32 nLen = rEngine.GetTextLen(nPar - 1);
pTableView->SetSelection(ESelection(0, 0, nPar - 1, nLen));
if (pTopView)
pTopView->SetSelection(ESelection(0, 0, nPar - 1, nLen));
@@ -900,18 +900,18 @@ std::unique_ptr<const SvxFieldData> ScEditShell::GetURLField()
std::unique_ptr<const SvxFieldData> ScEditShell::GetFirstURLFieldFromCell()
{
- EditEngine* pEE = GetEditView()->GetEditEngine();
- sal_Int32 nParaCount = pEE->GetParagraphCount();
+ EditEngine& rEditEngine = GetEditView()->getEditEngine();
+ sal_Int32 nParaCount = rEditEngine.GetParagraphCount();
for (sal_Int32 nPara = 0; nPara < nParaCount; ++nPara)
{
ESelection aSel(nPara, 0);
std::vector<sal_Int32> aPosList;
- pEE->GetPortions(nPara, aPosList);
+ rEditEngine.GetPortions(nPara, aPosList);
for (const auto& rPos : aPosList)
{
aSel.nEndPos = rPos;
- SfxItemSet aEditSet(pEE->GetAttribs(aSel));
+ SfxItemSet aEditSet(rEditEngine.GetAttribs(aSel));
if (aSel.nStartPos + 1 == aSel.nEndPos)
{
// test if the character is a text field
@@ -1211,12 +1211,12 @@ void ScEditShell::ExecuteAttr(SfxRequest& rReq)
// apply
- EditEngine* pEngine = pEditView->GetEditEngine();
- bool bOld = pEngine->SetUpdateLayout(false);
+ EditEngine& rEngine = pEditView->getEditEngine();
+ bool bOld = rEngine.SetUpdateLayout(false);
pEditView->SetAttribs( aSet );
- pEngine->SetUpdateLayout(bOld);
+ rEngine.SetUpdateLayout(bOld);
pEditView->Invalidate();
ScInputHandler* pHdl = GetMyInputHdl();
@@ -1305,13 +1305,13 @@ OUString ScEditShell::GetSelectionText( bool bWholeWord )
{
if ( bWholeWord )
{
- EditEngine* pEngine = pEditView->GetEditEngine();
+ EditEngine& rEngine = pEditView->getEditEngine();
ESelection aSel = pEditView->GetSelection();
- OUString aStrCurrentDelimiters = pEngine->GetWordDelimiters();
+ OUString aStrCurrentDelimiters = rEngine.GetWordDelimiters();
- pEngine->SetWordDelimiters(" .,;\"'");
- aStrSelection = pEngine->GetWord( aSel.nEndPara, aSel.nEndPos );
- pEngine->SetWordDelimiters( aStrCurrentDelimiters );
+ rEngine.SetWordDelimiters(" .,;\"'");
+ aStrSelection = rEngine.GetWord( aSel.nEndPara, aSel.nEndPos );
+ rEngine.SetWordDelimiters( aStrCurrentDelimiters );
}
else
{
@@ -1394,7 +1394,7 @@ void ScEditShell::GetUndoState(SfxItemSet &rSet)
EditView* pTopView = pHdl->GetTopView();
if (pTopView)
{
- SfxUndoManager& rTopMgr = pTopView->GetEditEngine()->GetUndoManager();
+ SfxUndoManager& rTopMgr = pTopView->getEditEngine().GetUndoManager();
if ( rTopMgr.GetUndoActionCount() == 0 )
rSet.DisableItem( SID_UNDO );
if ( rTopMgr.GetRedoActionCount() == 0 )
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 3ae1a37f5066..c83d18e57787 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2852,7 +2852,7 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt )
bool bAlt = rMEvt.IsMod2();
if ( !bAlt && !nButtonDown && ScGlobal::ShouldOpenURL() && pFld )
SetPointer( PointerStyle::RefHand );
- else if ( pEditView->GetEditEngine()->IsEffectivelyVertical() )
+ else if (pEditView->getEditEngine().IsEffectivelyVertical())
SetPointer( PointerStyle::TextVertical );
else
SetPointer( PointerStyle::Text );
@@ -3401,7 +3401,7 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
}
// if edit mode was just started above, online spelling may be incomplete
- pEditView->GetEditEngine()->CompleteOnlineSpelling();
+ pEditView->getEditEngine().CompleteOnlineSpelling();
// IsCursorAtWrongSpelledWord could be used for !bMouse
// if there was a corresponding ExecuteSpellPopup call
@@ -3500,12 +3500,12 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCCOL nCellX, S
// handle selection within the EditView
EditView* pEditView = mrViewData.GetEditView( eWhich ); // not NULL (HasEditView)
- EditEngine* pEditEngine = pEditView->GetEditEngine();
+ EditEngine& rEditEngine = pEditView->getEditEngine();
tools::Rectangle aOutputArea = pEditView->GetOutputArea();
tools::Rectangle aVisArea = pEditView->GetVisArea();
Point aTextPos = PixelToLogic( rPosPixel );
- if ( pEditEngine->IsEffectivelyVertical() ) // have to manually transform position
+ if (rEditEngine.IsEffectivelyVertical()) // have to manually transform position
{
aTextPos -= aOutputArea.TopRight();
tools::Long nTemp = -aTextPos.X();
@@ -3516,7 +3516,7 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCCOL nCellX, S
aTextPos -= aOutputArea.TopLeft();
aTextPos += aVisArea.TopLeft(); // position in the edit document
- EPosition aDocPosition = pEditEngine->FindDocPosition(aTextPos);
+ EPosition aDocPosition = rEditEngine.FindDocPosition(aTextPos);
ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
ESelection aSelection = pEditView->GetSelection();
aSelection.Adjust(); // needed for IsLess/IsGreater
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index fe8aab80693b..344d99b26cef 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -656,15 +656,15 @@ private:
namespace
{
-int lcl_GetMultiLineHeight(EditEngine* pEditEngine)
+int lcl_GetMultiLineHeight(EditEngine& rEditEngine)
{
int nHeight = 0;
- int nParagraphs = pEditEngine->GetParagraphCount();
- if (nParagraphs > 1 || (nParagraphs > 0 && pEditEngine->GetLineCount(0) > 1))
+ int nParagraphs = rEditEngine.GetParagraphCount();
+ if (nParagraphs > 1 || (nParagraphs > 0 && rEditEngine.GetLineCount(0) > 1))
{
for (int nPara = 0; nPara < nParagraphs; nPara++)
{
- nHeight += pEditEngine->GetLineCount(nPara) * pEditEngine->GetLineHeight(nPara);
+ nHeight += rEditEngine.GetLineCount(nPara) * rEditEngine.GetLineHeight(nPara);
}
}
@@ -1147,9 +1147,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
if (bIsTiledRendering)
{
- EditEngine* pEditEngine = pOtherEditView->GetEditEngine();
- if (pEditEngine)
- aEnd.AdjustY(lcl_GetMultiLineHeight(pEditEngine));
+ EditEngine& rEditEngine = pOtherEditView->getEditEngine();
+ aEnd.AdjustY(lcl_GetMultiLineHeight(rEditEngine));
}
if (bLokRTL)
diff --git a/sc/source/ui/view/spelldialog.cxx b/sc/source/ui/view/spelldialog.cxx
index da1e90698b38..015f1bf5c7e2 100644
--- a/sc/source/ui/view/spelldialog.cxx
+++ b/sc/source/ui/view/spelldialog.cxx
@@ -269,7 +269,7 @@ bool ScSpellDialogChildWindow::IsSelectionChanged()
return true;
if( EditView* pEditView = mpViewData->GetSpellingView() )
- if( pEditView->GetEditEngine() != mxEngine.get() )
+ if (&pEditView->getEditEngine() != mxEngine.get())
return true;
ScRangeList aCurrentRangeList;
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 444b78b20b64..aad1c8283858 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -125,7 +125,6 @@ void ScExtraEditViewManager::Apply(SfxViewShell* pViewShell, ScSplitPos eWhich)
mpOtherEditView = pOtherViewShell->GetViewData().GetEditView(eWhich);
if (mpOtherEditView != nullptr)
{
- DBG_ASSERT(mpOtherEditView->GetEditEngine(), "Edit view has no valid engine.");
for (int i = 0; i < 4; ++i)
{
ScGridWindow* pWin = mpGridWin[i].get();
@@ -2219,7 +2218,7 @@ void ScTabView::UpdateEditView()
tools::Long nY = GetViewData().GetCurYForTab(nRefTabNo);
aViewData.SetEditEngine(eCurrent,
- static_cast<ScEditEngineDefaulter*>(pEditView->GetEditEngine()),
+ static_cast<ScEditEngineDefaulter*>(&pEditView->getEditEngine()),
pGridWin[i], nX, nY );
if (eCurrent == eActive)
pEditView->ShowCursor( false );
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index e09fdcd62a92..4ce7acd94391 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1543,7 +1543,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
else
{
lcl_LOKRemoveWindow(GetViewShell(), eWhich);
- pEditView[eWhich]->SetEditEngine(pNewEngine);
+ pEditView[eWhich]->setEditEngine(pNewEngine);
}
if (pEditView[eWhich]->GetWindow() != pWin)
@@ -1555,7 +1555,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
}
else
{
- pEditView[eWhich].reset(new EditView( pNewEngine, pWin ));
+ pEditView[eWhich].reset(new EditView(pNewEngine, pWin));
if (bLOKActive)
{
@@ -1873,8 +1873,7 @@ void ScViewData::EditGrowX()
bool bLayoutRTL = rLocalDoc.IsLayoutRTL( nTabNo );
- ScEditEngineDefaulter* pEngine =
- static_cast<ScEditEngineDefaulter*>( pCurView->GetEditEngine() );
+ ScEditEngineDefaulter* pEngine = static_cast<ScEditEngineDefaulter*>(&pCurView->getEditEngine());
vcl::Window* pWin = pCurView->GetWindow();
// Get the left- and right-most column positions.
@@ -2166,38 +2165,38 @@ void ScViewData::EditGrowY( bool bInitial )
return;
}
- EditEngine* pEngine = pCurView->GetEditEngine();
+ EditEngine& rEngine = pCurView->getEditEngine();
vcl::Window* pWin = pCurView->GetWindow();
SCROW nBottom = GetPosY(eVWhich) + VisibleCellsY(eVWhich);
- Size aSize = pEngine->GetPaperSize();
+ Size aSize = rEngine.GetPaperSize();
Size aSizePTwips;
tools::Rectangle aArea = pCurView->GetOutputArea();
tools::Rectangle aAreaPTwips;
if (bLOKPrintTwips)
{
- aSizePTwips = pEngine->GetLOKSpecialPaperSize();
+ aSizePTwips = rEngine.GetLOKSpecialPaperSize();
aAreaPTwips = pCurView->GetLOKSpecialOutputArea();
}
- tools::Long nOldBottom = aArea.Bottom();
- tools::Long nTextHeight = pEngine->GetTextHeight();
+ tools::Long nOldBottom = aArea.Bottom();
+ tools::Long nTextHeight = rEngine.GetTextHeight();
// When editing a formula in a cell with optimal height, allow a larger portion
// to be clipped before extending to following rows, to avoid obscuring cells for
// reference input (next row is likely to be useful in formulas).
tools::Long nAllowedExtra = SC_GROWY_SMALL_EXTRA;
if (nEditEndRow == nEditRow && !(mrDoc.GetRowFlags(nEditRow, nTabNo) & CRFlags::ManualSize) &&
- pEngine->GetParagraphCount() <= 1 )
+ rEngine.GetParagraphCount() <= 1 )
{
// If the (only) paragraph starts with a '=', it's a formula.
// If this is the initial call and the text is empty, allow the larger value, too,
// because this occurs in the normal progress of editing a formula.
// Subsequent calls with empty text might involve changed attributes (including
// font height), so they are treated like normal text.
- OUString aText = pEngine->GetText( 0 );
+ OUString aText = rEngine.GetText( 0 );
if ( ( aText.isEmpty() && bInitial ) || aText.startsWith("=") )
nAllowedExtra = SC_GROWY_BIG_EXTRA;
}
@@ -2251,17 +2250,19 @@ void ScViewData::ResetEditView()
{
EditEngine* pEngine = nullptr;
for (sal_uInt16 i=0; i<4; i++)
+ {
if (pEditView[i])
{
if (bEditActive[i])
{
lcl_LOKRemoveWindow(GetViewShell(), static_cast<ScSplitPos>(i));
- pEngine = pEditView[i]->GetEditEngine();
+ pEngine = &pEditView[i]->getEditEngine();
pEngine->RemoveView(pEditView[i].get());
pEditView[i]->SetOutputArea( tools::Rectangle() );
}
bEditActive[i] = false;
}
+ }
if (pEngine)
pEngine->SetStatusEventHdl( Link<EditStatus&,void>() );
@@ -2269,15 +2270,13 @@ void ScViewData::ResetEditView()
void ScViewData::KillEditView()
{
- EditEngine* pEngine = nullptr;
for (sal_uInt16 i=0; i<4; i++)
if (pEditView[i])
{
if (bEditActive[i])
{
- pEngine = pEditView[i]->GetEditEngine();
- if (pEngine)
- pEngine->RemoveView(pEditView[i].get());
+ EditEngine& rEngine = pEditView[i]->getEditEngine();
+ rEngine.RemoveView(pEditView[i].get());
}
pEditView[i].reset();
}