diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-09-15 23:53:29 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-09-16 13:04:07 +0200 |
commit | 01648a391107c1501ed1948ef1b18539d551176e (patch) | |
tree | e581f6b6e4fdc8696b624e45599ea8bcf0a8ad4b /sw | |
parent | 54045cc813c79e53abe608cc1a8d35ee7177465e (diff) |
sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I880526fdcce3be0f9e9149695812e048d95004e6
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/tblafmt.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/tblafmt.cxx | 38 | ||||
-rw-r--r-- | sw/source/ui/table/tautofmt.cxx | 11 |
3 files changed, 29 insertions, 24 deletions
diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index 64b8a9776d82..3503bb72eb51 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 d35ccc2ad4fb..6d2f4e5be6e8 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 4d9c25b3c572..c52ecc24cffa 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 ); |