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

sw: replace boost::ptr_vector with std::vector<std::unique_ptr>

Change-Id: I913648a8dd407c5629df7a0355d2cfdf66240cf9
üst d119c840
...@@ -21,9 +21,12 @@ ...@@ -21,9 +21,12 @@
#define INCLUDED_SW_SOURCE_CORE_INC_UNDOSORT_HXX #define INCLUDED_SW_SOURCE_CORE_INC_UNDOSORT_HXX
#include <undobj.hxx> #include <undobj.hxx>
#include <boost/ptr_container/ptr_vector.hpp>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <memory>
#include <vector>
struct SwSortOptions; struct SwSortOptions;
class SwTableNode; class SwTableNode;
class SwUndoAttrTable; class SwUndoAttrTable;
...@@ -59,8 +62,7 @@ typedef std::vector<SwNodeIndex*> SwUndoSortList; ...@@ -59,8 +62,7 @@ typedef std::vector<SwNodeIndex*> SwUndoSortList;
class SwUndoSort : public SwUndo, private SwUndRng class SwUndoSort : public SwUndo, private SwUndRng
{ {
SwSortOptions* pSortOpt; SwSortOptions* pSortOpt;
boost::ptr_vector<SwSortUndoElement> std::vector<std::unique_ptr<SwSortUndoElement>> m_SortList;
aSortList;
SwUndoAttrTable* pUndoTableAttr; SwUndoAttrTable* pUndoTableAttr;
SwRedlineData* pRedlData; SwRedlineData* pRedlData;
sal_uLong nTableNd; sal_uLong nTableNd;
......
...@@ -94,12 +94,12 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext) ...@@ -94,12 +94,12 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
const SwTable& rTable = pTableNd->GetTable(); const SwTable& rTable = pTableNd->GetTable();
SwMovedBoxes aMovedList; SwMovedBoxes aMovedList;
for( size_t i=0; i < aSortList.size(); i++) for (size_t i=0; i < m_SortList.size(); i++)
{ {
const SwTableBox* pSource = rTable.GetTableBox( const SwTableBox* pSource = rTable.GetTableBox(
*aSortList[i].SORT_TXT_TBL.TBL.pSource ); *m_SortList[i]->SORT_TXT_TBL.TBL.pSource );
const SwTableBox* pTarget = rTable.GetTableBox( const SwTableBox* pTarget = rTable.GetTableBox(
*aSortList[i].SORT_TXT_TBL.TBL.pTarget ); *m_SortList[i]->SORT_TXT_TBL.TBL.pTarget );
// move back // move back
MoveCell(&rDoc, pTarget, pSource, MoveCell(&rDoc, pTarget, pSource,
...@@ -125,17 +125,21 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext) ...@@ -125,17 +125,21 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
// The IndexList must be created based on (asc.) sorted SourcePosition. // The IndexList must be created based on (asc.) sorted SourcePosition.
SwUndoSortList aIdxList; SwUndoSortList aIdxList;
for( size_t i = 0; i < aSortList.size(); ++i) for (size_t i = 0; i < m_SortList.size(); ++i)
for( size_t ii=0; ii < aSortList.size(); ++ii ) {
if( aSortList[ii].SORT_TXT_TBL.TXT.nSource == nSttNode + i ) for (size_t ii = 0; ii < m_SortList.size(); ++ii)
{
if (m_SortList[ii]->SORT_TXT_TBL.TXT.nSource == nSttNode + i)
{ {
SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(), SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(),
aSortList[ii].SORT_TXT_TBL.TXT.nTarget ); m_SortList[ii]->SORT_TXT_TBL.TXT.nTarget );
aIdxList.insert( aIdxList.begin() + i, pIdx ); aIdxList.insert( aIdxList.begin() + i, pIdx );
break; break;
} }
}
}
for(size_t i=0; i < aSortList.size(); ++i) for (size_t i = 0; i < m_SortList.size(); ++i)
{ {
SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i ); SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i );
SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
...@@ -169,12 +173,12 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext) ...@@ -169,12 +173,12 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
const SwTable& rTable = pTableNd->GetTable(); const SwTable& rTable = pTableNd->GetTable();
SwMovedBoxes aMovedList; SwMovedBoxes aMovedList;
for(size_t i=0; i < aSortList.size(); ++i) for (size_t i = 0; i < m_SortList.size(); ++i)
{ {
const SwTableBox* pSource = rTable.GetTableBox( const SwTableBox* pSource = rTable.GetTableBox(
*aSortList[i].SORT_TXT_TBL.TBL.pSource ); *m_SortList[i]->SORT_TXT_TBL.TBL.pSource );
const SwTableBox* pTarget = rTable.GetTableBox( const SwTableBox* pTarget = rTable.GetTableBox(
*aSortList[i].SORT_TXT_TBL.TBL.pTarget ); *m_SortList[i]->SORT_TXT_TBL.TBL.pTarget );
// move back // move back
MoveCell(&rDoc, pSource, pTarget, MoveCell(&rDoc, pSource, pTarget,
...@@ -203,14 +207,14 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext) ...@@ -203,14 +207,14 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
SwUndoSortList aIdxList; SwUndoSortList aIdxList;
for( size_t i = 0; i < aSortList.size(); ++i) for (size_t i = 0; i < m_SortList.size(); ++i)
{ // current position is starting point { // current position is starting point
SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(), SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(),
aSortList[i].SORT_TXT_TBL.TXT.nSource); m_SortList[i]->SORT_TXT_TBL.TXT.nSource);
aIdxList.insert( aIdxList.begin() + i, pIdx ); aIdxList.insert( aIdxList.begin() + i, pIdx );
} }
for( size_t i = 0; i < aSortList.size(); ++i) for (size_t i = 0; i < m_SortList.size(); ++i)
{ {
SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i); SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i);
SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
...@@ -245,14 +249,14 @@ void SwUndoSort::RepeatImpl(::sw::RepeatContext & rContext) ...@@ -245,14 +249,14 @@ void SwUndoSort::RepeatImpl(::sw::RepeatContext & rContext)
void SwUndoSort::Insert( const OUString& rOrgPos, const OUString& rNewPos) void SwUndoSort::Insert( const OUString& rOrgPos, const OUString& rNewPos)
{ {
SwSortUndoElement* pEle = new SwSortUndoElement(rOrgPos, rNewPos); std::unique_ptr<SwSortUndoElement> p(new SwSortUndoElement(rOrgPos, rNewPos));
aSortList.push_back( pEle ); m_SortList.push_back(std::move(p));
} }
void SwUndoSort::Insert( sal_uLong nOrgPos, sal_uLong nNewPos) void SwUndoSort::Insert( sal_uLong nOrgPos, sal_uLong nNewPos)
{ {
SwSortUndoElement* pEle = new SwSortUndoElement(nOrgPos, nNewPos); std::unique_ptr<SwSortUndoElement> p(new SwSortUndoElement(nOrgPos, nNewPos));
aSortList.push_back( pEle ); m_SortList.push_back(std::move(p));
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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