[Libreoffice-commits] core.git: 4 commits - sw/inc sw/qa sw/source

Michael Stahl mstahl at redhat.com
Wed Sep 16 04:05:49 PDT 2015


 sw/inc/ToxLinkProcessor.hxx             |    7 +++--
 sw/inc/fmtclds.hxx                      |    5 ++--
 sw/inc/tblafmt.hxx                      |    4 +--
 sw/qa/core/test_ToxLinkProcessor.cxx    |   24 ++++++++++----------
 sw/source/core/doc/tblafmt.cxx          |   38 +++++++++++++++++---------------
 sw/source/core/inc/UndoCore.hxx         |   21 +++++++++--------
 sw/source/core/layout/atrfrm.cxx        |   21 +++++++----------
 sw/source/core/tox/ToxLinkProcessor.cxx |   25 +++++++++++----------
 sw/source/core/undo/undobj.cxx          |   12 +++++-----
 sw/source/ui/table/tautofmt.cxx         |   11 +++++----
 10 files changed, 88 insertions(+), 80 deletions(-)

New commits:
commit bf2116353a89c402bf19b79d49eadf4454103423
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Sep 16 12:48:57 2015 +0200

    sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    Change-Id: I4abd8fcbbe8ef439097eed7c2b20584450182cd5

diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx
index 545b80b..c3e219e 100644
--- a/sw/source/core/inc/UndoCore.hxx
+++ b/sw/source/core/inc/UndoCore.hxx
@@ -25,7 +25,8 @@
 #include <rtl/ustring.hxx>
 #include <redline.hxx>
 
-#include <boost/ptr_container/ptr_vector.hpp>
+#include <memory>
+#include <vector>
 
 class SfxItemSet;
 class SwFormatColl;
@@ -65,17 +66,17 @@ public:
 
 class SwRedlineSaveDatas {
 private:
-    boost::ptr_vector<SwRedlineSaveData> mvData;
+    std::vector<std::unique_ptr<SwRedlineSaveData>> m_Data;
 
 public:
-    SwRedlineSaveDatas() : mvData() {}
-
-    void clear() { mvData.clear(); }
-    bool empty() const { return mvData.empty(); }
-    size_t size() const { return mvData.size(); }
-    void push_back (SwRedlineSaveData* value) { mvData.push_back(value); }
-    const SwRedlineSaveData& operator[]( size_t nIdx ) const { return mvData[ nIdx ]; }
-    SwRedlineSaveData& operator[]( size_t nIdx ) { return mvData[ nIdx ]; }
+    SwRedlineSaveDatas() : m_Data() {}
+
+    void clear() { m_Data.clear(); }
+    bool empty() const { return m_Data.empty(); }
+    size_t size() const { return m_Data.size(); }
+    void push_back(std::unique_ptr<SwRedlineSaveData> pNew) { m_Data.push_back(std::move(pNew)); }
+    const SwRedlineSaveData& operator[](size_t const nIdx) const { return *m_Data[ nIdx ]; }
+    SwRedlineSaveData& operator[](size_t const nIdx) { return *m_Data[ nIdx ]; }
 };
 
 namespace sw {
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 3683060..cfa249a 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -979,7 +979,6 @@ bool SwUndo::FillSaveData(
 {
     rSData.clear();
 
-    SwRedlineSaveData* pNewData;
     const SwPosition* pStt = rRange.Start();
     const SwPosition* pEnd = rRange.End();
     const SwRedlineTable& rTable = rRange.GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
@@ -996,8 +995,9 @@ bool SwUndo::FillSaveData(
              && eCmpPos != POS_COLLIDE_END
              && eCmpPos != POS_COLLIDE_START )
         {
-            pNewData = new SwRedlineSaveData( eCmpPos, *pStt, *pEnd, *pRedl, bCopyNext );
-            rSData.push_back( pNewData );
+            std::unique_ptr<SwRedlineSaveData> pNewData(
+                new SwRedlineSaveData(eCmpPos, *pStt, *pEnd, *pRedl, bCopyNext));
+            rSData.push_back(std::move(pNewData));
         }
     }
     if( !rSData.empty() && bDelRange )
@@ -1013,7 +1013,6 @@ bool SwUndo::FillSaveDataForFormat(
 {
     rSData.clear();
 
-    SwRedlineSaveData* pNewData;
     const SwPosition *pStt = rRange.Start(), *pEnd = rRange.End();
     const SwRedlineTable& rTable = rRange.GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
     sal_uInt16 n = 0;
@@ -1029,8 +1028,9 @@ bool SwUndo::FillSaveDataForFormat(
                  && eCmpPos != POS_COLLIDE_END
                  && eCmpPos != POS_COLLIDE_START )
             {
-                pNewData = new SwRedlineSaveData( eCmpPos, *pStt, *pEnd, *pRedl, true );
-                rSData.push_back( pNewData );
+                std::unique_ptr<SwRedlineSaveData> pNewData(
+                    new SwRedlineSaveData(eCmpPos, *pStt, *pEnd, *pRedl, true));
+                rSData.push_back(std::move(pNewData));
             }
 
         }
commit 0a601a0cb14dc0f60e00eb46929f53eebe59a6af
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Sep 16 12:40:14 2015 +0200

    sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    Change-Id: I3bfb0933d5233b89f24773500f07fdc92d0011e9

diff --git a/sw/inc/ToxLinkProcessor.hxx b/sw/inc/ToxLinkProcessor.hxx
index 3887121..699c0ec 100644
--- a/sw/inc/ToxLinkProcessor.hxx
+++ b/sw/inc/ToxLinkProcessor.hxx
@@ -13,7 +13,8 @@
 #include "fmtinfmt.hxx"
 #include "rtl/ustring.hxx"
 
-#include <boost/ptr_container/ptr_vector.hpp>
+#include <memory>
+#include <vector>
 
 class SwTextNode;
 
@@ -76,9 +77,9 @@ private:
         sal_Int32 mEndTextPos;
     };
 
-    boost::ptr_vector<ClosedLink> mClosedLinks;
+    std::vector<std::unique_ptr<ClosedLink>> m_ClosedLinks;
 
-    boost::ptr_vector<StartedLink> mStartedLinks;
+    std::vector<std::unique_ptr<StartedLink>> m_StartedLinks;
 
     friend class ::ToxLinkProcessorTest;
 };
diff --git a/sw/qa/core/test_ToxLinkProcessor.cxx b/sw/qa/core/test_ToxLinkProcessor.cxx
index 660d745..03c8550 100644
--- a/sw/qa/core/test_ToxLinkProcessor.cxx
+++ b/sw/qa/core/test_ToxLinkProcessor.cxx
@@ -81,8 +81,8 @@ ToxLinkProcessorTest::StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed(
     sut.StartNewLink(0, STYLE_NAME_1);
     sut.CloseLink(1, URL_1);
     sut.CloseLink(1, URL_1);
-    CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.mClosedLinks.size()));
-    CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned>(sut.mClosedLinks.at(1).mEndTextPos));
+    CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.m_ClosedLinks.size()));
+    CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned>(sut.m_ClosedLinks.at(1)->mEndTextPos));
 }
 
 void
