sw/inc/node.hxx | 4 ++-- sw/inc/shellres.hxx | 7 ++++--- sw/source/core/docnode/ndtbl.cxx | 4 ++-- sw/source/core/docnode/node.cxx | 20 ++++++++++---------- sw/source/core/inc/UndoTable.hxx | 2 +- sw/source/core/txtnode/thints.cxx | 5 ++--- sw/source/core/undo/untbl.cxx | 16 ++++++++-------- sw/source/uibase/utlui/initui.cxx | 8 ++++---- 8 files changed, 33 insertions(+), 33 deletions(-)
New commits: commit 8ee22cb0bd6e741a553ef7d5b78cedc7ca669939 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri May 28 15:45:46 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun May 30 09:08:41 2021 +0200 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.gran...@collabora.co.uk> 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); } } commit c78fa391c99885492d50de12b7a6b5912229061f Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri May 28 15:57:33 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun May 30 09:08:31 2021 +0200 std::unique_ptr->std::optional Change-Id: I7a10e9bf14d45d1fe958dc33fe96ebb8318b3bec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116393 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx index a65b4872c5fd..c5693ce98c87 100644 --- a/sw/inc/node.hxx +++ b/sw/inc/node.hxx @@ -107,7 +107,7 @@ private: /// all SwFrameFormat that are anchored at the node /// invariant: SwFrameFormat is in the list iff /// SwFrameFormat::GetAnchor().GetContentAnchor() points to this node - std::unique_ptr<std::vector<SwFrameFormat*>> m_pAnchoredFlys; + std::optional<std::vector<SwFrameFormat*>> m_xAnchoredFlys; protected: SwStartNode* m_pStartOfSection; @@ -294,7 +294,7 @@ public: sal_uInt8 HasPrevNextLayNode() const; - std::vector<SwFrameFormat *> const* GetAnchoredFlys() const { return m_pAnchoredFlys.get(); } + std::vector<SwFrameFormat *> const* GetAnchoredFlys() const { return m_xAnchoredFlys ? &*m_xAnchoredFlys : nullptr; } void AddAnchoredFly(SwFrameFormat *); void RemoveAnchoredFly(SwFrameFormat *); diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 809ecd349c81..3b0245969246 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -347,7 +347,7 @@ SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const SwNodeType nNdType ) SwNode::~SwNode() { - assert(!m_pAnchoredFlys || GetDoc().IsInDtor()); // must all be deleted + assert(!m_xAnchoredFlys || GetDoc().IsInDtor()); // must all be deleted InvalidateInSwCache(RES_OBJECTDYING); assert(!IsInCache()); } @@ -2119,11 +2119,11 @@ void SwNode::AddAnchoredFly(SwFrameFormat *const pFlyFormat) assert(&pFlyFormat->GetAnchor(false).GetContentAnchor()->nNode.GetNode() == this); // check node type, cf. SwFormatAnchor::SetAnchor() assert(IsTextNode() || IsStartNode() || IsTableNode()); - if (!m_pAnchoredFlys) + if (!m_xAnchoredFlys) { - m_pAnchoredFlys.reset(new std::vector<SwFrameFormat*>); + m_xAnchoredFlys.emplace(); } - m_pAnchoredFlys->push_back(pFlyFormat); + m_xAnchoredFlys->push_back(pFlyFormat); } void SwNode::RemoveAnchoredFly(SwFrameFormat *const pFlyFormat) @@ -2132,13 +2132,13 @@ void SwNode::RemoveAnchoredFly(SwFrameFormat *const pFlyFormat) // cannot assert this in Remove because it is called when new anchor is already set // assert(&pFlyFormat->GetAnchor(false).GetContentAnchor()->nNode.GetNode() == this); assert(IsTextNode() || IsStartNode() || IsTableNode()); - assert(m_pAnchoredFlys); - auto it(std::find(m_pAnchoredFlys->begin(), m_pAnchoredFlys->end(), pFlyFormat)); - assert(it != m_pAnchoredFlys->end()); - m_pAnchoredFlys->erase(it); - if (m_pAnchoredFlys->empty()) + assert(m_xAnchoredFlys); + auto it(std::find(m_xAnchoredFlys->begin(), m_xAnchoredFlys->end(), pFlyFormat)); + assert(it != m_xAnchoredFlys->end()); + m_xAnchoredFlys->erase(it); + if (m_xAnchoredFlys->empty()) { - m_pAnchoredFlys.reset(); + m_xAnchoredFlys.reset(); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits