[Libreoffice-commits] core.git: xmloff/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 18 06:23:44 UTC 2018


 xmloff/source/draw/sdxmlexp.cxx |   28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

New commits:
commit c2a91dc53431b5658f54ca4fd32ca79165e865af
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Dec 14 09:11:46 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Dec 18 07:23:21 2018 +0100

    use unique_ptr in ImpXMLAutoLayoutInfo
    
    Change-Id: Iede8522988ae26a76fe5bb28491c17b76376420f
    Reviewed-on: https://gerrit.libreoffice.org/65145
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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);


More information about the Libreoffice-commits mailing list