summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-12-21 14:22:36 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-12-22 12:59:56 +0100
commitb922988e2cd57c9397b9e512a7616a10612b2b8f (patch)
tree6969b66bf17a0947098f2d74a079b13387c7a967 /sw
parente0f13ce0f9e2dac836c42141bb848d2bf4fbda75 (diff)
sw: simplify SwNodes::FindPrvNxtFrameNode(), de-golf conditionals
Change-Id: Ie5b35793ce38e6338e34d47725e649a56078d603 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127271 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/docnode/nodes.cxx49
1 files changed, 32 insertions, 17 deletions
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 9ee61dd93d50..869be5779337 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -2061,11 +2061,15 @@ SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx,
--aIdx;
SwNode *const pNd = &aIdx.GetNode();
- if( ( pFrameNd = pNd )->IsContentNode() )
+ pFrameNd = pNd;
+ if (pFrameNd->IsContentNode())
+ {
rFrameIdx = aIdx;
-
+ return pFrameNd;
+ }
// search forward or backward for a content node
- else if( nullptr != ( pFrameNd = GoPrevSection( &aIdx, true, false )) &&
+ pFrameNd = GoPrevSection( &aIdx, true, false );
+ if ( nullptr != pFrameNd &&
::CheckNodesRange( aIdx, rFrameIdx, true ) &&
// Never out of the table at the start
pFrameNd->FindTableNode() == pTableNd &&
@@ -2082,24 +2086,32 @@ SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx,
{
aIdx = pEnd->GetIndex() + 1;
- // NEVER leave the section when doing this!
- if( ( ( pFrameNd = &aIdx.GetNode())->IsContentNode() ) ||
- ( nullptr != ( pFrameNd = GoNextSection( &aIdx, true, false )) &&
- ::CheckNodesRange( aIdx, rFrameIdx, true ) &&
- ( pFrameNd->FindTableNode() == pTableNd &&
- // NEVER go out of the table cell at the end
- (!pFrameNd->FindTableNode() || pFrameNd->FindTableBoxStartNode()
- == pSttNd->FindTableBoxStartNode() ) ) &&
- (!pSectNd || pSttNd->IsSectionNode() ||
- pSectNd->EndOfSectionIndex() > pFrameNd->GetIndex())
- ))
+ pFrameNd = &aIdx.GetNode();
+ if (!pFrameNd->IsContentNode())
+ {
+ pFrameNd = GoNextSection( &aIdx, true, false );
+ // NEVER leave the section when doing this!
+ if (pFrameNd
+ && !(::CheckNodesRange(aIdx, rFrameIdx, true)
+ && (pFrameNd->FindTableNode() == pTableNd &&
+ // NEVER go out of the table cell at the end
+ (!pFrameNd->FindTableNode() || pFrameNd->FindTableBoxStartNode()
+ == pSttNd->FindTableBoxStartNode()))
+ && (!pSectNd || pSttNd->IsSectionNode() ||
+ pSectNd->EndOfSectionIndex() > pFrameNd->GetIndex()))
+ )
+ {
+ pFrameNd = nullptr;
+ }
+ }
+ if (pFrameNd && pFrameNd->IsContentNode())
{
// Undo when merging a table with one before, if there is also one after it.
// However, if the node is in a table, it needs to be returned if the
// SttNode is a section or a table!
- SwTableNode* pTableNode;
+ SwTableNode *const pTableNode = pFrameNd->FindTableNode();
if (pSttNd->IsTableNode() &&
- nullptr != (pTableNode = pFrameNd->FindTableNode()) &&
+ nullptr != pTableNode &&
// TABLE IN TABLE:
pTableNode != pSttNd->StartOfSectionNode()->FindTableNode())
{
@@ -2118,8 +2130,11 @@ SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx,
{
aIdx = pEnd->GetIndex() + 1;
- if( (pFrameNd = &aIdx.GetNode())->IsTableNode() )
+ pFrameNd = &aIdx.GetNode();
+ if (pFrameNd->IsTableNode())
+ {
rFrameIdx = aIdx;
+ }
else
{
pFrameNd = nullptr;