@@ -93,8 +93,8 @@ ToxLinkProcessorTest::AddingAndClosingTwoLinksResultsInTwoClosedLinks()
     sut.StartNewLink(0, STYLE_NAME_2);
     sut.CloseLink(1, URL_1);
     sut.CloseLink(1, URL_2);
-    CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.mClosedLinks.size()));
-    CPPUNIT_ASSERT_MESSAGE("no links are open", sut.mStartedLinks.empty());
+    CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.m_ClosedLinks.size()));
+    CPPUNIT_ASSERT_MESSAGE("no links are open", sut.m_StartedLinks.empty());
 }
 
 class ToxLinkProcessorWithOverriddenObtainPoolId : public ToxLinkProcessor {
@@ -120,8 +120,8 @@ ToxLinkProcessorTest::LinkIsCreatedCorrectly()
     sut.StartNewLink(0, STYLE_NAME_1);
     sut.CloseLink(1, URL_1);
 
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Style is stored correctly in link", STYLE_NAME_1, sut.mClosedLinks.at(0).mINetFormat.GetVisitedFormat());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Url is stored correctly in link", URL_1, sut.mClosedLinks.at(0).mINetFormat.GetValue());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Style is stored correctly in link", STYLE_NAME_1, sut.m_ClosedLinks.at(0)->mINetFormat.GetVisitedFormat());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Url is stored correctly in link", URL_1, sut.m_ClosedLinks.at(0)->mINetFormat.GetValue());
 }
 
 void
