diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-22 14:45:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-23 11:34:48 +0200 |
commit | b1c44589581f7edefea782d5dadc4a4256f7ad37 (patch) | |
tree | 8bfbcea475dce8c0e6e21c75f0d28a5b2d8d9191 | |
parent | 77f7b4768a79e5a8489b163670e0ce10fbd07c49 (diff) |
simplify ScMyDeletedList
no need to use std::list and no need to allocate entries directly
Change-Id: If02cff310af85727d5d1152b7be6114ee0b0830e
Reviewed-on: https://gerrit.libreoffice.org/59450
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx | 37 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx | 9 |
2 files changed, 13 insertions, 33 deletions
diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index fe0feec6e36f..5f1862ae023e 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -78,16 +78,6 @@ const ScCellValue& ScMyCellInfo::CreateCell( ScDocument* pDoc ) return maCell; } -ScMyDeleted::ScMyDeleted() - : nID(0) - , pCellInfo(nullptr) -{ -} - -ScMyDeleted::~ScMyDeleted() -{ -} - ScMyGenerated::ScMyGenerated(std::unique_ptr<ScMyCellInfo> pTempCellInfo, const ScBigRange& aTempBigRange) : aBigRange(aTempBigRange) , nID(0) @@ -295,17 +285,12 @@ void ScXMLChangeTrackingImportHelper::SetPosition(const sal_Int32 nPosition, con void ScXMLChangeTrackingImportHelper::AddDeleted(const sal_uInt32 nID) { - ScMyDeleted* pDeleted = new ScMyDeleted(); - pDeleted->nID = nID; - pCurrentAction->aDeletedList.push_front(pDeleted); + pCurrentAction->aDeletedList.emplace_front( nID, nullptr ); } void ScXMLChangeTrackingImportHelper::AddDeleted(const sal_uInt32 nID, std::unique_ptr<ScMyCellInfo> pCellInfo) { - ScMyDeleted* pDeleted = new ScMyDeleted(); - pDeleted->nID = nID; - pDeleted->pCellInfo = std::move(pCellInfo); - pCurrentAction->aDeletedList.push_front(pDeleted); + pCurrentAction->aDeletedList.emplace_front( nID, std::move(pCellInfo) ); } void ScXMLChangeTrackingImportHelper::SetMultiSpanned(const sal_Int16 nTempMultiSpanned) @@ -669,28 +654,26 @@ void ScXMLChangeTrackingImportHelper::SetDependencies(ScMyBaseAction* pAction) } if (!pAction->aDeletedList.empty()) { - ScMyDeletedList::iterator aItr(pAction->aDeletedList.begin()); - ScMyDeletedList::iterator aEndItr(pAction->aDeletedList.end()); + auto aItr(pAction->aDeletedList.begin()); + auto aEndItr(pAction->aDeletedList.end()); while(aItr != aEndItr) { - pAct->SetDeletedInThis((*aItr)->nID, pTrack); - ScChangeAction* pDeletedAct = pTrack->GetAction((*aItr)->nID); - if ((pDeletedAct->GetType() == SC_CAT_CONTENT) && (*aItr)->pCellInfo) + pAct->SetDeletedInThis(aItr->nID, pTrack); + ScChangeAction* pDeletedAct = pTrack->GetAction(aItr->nID); + if ((pDeletedAct->GetType() == SC_CAT_CONTENT) && aItr->pCellInfo) { ScChangeActionContent* pContentAct = static_cast<ScChangeActionContent*>(pDeletedAct); - if (pContentAct && (*aItr)->pCellInfo) + if (pContentAct && aItr->pCellInfo) { - const ScCellValue& rCell = (*aItr)->pCellInfo->CreateCell(pDoc); + const ScCellValue& rCell = aItr->pCellInfo->CreateCell(pDoc); if (!rCell.equalsWithoutFormat(pContentAct->GetNewCell())) { // #i40704# Don't overwrite SetNewCell result by calling SetNewValue, // instead pass the input string to SetNewCell. - pContentAct->SetNewCell(rCell, pDoc, (*aItr)->pCellInfo->sInputString); + pContentAct->SetNewCell(rCell, pDoc, aItr->pCellInfo->sInputString); } } } - if (*aItr) - delete *aItr; aItr = pAction->aDeletedList.erase(aItr); } } diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx index 55b6588ab39c..036a9333613d 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx @@ -61,15 +61,12 @@ struct ScMyCellInfo struct ScMyDeleted { - sal_uInt32 nID; + sal_uInt32 nID = 0; std::unique_ptr<ScMyCellInfo> pCellInfo; - ScMyDeleted(); - ~ScMyDeleted(); + ScMyDeleted(sal_uInt32 id, std::unique_ptr<ScMyCellInfo> p) : nID(id), pCellInfo(std::move(p)) {} }; -typedef std::list<ScMyDeleted*> ScMyDeletedList; - struct ScMyGenerated { ScBigRange aBigRange; @@ -119,7 +116,7 @@ struct ScMyBaseAction ScMyActionInfo aInfo; ScBigRange aBigRange; ScMyDependencies aDependencies; - ScMyDeletedList aDeletedList; + std::deque<ScMyDeleted> aDeletedList; sal_uInt32 nActionNumber; sal_uInt32 nRejectingNumber; sal_uInt32 nPreviousAction; |