sw/source/uibase/utlui/content.cxx | 52 ++++++++++--------------------- sw/uiconfig/swriter/ui/navigatorpanel.ui | 4 ++ 2 files changed, 21 insertions(+), 35 deletions(-)
New commits: commit 7938500ad3b384f1f30858cea64e12c84610996d Author: Jim Raykowski <[email protected]> AuthorDate: Sat Apr 13 12:56:39 2024 -0800 Commit: Jim Raykowski <[email protected]> CommitDate: Sat May 4 19:28:27 2024 +0200 SwNavigator: improve when outline move controls/menu-items are active/visible Makes the outline content context menu not show the up/down/promote/ demote menu items when outline content is set to display by alphabetical sort. With intent to improve code readablility, reworks the SwContentTree::Select function used to set the sensitive state of the up/down/promote/demote buttons. The buttons are disabled for any of the following conditions; the Navigator is in "Zoom" mode, the document is in read-only mode, the selected entry is not an outline content entry, or the outline content is displayed by alphabetical sort. The patch also makes the alphabetical sort setting independent among the floating and sidebar versions. Change-Id: I6ff8fab2ce2fb6f68163ed3860b0440fba875fb1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166067 Tested-by: Jenkins Reviewed-by: Jim Raykowski <[email protected]> diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 994f18cdbee9..06c4d93f78dd 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1753,9 +1753,7 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) && nContentType != ContentTypeId::POSTIT && nContentType != ContentTypeId::UNKNOWN) { bRemoveSortEntry = false; - const sal_Int32 nMask = 1 << static_cast<int>(nContentType); - sal_uInt64 nSortAlphabeticallyBlock = m_pConfig->GetSortAlphabeticallyBlock(); - xPop->set_active("sort", nSortAlphabeticallyBlock & nMask); + xPop->set_active("sort", pType->IsAlphabeticSort()); } OUString aIdent; @@ -1912,7 +1910,8 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) if (!bReadonly) { bRemoveSelectEntry = false; - bRemoveChapterEntries = false; + if (!pType->IsAlphabeticSort()) + bRemoveChapterEntries = false; } bRemoveCopyEntry = false; } @@ -2893,20 +2892,8 @@ void SwContentTree::Display( bool bActive ) } else if (State::HIDDEN == m_eState) m_eState = State::ACTIVE; - SwWrtShell* pShell = GetWrtShell(); - const bool bReadOnly = !pShell || pShell->GetView().GetDocShell()->IsReadOnly(); - if(bReadOnly != m_bIsLastReadOnly) - { - m_bIsLastReadOnly = bReadOnly; - bool bDisable = pShell == nullptr || bReadOnly; - SwNavigationPI* pNavi = GetParentWindow(); - pNavi->m_xContent6ToolBox->set_item_sensitive("chapterup", !bDisable); - pNavi->m_xContent6ToolBox->set_item_sensitive("chapterdown", !bDisable); - pNavi->m_xContent6ToolBox->set_item_sensitive("promote", !bDisable); - pNavi->m_xContent6ToolBox->set_item_sensitive("demote", !bDisable); - pNavi->m_xContent5ToolBox->set_item_sensitive("reminder", !bDisable); - } + SwWrtShell* pShell = GetWrtShell(); if (pShell) { std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator(); @@ -3030,10 +3017,11 @@ void SwContentTree::Display( bool bActive ) } // set_cursor unselects all entries, makes passed entry visible, and selects it m_xTreeView->set_cursor(*xSelEntry); - Select(); } } + Select(); + if (!m_bIgnoreDocChange && GetEntryCount() == nOldEntryCount) { m_xTreeView->vadjustment_set_value(nOldScrollPos); @@ -5479,33 +5467,27 @@ IMPL_LINK_NOARG(SwContentTree, SelectHdl, weld::TreeView&, void) } // Here the buttons for moving outlines are en-/disabled. +// The buttons for moving outlines are disabled when the Navigator is in "Zoom" mode or when +// the document is in read-only mode or when the outline content is displayed alphabetically +// sorted or when the selected entry is not outline content. void SwContentTree::Select() { - std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator()); - if (!m_xTreeView->get_selected(xEntry.get())) - return; + SwNavigationPI* pNavi = GetParentWindow(); bool bEnable = false; - std::unique_ptr<weld::TreeIter> xParentEntry(m_xTreeView->make_iterator(xEntry.get())); - bool bParentEntry = m_xTreeView->iter_parent(*xParentEntry); - while (bParentEntry && (!lcl_IsContentType(*xParentEntry, *m_xTreeView))) - bParentEntry = m_xTreeView->iter_parent(*xParentEntry); - if (!m_bIsLastReadOnly) + + if (!pNavi->IsZoomedIn() && !m_bIsLastReadOnly) { - if (!m_xTreeView->get_visible()) - bEnable = true; - else if (bParentEntry) + std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator()); + if (m_xTreeView->get_selected(xEntry.get()) && lcl_IsContent(*xEntry, *m_xTreeView)) { - if ((m_bIsRoot && m_nRootType == ContentTypeId::OUTLINE) || - (lcl_IsContent(*xEntry, *m_xTreeView) && - weld::fromId<SwContentType*>(m_xTreeView->get_id(*xParentEntry))->GetType() == ContentTypeId::OUTLINE)) - { + const SwContentType* pCntType = + weld::fromId<SwContent*>(m_xTreeView->get_id(*xEntry))->GetParent(); + if (pCntType->GetType() == ContentTypeId::OUTLINE && !pCntType->IsAlphabeticSort()) bEnable = true; - } } } - SwNavigationPI* pNavi = GetParentWindow(); pNavi->m_xContent6ToolBox->set_item_sensitive("chapterup", bEnable); pNavi->m_xContent6ToolBox->set_item_sensitive("chapterdown", bEnable); pNavi->m_xContent6ToolBox->set_item_sensitive("promote", bEnable); diff --git a/sw/uiconfig/swriter/ui/navigatorpanel.ui b/sw/uiconfig/swriter/ui/navigatorpanel.ui index e12dc94e3f47..afb588a7a65d 100644 --- a/sw/uiconfig/swriter/ui/navigatorpanel.ui +++ b/sw/uiconfig/swriter/ui/navigatorpanel.ui @@ -554,6 +554,7 @@ <child> <object class="GtkToolButton" id="promote"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">False</property> <property name="tooltip-text" translatable="yes" context="navigatorpanel|promote|tooltip_text">Promote Outline Level</property> <property name="icon-name">sw/res/sc20172.png</property> @@ -572,6 +573,7 @@ <child> <object class="GtkToolButton" id="demote"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">False</property> <property name="tooltip-text" translatable="yes" context="navigatorpanel|demote|tooltip_text">Demote Outline Level</property> <property name="icon-name">sw/res/sc20173.png</property> @@ -590,6 +592,7 @@ <child> <object class="GtkToolButton" id="chapterup"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">False</property> <property name="tooltip-text" translatable="yes" context="navigatorpanel|chapterup|tooltip_text">Move Heading Up</property> <property name="icon-name">sw/res/sc20174.png</property> @@ -608,6 +611,7 @@ <child> <object class="GtkToolButton" id="chapterdown"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">False</property> <property name="tooltip-text" translatable="yes" context="navigatorpanel|chapterdown|tooltip_text">Move Heading Down</property> <property name="icon-name">sw/res/sc20171.png</property>
