summaryrefslogtreecommitdiff
path: root/sc/source/ui/namedlg
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-11-14 12:54:56 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-11-14 21:23:11 +0100
commit7cb1599411c309a8544c8e86845593026a773f32 (patch)
treeefe999e982c321fe65c5bc9dc5f57c23ddb2bd87 /sc/source/ui/namedlg
parentc6f67ba90352c6506d5131a5f7ecca1f727ce377 (diff)
mpDoc is assumed to be non-null
Change-Id: Ib3fbd6cc2b01e4923e97260b66aa1cd7807ee281 Reviewed-on: https://gerrit.libreoffice.org/82684 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui/namedlg')
-rw-r--r--sc/source/ui/namedlg/namedefdlg.cxx111
1 files changed, 54 insertions, 57 deletions
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 06f8c720f1b7..8b744839a0a7 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 )
- , mpDoc( pViewData->GetDocument() )
+ , mrDoc(*pViewData->GetDocument())
, mpDocShell ( pViewData->GetDocShell() )
, maCursorPos( aCursorPos )
, maGlobalNameStr ( ScResId(STR_GLOBAL_SCOPE) )
@@ -59,11 +59,11 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window*
// 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);
}
@@ -77,8 +77,8 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window*
ScRange aRange;
pViewData->GetSimpleArea( aRange );
- OUString aAreaStr(aRange.Format(ScRefFlags::RANGE_ABS_3D, mpDoc,
- ScAddress::Details(mpDoc->GetAddressConvention(), 0, 0)));
+ OUString aAreaStr(aRange.Format(ScRefFlags::RANGE_ABS_3D, &mrDoc,
+ ScAddress::Details(mrDoc.GetAddressConvention(), 0, 0)));
m_xEdRange->SetText( aAreaStr );
@@ -103,7 +103,7 @@ void ScNameDefDlg::CancelPushed()
bool ScNameDefDlg::IsFormulaValid()
{
- ScCompiler aComp( mpDoc, maCursorPos, mpDoc->GetGrammar());
+ ScCompiler aComp( &mrDoc, maCursorPos, mrDoc.GetGrammar());
std::unique_ptr<ScTokenArray> pCode = aComp.CompileString(m_xEdRange->GetText());
if (pCode->GetCodeError() != FormulaError::NONE)
{
@@ -139,7 +139,7 @@ bool ScNameDefDlg::IsNameValid()
m_xFtInfo->set_label(maStrInfoDefault);
return false;
}
- else if ((eType = ScRangeData::IsNameValid( aName, mpDoc )) != ScRangeData::NAME_VALID)
+ else if ((eType = ScRangeData::IsNameValid( aName, &mrDoc )) != ScRangeData::NAME_VALID)
{
m_xFtInfo->set_message_type(weld::EntryMessageType::Error);
if (eType == ScRangeData::NAME_INVALID_BAD_STRING)
@@ -204,66 +204,63 @@ void ScNameDefDlg::AddPushed()
return;
else
{
- if ( mpDoc )
- {
- ScRangeData::Type nType = ScRangeData::Type::Name;
+ ScRangeData::Type nType = ScRangeData::Type::Name;
+
+ ScRangeData* pNewEntry = new ScRangeData( &mrDoc,
+ aName,
+ aExpression,
+ maCursorPos,
+ nType );
- ScRangeData* pNewEntry = new ScRangeData( mpDoc,
- aName,
- aExpression,
- maCursorPos,
- nType );
+ if ( m_xBtnRowHeader->get_active() ) nType |= ScRangeData::Type::RowHeader;
+ if ( m_xBtnColHeader->get_active() ) nType |= ScRangeData::Type::ColHeader;
+ if ( m_xBtnPrintArea->get_active() ) nType |= ScRangeData::Type::PrintArea;
+ if ( m_xBtnCriteria->get_active() ) nType |= ScRangeData::Type::Criteria;
- if ( m_xBtnRowHeader->get_active() ) nType |= ScRangeData::Type::RowHeader;
- if ( m_xBtnColHeader->get_active() ) nType |= ScRangeData::Type::ColHeader;
- if ( m_xBtnPrintArea->get_active() ) nType |= ScRangeData::Type::PrintArea;
- if ( m_xBtnCriteria->get_active() ) nType |= ScRangeData::Type::Criteria;
+ pNewEntry->AddType(nType);
- pNewEntry->AddType(nType);
+ // aExpression valid?
+ if ( FormulaError::NONE == pNewEntry->GetErrCode() )
+ {
+ if ( !pRangeName->insert( pNewEntry, false /*bReuseFreeIndex*/ ) )
+ pNewEntry = nullptr;
- // aExpression valid?
- if ( FormulaError::NONE == pNewEntry->GetErrCode() )
+ if (mbUndo)
{
- if ( !pRangeName->insert( pNewEntry, false /*bReuseFreeIndex*/ ) )
- pNewEntry = nullptr;
-
- if (mbUndo)
- {
- // this means we called directly through the menu
-
- SCTAB nTab;
- // if no table with that name is found, assume global range name
- if (!mpDoc->GetTable(aScope, nTab))
- nTab = -1;
-
- assert( pNewEntry); // undo of no insertion smells fishy
- if (pNewEntry)
- mpDocShell->GetUndoManager()->AddUndoAction(
- std::make_unique<ScUndoAddRangeData>( mpDocShell, pNewEntry, nTab) );
-
- // set table stream invalid, otherwise RangeName won't be saved if no other
- // call invalidates the stream
- if (nTab != -1)
- mpDoc->SetStreamValid(nTab, false);
- SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
- mpDocShell->SetDocumentModified();
- Close();
- }
- else
- {
- maName = aName;
- maScope = aScope;
- ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
- pViewSh->SwitchBetweenRefDialogs(this);
- }
+ // this means we called directly through the menu
+
+ SCTAB nTab;
+ // if no table with that name is found, assume global range name
+ if (!mrDoc.GetTable(aScope, nTab))
+ nTab = -1;
+
+ assert( pNewEntry); // undo of no insertion smells fishy
+ if (pNewEntry)
+ mpDocShell->GetUndoManager()->AddUndoAction(
+ std::make_unique<ScUndoAddRangeData>( mpDocShell, pNewEntry, nTab) );
+
+ // set table stream invalid, otherwise RangeName won't be saved if no other
+ // call invalidates the stream
+ if (nTab != -1)
+ mrDoc.SetStreamValid(nTab, false);
+ SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
+ mpDocShell->SetDocumentModified();
+ Close();
}
else
{
- delete pNewEntry;
- m_xEdRange->GrabFocus();
- m_xEdRange->SelectAll();
+ maName = aName;
+ maScope = aScope;
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ pViewSh->SwitchBetweenRefDialogs(this);
}
}
+ else
+ {
+ delete pNewEntry;
+ m_xEdRange->GrabFocus();
+ m_xEdRange->SelectAll();
+ }
}
}