sw/inc/ndarr.hxx | 11 +++----- sw/inc/node.hxx | 4 +-- sw/qa/extras/mailmerge/mailmerge.cxx | 4 +-- sw/source/core/doc/DocumentContentOperationsManager.cxx | 8 +++--- sw/source/core/doc/doc.cxx | 8 +++--- sw/source/core/doc/docedt.cxx | 8 +++--- sw/source/core/doc/docfmt.cxx | 8 +++--- sw/source/core/doc/docglbl.cxx | 20 ++++++++-------- sw/source/core/doc/docnum.cxx | 4 +-- sw/source/core/docnode/ndnum.cxx | 2 - sw/source/core/docnode/nodes.cxx | 16 +++++------- sw/source/core/edit/ednumber.cxx | 4 +-- sw/source/core/inc/DocumentContentOperationsManager.hxx | 2 - sw/source/core/unocore/unochart.cxx | 2 - sw/source/filter/basflt/shellio.cxx | 2 - sw/source/filter/xml/xmlimp.cxx | 4 +-- 16 files changed, 51 insertions(+), 56 deletions(-)
New commits: commit 18e49d2b998ba69d5363d25d285ee6fd188a698d Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Sep 29 17:15:45 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 29 18:29:16 2021 +0200 expand out SwNodePtr typedef instead of having a mix of SwNode* and SwNodePtr Also change the call signature of FnForEach_SwNodes - passing around a const& to a pointer is both unnecessary and inefficient. Change-Id: Ib2caab53071f434e85f7dc4795cbde38609c28df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122830 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index 7e095c8fb0a6..dea24da0ca81 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -64,8 +64,7 @@ namespace sw { class DocumentContentOperationsManager; } namespace svt { class EmbeddedObjectRef; } -typedef SwNode * SwNodePtr; -typedef bool (*FnForEach_SwNodes)( const SwNodePtr&, void* pArgs ); +typedef bool (*FnForEach_SwNodes)( SwNode*, void* pArgs ); typedef struct _xmlTextWriter *xmlTextWriterPtr; struct CompareSwOutlineNodes @@ -96,10 +95,8 @@ class SW_DLLPUBLIC SwNodes final SwNodeIndex* m_vIndices; ///< ring of all indices on nodes. void RemoveNode( sal_uLong nDelPos, sal_uLong nLen, bool bDel ); - void InsertNode( const SwNodePtr pNode, - const SwNodeIndex& rPos ); - void InsertNode( const SwNodePtr pNode, - sal_uLong nPos ); + void InsertNode( SwNode* pNode, const SwNodeIndex& rPos ); + void InsertNode( SwNode* pNode, sal_uLong nPos ); SwDoc& m_rMyDoc; ///< This Doc contains the nodes-array. @@ -137,7 +134,7 @@ public: typedef std::vector<SwNodeRange> NodeRanges_t; typedef std::vector<NodeRanges_t> TableRanges_t; - SwNodePtr operator[]( sal_uLong n ) const; // defined in node.hxx + SwNode* operator[]( sal_uLong n ) const; // defined in node.hxx sal_uLong Count() const { return BigPtrArray::Count(); } void ForEach( FnForEach_SwNodes fnForEach, void* pArgs = nullptr ) diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx index 6639aefb5f97..df30db2b9f9e 100644 --- a/sw/inc/node.hxx +++ b/sw/inc/node.hxx @@ -730,9 +730,9 @@ inline SwPlaceholderNode::SwPlaceholderNode(const SwNodeIndex &rWhere) { } -inline SwNodePtr SwNodes::operator[]( sal_uLong n ) const +inline SwNode* SwNodes::operator[]( sal_uLong n ) const { - return static_cast<SwNodePtr>(BigPtrArray::operator[] ( n )); + return static_cast<SwNode*>(BigPtrArray::operator[] ( n )); } #endif diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx index a1c71e0a0d49..e1d1ed0aa248 100644 --- a/sw/qa/extras/mailmerge/mailmerge.cxx +++ b/sw/qa/extras/mailmerge/mailmerge.cxx @@ -950,7 +950,7 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf62364, "tdf62364.odt", "10-testing-addresses { for (int nodeIndex = 0; nodeIndex<4; nodeIndex++) { - const SwNodePtr aNode = rNodes[9 + pageIndex * 4 + nodeIndex]; + SwNode* aNode = rNodes[9 + pageIndex * 4 + nodeIndex]; CPPUNIT_ASSERT_EQUAL(true, aNode->IsTextNode()); const SwTextNode* pTextNode = aNode->GetTextNode(); @@ -976,7 +976,7 @@ DECLARE_SHELL_MAILMERGE_TEST(tdf125522_shell, "tdf125522.odt", "10-testing-addre const auto & rNodes = pTextDoc->GetDocShell()->GetDoc()->GetNodes(); for (sal_uLong nodeIndex = 0; nodeIndex<rNodes.Count(); nodeIndex++) { - const SwNodePtr aNode = rNodes[nodeIndex]; + SwNode* aNode = rNodes[nodeIndex]; if (aNode->StartOfSectionNode()) { CPPUNIT_ASSERT(!aNode->StartOfSectionNode()->GetFlyFormat()); diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 8257bec7d8f2..29fd60545ff0 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -3993,15 +3993,15 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl( /** @params pArgs contains the document's ChrFormatTable * Is need for selections at the beginning/end and with no SSelection. */ -bool DocumentContentOperationsManager::lcl_RstTextAttr( const SwNodePtr& rpNd, void* pArgs ) +bool DocumentContentOperationsManager::lcl_RstTextAttr( SwNode* pNd, void* pArgs ) { ParaRstFormat* pPara = static_cast<ParaRstFormat*>(pArgs); if (pPara->pLayout && pPara->pLayout->HasMergedParas() - && rpNd->GetRedlineMergeFlag() == SwNode::Merge::Hidden) + && pNd->GetRedlineMergeFlag() == SwNode::Merge::Hidden) { return true; // skip hidden, since new items aren't applied } - SwTextNode * pTextNode = rpNd->GetTextNode(); + SwTextNode * pTextNode = pNd->GetTextNode(); if( pTextNode && pTextNode->GetpSwpHints() ) { SwIndex aSt( pTextNode, 0 ); @@ -4011,7 +4011,7 @@ bool DocumentContentOperationsManager::lcl_RstTextAttr( const SwNodePtr& rpNd, v pPara->pSttNd->nContent.GetIndex() ) aSt = pPara->pSttNd->nContent.GetIndex(); - if( &pPara->pEndNd->nNode.GetNode() == rpNd ) + if( &pPara->pEndNd->nNode.GetNode() == pNd ) nEnd = pPara->pEndNd->nContent.GetIndex(); if( pPara->pHistory ) diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 6539cc5fd1db..1dec7c289674 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1109,9 +1109,9 @@ sal_uInt16 SwDoc::GetRefMarks( std::vector<OUString>* pNames ) const return nCount; } -static bool lcl_SpellAndGrammarAgain( const SwNodePtr& rpNd, void* pArgs ) +static bool lcl_SpellAndGrammarAgain( SwNode* pNd, void* pArgs ) { - SwTextNode *pTextNode = rpNd->GetTextNode(); + SwTextNode *pTextNode = pNd->GetTextNode(); bool bOnlyWrong = *static_cast<sal_Bool*>(pArgs); if( pTextNode ) { @@ -1137,9 +1137,9 @@ static bool lcl_SpellAndGrammarAgain( const SwNodePtr& rpNd, void* pArgs ) return true; } -static bool lcl_CheckSmartTagsAgain( const SwNodePtr& rpNd, void* ) +static bool lcl_CheckSmartTagsAgain( SwNode* pNd, void* ) { - SwTextNode *pTextNode = rpNd->GetTextNode(); + SwTextNode *pTextNode = pNd->GetTextNode(); if( pTextNode ) { pTextNode->SetSmartTagDirty( true ); diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 3b61ce5cef65..2a9272214593 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -770,10 +770,10 @@ void SwHyphArgs::SetPam( SwPaM *pPam ) const } // Returns true if we can proceed. -static bool lcl_HyphenateNode( const SwNodePtr& rpNd, void* pArgs ) +static bool lcl_HyphenateNode( SwNode* pNd, void* pArgs ) { // Hyphenate returns true if there is a hyphenation point and sets pPam - SwTextNode *pNode = rpNd->GetTextNode(); + SwTextNode *pNode = pNd->GetTextNode(); SwHyphArgs *pHyphArgs = static_cast<SwHyphArgs*>(pArgs); if( pNode ) { @@ -797,10 +797,10 @@ static bool lcl_HyphenateNode( const SwNodePtr& rpNd, void* pArgs ) : nPageNr + *pPageCnt - *pPageSt + 1; ::SetProgressState( nStat, pNode->GetDoc().GetDocShell() ); } - pHyphArgs->SetRange( rpNd ); + pHyphArgs->SetRange( pNd ); if( pNode->Hyphenate( *pHyphArgs ) ) { - pHyphArgs->SetNode( rpNd ); + pHyphArgs->SetNode( pNd ); return false; } } diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 0f93a708c388..4b5d592e87c9 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -94,10 +94,10 @@ static void SetTextFormatCollNext( SwTextFormatColl* pTextColl, const SwTextForm } } -static bool lcl_RstAttr( const SwNodePtr& rpNd, void* pArgs ) +static bool lcl_RstAttr( SwNode* pNd, void* pArgs ) { const sw::DocumentContentOperationsManager::ParaRstFormat* pPara = static_cast<sw::DocumentContentOperationsManager::ParaRstFormat*>(pArgs); - SwContentNode* pNode = rpNd->GetContentNode(); + SwContentNode* pNode = pNd->GetContentNode(); if (pPara && pPara->pLayout && pPara->pLayout->HasMergedParas() && pNode && pNode->GetRedlineMergeFlag() == SwNode::Merge::Hidden) { @@ -1003,9 +1003,9 @@ void SwDoc::DelTextFormatColl( SwTextFormatColl const *pColl, bool bBroadcast ) DelTextFormatColl( nFormat, bBroadcast ); } -static bool lcl_SetTextFormatColl( const SwNodePtr& rpNode, void* pArgs ) +static bool lcl_SetTextFormatColl( SwNode* pNode, void* pArgs ) { - SwContentNode* pCNd = rpNode->GetTextNode(); + SwContentNode* pCNd = pNode->GetTextNode(); if( pCNd == nullptr) return true; diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index a9ab35670ed1..4ed288c79bf7 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -86,11 +86,11 @@ bool SwDoc::GenerateHTMLDoc( const OUString& rPath, } // two helpers for outline mode -static SwNodePtr GetStartNode( SwOutlineNodes const * pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type* nOutl ) +static SwNode* GetStartNode( SwOutlineNodes const * pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type* nOutl ) { for( ; *nOutl < pOutlNds->size(); ++(*nOutl) ) { - SwNodePtr pNd = (*pOutlNds)[ *nOutl ]; + SwNode* pNd = (*pOutlNds)[ *nOutl ]; if( pNd->GetTextNode()->GetAttrOutlineLevel() == nOutlineLevel && !pNd->FindTableNode() ) { return pNd; @@ -100,9 +100,9 @@ static SwNodePtr GetStartNode( SwOutlineNodes const * pOutlNds, int nOutlineLeve return nullptr; } -static SwNodePtr GetEndNode( SwOutlineNodes const * pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type* nOutl ) +static SwNode* GetEndNode( SwOutlineNodes const * pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type* nOutl ) { - SwNodePtr pNd; + SwNode* pNd; for( ++(*nOutl); (*nOutl) < pOutlNds->size(); ++(*nOutl) ) { @@ -120,11 +120,11 @@ static SwNodePtr GetEndNode( SwOutlineNodes const * pOutlNds, int nOutlineLevel, } // two helpers for collection mode -static SwNodePtr GetStartNode( const SwOutlineNodes* pOutlNds, const SwTextFormatColl* pSplitColl, SwOutlineNodes::size_type* nOutl ) +static SwNode* GetStartNode( const SwOutlineNodes* pOutlNds, const SwTextFormatColl* pSplitColl, SwOutlineNodes::size_type* nOutl ) { for( ; *nOutl < pOutlNds->size(); ++(*nOutl) ) { - SwNodePtr pNd = (*pOutlNds)[ *nOutl ]; + SwNode* pNd = (*pOutlNds)[ *nOutl ]; if( pNd->GetTextNode()->GetTextColl() == pSplitColl && !pNd->FindTableNode() ) { @@ -134,9 +134,9 @@ static SwNodePtr GetStartNode( const SwOutlineNodes* pOutlNds, const SwTextForma return nullptr; } -static SwNodePtr GetEndNode( const SwOutlineNodes* pOutlNds, const SwTextFormatColl* pSplitColl, SwOutlineNodes::size_type* nOutl ) +static SwNode* GetEndNode( const SwOutlineNodes* pOutlNds, const SwTextFormatColl* pSplitColl, SwOutlineNodes::size_type* nOutl ) { - SwNodePtr pNd; + SwNode* pNd; for( ++(*nOutl); *nOutl < pOutlNds->size(); ++(*nOutl) ) { @@ -168,7 +168,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline, SwOutlineNodes::size_type nOutl = 0; SwOutlineNodes* pOutlNds = const_cast<SwOutlineNodes*>(&GetNodes().GetOutLineNds()); std::unique_ptr<SwOutlineNodes> xTmpOutlNds; - SwNodePtr pStartNd; + SwNode* pStartNd; if ( !bOutline) { if( pSplitColl ) @@ -262,7 +262,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline, if( pStartNd ) { - SwNodePtr pEndNd; + SwNode* pEndNd; if( bOutline ) pEndNd = GetEndNode( pOutlNds, nOutlineLevel, &nOutl ); else diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 5819947544c2..026eea9d503d 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -209,8 +209,8 @@ bool SwDoc::OutlineUpDown(const SwPaM& rPam, short nOffset, SwPaM aPam(rPam, nullptr); ExpandPamForParaPropsNodes(aPam, pLayout); const SwOutlineNodes& rOutlNds = GetNodes().GetOutLineNds(); - const SwNodePtr pSttNd = &aPam.Start()->nNode.GetNode(); - const SwNodePtr pEndNd = &aPam.End()->nNode.GetNode(); + SwNode* const pSttNd = &aPam.Start()->nNode.GetNode(); + SwNode* const pEndNd = &aPam.End()->nNode.GetNode(); SwOutlineNodes::size_type nSttPos, nEndPos; if( !rOutlNds.Seek_Entry( pSttNd, &nSttPos ) && diff --git a/sw/source/core/docnode/ndnum.cxx b/sw/source/core/docnode/ndnum.cxx index b3d66affa66e..9cce9a6b7780 100644 --- a/sw/source/core/docnode/ndnum.cxx +++ b/sw/source/core/docnode/ndnum.cxx @@ -77,7 +77,7 @@ void SwNodes::UpdateOutlineIdx( const SwNode& rNd ) if( m_pOutlineNodes->empty() ) // no OutlineNodes present ? return; - const SwNodePtr pSrch = const_cast<SwNodePtr>(&rNd); + SwNode* const pSrch = const_cast<SwNode*>(&rNd); SwOutlineNodes::size_type nPos; if (!m_pOutlineNodes->Seek_Entry(pSrch, &nPos)) diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index da593261074b..f720b29f3289 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -152,7 +152,7 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz, if (pTextNode->IsOutline()) { - const SwNodePtr pSrch = &rNd; + SwNode* pSrch = &rNd; m_pOutlineNodes->erase( pSrch ); } } @@ -167,7 +167,7 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz, if (bInsOutlineIdx && rTextNd.IsOutline()) { - const SwNodePtr pSrch = &rNd; + SwNode* pSrch = &rNd; m_pOutlineNodes->insert( pSrch ); } rTextNd.InvalidateNumRule(); @@ -1396,12 +1396,12 @@ struct HighLevel } -static bool lcl_HighestLevel( const SwNodePtr& rpNode, void * pPara ) +static bool lcl_HighestLevel( SwNode* pNode, void * pPara ) { HighLevel * pHL = static_cast<HighLevel*>(pPara); - if( rpNode->GetStartNode() ) + if( pNode->GetStartNode() ) pHL->nLevel++; - else if( rpNode->GetEndNode() ) + else if( pNode->GetEndNode() ) pHL->nLevel--; if( pHL->nTop > pHL->nLevel ) pHL->nTop = pHL->nLevel; @@ -2288,15 +2288,13 @@ void SwNodes::RemoveNode( sal_uLong nDelPos, sal_uLong nSz, bool bDel ) BigPtrArray::Remove( nDelPos, nSz ); } -void SwNodes::InsertNode( const SwNodePtr pNode, - const SwNodeIndex& rPos ) +void SwNodes::InsertNode( SwNode* pNode, const SwNodeIndex& rPos ) { BigPtrEntry* pIns = pNode; BigPtrArray::Insert( pIns, rPos.GetIndex() ); } -void SwNodes::InsertNode( const SwNodePtr pNode, - sal_uLong nPos ) +void SwNodes::InsertNode( SwNode* pNode, sal_uLong nPos ) { BigPtrEntry* pIns = pNode; BigPtrArray::Insert( pIns, nPos ); diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index 994efbf37ec4..101e1494e4fc 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -589,7 +589,7 @@ bool SwEditShell::IsProtectedOutlinePara() const if( rNd.IsTextNode() ) { const SwOutlineNodes& rOutlNd = GetDoc()->GetNodes().GetOutLineNds(); - SwNodePtr pNd = const_cast<SwNodePtr>(&rNd); + SwNode* pNd = const_cast<SwNode*>(&rNd); bool bFirst = true; SwOutlineNodes::size_type nPos; int nLvl(0); @@ -598,7 +598,7 @@ bool SwEditShell::IsProtectedOutlinePara() const for( ; nPos < rOutlNd.size(); ++nPos ) { - SwNodePtr pTmpNd = rOutlNd[ nPos ]; + SwNode* pTmpNd = rOutlNd[ nPos ]; if (!sw::IsParaPropsNode(*GetLayout(), *pTmpNd->GetTextNode())) { diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx index 37b34a432bf1..a7a50e48d890 100644 --- a/sw/source/core/inc/DocumentContentOperationsManager.hxx +++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx @@ -149,7 +149,7 @@ public: { } }; - static bool lcl_RstTextAttr( const SwNodePtr& rpNd, void* pArgs ); //originally from docfmt.cxx + static bool lcl_RstTextAttr( SwNode* pNd, void* pArgs ); //originally from docfmt.cxx virtual ~DocumentContentOperationsManager() override; diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index a5fc70e0debb..fd0be53e8a91 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -587,7 +587,7 @@ uno::Reference< chart2::data::XDataSource > SwChartDataProvider::Impl_createData const SwNodes& rNodes = m_pDoc->GetNodes(); for( sal_uLong nN = rNodes.Count(); nN--; ) { - SwNodePtr pNode = rNodes[nN]; + SwNode* pNode = rNodes[nN]; if( !pNode ) continue; const SwOLENode* pOleNode = pNode->GetOLENode(); diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 73cdb8d25caf..792ca0b69e3a 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -66,7 +66,7 @@ using namespace ::com::sun::star; -static bool sw_MergePortions(SwNode *const& pNode, void *) +static bool sw_MergePortions(SwNode* pNode, void *) { if (pNode->IsTextNode()) { diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index eea1ca435720..59f9e6bea81f 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -953,10 +953,10 @@ void SwXMLImport::MergeListsAtDocumentInsertPosition(SwDoc *pDoc) sal_uLong index = 1; // the last node of the main document where we have inserted a document - const SwNodePtr node1 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + 0]; + SwNode* const node1 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + 0]; // the first node of the inserted document - SwNodePtr node2 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + index]; + SwNode* node2 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + index]; if (! (node1 && node2 && (node1->GetNodeType() == node2->GetNodeType())