summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-28 15:45:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-30 09:08:41 +0200
commit8ee22cb0bd6e741a553ef7d5b78cedc7ca669939 (patch)
treedb8fc19623ee9463409d0e483de999f45420e244 /sw/source/core
parentc78fa391c99885492d50de12b7a6b5912229061f (diff)
std::unique_ptr -> std::optional
Change-Id: I78e5995b1a5cccff9c632ef4bcf75ea3ec01ff65 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116382 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/docnode/ndtbl.cxx4
-rw-r--r--sw/source/core/inc/UndoTable.hxx2
-rw-r--r--sw/source/core/txtnode/thints.cxx5
-rw-r--r--sw/source/core/undo/untbl.cxx16
4 files changed, 13 insertions, 14 deletions
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index d11f09ecf69a..1b23437c3fbd 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -759,14 +759,14 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts,
{
sal_uInt8 nBoxArrLen = pTAFormat ? 16 : 4;
std::unique_ptr< DfltBoxAttrList_t > aBoxFormatArr1;
- std::unique_ptr< std::vector<SwTableBoxFormat*> > aBoxFormatArr2;
+ std::optional< std::vector<SwTableBoxFormat*> > aBoxFormatArr2;
if( bUseBoxFormat )
{
aBoxFormatArr1.reset(new DfltBoxAttrList_t( nBoxArrLen, nullptr ));
}
else
{
- aBoxFormatArr2.reset(new std::vector<SwTableBoxFormat*>( nBoxArrLen, nullptr ));
+ aBoxFormatArr2 = std::vector<SwTableBoxFormat*>( nBoxArrLen, nullptr );
}
SfxItemSet aCharSet( GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_PARATR_LIST_END-1>{} );
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 81b4780b9792..c15f0f10ca1c 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -175,7 +175,7 @@ class SwUndoTableNdsChg : public SwUndo
BoxMove(sal_uLong idx, bool moved=false) : index(idx), hasMoved(moved) {};
bool operator<(const BoxMove& other) const { return index < other.index; };
};
- std::unique_ptr< std::set<BoxMove> > m_pNewSttNds;
+ std::optional< std::set<BoxMove> > m_xNewSttNds;
std::unique_ptr<SwUndoSaveSections> m_pDelSects;
tools::Long m_nMin, m_nMax; // for redo of delete column
sal_uLong m_nSttNode;
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 2a97d9017e79..bc49210e14f0 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -2183,7 +2183,7 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
else // a query range is defined
{
// #i75299#
- std::unique_ptr< std::vector< SwPoolItemEndPair > > pAttrArr;
+ std::optional< std::vector< SwPoolItemEndPair > > pAttrArr;
const size_t coArrSz = RES_TXTATR_WITHEND_END - RES_CHRATR_BEGIN;
@@ -2243,8 +2243,7 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
if (!pAttrArr)
{
- pAttrArr.reset(
- new std::vector< SwPoolItemEndPair >(coArrSz));
+ pAttrArr = std::vector< SwPoolItemEndPair >(coArrSz);
}
std::vector< SwPoolItemEndPair >::iterator pPrev = pAttrArr->begin();
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 28f54bcd7277..ee509e6b602c 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1491,7 +1491,7 @@ void SwUndoTableNdsChg::SaveNewBoxes( const SwTableNode& rTableNd,
const SwTableSortBoxes& rTableBoxes = rTable.GetTabSortBoxes();
OSL_ENSURE( ! IsDelBox(), "wrong Action" );
- m_pNewSttNds.reset( new std::set<BoxMove> );
+ m_xNewSttNds.emplace();
size_t i = 0;
for (size_t n = 0; n < rOld.size(); ++i)
@@ -1500,12 +1500,12 @@ void SwUndoTableNdsChg::SaveNewBoxes( const SwTableNode& rTableNd,
++n;
else
// new box: insert sorted
- m_pNewSttNds->insert( BoxMove(rTableBoxes[ i ]->GetSttIdx()) );
+ m_xNewSttNds->insert( BoxMove(rTableBoxes[ i ]->GetSttIdx()) );
}
for( ; i < rTableBoxes.size(); ++i )
// new box: insert sorted
- m_pNewSttNds->insert( BoxMove(rTableBoxes[ i ]->GetSttIdx()) );
+ m_xNewSttNds->insert( BoxMove(rTableBoxes[ i ]->GetSttIdx()) );
}
static SwTableLine* lcl_FindTableLine( const SwTable& rTable,
@@ -1543,7 +1543,7 @@ void SwUndoTableNdsChg::SaveNewBoxes( const SwTableNode& rTableNd,
const SwTableSortBoxes& rTableBoxes = rTable.GetTabSortBoxes();
OSL_ENSURE( ! IsDelBox(), "wrong Action" );
- m_pNewSttNds.reset( new std::set<BoxMove> );
+ m_xNewSttNds.emplace();
OSL_ENSURE( rTable.IsNewModel() || rOld.size() + m_nCount * rBoxes.size() == rTableBoxes.size(),
"unexpected boxes" );
@@ -1610,7 +1610,7 @@ void SwUndoTableNdsChg::SaveNewBoxes( const SwTableNode& rTableNd,
( nNodes != ( pSourceBox->GetSttNd()->EndOfSectionIndex() -
pSourceBox->GetSttIdx() ) )
&& ( nNodes - 1 > nLineDiff );
- m_pNewSttNds->insert( BoxMove(pBox->GetSttIdx(), bNodesMoved) );
+ m_xNewSttNds->insert( BoxMove(pBox->GetSttIdx(), bNodesMoved) );
}
}
}
@@ -1669,11 +1669,11 @@ void SwUndoTableNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
}
m_pDelSects->clear();
}
- else if( !m_pNewSttNds->empty() )
+ else if( !m_xNewSttNds->empty() )
{
// Then the nodes have be moved and not deleted!
// But for that we need a temp array.
- std::vector<BoxMove> aTmp( m_pNewSttNds->begin(), m_pNewSttNds->end() );
+ std::vector<BoxMove> aTmp( m_xNewSttNds->begin(), m_xNewSttNds->end() );
// backwards
for (size_t n = aTmp.size(); n > 0 ; )
@@ -1722,7 +1722,7 @@ void SwUndoTableNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
{
// Remove nodes from nodes array (backwards!)
std::set<BoxMove>::reverse_iterator it;
- for( it = m_pNewSttNds->rbegin(); it != m_pNewSttNds->rend(); ++it )
+ for( it = m_xNewSttNds->rbegin(); it != m_xNewSttNds->rend(); ++it )
{
sal_uLong nIdx = (*it).index;
SwTableBox* pBox = pTableNd->GetTable().GetTableBox( nIdx );