summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-08-20 13:40:59 +0200
committerMichael Stahl <mstahl@redhat.com>2015-08-20 14:17:51 +0200
commit8cf79b567010ff885da1f6a121a4e9b2ef96fccf (patch)
treeaed88dda5ea6911b68b64b051888d5801a42c4d7
parent959a5043ccb4bb027e0149a56d31ebb78d5eb862 (diff)
tdf#93240: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I38f9140e565ab2a4d5dc7ad0c1d52837a5b5b67a
-rw-r--r--sw/inc/doc.hxx14
-rw-r--r--sw/source/core/doc/docdesc.cxx36
-rw-r--r--sw/source/core/doc/docfmt.cxx8
-rw-r--r--sw/source/core/doc/docnew.cxx12
4 files changed, 34 insertions, 36 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index b9f803b076ce..1873a7d71577 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -55,8 +55,6 @@
#include <unordered_map>
#include <vector>
-#include <boost/ptr_container/ptr_vector.hpp>
-
namespace editeng { class SvxBorderLine; }
class SvxForbiddenCharactersTable;
@@ -235,7 +233,7 @@ namespace sfx2 {
class LinkManager;
}
-typedef boost::ptr_vector<SwPageDesc> SwPageDescs;
+typedef std::vector<std::unique_ptr<SwPageDesc>> SwPageDescs;
void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem );
@@ -254,7 +252,7 @@ class SW_DLLPUBLIC SwDoc :
// private Member
std::unique_ptr<SwNodes> m_pNodes; //< document content (Nodes Array)
SwAttrPool* mpAttrPool; //< the attribute pool
- SwPageDescs maPageDescs; //< PageDescriptors
+ SwPageDescs m_PageDescs; //< PageDescriptors
Link<> maOle2Link; //< OLE 2.0-notification
/* @@@MAINTAINABILITY-HORROR@@@
Timer should not be members of the model
@@ -916,12 +914,12 @@ public:
sal_Int32 nDocPageCount );
// PageDescriptor interface.
- size_t GetPageDescCnt() const { return maPageDescs.size(); }
- const SwPageDesc& GetPageDesc( const size_t i ) const { return maPageDescs[i]; }
- SwPageDesc& GetPageDesc( size_t i ) { return maPageDescs[i]; }
+ size_t GetPageDescCnt() const { return m_PageDescs.size(); }
+ const SwPageDesc& GetPageDesc(const size_t i) const { return *m_PageDescs[i]; }
+ SwPageDesc& GetPageDesc(size_t const i) { return *m_PageDescs[i]; }
SwPageDesc* FindPageDesc(const OUString& rName, size_t* pPos = NULL);
SwPageDesc* FindPageDesc(const OUString& rName, size_t* pPos = NULL) const;
- // Just searches the pointer in the maPageDescs vector!
+ // Just searches the pointer in the m_PageDescs vector!
bool ContainsPageDesc(const SwPageDesc *pDesc, size_t* pPos = NULL);
/** Copy the complete PageDesc - beyond document and "deep"!
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index cdf5f7d516a4..420478edb7ea 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -379,9 +379,9 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFormatFooter &rFo
void SwDoc::ChgPageDesc( size_t i, const SwPageDesc &rChged )
{
- OSL_ENSURE( i < maPageDescs.size(), "PageDescs is out of range." );
+ OSL_ENSURE(i < m_PageDescs.size(), "PageDescs is out of range.");
- SwPageDesc& rDesc = maPageDescs[i];
+ SwPageDesc& rDesc = *m_PageDescs[i];
SwRootFrm* pTmpRoot = getIDocumentLayoutAccess().GetCurrentLayout();
if (GetIDocumentUndoRedo().DoesUndo())
@@ -557,13 +557,13 @@ void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
return;
// mba: test iteration as clients are removed while iteration
- SwPageDescHint aHint( &maPageDescs[0] );
+ SwPageDescHint aHint(m_PageDescs[0].get());
pDel->CallSwClientNotify( aHint );
bool bHasLayout = getIDocumentLayoutAccess().HasLayout();
if ( mpFootnoteInfo->DependsOn( pDel ) )
{
- mpFootnoteInfo->ChgPageDesc( &maPageDescs[0] );
+ mpFootnoteInfo->ChgPageDesc(m_PageDescs[0].get());
if ( bHasLayout )
{
std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
@@ -572,7 +572,7 @@ void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
}
else if ( mpEndNoteInfo->DependsOn( pDel ) )
{
- mpEndNoteInfo->ChgPageDesc( &maPageDescs[0] );
+ mpEndNoteInfo->ChgPageDesc(m_PageDescs[0].get());
if ( bHasLayout )
{
std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
@@ -580,11 +580,11 @@ void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
}
}
- for ( SwPageDescs::size_type j = 0; j < maPageDescs.size(); ++j )
+ for (SwPageDescs::size_type j = 0; j < m_PageDescs.size(); ++j)
{
- if ( maPageDescs[j].GetFollow() == pDel )
+ if (m_PageDescs[j]->GetFollow() == pDel)
{
- maPageDescs[j].SetFollow( 0 );
+ m_PageDescs[j]->SetFollow(nullptr);
if( bHasLayout )
{
std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
@@ -614,12 +614,12 @@ void SwDoc::BroadcastStyleOperation(const OUString& rName, SfxStyleFamily eFamil
void SwDoc::DelPageDesc( size_t i, bool bBroadcast )
{
- OSL_ENSURE( i < maPageDescs.size(), "PageDescs is out of range." );
+ OSL_ENSURE(i < m_PageDescs.size(), "PageDescs is out of range.");
OSL_ENSURE( i != 0, "You cannot delete the default Pagedesc.");
if ( i == 0 )
return;
- SwPageDesc &rDel = maPageDescs[i];
+ SwPageDesc &rDel = *m_PageDescs[i];
if (bBroadcast)
BroadcastStyleOperation(rDel.GetName(), SFX_STYLE_FAMILY_PAGE,
@@ -633,7 +633,7 @@ void SwDoc::DelPageDesc( size_t i, bool bBroadcast )
PreDelPageDesc(&rDel); // #i7983#
- maPageDescs.erase( maPageDescs.begin() + i );
+ m_PageDescs.erase(m_PageDescs.begin() + i);
getIDocumentState().SetModified();
}
@@ -667,7 +667,7 @@ SwPageDesc* SwDoc::MakePageDesc(const OUString &rName, const SwPageDesc *pCpy,
pNew->GetFirstMaster().SetFormatAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
pNew->GetFirstLeft().SetFormatAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
}
- maPageDescs.push_back( pNew );
+ m_PageDescs.push_back(std::unique_ptr<SwPageDesc>(pNew));
if (bBroadcast)
BroadcastStyleOperation(rName, SFX_STYLE_FAMILY_PAGE,
@@ -811,7 +811,7 @@ IMPL_LINK_NOARG_TYPED( SwDoc, DoUpdateModifiedOLE, Idle *, void )
struct CompareSwPageDescName {
explicit CompareSwPageDescName(const OUString &rName) : mName(rName) {}
- bool operator () (const SwPageDesc& other) const { return other.GetName() == mName; }
+ bool operator () (const std::unique_ptr<SwPageDesc>& other) const { return other->GetName() == mName; }
const OUString &mName;
};
@@ -824,7 +824,7 @@ static SwPageDesc* lcl_FindPageDesc( SwPageDescs *pPageDescs,
SwPageDesc* res = NULL;
if( it != pPageDescs->end() )
{
- res = &( *it ) ;;
+ res = it->get();
if( pPos )
*pPos = std::distance( pPageDescs->begin(), it );
}
@@ -836,19 +836,19 @@ static SwPageDesc* lcl_FindPageDesc( SwPageDescs *pPageDescs,
SwPageDesc* SwDoc::FindPageDesc( const OUString & rName, size_t* pPos )
{
return lcl_FindPageDesc<CompareSwPageDescName>(
- &maPageDescs, pPos, CompareSwPageDescName(rName) );
+ &m_PageDescs, pPos, CompareSwPageDescName(rName) );
}
SwPageDesc* SwDoc::FindPageDesc( const OUString & rName, size_t* pPos ) const
{
return lcl_FindPageDesc<CompareSwPageDescName>(
- const_cast <SwPageDescs *>( &maPageDescs ), pPos,
+ const_cast <SwPageDescs *>( &m_PageDescs ), pPos,
CompareSwPageDescName(rName) );
}
struct CompareSwPageDescToPtr {
explicit CompareSwPageDescToPtr(const SwPageDesc* ptr) : mPtr(ptr) {}
- bool operator () (const SwPageDesc& other) const { return &other == mPtr; }
+ bool operator () (const std::unique_ptr<SwPageDesc>& other) const { return other.get() == mPtr; }
const SwPageDesc *mPtr;
};
@@ -857,7 +857,7 @@ bool SwDoc::ContainsPageDesc( const SwPageDesc *pDesc, size_t* pPos )
if (pDesc == NULL)
return false;
SwPageDesc *res = lcl_FindPageDesc<CompareSwPageDescToPtr>(
- &maPageDescs, pPos,
+ &m_PageDescs, pPos,
CompareSwPageDescToPtr(pDesc) );
return res != NULL;
}
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 32e3a2db6bc6..1ee306910445 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1538,7 +1538,7 @@ void SwDoc::ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles )
if (bIncludePageStyles)
{
// and now the page templates
- SwPageDescs::size_type nCnt = rSource.maPageDescs.size();
+ SwPageDescs::size_type nCnt = rSource.m_PageDescs.size();
if( nCnt )
{
// a different Doc -> Number formatter needs to be merged
@@ -1547,15 +1547,15 @@ void SwDoc::ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles )
// 1st step: Create all formats (skip the 0th - it's the default!)
while( nCnt )
{
- const SwPageDesc &rSrc = rSource.maPageDescs[ --nCnt ];
+ const SwPageDesc &rSrc = *rSource.m_PageDescs[ --nCnt ];
if( 0 == FindPageDesc( rSrc.GetName() ) )
MakePageDesc( rSrc.GetName() );
}
// 2nd step: Copy all attributes, set the right parents
- for( nCnt = rSource.maPageDescs.size(); nCnt; )
+ for (SwPageDescs::size_type i = rSource.m_PageDescs.size(); i; )
{
- const SwPageDesc &rSrc = rSource.maPageDescs[ --nCnt ];
+ const SwPageDesc &rSrc = *rSource.m_PageDescs[ --i ];
SwPageDesc* pDesc = FindPageDesc( rSrc.GetName() );
CopyPageDesc( rSrc, *pDesc);
}
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 51a30ba125b9..e4501d2347df 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -313,7 +313,7 @@ SwDoc::SwDoc()
mpGrfFormatCollTable->push_back(mpDfltGrfFormatColl);
// Create PageDesc, EmptyPageFormat and ColumnFormat
- if ( maPageDescs.empty() )
+ if (m_PageDescs.empty())
getIDocumentStylePoolAccess().GetPageDescFromPool( RES_POOLPAGE_STANDARD );
// Set to "Empty Page"
@@ -493,7 +493,7 @@ SwDoc::~SwDoc()
// Destroy these only after destroying the FormatIndices, because the content
// of headers/footers has to be deleted as well. If in the headers/footers
// there are still Flys registered at that point, we have a problem.
- maPageDescs.clear();
+ m_PageDescs.clear();
// Delete content selections.
// Don't wait for the SwNodes dtor to destroy them; so that Formats
@@ -703,8 +703,8 @@ void SwDoc::ClearDoc()
// remove the dummy pagedesc from the array and delete all the old ones
size_t nDummyPgDsc = 0;
if (FindPageDesc(pDummyPgDsc->GetName(), &nDummyPgDsc))
- pDummyPgDsc = maPageDescs.release(maPageDescs.begin() + nDummyPgDsc).release();
- maPageDescs.clear();
+ pDummyPgDsc = m_PageDescs[nDummyPgDsc].release();
+ m_PageDescs.clear();
// Delete for Collections
// So that we get rid of the dependencies
@@ -738,8 +738,8 @@ void SwDoc::ClearDoc()
getIDocumentStylePoolAccess().GetPageDescFromPool( RES_POOLPAGE_STANDARD );
pFirstNd->ChgFormatColl( getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD ));
- nDummyPgDsc = maPageDescs.size();
- maPageDescs.push_back( pDummyPgDsc );
+ nDummyPgDsc = m_PageDescs.size();
+ m_PageDescs.push_back(std::unique_ptr<SwPageDesc>(pDummyPgDsc));
// set the layout back to the new standard pagedesc
pFirstNd->ResetAllAttr();
// delete now the dummy pagedesc