diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-09-14 16:42:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-09-15 21:36:27 +0200 |
commit | bf3d1b8e8f89bfdb409c70cfea126f36474d4772 (patch) | |
tree | 9d496d04fc1bbd76c15ab215f947ac28587f0e1e /sc/source/ui/navipi | |
parent | 957adc83e67276805c6dcd7be1ea23c142c49306 (diff) |
establish that ScViewData::GetDocument can always return ScDocument&
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 <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui/navipi')
-rw-r--r-- | sc/source/ui/navipi/navcitem.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/navipi/navipi.cxx | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/sc/source/ui/navipi/navcitem.cxx b/sc/source/ui/navipi/navcitem.cxx index a3ba855cc27c..bac2b45e179d 100644 --- a/sc/source/ui/navipi/navcitem.cxx +++ b/sc/source/ui/navipi/navcitem.cxx @@ -51,7 +51,7 @@ void ScNavigatorControllerItem::StateChanged( sal_uInt16 /* nSID */, SfxItemStat const OUString& aAddress( pCellPosItem->GetValue() ); ScAddress aScAddress; ScViewData* pViewData = rNavigatorDlg.GetViewData(); - aScAddress.Parse(aAddress, pViewData ? pViewData->GetDocument() : nullptr); + aScAddress.Parse(aAddress, pViewData ? &pViewData->GetDocument() : nullptr); SCCOL nCol = aScAddress.Col()+1; SCROW nRow = aScAddress.Row()+1; diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx index d0bf33ae0d95..1ff33a64cfd4 100644 --- a/sc/source/ui/navipi/navipi.cxx +++ b/sc/source/ui/navipi/navipi.cxx @@ -136,7 +136,7 @@ IMPL_LINK(ScNavigatorDlg, ParseRowInputHdl, int*, result, bool) // nKeyGroup is no longer set at VCL, in cause of lack of keyinput ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); - auto& rDoc = *pViewSh->GetViewData().GetDocument(); + auto& rDoc = pViewSh->GetViewData().GetDocument(); if ( CharClass::isAsciiNumeric(aStrCol) ) nCol = NumStrToAlpha( rDoc.GetSheetLimits(), aStrCol ); else @@ -347,14 +347,14 @@ ScNavigatorDlg::ScNavigatorDlg(SfxBindings* pB, vcl::Window* pParent) set_id("NavigatorPanelParent"); // for uitests GetViewData(); - ScDocument* pDoc = pViewData->GetDocument(); - m_xEdRow->set_range(1, SCNAV_MAXROW(pDoc->GetSheetLimits())); + ScDocument& rDoc = pViewData->GetDocument(); + m_xEdRow->set_range(1, SCNAV_MAXROW(rDoc.GetSheetLimits())); m_xEdRow->set_width_chars(5); //max rows is 1,000,000, which is too long for typical use m_xEdRow->connect_activate(LINK(this, ScNavigatorDlg, ExecuteRowHdl)); - m_xEdCol->set_range(1, SCNAV_MAXCOL(pDoc->GetSheetLimits())); - m_xEdCol->set_width_chars(SCNAV_COLDIGITS(pDoc->GetSheetLimits())); // 1...256...18278 or A...IV...ZZZ + m_xEdCol->set_range(1, SCNAV_MAXCOL(rDoc.GetSheetLimits())); + m_xEdCol->set_width_chars(SCNAV_COLDIGITS(rDoc.GetSheetLimits())); // 1...256...18278 or A...IV...ZZZ m_xEdCol->connect_activate(LINK(this, ScNavigatorDlg, ExecuteColHdl)); m_xEdCol->connect_output(LINK(this, ScNavigatorDlg, FormatRowOutputHdl)); m_xEdCol->connect_input(LINK(this, ScNavigatorDlg, ParseRowInputHdl)); @@ -607,19 +607,19 @@ void ScNavigatorDlg::SetCurrentTableStr( const OUString& rName ) { if (!GetViewData()) return; - ScDocument* pDoc = pViewData->GetDocument(); - SCTAB nCount = pDoc->GetTableCount(); + ScDocument& rDoc = pViewData->GetDocument(); + SCTAB nCount = rDoc.GetTableCount(); OUString aTabName; SCTAB nLastSheet = 0; for (SCTAB i = 0; i<nCount; i++) { - pDoc->GetName(i, aTabName); + rDoc.GetName(i, aTabName); if (aTabName == rName) { // Check if this is a Scenario sheet and if so select the sheet // where it belongs to, which is the previous non-Scenario sheet. - if (pDoc->IsScenario(i)) + if (rDoc.IsScenario(i)) { SetCurrentTable(nLastSheet); return; @@ -632,7 +632,7 @@ void ScNavigatorDlg::SetCurrentTableStr( const OUString& rName ) } else { - if (!pDoc->IsScenario(i)) + if (!rDoc.IsScenario(i)) nLastSheet = i; } } |