summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-09 12:24:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-10 08:16:19 +0100
commit50887c9010515fe9fe61b3067f502cd28333773a (patch)
treebf927a1dc6a920c7ca299ef10020b7717787bda6 /sc
parent6d8594950bea25175e62f38981d84811cff64b8b (diff)
use unique_ptr in ScRangeUtil::IsAbsTabArea
Change-Id: I3a5f88eef1e7a8241921f2fed15a1ebc2c4c3445 Reviewed-on: https://gerrit.libreoffice.org/66006 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/rangeutl.hxx2
-rw-r--r--sc/source/core/tool/rangeutl.cxx11
-rw-r--r--sc/source/ui/dbgui/consdlg.cxx23
3 files changed, 14 insertions, 22 deletions
diff --git a/sc/inc/rangeutl.hxx b/sc/inc/rangeutl.hxx
index feab1fa5f853..54aba7bf817c 100644
--- a/sc/inc/rangeutl.hxx
+++ b/sc/inc/rangeutl.hxx
@@ -51,7 +51,7 @@ public:
static bool IsAbsTabArea ( const OUString& rAreaStr,
const ScDocument* pDoc,
- ScArea*** pppAreas,
+ std::unique_ptr<ScArea[]>* ppAreas,
sal_uInt16* pAreaCount,
bool bAcceptCellRef = false,
ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index 5d6f74ef5b71..a29b33907869 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -86,7 +86,7 @@ void ScRangeUtil::CutPosString( const OUString& theAreaStr,
bool ScRangeUtil::IsAbsTabArea( const OUString& rAreaStr,
const ScDocument* pDoc,
- ScArea*** pppAreas,
+ std::unique_ptr<ScArea[]>* ppAreas,
sal_uInt16* pAreaCount,
bool /* bAcceptCellRef */,
ScAddress::Details const & rDetails )
@@ -143,12 +143,12 @@ bool ScRangeUtil::IsAbsTabArea( const OUString& rAreaStr,
bStrOk = true;
- if ( pppAreas && pAreaCount ) // Array returned ?
+ if ( ppAreas && pAreaCount ) // Array returned ?
{
SCTAB nStartTab = aStartPos.Tab();
SCTAB nEndTab = aEndPos.Tab();
sal_uInt16 nTabCount = static_cast<sal_uInt16>(nEndTab-nStartTab+1);
- ScArea** theAreas = new ScArea*[nTabCount];
+ ppAreas->reset(new ScArea[nTabCount]);
SCTAB nTab = 0;
sal_uInt16 i = 0;
ScArea theArea( 0, aStartPos.Col(), aStartPos.Row(),
@@ -157,11 +157,10 @@ bool ScRangeUtil::IsAbsTabArea( const OUString& rAreaStr,
nTab = nStartTab;
for ( i=0; i<nTabCount; i++ )
{
- theAreas[i] = new ScArea( theArea );
- theAreas[i]->nTab = nTab;
+ (*ppAreas)[i] = theArea;
+ (*ppAreas)[i].nTab = nTab;
nTab++;
}
- *pppAreas = theAreas;
*pAreaCount = nTabCount;
}
}
diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx
index 43ebbe00c9f8..d1df2b6647a1 100644
--- a/sc/source/ui/dbgui/consdlg.cxx
+++ b/sc/source/ui/dbgui/consdlg.cxx
@@ -426,7 +426,7 @@ IMPL_LINK( ScConsolidateDlg, ClickHdl, Button*, pBtn, void )
if ( !pEdDataArea->GetText().isEmpty() )
{
OUString aNewEntry( pEdDataArea->GetText() );
- ScArea** ppAreas = nullptr;
+ std::unique_ptr<ScArea[]> ppAreas;
sal_uInt16 nAreaCount = 0;
const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
@@ -438,24 +438,17 @@ IMPL_LINK( ScConsolidateDlg, ClickHdl, Button*, pBtn, void )
for ( sal_uInt16 i=0; i<nAreaCount; i++ )
{
- OUString aNewArea;
+ const ScArea& rArea = ppAreas[i];
+ OUString aNewArea = ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
+ rArea.nColEnd, rArea.nRowEnd, rArea.nTab
+ ).Format(ScRefFlags::RANGE_ABS_3D, pDoc, eConv);
- if ( ppAreas[i] )
+ if ( pLbConsAreas->GetEntryPos( aNewArea )
+ == LISTBOX_ENTRY_NOTFOUND )
{
- const ScArea& rArea = *(ppAreas[i]);
- aNewArea = ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
- rArea.nColEnd, rArea.nRowEnd, rArea.nTab
- ).Format(ScRefFlags::RANGE_ABS_3D, pDoc, eConv);
-
- if ( pLbConsAreas->GetEntryPos( aNewArea )
- == LISTBOX_ENTRY_NOTFOUND )
- {
- pLbConsAreas->InsertEntry( aNewArea );
- }
- delete ppAreas[i];
+ pLbConsAreas->InsertEntry( aNewArea );
}
}
- delete [] ppAreas;
}
else if ( VerifyEdit( pEdDataArea ) )
{