Kaydet (Commit) 4467dc66 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in sc

Change-Id: Ia647ef2dda2dd54a4958a7dc561a0fb86abdfd86
Reviewed-on: https://gerrit.libreoffice.org/41522Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 4d41b2e4
......@@ -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?
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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 )
......
......@@ -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 )
......
......@@ -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 )
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment