diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-28 15:45:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-30 09:08:41 +0200 |
commit | 8ee22cb0bd6e741a553ef7d5b78cedc7ca669939 (patch) | |
tree | db8fc19623ee9463409d0e483de999f45420e244 | |
parent | c78fa391c99885492d50de12b7a6b5912229061f (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>
-rw-r--r-- | sw/inc/shellres.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/inc/UndoTable.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/undo/untbl.cxx | 16 | ||||
-rw-r--r-- | sw/source/uibase/utlui/initui.cxx | 8 |
6 files changed, 21 insertions, 21 deletions
diff --git a/sw/inc/shellres.hxx b/sw/inc/shellres.hxx index ef81f1a64eaa..6cbcd91e8ab0 100644 --- a/sw/inc/shellres.hxx +++ b/sw/inc/shellres.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_INC_SHELLRES_HXX #include <memory> +#include <optional> #include <vector> #include "swdllapi.h" #include <rtl/ustring.hxx> @@ -78,7 +79,7 @@ struct SW_DLLPUBLIC ShellResource private: void GetAutoFormatNameLst_() const; - mutable std::unique_ptr<std::vector<OUString>> pAutoFormatNameLst; + mutable std::optional<std::vector<OUString>> mxAutoFormatNameLst; OUString sPageDescFirstName; OUString sPageDescFollowName; OUString sPageDescName; @@ -86,9 +87,9 @@ private: inline const std::vector<OUString>& ShellResource::GetAutoFormatNameLst() const { - if( !pAutoFormatNameLst ) + if( !mxAutoFormatNameLst ) GetAutoFormatNameLst_(); - return *pAutoFormatNameLst; + return *mxAutoFormatNameLst; } #endif // INCLUDED_SW_INC_SHELLRES_HXX 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 ); diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx index a690b7cfe9df..5b015c71d9b6 100644 --- a/sw/source/uibase/utlui/initui.cxx +++ b/sw/source/uibase/utlui/initui.cxx @@ -181,9 +181,9 @@ SwGlossaryList* GetGlossaryList() void ShellResource::GetAutoFormatNameLst_() const { - assert(!pAutoFormatNameLst); - pAutoFormatNameLst.reset( new std::vector<OUString> ); - pAutoFormatNameLst->reserve(STR_AUTOFMTREDL_END); + assert(!mxAutoFormatNameLst); + mxAutoFormatNameLst.emplace(); + mxAutoFormatNameLst->reserve(STR_AUTOFMTREDL_END); assert(SAL_N_ELEMENTS(RID_SHELLRES_AUTOFMTSTRS) == STR_AUTOFMTREDL_END); for (sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n) @@ -196,7 +196,7 @@ void ShellResource::GetAutoFormatNameLst_() const p = p.replaceFirst("%1", rLclD.getDoubleQuotationMarkStart()); p = p.replaceFirst("%2", rLclD.getDoubleQuotationMarkEnd()); } - pAutoFormatNameLst->push_back(p); + mxAutoFormatNameLst->push_back(p); } } |