@@ -138,18 +138,18 @@ ToxLinkProcessorTest::LinkSequenceIsPreserved()
 
     // check first closed element
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Style is stored correctly in link",
-            STYLE_NAME_2, sut.mClosedLinks.at(0).mINetFormat.GetVisitedFormat());
+            STYLE_NAME_2, sut.m_ClosedLinks.at(0)->mINetFormat.GetVisitedFormat());
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Pool id is stored correctly in link",
-            POOL_ID_2, sut.mClosedLinks.at(0).mINetFormat.GetINetFormatId());
+            POOL_ID_2, sut.m_ClosedLinks.at(0)->mINetFormat.GetINetFormatId());
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Url is stored correctly in link",
-            URL_2, sut.mClosedLinks.at(0).mINetFormat.GetValue());
+            URL_2, sut.m_ClosedLinks.at(0)->mINetFormat.GetValue());
     // check second closed element
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Style is stored correctly in link",
-            STYLE_NAME_1, sut.mClosedLinks.at(1).mINetFormat.GetVisitedFormat());
+            STYLE_NAME_1, sut.m_ClosedLinks.at(1)->mINetFormat.GetVisitedFormat());
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Pool id is stored correctly in link",
-            POOL_ID_1, sut.mClosedLinks.at(1).mINetFormat.GetINetFormatId());
+            POOL_ID_1, sut.m_ClosedLinks.at(1)->mINetFormat.GetINetFormatId());
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Url is stored correctly in link",
-            URL_1, sut.mClosedLinks.at(1).mINetFormat.GetValue());
+            URL_1, sut.m_ClosedLinks.at(1)->mINetFormat.GetValue());
 }
 
 // Put the test suite in the registry
diff --git a/sw/source/core/tox/ToxLinkProcessor.cxx b/sw/source/core/tox/ToxLinkProcessor.cxx
index bd2d6f8..cbb7275 100644
--- a/sw/source/core/tox/ToxLinkProcessor.cxx
+++ b/sw/source/core/tox/ToxLinkProcessor.cxx
@@ -20,32 +20,34 @@ namespace sw {
 void
 ToxLinkProcessor::StartNewLink(sal_Int32 startPosition, const OUString& characterStyle)
 {
-    mStartedLinks.push_back(new StartedLink(startPosition, characterStyle));
+    m_StartedLinks.push_back(std::unique_ptr<StartedLink>(
+                new StartedLink(startPosition, characterStyle)));
 }
 
 void
 ToxLinkProcessor::CloseLink(sal_Int32 endPosition, const OUString& url)
 {
-    StartedLink const startedLink( (mStartedLinks.empty())
+    StartedLink const startedLink( (m_StartedLinks.empty())
         ? StartedLink(0, SW_RES(STR_POOLCHR_TOXJUMP))
-        : mStartedLinks.back() );
-    if (!mStartedLinks.empty())
+        : *m_StartedLinks.back() );
+    if (!m_StartedLinks.empty())
     {
-        mStartedLinks.pop_back();
+        m_StartedLinks.pop_back();
     }
 
     if (url.isEmpty()) {
         return;
     }
 
-    ClosedLink* closedLink = new ClosedLink(url, startedLink.mStartPosition, endPosition);
+    std::unique_ptr<ClosedLink> pClosedLink(
+            new ClosedLink(url, startedLink.mStartPosition, endPosition));
 
     const OUString& characterStyle = startedLink.mCharacterStyle;
     sal_uInt16 poolId = ObtainPoolId(characterStyle);
-    closedLink->mINetFormat.SetVisitedFormatAndId(characterStyle, poolId);
-    closedLink->mINetFormat.SetINetFormatAndId(characterStyle, poolId);
+    pClosedLink->mINetFormat.SetVisitedFormatAndId(characterStyle, poolId);
+    pClosedLink->mINetFormat.SetINetFormatAndId(characterStyle, poolId);
 
-    mClosedLinks.push_back(closedLink);
+    m_ClosedLinks.push_back(std::move(pClosedLink));
 }
 
 sal_uInt16
@@ -63,8 +65,9 @@ ToxLinkProcessor::ObtainPoolId(const OUString& characterStyle) const
 void
 ToxLinkProcessor::InsertLinkAttributes(SwTextNode& node)
 {
-    for (ClosedLink& clink : mClosedLinks) {
-        node.InsertItem(clink.mINetFormat, clink.mStartTextPos, clink.mEndTextPos);
+    for (auto const& clink : m_ClosedLinks)
+    {
+        node.InsertItem(clink->mINetFormat, clink->mStartTextPos, clink->mEndTextPos);
     }
 }
 
commit 529f5441a7633a76f0a393e9f6dcb83b0b2e408c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Sep 15 23:41:24 2015 +0200

    sw: replace boost::ptr_vector with std::vector
    
    Change-Id: I708bd090b28fd8b9f2642425fa55fcaa5f8346ec

diff --git a/sw/inc/fmtclds.hxx b/sw/inc/fmtclds.hxx
index 7bf1a4b..0213c20 100644
--- a/sw/inc/fmtclds.hxx
+++ b/sw/inc/fmtclds.hxx
@@ -25,7 +25,8 @@
 #include "swdllapi.h"
 #include <hintids.hxx>
 #include <format.hxx>
-#include <boost/ptr_container/ptr_vector.hpp>
+
+#include <vector>
 
 /// ColumnDescriptor
 class SwColumn
@@ -56,7 +57,7 @@ public:
     void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
-typedef boost::ptr_vector<SwColumn> SwColumns;
+typedef std::vector<SwColumn> SwColumns;
 
 enum SwColLineAdj
 {
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index b131719..a1512f4 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -821,15 +821,14 @@ SwFormatCol::SwFormatCol( const SwFormatCol& rCpy )
     m_aLineColor( rCpy.m_aLineColor),
     m_nLineHeight( rCpy.GetLineHeight() ),
     m_eAdj( rCpy.GetLineAdj() ),
-    m_aColumns( (sal_Int8)rCpy.GetNumCols() ),
     m_nWidth( rCpy.GetWishWidth() ),
     m_aWidthAdjustValue( rCpy.m_aWidthAdjustValue ),
     m_bOrtho( rCpy.IsOrtho() )
 {
+    m_aColumns.reserve(rCpy.GetNumCols());
     for ( sal_uInt16 i = 0; i < rCpy.GetNumCols(); ++i )
     {
-        SwColumn *pCol = new SwColumn( rCpy.GetColumns()[i] );
-        m_aColumns.push_back( pCol );
+        m_aColumns.push_back( SwColumn(rCpy.GetColumns()[i]) );
     }
 }
 
@@ -850,8 +849,7 @@ SwFormatCol& SwFormatCol::operator=( const SwFormatCol& rCpy )
         m_aColumns.clear();
     for ( sal_uInt16 i = 0; i < rCpy.GetNumCols(); ++i )
     {
-        SwColumn *pCol = new SwColumn( rCpy.GetColumns()[i] );
-        m_aColumns.push_back( pCol );
+        m_aColumns.push_back( SwColumn(rCpy.GetColumns()[i]) );
     }
     return *this;
 }
@@ -956,8 +954,7 @@ void SwFormatCol::Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16
         m_aColumns.clear();
     for ( sal_uInt16 i = 0; i < nNumCols; ++i )
     {
-        SwColumn *pCol = new SwColumn;
-        m_aColumns.push_back( pCol );
+        m_aColumns.push_back( SwColumn() );
     }
     m_bOrtho = true;
     m_nWidth = USHRT_MAX;
@@ -1092,12 +1089,12 @@ bool SwFormatCol::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
             if(nCount > 1)
                 for(sal_uInt16 i = 0; i < nCount; i++)
                 {
-                    SwColumn* pCol = new SwColumn;
-                    pCol->SetWishWidth( static_cast<sal_uInt16>(pArray[i].Width) );
+                    SwColumn aCol;
+                    aCol.SetWishWidth(static_cast<sal_uInt16>(pArray[i].Width) );
                     nWidthSum = static_cast<sal_uInt16>(nWidthSum + pArray[i].Width);
-                    pCol->SetLeft ( static_cast<sal_uInt16>(convertMm100ToTwip(pArray[i].LeftMargin)) );
-                    pCol->SetRight( static_cast<sal_uInt16>(convertMm100ToTwip(pArray[i].RightMargin)) );
-                    m_aColumns.insert(m_aColumns.begin() + i, pCol);
+                    aCol.SetLeft (static_cast<sal_uInt16>(convertMm100ToTwip(pArray[i].LeftMargin)));
+                    aCol.SetRight(static_cast<sal_uInt16>(convertMm100ToTwip(pArray[i].RightMargin)));
+                    m_aColumns.insert(m_aColumns.begin() + i, aCol);
                 }
             bRet = true;
             m_nWidth = nWidthSum;
commit 01648a391107c1501ed1948ef1b18539d551176e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Sep 15 23:53:29 2015 +0200

    sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
    
    Change-Id: I880526fdcce3be0f9e9149695812e048d95004e6

diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index 64b8a97..3503bb7 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -310,9 +310,9 @@ public:
     size_t size() const;
     SwTableAutoFormat const& operator[](size_t i) const;
     SwTableAutoFormat      & operator[](size_t i);
-    void InsertAutoFormat(size_t i, SwTableAutoFormat * pFormat);
+    void InsertAutoFormat(size_t i, std::unique_ptr<SwTableAutoFormat> pFormat);
     void EraseAutoFormat(size_t i);
-    SwTableAutoFormat* ReleaseAutoFormat(size_t i);
+    std::unique_ptr<SwTableAutoFormat> ReleaseAutoFormat(size_t i);
 
     bool Load();
     bool Save() const;
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index d35ccc2..6d2f4e5 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -41,9 +41,11 @@
 #include <fmtornt.hxx>
 #include <editsh.hxx>
 
-#include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/noncopyable.hpp>
 
+#include <memory>
+#include <vector>
+
 /*
  * XXX: BIG RED NOTICE! Changes MUST be binary file format compatible and MUST
  * be synchronized with Calc's ScAutoFormat sc/source/core/tool/autoform.cxx
@@ -1006,7 +1008,7 @@ bool SwTableAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
 
 struct SwTableAutoFormatTable::Impl
 {
-    boost::ptr_vector<SwTableAutoFormat> m_AutoFormats;
+    std::vector<std::unique_ptr<SwTableAutoFormat>> m_AutoFormats;
 };
 
 size_t SwTableAutoFormatTable::size() const
@@ -1016,17 +1018,17 @@ size_t SwTableAutoFormatTable::size() const
 
 SwTableAutoFormat const& SwTableAutoFormatTable::operator[](size_t const i) const
 {
-    return m_pImpl->m_AutoFormats[i];
+    return *m_pImpl->m_AutoFormats[i];
 }
 SwTableAutoFormat      & SwTableAutoFormatTable::operator[](size_t const i)
 {
-    return m_pImpl->m_AutoFormats[i];
+    return *m_pImpl->m_AutoFormats[i];
 }
 
 void
-SwTableAutoFormatTable::InsertAutoFormat(size_t const i, SwTableAutoFormat *const pFormat)
+SwTableAutoFormatTable::InsertAutoFormat(size_t const i, std::unique_ptr<SwTableAutoFormat> pFormat)
 {
-    m_pImpl->m_AutoFormats.insert(m_pImpl->m_AutoFormats.begin() + i, pFormat);
+    m_pImpl->m_AutoFormats.insert(m_pImpl->m_AutoFormats.begin() + i, std::move(pFormat));
 }
 
 void SwTableAutoFormatTable::EraseAutoFormat(size_t const i)
@@ -1034,9 +1036,12 @@ void SwTableAutoFormatTable::EraseAutoFormat(size_t const i)
     m_pImpl->m_AutoFormats.erase(m_pImpl->m_AutoFormats.begin() + i);
 }
 
-SwTableAutoFormat* SwTableAutoFormatTable::ReleaseAutoFormat(size_t const i)
+std::unique_ptr<SwTableAutoFormat> SwTableAutoFormatTable::ReleaseAutoFormat(size_t const i)
 {
-    return m_pImpl->m_AutoFormats.release(m_pImpl->m_AutoFormats.begin() + i).release();
+    auto const iter(m_pImpl->m_AutoFormats.begin() + i);
+    std::unique_ptr<SwTableAutoFormat> pRet(std::move(*iter));
+    m_pImpl->m_AutoFormats.erase(iter);
+    return pRet;
 }
 
 SwTableAutoFormatTable::~SwTableAutoFormatTable()
@@ -1047,8 +1052,8 @@ SwTableAutoFormatTable::SwTableAutoFormatTable()
     : m_pImpl(new Impl)
 {
     OUString sNm;
-    SwTableAutoFormat* pNew = new SwTableAutoFormat(
-                            SwStyleNameMapper::GetUIName( RES_POOLCOLL_STANDARD, sNm ) );
+    std::unique_ptr<SwTableAutoFormat> pNew(new SwTableAutoFormat(
+                SwStyleNameMapper::GetUIName(RES_POOLCOLL_STANDARD, sNm)));
 
     SwBoxAutoFormat aNew;
 
@@ -1098,7 +1103,7 @@ SwTableAutoFormatTable::SwTableAutoFormatTable()
         const_cast<SwBoxAutoFormat&>(pNew->GetBoxFormat( i )).SetBox( aBox );
     }
 
-    m_pImpl->m_AutoFormats.push_back(pNew);
+    m_pImpl->m_AutoFormats.push_back(std::move(pNew));
 }
 
 bool SwTableAutoFormatTable::Load()
@@ -1163,7 +1168,6 @@ bool SwTableAutoFormatTable::Load( SvStream& rStream )
             {
                 aVersions.Load( rStream, nVal );        // Item versions
 
-                SwTableAutoFormat* pNew;
                 sal_uInt16 nCount = 0;
                 rStream.ReadUInt16( nCount );
 
@@ -1180,15 +1184,15 @@ bool SwTableAutoFormatTable::Load( SvStream& rStream )
                     }
                     for (sal_uInt16 i = 0; i < nCount; ++i)
                     {
-                        pNew = new SwTableAutoFormat( OUString() );
+                        std::unique_ptr<SwTableAutoFormat> pNew(
+                            new SwTableAutoFormat( OUString() ));
                         bRet = pNew->Load( rStream, aVersions );
                         if( bRet )
                         {
-                            m_pImpl->m_AutoFormats.push_back(pNew);
+                            m_pImpl->m_AutoFormats.push_back(std::move(pNew));
                         }
                         else
                         {
-                            delete pNew;
                             break;
                         }
                     }
@@ -1221,7 +1225,7 @@ bool SwTableAutoFormatTable::Save( SvStream& rStream ) const
             return false;
 
         // Write this version number for all attributes
-        m_pImpl->m_AutoFormats[0].GetBoxFormat(0).SaveVersionNo(
+        m_pImpl->m_AutoFormats[0]->GetBoxFormat(0).SaveVersionNo(
                 rStream, AUTOFORMAT_FILE_VERSION);
 
         rStream.WriteUInt16( m_pImpl->m_AutoFormats.size() - 1 );
@@ -1229,7 +1233,7 @@ bool SwTableAutoFormatTable::Save( SvStream& rStream ) const
 
         for (sal_uInt16 i = 1; bRet && i < m_pImpl->m_AutoFormats.size(); ++i)
         {
-            SwTableAutoFormat const& rFormat = m_pImpl->m_AutoFormats[i];
+            SwTableAutoFormat const& rFormat = *m_pImpl->m_AutoFormats[i];
             bRet = rFormat.Save(rStream, AUTOFORMAT_FILE_VERSION);
         }
     }
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index 4d9c25b..c52ecc2 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -328,8 +328,8 @@ IMPL_LINK_NOARG_TYPED(SwAutoFormatDlg, AddHdl, Button*, void)
                 if( n >= pTableTable->size() )
                 {
                     // Format with the name does not already exist, so take up.
-                    SwTableAutoFormat* pNewData = new
-                                        SwTableAutoFormat( aFormatName );
+                    std::unique_ptr<SwTableAutoFormat> pNewData(
+                            new SwTableAutoFormat(aFormatName));
                     pShell->GetTableAutoFormat( *pNewData );
 
                     // Insert sorted!!
@@ -337,7 +337,7 @@ IMPL_LINK_NOARG_TYPED(SwAutoFormatDlg, AddHdl, Button*, void)
                         if( (*pTableTable)[ n ].GetName() > aFormatName )
                             break;
 
-                    pTableTable->InsertAutoFormat(n, pNewData);
+                    pTableTable->InsertAutoFormat(n, std::move(pNewData));
                     m_pLbFormat->InsertEntry( aFormatName, nDfltStylePos + n );
                     m_pLbFormat->SelectEntryPos( nDfltStylePos + n );
                     bFormatInserted = true;
@@ -423,7 +423,8 @@ IMPL_LINK_NOARG_TYPED(SwAutoFormatDlg, RenameHdl, Button*, void)
                 {
                     // no format with this name exists, so rename it
                     m_pLbFormat->RemoveEntry( nDfltStylePos + nIndex );
-                    SwTableAutoFormat* p = pTableTable->ReleaseAutoFormat( nIndex );
+                    std::unique_ptr<SwTableAutoFormat> p(
+                            pTableTable->ReleaseAutoFormat(nIndex));
 
                     p->SetName( aFormatName );
 
@@ -434,7 +435,7 @@ IMPL_LINK_NOARG_TYPED(SwAutoFormatDlg, RenameHdl, Button*, void)
                             break;
                         }
 
-                    pTableTable->InsertAutoFormat( n, p );
+                    pTableTable->InsertAutoFormat( n, std::move(p) );
                     m_pLbFormat->InsertEntry( aFormatName, nDfltStylePos + n );
                     m_pLbFormat->SelectEntryPos( nDfltStylePos + n );
 


More information about the Libreoffice-commits mailing list