summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-12-14 09:11:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-12-18 07:23:21 +0100
commitc2a91dc53431b5658f54ca4fd32ca79165e865af (patch)
tree677f18fdd036a460af408d6e3a2bc031f4132666 /xmloff
parent49fb2a24c46e5097650c0951eeabe336d242834a (diff)
use unique_ptr in ImpXMLAutoLayoutInfo
Change-Id: Iede8522988ae26a76fe5bb28491c17b76376420f Reviewed-on: https://gerrit.libreoffice.org/65145 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/draw/sdxmlexp.cxx28
1 files changed, 8 insertions, 20 deletions
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 2383e4344321..3e16678ced13 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -205,9 +205,8 @@ class ImpXMLAutoLayoutInfo
public:
ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf);
- bool operator==(const ImpXMLAutoLayoutInfo& rInfo) const;
-
sal_uInt16 GetLayoutType() const { return mnType; }
+ ImpXMLEXPPageMasterInfo* GetPageMasterInfo() const { return mpPageMasterInfo; }
sal_Int32 GetGapX() const { return mnGapX; }
sal_Int32 GetGapY() const { return mnGapY; }
@@ -229,12 +228,6 @@ bool ImpXMLAutoLayoutInfo::IsCreateNecessary(sal_uInt16 nTyp)
return true;
}
-bool ImpXMLAutoLayoutInfo::operator==(const ImpXMLAutoLayoutInfo& rInfo) const
-{
- return mnType == rInfo.mnType
- && mpPageMasterInfo == rInfo.mpPageMasterInfo;
-}
-
ImpXMLAutoLayoutInfo::ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf)
: mnType(nTyp)
, mpPageMasterInfo(pInf)
@@ -712,21 +705,16 @@ bool SdXMLExport::ImpPrepAutoLayoutInfo(const Reference<XDrawPage>& xPage, OUStr
}
// create entry and look for existence
- ImpXMLAutoLayoutInfo* pNew = new ImpXMLAutoLayoutInfo(nType, pInfo);
- bool bDidExist(false);
-
- for( size_t nCnt = 0; !bDidExist && nCnt < mvAutoLayoutInfoList.size(); nCnt++)
+ ImpXMLAutoLayoutInfo* pNew;
+ auto it = std::find_if(mvAutoLayoutInfoList.begin(), mvAutoLayoutInfoList.end(),
+ [=](std::unique_ptr<ImpXMLAutoLayoutInfo> const & rInfo) { return nType == rInfo->GetLayoutType() && pInfo == rInfo->GetPageMasterInfo(); });
+ if (it != mvAutoLayoutInfoList.end())
{
- if( *mvAutoLayoutInfoList.at( nCnt ) == *pNew)
- {
- delete pNew;
- pNew = mvAutoLayoutInfoList.at( nCnt ).get();
- bDidExist = true;
- }
+ pNew = it->get();
}
-
- if(!bDidExist)
+ else
{
+ pNew = new ImpXMLAutoLayoutInfo(nType, pInfo);
mvAutoLayoutInfoList.emplace_back( pNew );
OUString sNewName = "AL";
sNewName += OUString::number(mvAutoLayoutInfoList.size() - 1);