diff options
author | Jim Raykowski <raykowj@gmail.com> | 2024-04-13 12:56:39 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2024-05-04 19:28:27 +0200 |
commit | 7938500ad3b384f1f30858cea64e12c84610996d (patch) | |
tree | 38418beda0e0382db1aa49e9f9461044f7e758fa /sw/source/uibase/utlui | |
parent | 6efe3a7a83bf5e110cbe84c225ca4f0a6364a906 (diff) |
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 <raykowj@gmail.com>
Diffstat (limited to 'sw/source/uibase/utlui')
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 52 |
1 files changed, 17 insertions, 35 deletions
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); |