sw/source/uibase/utlui/content.cxx | 24 +++++++++++++++++++++++- sw/source/uibase/wrtsh/wrtsh1.cxx | 7 +++++++ 2 files changed, 30 insertions(+), 1 deletion(-)
New commits: commit ceceb574251d6ed3ce4da2fdcae398cb72488dfa Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Fri Oct 6 21:38:45 2023 -0800 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Tue Oct 10 06:30:57 2023 +0200 tdf#156980 SwNavigator: Make headings delete even if they have folded outline content Change-Id: If952d8d845c2eeec86231014b924f1632d2f5efe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157667 Tested-by: Jenkins Reviewed-by: Jim Raykowski <rayk...@gmail.com> diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index a8b939b774be..c9a30aaddfe4 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -4871,12 +4871,13 @@ void SwContentTree::ExecuteContextMenuAction(const OUString& rSelectedPopupEntry void SwContentTree::DeleteOutlineSelections() { + const SwOutlineNodes& rOutlineNodes = m_pActiveShell->GetNodes().GetOutLineNds(); auto nChapters(0); m_pActiveShell->StartAction(); m_pActiveShell->EnterAddMode(); - m_xTreeView->selected_foreach([this, &nChapters](weld::TreeIter& rEntry){ + m_xTreeView->selected_foreach([this, &rOutlineNodes, &nChapters](weld::TreeIter& rEntry){ ++nChapters; if (m_xTreeView->iter_has_child(rEntry) && !m_xTreeView->get_row_expanded(rEntry)) // only count children if not expanded @@ -4884,6 +4885,27 @@ void SwContentTree::DeleteOutlineSelections() nChapters += m_xTreeView->iter_n_children(rEntry); } SwOutlineNodes::size_type nActPos = weld::fromId<SwOutlineContent*>(m_xTreeView->get_id(rEntry))->GetOutlinePos(); + if (m_pActiveShell->GetViewOptions()->IsShowOutlineContentVisibilityButton()) + { + // make folded content visible so it can be selected + if (!m_pActiveShell->IsOutlineContentVisible(nActPos)) + m_pActiveShell->MakeOutlineContentVisible(nActPos); + if (!m_xTreeView->get_row_expanded(rEntry)) + { + // include children + SwNode* pNode = rOutlineNodes[nActPos]; + const int nLevel = pNode->GetTextNode()->GetAttrOutlineLevel() - 1; + for (auto nPos = nActPos + 1; nPos < rOutlineNodes.size(); ++nPos) + { + pNode = rOutlineNodes[nPos]; + const int nNextLevel = pNode->GetTextNode()->GetAttrOutlineLevel() - 1; + if (nNextLevel <= nLevel) + break; + if (!m_pActiveShell->IsOutlineContentVisible(nNextLevel)) + m_pActiveShell->MakeOutlineContentVisible(nNextLevel); + } + } + } m_pActiveShell->SttSelect(); m_pActiveShell->MakeOutlineSel(nActPos, nActPos, !m_xTreeView->get_row_expanded(rEntry), false); // select children if not expanded // The outline selection may already be to the start of the following outline paragraph diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 921d71415d95..9dc476fb18ba 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -2662,6 +2662,13 @@ bool SwWrtShell::HasFoldedOutlineContentSelected() const SwOutlineNodes::size_type nPos; for (SwNodeIndex aIdx = aPointIdx; aIdx <= aMarkIdx; ++aIdx) { + // To allow delete when the start of the selection is at the start of a + // paragraph and the end of the selection is at the start of a paragraph and there + // are no folded outline content nodes in between. + if (aIdx == aMarkIdx && aPaM.GetPoint()->GetContentIndex() == 0 && + aPaM.GetMark()->GetContentIndex() == 0) + return false; + if (GetDoc()->GetNodes().GetOutLineNds().Seek_Entry(&(aIdx.GetNode()), &nPos) && !GetAttrOutlineContentVisible(nPos)) return true;