From bf3d1b8e8f89bfdb409c70cfea126f36474d4772 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 14 Sep 2020 16:42:52 +0100 Subject: establish that ScViewData::GetDocument can always return ScDocument& MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit we can only be ctored with a ScDocShell& or ScDocument&, and ScDocShell provides a ScDocument& from its GetDocument() so we can always have a ScDocument& when a public ctor has completed some null checks can then be seen to be redundant and are removed Change-Id: Ifaf39cb06e8dbce363999c05ee0aeb3ec4f00428 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102775 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- sc/source/ui/miscdlgs/anyrefdg.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sc/source/ui/miscdlgs/anyrefdg.cxx') diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index d8d7777a5efb..968bb5f4cf69 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -117,7 +117,7 @@ void ScFormulaReferenceHelper::ShowSimpleReference(const OUString& rStr) if ( !pViewData ) return; - ScDocument* pDoc=pViewData->GetDocument(); + ScDocument& rDoc = pViewData->GetDocument(); ScTabViewShell* pTabViewShell=pViewData->GetViewShell(); ScRangeList aRangeList; @@ -125,7 +125,7 @@ void ScFormulaReferenceHelper::ShowSimpleReference(const OUString& rStr) pTabViewShell->DoneRefMode(); pTabViewShell->ClearHighlightRanges(); - if( ParseWithNames( aRangeList, rStr, *pDoc ) ) + if( ParseWithNames( aRangeList, rStr, rDoc ) ) { for ( size_t i = 0, nRanges = aRangeList.size(); i < nRanges; ++i ) { @@ -193,7 +193,7 @@ void ScFormulaReferenceHelper::ShowFormulaReference(const OUString& rStr) return; const ScViewData& rViewData = pTabViewShell->GetViewData(); - ScDocument* pDoc = rViewData.GetDocument(); + ScDocument& rDoc = rViewData.GetDocument(); pTabViewShell->DoneRefMode(); pTabViewShell->ClearHighlightRanges(); @@ -212,12 +212,12 @@ void ScFormulaReferenceHelper::ShowFormulaReference(const OUString& rStr) if(bDoubleRef) { ScComplexRefData aRef( *pToken->GetDoubleRef() ); - aRange = aRef.toAbs(*pDoc, aPos); + aRange = aRef.toAbs(rDoc, aPos); } else { ScSingleRefData aRef( *pToken->GetSingleRef() ); - aRange.aStart = aRef.toAbs(*pDoc, aPos); + aRange.aStart = aRef.toAbs(rDoc, aPos); aRange.aEnd = aRange.aStart; } Color aColName=ScRangeFindList::GetColorName(nIndex++); @@ -296,9 +296,9 @@ void ScFormulaReferenceHelper::ReleaseFocus( formula::RefEdit* pEdit ) return; const ScViewData& rViewData = pViewShell->GetViewData(); - ScDocument* pDoc = rViewData.GetDocument(); + ScDocument& rDoc = rViewData.GetDocument(); ScRangeList aRangeList; - if( !ParseWithNames( aRangeList, m_pRefEdit->GetText(), *pDoc ) ) + if( !ParseWithNames( aRangeList, m_pRefEdit->GetText(), rDoc ) ) return; if ( !aRangeList.empty() ) @@ -309,7 +309,7 @@ void ScFormulaReferenceHelper::ReleaseFocus( formula::RefEdit* pEdit ) rRange.aStart.Row(), SC_FOLLOW_JUMP, false, false ); pViewShell->MoveCursorAbs( rRange.aEnd.Col(), rRange.aEnd.Row(), SC_FOLLOW_JUMP, true, false ); - m_pDlg->SetReference( rRange, *pDoc ); + m_pDlg->SetReference( rRange, rDoc ); } } @@ -319,13 +319,13 @@ void ScFormulaReferenceHelper::Init() if ( !pViewData ) return; - ScDocument* pDoc = pViewData->GetDocument(); + ScDocument& rDoc = pViewData->GetDocument(); SCCOL nCol = pViewData->GetCurX(); SCROW nRow = pViewData->GetCurY(); SCTAB nTab = pViewData->GetTabNo(); ScAddress aCursorPos( nCol, nRow, nTab ); - m_pRefComp.reset( new ScCompiler( pDoc, aCursorPos, pDoc->GetGrammar()) ); + m_pRefComp.reset( new ScCompiler( &rDoc, aCursorPos, rDoc.GetGrammar()) ); m_pRefComp->EnableJumpCommandReorder(false); m_pRefComp->EnableStopOnError(false); -- cgit