diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-08-31 22:56:45 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2017-09-01 09:36:53 +0200 |
commit | 6a7bbef0360b2958379e681f4ee22632f60e9278 (patch) | |
tree | 6597b3f4140fdd36e632d16eaeeb07d1b7fa1157 /sc | |
parent | 65ca7bd49ae3c567f2cc4331c6b35f350649dcee (diff) |
Replace list with a vector in PutData (sc)
+ revamp a little bit by using unique_ptr
Change-Id: I07fa08d1981db65dbb22e887fcab0e8a6ca64b58
Reviewed-on: https://gerrit.libreoffice.org/41774
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 6cc3ae4db697..308fc524ff64 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -1062,7 +1062,7 @@ void ScDocFunc::NotifyInputHandler( const ScAddress& rPos ) nIndex(nTempIndex), aItemSet(rItemSet) {} }; - typedef ::std::list<ScMyRememberItem*> ScMyRememberItemList; + typedef ::std::vector<std::unique_ptr<ScMyRememberItem>> ScMyRememberItemVector; void ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bool bApi ) { @@ -1083,13 +1083,12 @@ void ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, if (bUpdateMode) rEngine.SetUpdateMode(false); - ScMyRememberItemList aRememberItems; - ScMyRememberItem* pRememberItem = nullptr; + ScMyRememberItemVector aRememberItems; // All paragraph attributes must be removed before calling CreateTextObject, // not only alignment, so the object doesn't contain the cell attributes as - // paragraph attributes. Before remove the attributes store they in a list to - // set they back to the EditEngine. + // paragraph attributes. Before removing the attributes store them in a vector to + // set them back to the EditEngine. sal_Int32 nCount = rEngine.GetParagraphCount(); for (sal_Int32 i=0; i<nCount; i++) { @@ -1098,8 +1097,7 @@ void ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, { if ( !bLoseContent ) { - pRememberItem = new ScMyRememberItem(rEngine.GetParaAttribs(i), i); - aRememberItems.push_back(pRememberItem); + aRememberItems.push_back(o3tl::make_unique<ScMyRememberItem>(rEngine.GetParaAttribs(i), i)); } rEngine.SetParaAttribs( i, SfxItemSet( *rOld.GetPool(), rOld.GetRanges() ) ); } @@ -1112,13 +1110,11 @@ void ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, // Set the paragraph attributes back to the EditEngine. if (!aRememberItems.empty()) { - ScMyRememberItemList::iterator aItr = aRememberItems.begin(); + ScMyRememberItemVector::iterator aItr = aRememberItems.begin(); while (aItr != aRememberItems.end()) { - pRememberItem = *aItr; - rEngine.SetParaAttribs(pRememberItem->nIndex, pRememberItem->aItemSet); - delete pRememberItem; - aItr = aRememberItems.erase(aItr); + rEngine.SetParaAttribs((*aItr).get()->nIndex, (*aItr).get()->aItemSet); + ++aItr; } } |