summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-08-24 16:50:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-08-25 13:14:20 +0200
commit4467dc6685dbe2862da5eb54edb89c1711253812 (patch)
treefb57b72dc85ff9478622c65fa293b1af96d48adf
parent4d41b2e42fb91b99bd17b13f0f592978f4ccfba7 (diff)
loplugin:useuniqueptr in sc
Change-Id: Ia647ef2dda2dd54a4958a7dc561a0fb86abdfd86 Reviewed-on: https://gerrit.libreoffice.org/41522 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/inc/dptabres.hxx4
-rw-r--r--sc/inc/funcdesc.hxx3
-rw-r--r--sc/source/core/data/dptabres.cxx60
-rw-r--r--sc/source/core/data/funcdesc.cxx8
-rw-r--r--sc/source/filter/inc/tool.h6
-rw-r--r--sc/source/filter/lotus/tool.cxx2
-rw-r--r--sc/source/ui/app/inputhdl.cxx42
-rw-r--r--sc/source/ui/inc/inputhdl.hxx19
8 files changed, 65 insertions, 79 deletions
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index 40a0d9aa0a18..c0a29c8ae52f 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -500,13 +500,13 @@ typedef std::vector<ScDPDataMember*> ScDPDataMembers;
class ScDPResultDimension
{
public:
- typedef std::vector<ScDPResultMember*> MemberArray;
+ typedef std::vector<std::unique_ptr<ScDPResultMember>> MemberArray;
typedef std::map<SCROW, ScDPResultMember*> MemberHash;
private:
const ScDPResultData* pResultData;
MemberArray maMemberArray;
MemberHash maMemberHash;
- OUString aDimensionName; //! or ptr to IntDimension?
+ OUString aDimensionName; //! or ptr to IntDimension?
long nSortMeasure;
ScMemberSortOrder aMemberOrder; // used when sorted by measure
bool bIsDataLayout:1; //! or ptr to IntDimension?
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx
index bb0361def4eb..feabadf9bb82 100644
--- a/sc/inc/funcdesc.hxx
+++ b/sc/inc/funcdesc.hxx
@@ -28,6 +28,7 @@
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <map>
+#include <memory>
#define MAX_FUNCCAT 12 /* maximum number of categories for functions */
#define LRU_MAX 10 /* maximal number of last recently used functions */
@@ -393,7 +394,7 @@ public:
private:
ScFunctionList* pFuncList; /**< list of all calc functions */
- std::vector<const ScFuncDesc*>* aCatLists[MAX_FUNCCAT]; /**< array of all categories, 0 is the cumulative ('All') category */
+ std::unique_ptr<std::vector<const ScFuncDesc*>> aCatLists[MAX_FUNCCAT]; /**< array of all categories, 0 is the cumulative ('All') category */
mutable std::map< sal_uInt32, std::shared_ptr<ScFunctionCategory> > m_aCategories; /**< map of category pos to IFunctionCategory */
mutable std::vector<const ScFuncDesc*>::iterator pCurCatListIter; /**< position in current category */
mutable std::vector<const ScFuncDesc*>::iterator pCurCatListEnd; /**< end of current category */
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 1519e5186e52..f0fd4fd87c05 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -74,7 +74,7 @@ const char* aFuncStrIds[] = // matching enum ScSubTotalFunc
nullptr // SUBTOTAL_FUNC_SELECTION_COUNT - not used for pivot table
};
-bool lcl_SearchMember( const std::vector <ScDPResultMember *>& list, SCROW nOrder, SCROW& rIndex)
+bool lcl_SearchMember( const std::vector<std::unique_ptr<ScDPResultMember>>& list, SCROW nOrder, SCROW& rIndex)
{
rIndex = list.size();
bool bFound = false;
@@ -2765,14 +2765,12 @@ ScDPResultDimension::ScDPResultDimension( const ScDPResultData* pData ) :
ScDPResultDimension::~ScDPResultDimension()
{
- for( int i = maMemberArray.size () ; i-- > 0 ; )
- delete maMemberArray[i];
}
ScDPResultMember *ScDPResultDimension::FindMember( SCROW iData ) const
{
if( bIsDataLayout )
- return maMemberArray[0];
+ return maMemberArray[0].get();
MemberHash::const_iterator aRes = maMemberHash.find( iData );
if( aRes != maMemberHash.end()) {
@@ -2785,7 +2783,7 @@ ScDPResultMember *ScDPResultDimension::FindMember( SCROW iData ) const
unsigned int nCount = maMemberArray.size();
for( i = 0; i < nCount ; i++ )
{
- ScDPResultMember* pResultMember = maMemberArray[i];
+ ScDPResultMember* pResultMember = maMemberArray[i].get();
if ( pResultMember->IsNamedItem( iData ) )
return pResultMember;
}
@@ -2944,7 +2942,7 @@ void ScDPResultDimension::LateInitFrom(
long nCount = maMemberArray.size();
for (long i=0; i<nCount; i++)
{
- ScDPResultMember* pResultMember = maMemberArray[i];
+ ScDPResultMember* pResultMember = maMemberArray[i].get();
// check show empty
bool bAllChildren = false;
@@ -3041,7 +3039,7 @@ void ScDPResultDimension::FillMemberResults( uno::Sequence<sheet::MemberResult>*
{
long nSorted = aMemberOrder.empty() ? i : aMemberOrder[i];
- ScDPResultMember* pMember = maMemberArray[nSorted];
+ ScDPResultMember* pMember = maMemberArray[nSorted].get();
// in data layout dimension, use first member with different measures/names
if ( bIsDataLayout )
{
@@ -3076,11 +3074,11 @@ void ScDPResultDimension::FillDataResults(
{
OSL_ENSURE(nMeasure == SC_DPMEASURE_ALL || pResultData->GetMeasureCount() == 1,
"DataLayout dimension twice?");
- pMember = maMemberArray[0];
+ pMember = maMemberArray[0].get();
nMemberMeasure = nSorted;
}
else
- pMember = maMemberArray[nSorted];
+ pMember = maMemberArray[nSorted].get();
if ( pMember->IsVisible() )
pMember->FillDataResults(pRefMember, rFilterCxt, rSequence, nMemberMeasure);
@@ -3098,11 +3096,11 @@ void ScDPResultDimension::UpdateDataResults( const ScDPResultMember* pRefMember,
{
OSL_ENSURE(nMeasure == SC_DPMEASURE_ALL || pResultData->GetMeasureCount() == 1,
"DataLayout dimension twice?");
- pMember = maMemberArray[0];
+ pMember = maMemberArray[0].get();
nMemberMeasure = i;
}
else
- pMember = maMemberArray[i];
+ pMember = maMemberArray[i].get();
if ( pMember->IsVisible() )
pMember->UpdateDataResults( pRefMember, nMemberMeasure );
@@ -3132,7 +3130,7 @@ void ScDPResultDimension::SortMembers( ScDPResultMember* pRefMember )
long nLoopCount = bIsDataLayout ? 1 : nCount;
for (long i=0; i<nLoopCount; i++)
{
- ScDPResultMember* pMember = maMemberArray[i];
+ ScDPResultMember* pMember = maMemberArray[i].get();
if ( pMember->IsVisible() )
pMember->SortMembers( pRefMember );
}
@@ -3148,7 +3146,7 @@ void ScDPResultDimension::DoAutoShow( ScDPResultMember* pRefMember )
long nLoopCount = bIsDataLayout ? 1 : nCount;
for (long i=0; i<nLoopCount; i++)
{
- ScDPResultMember* pMember = maMemberArray[i];
+ ScDPResultMember* pMember = maMemberArray[i].get();
if ( pMember->IsVisible() )
pMember->DoAutoShow( pRefMember );
}
@@ -3169,7 +3167,7 @@ void ScDPResultDimension::DoAutoShow( ScDPResultMember* pRefMember )
// look for equal values to the last included one
long nIncluded = nAutoCount;
- const ScDPResultMember* pMember1 = maMemberArray[aAutoOrder[nIncluded - 1]];
+ const ScDPResultMember* pMember1 = maMemberArray[aAutoOrder[nIncluded - 1]].get();
const ScDPDataMember* pDataMember1 = pMember1->IsVisible() ? pMember1->GetDataRoot() : nullptr;
bool bContinue = true;
while ( bContinue )
@@ -3177,7 +3175,7 @@ void ScDPResultDimension::DoAutoShow( ScDPResultMember* pRefMember )
bContinue = false;
if ( nIncluded < nCount )
{
- const ScDPResultMember* pMember2 = maMemberArray[aAutoOrder[nIncluded]];
+ const ScDPResultMember* pMember2 = maMemberArray[aAutoOrder[nIncluded]].get();
const ScDPDataMember* pDataMember2 = pMember2->IsVisible() ? pMember2->GetDataRoot() : nullptr;
if ( lcl_IsEqual( pDataMember1, pDataMember2, nAutoMeasure ) )
@@ -3192,7 +3190,7 @@ void ScDPResultDimension::DoAutoShow( ScDPResultMember* pRefMember )
for (nPos = nIncluded; nPos < nCount; nPos++)
{
- ScDPResultMember* pMember = maMemberArray[aAutoOrder[nPos]];
+ ScDPResultMember* pMember = maMemberArray[aAutoOrder[nPos]].get();
pMember->SetAutoHidden();
}
}
@@ -3204,7 +3202,7 @@ void ScDPResultDimension::ResetResults()
for (long i=0; i<nCount; i++)
{
// sort order doesn't matter
- ScDPResultMember* pMember = maMemberArray[bIsDataLayout ? 0 : i];
+ ScDPResultMember* pMember = maMemberArray[bIsDataLayout ? 0 : i].get();
pMember->ResetResults();
}
}
@@ -3228,11 +3226,11 @@ void ScDPResultDimension::UpdateRunningTotals( const ScDPResultMember* pRefMembe
{
OSL_ENSURE(nMeasure == SC_DPMEASURE_ALL || pResultData->GetMeasureCount() == 1,
"DataLayout dimension twice?");
- pMember = maMemberArray[0];
+ pMember = maMemberArray[0].get();
nMemberMeasure = nSorted;
}
else
- pMember = maMemberArray[nSorted];
+ pMember = maMemberArray[nSorted].get();
if ( pMember->IsVisible() )
{
@@ -3271,14 +3269,14 @@ ScDPDataMember* ScDPResultDimension::GetRowReferenceMember(
{
// search for named member
- const ScDPResultMember* pRowMember = maMemberArray[GetSortedIndex(nMemberIndex)];
+ const ScDPResultMember* pRowMember = maMemberArray[GetSortedIndex(nMemberIndex)].get();
//TODO: use ScDPItemData, as in ScDPDimension::IsValidPage?
while ( pRowMember && pRowMember->GetName() != *pName )
{
++nMemberIndex;
if ( nMemberIndex < nMemberCount )
- pRowMember = maMemberArray[GetSortedIndex(nMemberIndex)];
+ pRowMember = maMemberArray[GetSortedIndex(nMemberIndex)].get();
else
pRowMember = nullptr;
}
@@ -3287,7 +3285,7 @@ ScDPDataMember* ScDPResultDimension::GetRowReferenceMember(
bool bContinue = true;
while ( bContinue && nMemberIndex >= 0 && nMemberIndex < nMemberCount )
{
- const ScDPResultMember* pRowMember = maMemberArray[GetSortedIndex(nMemberIndex)];
+ const ScDPResultMember* pRowMember = maMemberArray[GetSortedIndex(nMemberIndex)].get();
// get child members by given indexes
@@ -3468,7 +3466,7 @@ void ScDPResultDimension::DumpState( const ScDPResultMember* pRefMember, ScDocum
long nCount = bIsDataLayout ? 1 : maMemberArray.size();
for (long i=0; i<nCount; i++)
{
- const ScDPResultMember* pMember = maMemberArray[i];
+ const ScDPResultMember* pMember = maMemberArray[i].get();
pMember->DumpState( pRefMember, pDoc, rPos );
}
@@ -3482,7 +3480,7 @@ void ScDPResultDimension::Dump(int nIndent) const
MemberArray::const_iterator it = maMemberArray.begin(), itEnd = maMemberArray.end();
for (; it != itEnd; ++it)
{
- const ScDPResultMember* p = *it;
+ const ScDPResultMember* p = it->get();
p->Dump(nIndent+1);
}
}
@@ -3495,11 +3493,11 @@ long ScDPResultDimension::GetMemberCount() const
const ScDPResultMember* ScDPResultDimension::GetMember(long n) const
{
- return maMemberArray[n];
+ return maMemberArray[n].get();
}
ScDPResultMember* ScDPResultDimension::GetMember(long n)
{
- return maMemberArray[n];
+ return maMemberArray[n].get();
}
ScDPResultDimension* ScDPResultDimension::GetFirstChildDimension() const
@@ -3519,7 +3517,7 @@ void ScDPResultDimension::FillVisibilityData(ScDPResultVisibilityData& rData) co
for (;itr != itrEnd; ++itr)
{
- ScDPResultMember* pMember = *itr;
+ ScDPResultMember* pMember = itr->get();
if (pMember->IsValid())
{
ScDPItemData aItem(pMember->FillItemData());
@@ -3976,7 +3974,7 @@ ScDPResultMember* ScDPResultDimension::AddMember(const ScDPParentDimData &aData
{
ScDPResultMember* pMember = new ScDPResultMember( pResultData, aData );
SCROW nDataIndex = pMember->GetDataId();
- maMemberArray.push_back( pMember );
+ maMemberArray.emplace_back( pMember );
if ( maMemberHash.end() == maMemberHash.find( nDataIndex ) )
maMemberHash.insert( std::pair< SCROW, ScDPResultMember *>( nDataIndex, pMember ) );
@@ -3989,14 +3987,14 @@ ScDPResultMember* ScDPResultDimension::InsertMember(ScDPParentDimData *pMemberDa
if ( !lcl_SearchMember( maMemberArray, pMemberData->mnOrder , nInsert ) )
{
ScDPResultMember* pNew = new ScDPResultMember( pResultData, *pMemberData );
- maMemberArray.insert( maMemberArray.begin()+nInsert, pNew );
+ maMemberArray.emplace( maMemberArray.begin()+nInsert, pNew );
SCROW nDataIndex = pMemberData->mpMemberDesc->GetItemDataId();
if ( maMemberHash.end() == maMemberHash.find( nDataIndex ) )
maMemberHash.insert( std::pair< SCROW, ScDPResultMember *>( nDataIndex, pNew ) );
return pNew;
}
- return maMemberArray[ nInsert ];
+ return maMemberArray[ nInsert ].get();
}
void ScDPResultDimension::InitWithMembers(
@@ -4096,7 +4094,7 @@ void ScDPResultDimension::CheckShowEmpty( bool bShow )
for (long i=0; i<nCount; i++)
{
- ScDPResultMember* pMember = maMemberArray.at(i);
+ ScDPResultMember* pMember = maMemberArray.at(i).get();
pMember->CheckShowEmpty(bShow);
}
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index 4eb19ef2fadf..f91d8b5c9627 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -1071,7 +1071,7 @@ ScFunctionMgr::ScFunctionMgr() :
OSL_ENSURE( pFuncList, "Functionlist not found." );
sal_uInt32 catCount[MAX_FUNCCAT] = {0};
- aCatLists[0] = new ::std::vector<const ScFuncDesc*>;
+ aCatLists[0].reset( new ::std::vector<const ScFuncDesc*> );
aCatLists[0]->reserve(pFuncList->GetCount());
// Retrieve all functions, store in cumulative ("All") category, and count
@@ -1090,7 +1090,7 @@ ScFunctionMgr::ScFunctionMgr() :
// Allocate correct amount of space for categories
for (sal_uInt16 i = 1; i < MAX_FUNCCAT; ++i)
{
- aCatLists[i] = new ::std::vector<const ScFuncDesc*>;
+ aCatLists[i].reset( new ::std::vector<const ScFuncDesc*> );
aCatLists[i]->reserve(catCount[i]);
}
@@ -1108,8 +1108,6 @@ ScFunctionMgr::ScFunctionMgr() :
ScFunctionMgr::~ScFunctionMgr()
{
- for (std::vector<const ScFuncDesc*> * pCatList : aCatLists)
- delete pCatList;
}
@@ -1163,7 +1161,7 @@ const formula::IFunctionCategory* ScFunctionMgr::getCategory(sal_uInt32 nCategor
if ( nCategory < (MAX_FUNCCAT-1) )
{
if (m_aCategories.find(nCategory) == m_aCategories.end())
- m_aCategories[nCategory].reset(new ScFunctionCategory(aCatLists[nCategory+1],nCategory)); // aCatLists[0] is "all"
+ m_aCategories[nCategory].reset(new ScFunctionCategory(aCatLists[nCategory+1].get(),nCategory)); // aCatLists[0] is "all"
return m_aCategories[nCategory].get();
}
return nullptr;
diff --git a/sc/source/filter/inc/tool.h b/sc/source/filter/inc/tool.h
index c2a5b2bc62b7..1fde4eee450b 100644
--- a/sc/source/filter/inc/tool.h
+++ b/sc/source/filter/inc/tool.h
@@ -48,7 +48,7 @@ class FormIdent
{
private:
StampTyp nStamp; // ID key
- SfxUInt32Item* pAttr; // associated attribute
+ std::unique_ptr<SfxUInt32Item> pAttr; // associated attribute
public:
FormIdent( void )
{
@@ -59,7 +59,7 @@ public:
FormIdent( sal_uInt8 nFormat, sal_uInt8 nSt, SfxUInt32Item& rAttr )
{
nStamp = MAKE_STAMP( nFormat, nSt );
- pAttr = &rAttr;
+ pAttr.reset(&rAttr);
}
StampTyp GetStamp( void ) const
@@ -69,7 +69,7 @@ public:
SfxUInt32Item* GetAttr( void )
{
- return pAttr;
+ return pAttr.get();
}
void SetStamp( sal_uInt8 nFormat, sal_uInt8 nSt )
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index 07c1f93a8dd3..d29d9f981480 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -158,8 +158,6 @@ FormCache::FormCache( ScDocument* pDoc1 )
FormCache::~FormCache()
{
- for(FormIdent & rIdent : aIdents)
- delete rIdent.GetAttr();
}
SfxUInt32Item* FormCache::NewAttr( sal_uInt8 nFormat, sal_uInt8 nSt )
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index f9435aac55f1..52793a927060 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -374,7 +374,7 @@ handle_r1c1:
if (!nCount)
{
mpEditEngine->SetUpdateMode( false );
- pRangeFindList = new ScRangeFindList( pDocSh->GetTitle() );
+ pRangeFindList.reset(new ScRangeFindList( pDocSh->GetTitle() ));
}
ColorData nColorData = pRangeFindList->Insert( ScRangeFindData( aRange, nFlags, nStart, nPos ) );
@@ -486,7 +486,7 @@ void ScInputHandler::DeleteRangeFinder()
ScDocShell* pDocSh = pActiveViewSh->GetViewData().GetDocShell();
pRangeFindList->SetHidden(true);
pDocSh->Broadcast( SfxHint( SfxHintId::ScShowRangeFinder ) ); // Steal
- DELETEZ(pRangeFindList);
+ pRangeFindList.reset();
}
}
@@ -647,7 +647,7 @@ ScInputHandler::ScInputHandler()
// Bindings (only still used for Invalidate) are retrieved if needed on demand
- pDelayTimer = new Timer( "ScInputHandlerDelay timer" );
+ pDelayTimer.reset( new Timer( "ScInputHandlerDelay timer" ) );
pDelayTimer->SetTimeout( 500 ); // 500 ms delay
pDelayTimer->SetInvokeHandler( LINK( this, ScInputHandler, DelayTimer ) );
}
@@ -664,15 +664,6 @@ ScInputHandler::~ScInputHandler()
if ( pInputWin && pInputWin->GetInputHandler() == this )
pInputWin->SetInputHandler( nullptr );
-
- delete pRangeFindList; pRangeFindList = nullptr;
- delete pEditDefaults; pEditDefaults = nullptr;
- mpEditEngine.reset();
- delete pLastState; pLastState = nullptr;
- delete pDelayTimer; pDelayTimer = nullptr;
- delete pColumnData; pColumnData = nullptr;
- delete pFormulaData; pFormulaData = nullptr;
- delete pFormulaDataPara; pFormulaDataPara = nullptr;
}
void ScInputHandler::SetRefScale( const Fraction& rX, const Fraction& rY )
@@ -733,7 +724,7 @@ void ScInputHandler::ImplCreateEditEngine()
mpEditEngine->SetWordDelimiters( ScEditUtil::ModifyDelimiters( mpEditEngine->GetWordDelimiters() ) );
UpdateRefDevice(); // also sets MapMode
mpEditEngine->SetPaperSize( Size( 1000000, 1000000 ) );
- pEditDefaults = new SfxItemSet( mpEditEngine->GetEmptyItemSet() );
+ pEditDefaults.reset( new SfxItemSet( mpEditEngine->GetEmptyItemSet() ) );
mpEditEngine->SetControlWord( mpEditEngine->GetControlWord() | EEControlBits::AUTOCORRECT );
mpEditEngine->SetReplaceLeadingSingleQuotationMark( false );
@@ -823,13 +814,13 @@ void ScInputHandler::GetFormulaData()
pFormulaData->clear();
else
{
- pFormulaData = new ScTypedCaseStrSet;
+ pFormulaData.reset( new ScTypedCaseStrSet );
}
if( pFormulaDataPara )
pFormulaDataPara->clear();
else
- pFormulaDataPara = new ScTypedCaseStrSet;
+ pFormulaDataPara.reset( new ScTypedCaseStrSet );
const OUString aParenthesesReplacement( cParenthesesReplacement);
const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
@@ -1621,7 +1612,7 @@ void ScInputHandler::GetColData()
if ( pColumnData )
pColumnData->clear();
else
- pColumnData = new ScTypedCaseStrSet;
+ pColumnData.reset( new ScTypedCaseStrSet );
std::vector<ScTypedStrData> aEntries;
rDoc.GetDataEntries(
@@ -1831,8 +1822,7 @@ void ScInputHandler::ViewShellGone(const ScTabViewShell* pViewSh) // Executed sy
{
if ( pViewSh == pActiveViewSh )
{
- delete pLastState;
- pLastState = nullptr;
+ pLastState.reset();
pLastPattern = nullptr;
}
@@ -1936,7 +1926,7 @@ void ScInputHandler::ForgetLastPattern()
if ( !pLastState && pActiveViewSh )
pActiveViewSh->UpdateInputHandler( true ); // Get status again
else
- NotifyChange( pLastState, true );
+ NotifyChange( pLastState.get(), true );
}
void ScInputHandler::UpdateAdjust( sal_Unicode cTyped )
@@ -2115,7 +2105,7 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn
//! EditEngine changes) implemented as a SetParaAttribs.
//! Any problems?
- pPattern->FillEditItemSet( pEditDefaults );
+ pPattern->FillEditItemSet( pEditDefaults.get() );
mpEditEngine->SetDefaults( *pEditDefaults );
pLastPattern = pPattern;
bLastIsSymbol = pPattern->IsSymbolFont();
@@ -2912,8 +2902,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
rBindings.Execute( nId, aArgs );
}
- delete pLastState; // pLastState still contains the old text
- pLastState = nullptr;
+ pLastState.reset(); // pLastState still contains the old text
}
else
pSfxApp->Broadcast( SfxHint( SfxHintId::ScKillEditView ) );
@@ -2978,7 +2967,7 @@ void ScInputHandler::CancelHandler()
if ( !pLastState && pExecuteSh )
pExecuteSh->UpdateInputHandler( true ); // Update status again
else
- NotifyChange( pLastState, true );
+ NotifyChange( pLastState.get(), true );
nFormSelStart = nFormSelEnd = 0;
aFormText.clear();
@@ -3571,7 +3560,7 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
if (bInEnterHandler)
return;
- bool bRepeat = (pState == pLastState);
+ bool bRepeat = (pState == pLastState.get());
if (!bRepeat && pState && pLastState)
bRepeat = (*pState == *pLastState);
if (bRepeat && !bForce)
@@ -3592,10 +3581,9 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
ImplCreateEditEngine();
- if ( pState != pLastState )
+ if ( pState != pLastState.get() )
{
- delete pLastState;
- pLastState = pState ? new ScInputHdlState( *pState ) : nullptr;
+ pLastState.reset( pState ? new ScInputHdlState( *pState ) : nullptr);
}
if ( pState && pActiveViewSh )
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index 99fd54f299a2..c470792fa662 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -60,9 +60,9 @@ private:
EditView* pTableView; // associated active EditView
EditView* pTopView; // EditView in the input row
- ScTypedCaseStrSet* pColumnData;
- ScTypedCaseStrSet* pFormulaData;
- ScTypedCaseStrSet* pFormulaDataPara;
+ std::unique_ptr<ScTypedCaseStrSet> pColumnData;
+ std::unique_ptr<ScTypedCaseStrSet> pFormulaData;
+ std::unique_ptr<ScTypedCaseStrSet> pFormulaDataPara;
ScTypedCaseStrSet::const_iterator miAutoPosColumn;
ScTypedCaseStrSet::const_iterator miAutoPosFormula;
@@ -109,12 +109,15 @@ private:
ScTabViewShell* pActiveViewSh;
const ScPatternAttr* pLastPattern;
- SfxItemSet* pEditDefaults;
+ std::unique_ptr<SfxItemSet>
+ pEditDefaults;
- ScInputHdlState* pLastState;
- Timer* pDelayTimer;
+ std::unique_ptr<ScInputHdlState>
+ pLastState;
+ std::unique_ptr<Timer> pDelayTimer;
- ScRangeFindList* pRangeFindList;
+ std::unique_ptr<ScRangeFindList>
+ pRangeFindList;
static bool bAutoComplete; // from app options
static bool bOptLoaded;
@@ -232,7 +235,7 @@ public:
void ShowRefFrame();
- ScRangeFindList* GetRangeFindList() { return pRangeFindList; }
+ ScRangeFindList* GetRangeFindList() { return pRangeFindList.get(); }
void UpdateRange( sal_uInt16 nIndex, const ScRange& rNew );