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/namedlg | |
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/namedlg')
-rw-r--r-- | sc/source/ui/namedlg/namedefdlg.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/namedlg/namedlg.cxx | 16 |
2 files changed, 8 insertions, 10 deletions
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx index 920f4d52ce11..9a4ec692bd7c 100644 --- a/sc/source/ui/namedlg/namedefdlg.cxx +++ b/sc/source/ui/namedlg/namedefdlg.cxx @@ -30,7 +30,7 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* const ScAddress& aCursorPos, const bool bUndo ) : ScAnyRefDlgController( pB, pCW, pParent, "modules/scalc/ui/definename.ui", "DefineNameDialog") , mbUndo( bUndo ) - , mrDoc(*pViewData->GetDocument()) + , mrDoc(pViewData->GetDocument()) , mpDocShell ( pViewData->GetDocShell() ) , maCursorPos( aCursorPos ) , maGlobalNameStr ( ScResId(STR_GLOBAL_SCOPE) ) diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx index 2b237dedf16c..140e74eb547e 100644 --- a/sc/source/ui/namedlg/namedlg.cxx +++ b/sc/source/ui/namedlg/namedlg.cxx @@ -54,7 +54,7 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParen , maStrMultiSelect(ScResId(STR_MULTI_SELECT)) , mpViewData(ptrViewData) - , mpDoc(ptrViewData->GetDocument()) + , mrDoc(ptrViewData->GetDocument()) , maCursorPos(aCursorPos) , mbDataChanged(false) , mbCloseWithoutUndo(false) @@ -83,7 +83,7 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParen if (!pRangeMap) { std::map<OUString, ScRangeName*> aRangeMap; - mpDoc->GetRangeNameMap(aRangeMap); + mrDoc.GetRangeNameMap(aRangeMap); for (const auto& [aTemp, pRangeName] : aRangeMap) { m_RangeMap.insert(std::make_pair(aTemp, std::make_unique<ScRangeName>(*pRangeName))); @@ -102,8 +102,6 @@ ScNameDlg::~ScNameDlg() void ScNameDlg::Init() { - OSL_ENSURE( mpViewData && mpDoc, "ViewData or Document not found!" ); - //init UI std::unique_ptr<weld::TreeView> xTreeView(m_xBuilder->weld_tree_view("names")); @@ -136,11 +134,11 @@ void ScNameDlg::Init() // Initialize scope list. m_xLbScope->append_text(maGlobalNameStr); m_xLbScope->set_active(0); - SCTAB n = mpDoc->GetTableCount(); + SCTAB n = mrDoc.GetTableCount(); for (SCTAB i = 0; i < n; ++i) { OUString aTabName; - mpDoc->GetName(i, aTabName); + mrDoc.GetName(i, aTabName); m_xLbScope->append_text(aTabName); } @@ -250,7 +248,7 @@ bool ScNameDlg::IsNameValid() ScRangeName* pRangeName = GetRangeName( aScope ); - if (ScRangeData::IsNameValid( aName, mpDoc ) != ScRangeData::NAME_VALID) + if (ScRangeData::IsNameValid( aName, &mrDoc ) != ScRangeData::NAME_VALID) { m_xFtInfo->set_label_type(weld::LabelType::Error); m_xFtInfo->set_label(maErrInvalidNameStr); @@ -268,7 +266,7 @@ bool ScNameDlg::IsNameValid() bool ScNameDlg::IsFormulaValid() { - ScCompiler aComp( mpDoc, maCursorPos, mpDoc->GetGrammar()); + ScCompiler aComp( &mrDoc, maCursorPos, mrDoc.GetGrammar()); std::unique_ptr<ScTokenArray> pCode = aComp.CompileString(m_xEdAssign->GetText()); if (pCode->GetCodeError() != FormulaError::NONE) { @@ -388,7 +386,7 @@ void ScNameDlg::NameModified() if ( m_xBtnPrintArea->get_active() ) nType |= ScRangeData::Type::PrintArea; if ( m_xBtnCriteria->get_active() ) nType |= ScRangeData::Type::Criteria; - ScRangeData* pNewEntry = new ScRangeData( *mpDoc, aNewName, aExpr, + ScRangeData* pNewEntry = new ScRangeData( mrDoc, aNewName, aExpr, maCursorPos, nType); pNewEntry->SetIndex( nIndex); pNewRangeName->insert(pNewEntry, false /*bReuseFreeIndex*/); |