diff options
author | Jim Raykowski <raykowj@gmail.com> | 2021-08-08 21:43:25 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2021-08-11 07:10:20 +0200 |
commit | 0ff5eb97b89f89e770d4397bf76f24fb7cd76b57 (patch) | |
tree | 765a9bcf390cd3bdffc8ca103290710a423107d4 | |
parent | fa339b3adb53300ae68913bed87e18caf9f2e262 (diff) |
tdf#143577 check node is a text node before use as such
Change-Id: I337c94aa90ed906c5b744171728022ba5f9c64b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120191
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
-rw-r--r-- | sw/source/uibase/shells/basesh.cxx | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 4a0691d36f99..0ef37aeb3a00 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -199,25 +199,26 @@ void SwBaseShell::ExecDelete(SfxRequest &rReq) case SID_DELETE: if (rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton()) { + // Disallow if the cursor is at the end of a paragraph and the document model + // node at this position is an outline node with folded content or the next node + // is an outline node with folded content. if (rSh.IsEndPara()) { SwNodeIndex aIdx(rSh.GetCursor()->GetNode()); - // disallow if this is an outline node having folded content - bool bVisible = true; - aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible); - if (!bVisible) - return; - // disallow if the next text node is an outline node having folded content - ++aIdx; - SwNodeType aNodeType; - while ((aNodeType = aIdx.GetNode().GetNodeType()) != SwNodeType::Text) - ++aIdx; if (aIdx.GetNode().IsTextNode()) { - bVisible = true; + bool bVisible = true; aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible); if (!bVisible) - return; + break; + ++aIdx; + if (aIdx.GetNode().IsTextNode()) + { + bVisible = true; + aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible); + if (!bVisible) + break; + } } } } @@ -227,21 +228,23 @@ void SwBaseShell::ExecDelete(SfxRequest &rReq) case FN_BACKSPACE: if (rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton()) { + // Disallow if the cursor is at the start of a paragraph and the document model + // node at this position is an outline node with folded content or the previous + // node is a content node without a layout frame. if (rSh.IsSttPara()) { SwNodeIndex aIdx(rSh.GetCursor()->GetNode()); - // disallow if this is a folded outline node - bool bVisible = true; - aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible); - if (!bVisible) - return; - // disallow if previous text node does not have a layout frame - --aIdx; - SwNodeType aNodeType; - while ((aNodeType = aIdx.GetNode().GetNodeType()) != SwNodeType::Text) + if (aIdx.GetNode().IsTextNode()) + { + bool bVisible = true; + aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible); + if (!bVisible) + break; --aIdx; - if (aIdx.GetNode().IsContentNode() && !aIdx.GetNode().GetContentNode()->getLayoutFrame(nullptr)) - return; + if (aIdx.GetNode().IsContentNode() && + !aIdx.GetNode().GetContentNode()->getLayoutFrame(nullptr)) + break; + } } } if( rSh.IsNoNum() ) |