Kaydet (Commit) fdc83939 authored tarafından Michael Stahl's avatar Michael Stahl

sw: replace boost::ptr_deque with std::deque<std::unique_ptr>

Change-Id: Ibb51b67d4d9568577b73a43411322fb5d09bb399
üst 327ab3c0
...@@ -172,7 +172,7 @@ SwFltControlStack::SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl) ...@@ -172,7 +172,7 @@ SwFltControlStack::SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl)
SwFltControlStack::~SwFltControlStack() SwFltControlStack::~SwFltControlStack()
{ {
OSL_ENSURE(maEntries.empty(), "There are still Attributes on the stack"); OSL_ENSURE(m_Entries.empty(), "There are still Attributes on the stack");
} }
// MoveAttrs() is meant to address the following problem: // MoveAttrs() is meant to address the following problem:
...@@ -184,13 +184,13 @@ SwFltControlStack::~SwFltControlStack() ...@@ -184,13 +184,13 @@ SwFltControlStack::~SwFltControlStack()
// same paragraph further out by one character. // same paragraph further out by one character.
void SwFltControlStack::MoveAttrs( const SwPosition& rPos ) void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
{ {
size_t nCnt = maEntries.size(); size_t nCnt = m_Entries.size();
sal_uLong nPosNd = rPos.nNode.GetIndex(); sal_uLong nPosNd = rPos.nNode.GetIndex();
sal_uInt16 nPosCt = rPos.nContent.GetIndex() - 1; sal_uInt16 nPosCt = rPos.nContent.GetIndex() - 1;
for (size_t i=0; i < nCnt; ++i) for (size_t i=0; i < nCnt; ++i)
{ {
SwFltStackEntry& rEntry = maEntries[i]; SwFltStackEntry& rEntry = *m_Entries[i];
if ( if (
(rEntry.m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) && (rEntry.m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
(rEntry.m_aMkPos.m_nContent >= nPosCt) (rEntry.m_aMkPos.m_nContent >= nPosCt)
...@@ -216,9 +216,9 @@ void SwFltControlStack::MoveAttrs( const SwPosition& rPos ) ...@@ -216,9 +216,9 @@ void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
void SwFltControlStack::MarkAllAttrsOld() void SwFltControlStack::MarkAllAttrsOld()
{ {
size_t nCnt = maEntries.size(); size_t nCnt = m_Entries.size();
for (size_t i=0; i < nCnt; ++i) for (size_t i=0; i < nCnt; ++i)
maEntries[i].bOld = true; m_Entries[i]->bOld = true;
} }
namespace namespace
...@@ -256,17 +256,17 @@ void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr ...@@ -256,17 +256,17 @@ void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr
{ {
SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone() ); SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone() );
pTmp->SetStartCP(GetCurrAttrCP()); pTmp->SetStartCP(GetCurrAttrCP());
maEntries.push_back(pTmp); m_Entries.push_back(std::unique_ptr<SwFltStackEntry>(pTmp));
} }
} }
void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt) void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
{ {
OSL_ENSURE(nCnt < maEntries.size(), "Out of range!"); OSL_ENSURE(nCnt < m_Entries.size(), "Out of range!");
if (nCnt < maEntries.size()) if (nCnt < m_Entries.size())
{ {
myEIter aElement = maEntries.begin() + nCnt; myEIter aElement = m_Entries.begin() + nCnt;
maEntries.erase(aElement); m_Entries.erase(aElement);
} }
//Clear the para end position recorded in reader intermittently for the least impact on loading performance //Clear the para end position recorded in reader intermittently for the least impact on loading performance
//Because the attributes handled based on the unit of para //Because the attributes handled based on the unit of para
...@@ -285,12 +285,12 @@ void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt) ...@@ -285,12 +285,12 @@ void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
// graphic apos -> images. // graphic apos -> images.
void SwFltControlStack::StealAttr(const SwNodeIndex& rNode, sal_uInt16 nAttrId) void SwFltControlStack::StealAttr(const SwNodeIndex& rNode, sal_uInt16 nAttrId)
{ {
size_t nCnt = maEntries.size(); size_t nCnt = m_Entries.size();
while (nCnt) while (nCnt)
{ {
nCnt --; nCnt --;
SwFltStackEntry& rEntry = maEntries[nCnt]; SwFltStackEntry& rEntry = *m_Entries[nCnt];
if (rEntry.m_aPtPos.m_nNode.GetIndex()+1 == rNode.GetIndex() && if (rEntry.m_aPtPos.m_nNode.GetIndex()+1 == rNode.GetIndex() &&
(!nAttrId || nAttrId == rEntry.pAttr->Which())) (!nAttrId || nAttrId == rEntry.pAttr->Which()))
{ {
...@@ -307,11 +307,11 @@ void SwFltControlStack::KillUnlockedAttrs(const SwPosition& rPos) ...@@ -307,11 +307,11 @@ void SwFltControlStack::KillUnlockedAttrs(const SwPosition& rPos)
{ {
SwFltPosition aFltPos(rPos); SwFltPosition aFltPos(rPos);
size_t nCnt = maEntries.size(); size_t nCnt = m_Entries.size();
while( nCnt ) while( nCnt )
{ {
nCnt --; nCnt --;
SwFltStackEntry& rEntry = maEntries[nCnt]; SwFltStackEntry& rEntry = *m_Entries[nCnt];
if( !rEntry.bOld if( !rEntry.bOld
&& !rEntry.bOpen && !rEntry.bOpen
&& (rEntry.m_aMkPos == aFltPos) && (rEntry.m_aMkPos == aFltPos)
...@@ -338,12 +338,12 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos, ...@@ -338,12 +338,12 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
(RES_FLTRATTR_BEGIN <= nAttrId && RES_FLTRATTR_END > nAttrId), (RES_FLTRATTR_BEGIN <= nAttrId && RES_FLTRATTR_END > nAttrId),
"Wrong id for attribute"); "Wrong id for attribute");
myEIter aI = maEntries.begin(); myEIter aI = m_Entries.begin();
while (aI != maEntries.end()) while (aI != m_Entries.end())
{ {
bool bLastEntry = aI == maEntries.end() - 1; bool bLastEntry = aI == m_Entries.end() - 1;
SwFltStackEntry& rEntry = *aI; SwFltStackEntry& rEntry = **aI;
if (rEntry.bOpen) if (rEntry.bOpen)
{ {
// set end of attribute // set end of attribute
...@@ -413,7 +413,7 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos, ...@@ -413,7 +413,7 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
} }
} }
SetAttrInDoc(rPos, rEntry); SetAttrInDoc(rPos, rEntry);
aI = maEntries.erase(aI); aI = m_Entries.erase(aI);
} }
return pRet; return pRet;
...@@ -490,7 +490,7 @@ bool SwFltControlStack::HasSdOD() ...@@ -490,7 +490,7 @@ bool SwFltControlStack::HasSdOD()
{ {
bool bRet = false; bool bRet = false;
for (Entries::iterator it = maEntries.begin(); it != maEntries.end(); ++it) for (auto const& it : m_Entries)
{ {
SwFltStackEntry& rEntry = *it; SwFltStackEntry& rEntry = *it;
if ( rEntry.mnStartCP == rEntry.mnEndCP ) if ( rEntry.mnStartCP == rEntry.mnEndCP )
...@@ -728,13 +728,13 @@ bool SwFltControlStack::CheckSdOD(sal_Int32 /*nStart*/, sal_Int32 /*nEnd*/) ...@@ -728,13 +728,13 @@ bool SwFltControlStack::CheckSdOD(sal_Int32 /*nStart*/, sal_Int32 /*nEnd*/)
SfxPoolItem* SwFltControlStack::GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos) SfxPoolItem* SwFltControlStack::GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos)
{ {
size_t nSize = maEntries.size(); size_t nSize = m_Entries.size();
while (nSize) while (nSize)
{ {
// is it the looked-for attribute ? (only applies to locked, meaning // is it the looked-for attribute ? (only applies to locked, meaning
// currently set attributes!!) // currently set attributes!!)
SwFltStackEntry &rEntry = maEntries[--nSize]; SwFltStackEntry &rEntry = *m_Entries[--nSize];
if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich) if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich)
{ {
if (pPos) if (pPos)
...@@ -749,11 +749,11 @@ const SfxPoolItem* SwFltControlStack::GetOpenStackAttr(const SwPosition& rPos, s ...@@ -749,11 +749,11 @@ const SfxPoolItem* SwFltControlStack::GetOpenStackAttr(const SwPosition& rPos, s
{ {
SwFltPosition aFltPos(rPos); SwFltPosition aFltPos(rPos);
size_t nSize = maEntries.size(); size_t nSize = m_Entries.size();
while (nSize) while (nSize)
{ {
SwFltStackEntry &rEntry = maEntries[--nSize]; SwFltStackEntry &rEntry = *m_Entries[--nSize];
if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich && rEntry.m_aMkPos == aFltPos) if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich && rEntry.m_aMkPos == aFltPos)
{ {
return rEntry.pAttr; return rEntry.pAttr;
...@@ -779,9 +779,9 @@ void SwFltControlStack::Delete(const SwPaM &rPam) ...@@ -779,9 +779,9 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
if (aEndNode != aStartNode) if (aEndNode != aStartNode)
return; return;
for (size_t nSize = maEntries.size(); nSize > 0;) for (size_t nSize = m_Entries.size(); nSize > 0;)
{ {
SwFltStackEntry& rEntry = maEntries[--nSize]; SwFltStackEntry& rEntry = *m_Entries[--nSize];
bool bEntryStartAfterSelStart = bool bEntryStartAfterSelStart =
(rEntry.m_aMkPos.m_nNode == aStartNode && (rEntry.m_aMkPos.m_nNode == aStartNode &&
......
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
#include <IDocumentRedlineAccess.hxx> #include <IDocumentRedlineAccess.hxx>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_deque.hpp>
#include <memory>
#include <deque>
class SwTOXBase; class SwTOXBase;
class SwField; class SwField;
...@@ -131,9 +133,9 @@ public: ...@@ -131,9 +133,9 @@ public:
class SW_DLLPUBLIC SwFltControlStack : private ::boost::noncopyable class SW_DLLPUBLIC SwFltControlStack : private ::boost::noncopyable
{ {
typedef boost::ptr_deque<SwFltStackEntry> Entries; typedef std::deque<std::unique_ptr<SwFltStackEntry>> Entries;
typedef Entries::iterator myEIter; typedef Entries::iterator myEIter;
Entries maEntries; Entries m_Entries;
sal_uLong nFieldFlags; sal_uLong nFieldFlags;
vcl::KeyCode aEmptyKeyCode; // fuer Bookmarks vcl::KeyCode aEmptyKeyCode; // fuer Bookmarks
...@@ -186,10 +188,10 @@ public: ...@@ -186,10 +188,10 @@ public:
const SfxPoolItem* GetOpenStackAttr(const SwPosition& rPos, sal_uInt16 nWhich); const SfxPoolItem* GetOpenStackAttr(const SwPosition& rPos, sal_uInt16 nWhich);
void Delete(const SwPaM &rPam); void Delete(const SwPaM &rPam);
bool empty() const { return maEntries.empty(); } bool empty() const { return m_Entries.empty(); }
Entries::size_type size() const { return maEntries.size(); } Entries::size_type size() const { return m_Entries.size(); }
SwFltStackEntry& operator[](Entries::size_type nIndex) SwFltStackEntry& operator[](Entries::size_type nIndex)
{ return maEntries[nIndex]; } { return *m_Entries[nIndex]; }
void DeleteAndDestroy(Entries::size_type nCnt); void DeleteAndDestroy(Entries::size_type nCnt);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment