[Libreoffice-commits] core.git: sc/source
Julien Nabet
serval2412 at yahoo.fr
Fri Sep 1 07:37:12 UTC 2017
sc/source/ui/docshell/docfunc.cxx | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
New commits:
commit 6a7bbef0360b2958379e681f4ee22632f60e9278
Author: Julien Nabet <serval2412 at yahoo.fr>
Date: Thu Aug 31 22:56:45 2017 +0200
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 at libreoffice.org>
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
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;
}
}
More information about the Libreoffice-commits
mailing list