sw/inc/swtable.hxx | 2 +- sw/source/core/table/swnewtable.cxx | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
New commits: commit c4d43643ac53249df870141eb8b89ea0e774b9a5 Author: Noel Grandin <[email protected]> AuthorDate: Fri Aug 19 17:05:33 2022 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Aug 20 09:50:11 2022 +0200 unique_ptr->optional in CollectBoxSelection Change-Id: Id9e32567805130985c96525d7de61ec6036ac9b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138560 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index 483753d56767..8099077b91f3 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -162,7 +162,7 @@ private: bool NewMerge( SwDoc*, const SwSelBoxes&, const SwSelBoxes& rMerged, SwUndoTableMerge* ); bool NewSplitRow( SwDoc&, const SwSelBoxes&, sal_uInt16, bool ); - std::unique_ptr<SwBoxSelection> CollectBoxSelection( const SwPaM& rPam ) const; + std::optional<SwBoxSelection> CollectBoxSelection( const SwPaM& rPam ) const; void InsertSpannedRow( SwDoc& rDoc, sal_uInt16 nIdx, sal_uInt16 nCnt ); bool InsertRow_( SwDoc*, const SwSelBoxes&, sal_uInt16 nCnt, bool bBehind ); bool NewInsertCol( SwDoc&, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, bool ); diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index 1a9fe882b3a9..5e7111553559 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -326,15 +326,15 @@ static void lcl_ChangeRowSpan( const SwTable& rTable, const tools::Long nDiff, and prepares the selected cells for merging */ -std::unique_ptr<SwBoxSelection> SwTable::CollectBoxSelection( const SwPaM& rPam ) const +std::optional<SwBoxSelection> SwTable::CollectBoxSelection( const SwPaM& rPam ) const { OSL_ENSURE( m_bNewModel, "Don't call me for old tables" ); if( m_aLines.empty() ) - return nullptr; + return std::nullopt; const SwNode* pStartNd = rPam.Start()->GetNode().FindTableBoxStartNode(); const SwNode* pEndNd = rPam.End()->GetNode().FindTableBoxStartNode(); if( !pStartNd || !pEndNd || pStartNd == pEndNd ) - return nullptr; + return std::nullopt; const size_t nLines = m_aLines.size(); size_t nTop = 0; @@ -369,12 +369,12 @@ std::unique_ptr<SwBoxSelection> SwTable::CollectBoxSelection( const SwPaM& rPam } } if( nFound < 2 ) - return nullptr; + return std::nullopt; bool bOkay = true; tools::Long nMid = ( nMin + nMax ) / 2; - auto pRet(std::make_unique<SwBoxSelection>()); + std::optional<SwBoxSelection> pRet(std::in_place); std::vector< std::pair< SwTableBox*, tools::Long > > aNewWidthVector; size_t nCheckBottom = nBottom; tools::Long nLeftSpan = 0; @@ -816,7 +816,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, } CHECK_TABLE( *this ) // We have to assert a "rectangular" box selection before we start to merge - std::unique_ptr< SwBoxSelection > pSel( CollectBoxSelection( rPam ) ); + std::optional< SwBoxSelection > pSel( CollectBoxSelection( rPam ) ); if (!pSel || pSel->isEmpty()) return false; // Now we should have a rectangle of boxes,
