diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-12-21 13:47:32 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-12-22 17:04:53 +0100 |
commit | 0e4f4b9ea8cf5223b90af47bea3c20e4541fc532 (patch) | |
tree | 4c9917c6ec816118e289b8b7cd42461686544a0e /sw/source | |
parent | 631649f233bda500c627719b9e43df3fe08df7c5 (diff) |
sw: simplify SwNodes::FindPrvNxtFrameNode(), improve comments
Change-Id: I2f715ffe49d1c3ef373ffeb2a3cc335d511e0c13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127269
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 25aa814aa466cb0a59e34dfef33c50065c445f60)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127249
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/docnode/nodes.cxx | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index aa9dd63f4bfd..1b16c73b46eb 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -2023,16 +2023,17 @@ SwContentNode* SwNodes::GoPrevSection( SwNodeIndex * pIdx, return nullptr; } -//TODO: improve documentation //TODO: The inventor of the "single responsibility principle" will be crying if you ever show this code to him! -/** find the next/previous ContentNode or a table node with frames +/** find the next/previous ContentNode or table node that should have layout + * frames that are siblings to the ones of the node at rFrameIdx. * * If no pEnd is given, search is started with FrameIndex; otherwise - * search is started with the one before rFrameIdx and after pEnd. + * search is started backward with the one before rFrameIdx and + * forward after pEnd. * - * @param rFrameIdx node with frames to search in - * @param pEnd ??? - * @return result node; 0 (!!!) if not found + * @param rFrameIdx in: node with frames to search in; out: found node + * @param pEnd last node after rFrameIdx that should be excluded from search + * @return result node; 0 if not found */ SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx, const SwNode* pEnd ) const @@ -2042,17 +2043,17 @@ SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx, // no layout -> skip if( GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell() ) { - SwNode* pSttNd = &rFrameIdx.GetNode(); + SwNode *const pSttNd = &rFrameIdx.GetNode(); - // move of a hidden section? - SwSectionNode* pSectNd = pSttNd->IsSectionNode() + // inside a hidden section? + SwSectionNode *const pSectNd = pSttNd->IsSectionNode() ? pSttNd->StartOfSectionNode()->FindSectionNode() : pSttNd->FindSectionNode(); if( !( pSectNd && pSectNd->GetSection().CalcHiddenFlag() ) ) { // in a table in table situation we have to assure that we don't leave the // outer table cell when the inner table is looking for a PrvNxt... - SwTableNode* pTableNd = pSttNd->IsTableNode() + SwTableNode *const pTableNd = pSttNd->IsTableNode() ? pSttNd->StartOfSectionNode()->FindTableNode() : pSttNd->FindTableNode(); SwNodeIndex aIdx( rFrameIdx ); @@ -2060,10 +2061,8 @@ SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx, if( pEnd ) { --aIdx; - pNd = &aIdx.GetNode(); } - else - pNd = pSttNd; + pNd = &aIdx.GetNode(); if( ( pFrameNd = pNd )->IsContentNode() ) rFrameIdx = aIdx; |