sw/source/uibase/wrtsh/wrtsh1.cxx |    7 +++++++
 1 file changed, 7 insertions(+)

New commits:
commit 10689e0f24e96781664e734fe23d109af6df77f1
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Wed Sep 6 21:02:48 2023 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Sat Sep 9 02:41:12 2023 +0200

    Improve the HasFoldedOutlineContentSelected function
    
    Return false immediatly if there are no outline nodes in the document
    since then there can be no folded outline content selected.
    
    Adjust selection that includes the end of content node so that the
    end of content node is not included in the selection. This fixes a
    crash that occurs when outline folding is enabled and Master
    document 'Text' is deleted by using the Navigator popup menu item
    'Delete'.
    
    Change-Id: I28be127566c3820b3e78834495bbb354cf2d01aa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156631
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index af96916885d5..923fabb06167 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -2643,12 +2643,19 @@ bool SwWrtShell::GetAttrOutlineContentVisible(const 
size_t nPos) const
 
 bool SwWrtShell::HasFoldedOutlineContentSelected() const
 {
+    // No need to check for selection over folded outline content when there 
are no outline nodes.
+    if (GetDoc()->GetNodes().GetOutLineNds().empty())
+        return false;
     for(const SwPaM& rPaM : GetCursor()->GetRingContainer())
     {
         SwPaM aPaM(*rPaM.GetMark(), *rPaM.GetPoint());
         aPaM.Normalize();
         SwNodeIndex aPointIdx(aPaM.GetPoint()->GetNode());
         SwNodeIndex aMarkIdx(aPaM.GetMark()->GetNode());
+        // Prevent crash in the for loop below by adjusting the mark if it is 
set to the end of
+        // content node.
+        if (aMarkIdx.GetNode() == GetDoc()->GetNodes().GetEndOfContent())
+            --aMarkIdx;
         if (aPointIdx == aMarkIdx)
             continue;
         // Return true if any nodes in PaM are folded outline content nodes.

Reply via email to