diff options
author | Jim Raykowski <raykowj@gmail.com> | 2024-05-21 15:05:33 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2024-05-28 06:25:46 +0200 |
commit | ae94c420e6269f99cdaa611d19e73fc92ebd234b (patch) | |
tree | 2651fe472ac412534565659cac09383e1ff8a03b | |
parent | b860aea9d6f8ac46f6d2575ead25337495ec9a88 (diff) |
SwNavigator: Improve Indexes context menu
* Removes "Remove Index" menu item in favor of the repeated function
"Delete index" menu item.
* Hides the "Update", "Delete Index", and "Rename..." menu items when
the document or index is set read-only.
Change-Id: Ie907c33e2fe991ba6c02ad987193db481f375116
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167913
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
-rw-r--r-- | sw/source/uibase/inc/conttree.hxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 38 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/navigatorcontextmenu.ui | 8 |
3 files changed, 21 insertions, 32 deletions
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index 9a67d986f55f..d58123287e07 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -50,10 +50,9 @@ enum class EditEntryMode { EDIT = 0, UPD_IDX = 1, - RMV_IDX = 2, - UNPROTECT_TABLE = 3, - DELETE = 4, - RENAME = 5, + UNPROTECT_TABLE = 2, + DELETE = 3, + RENAME = 4, }; // Flags for PopupMenu-enable/disable diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 1346d3bb5094..f462148fa7d8 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1692,8 +1692,8 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) bRemoveGotoEntry = true; bool bRemovePostItEntries = true; - bool bRemoveIndexEntries = true; - bool bRemoveCopyEntry = true; + bool bRemoveUpdateIndexEntry = true; + bool bRemoveReadonlyIndexEntry = true; bool bRemoveCopyEntry = true; bool bRemoveEditEntry = true; bool bRemoveUnprotectEntry = true; bool bRemoveDeleteChapterEntry = true, @@ -1825,7 +1825,7 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) (State::ACTIVE == m_eState || (GetActiveView() && m_pActiveShell == GetActiveView()->GetWrtShellPtr())) && lcl_IsContent(*xEntry, *m_xTreeView)) { - const bool bReadonly = m_pActiveShell->GetView().GetDocShell()->IsReadOnly(); + bool bReadonly = m_pActiveShell->GetView().GetDocShell()->IsReadOnly(); const bool bVisible = !weld::fromId<SwContent*>(m_xTreeView->get_id(*xEntry))->IsInvisible(); const bool bProtected = weld::fromId<SwContent*>(m_xTreeView->get_id(*xEntry))->IsProtect(); const bool bProtectBM = (ContentTypeId::BOOKMARK == nContentType) @@ -1873,9 +1873,6 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) case ContentTypeId::REFERENCE: bRemoveDeleteReferenceEntry = false; break; - case ContentTypeId::INDEX: - bRemoveDeleteIndexEntry = false; - break; case ContentTypeId::POSTIT: bRemoveDeleteCommentEntry = false; break; @@ -1919,12 +1916,16 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) { if(ContentTypeId::INDEX == nContentType) { - bRemoveIndexEntries = false; - + bRemoveReadonlyIndexEntry = false; + bRemoveEditEntry = false; const SwTOXBase* pBase = weld::fromId<SwTOXBaseContent*>(m_xTreeView->get_id(*xEntry))->GetTOXBase(); - if (!pBase->IsTOXBaseInReadonly()) - bRemoveEditEntry = false; - + if (!pBase->IsTOXBaseInReadonly() && !SwEditShell::IsTOXBaseReadonly(*pBase)) + { + bRemoveUpdateIndexEntry = false; + bRemoveDeleteIndexEntry = false; + } + else + bReadonly = true; xPop->set_active(OUString::number(405), SwEditShell::IsTOXBaseReadonly(*pBase)); } else if(ContentTypeId::TABLE == nContentType) @@ -1955,7 +1956,7 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) else bRemoveEditEntry = false; } - if (bRenamable) + if (bRenamable && !bReadonly) bRemoveRenameEntry = false; } else @@ -2071,12 +2072,11 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) if (bRemoveRenameEntry) xPop->remove(OUString::number(502)); - if (bRemoveIndexEntries) - { - xPop->remove(OUString::number(401)); + if (bRemoveUpdateIndexEntry) xPop->remove(OUString::number(402)); + + if (bRemoveReadonlyIndexEntry) xPop->remove(OUString::number(405)); - } if (bRemoveUnprotectEntry) xPop->remove(OUString::number(404)); @@ -2098,7 +2098,7 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) bRemoveChapterEntries && bRemovePostItEntries && bRemoveRenameEntry && - bRemoveIndexEntries && + bRemoveReadonlyIndexEntry && bRemoveUnprotectEntry && bRemoveEditEntry) xPop->remove("separator2"); @@ -5260,9 +5260,8 @@ void SwContentTree::ExecuteContextMenuAction(const OUString& rSelectedPopupEntry if(m_nOutlineLevel != nSelectedPopupEntry ) SetOutlineLevel(static_cast<sal_Int8>(nSelectedPopupEntry)); break; - case 401: case 402: - EditEntry(*xFirst, nSelectedPopupEntry == 401 ? EditEntryMode::RMV_IDX : EditEntryMode::UPD_IDX); + EditEntry(*xFirst, EditEntryMode::UPD_IDX); break; // Edit entry case 403: @@ -5779,7 +5778,6 @@ void SwContentTree::EditEntry(const weld::TreeIter& rEntry, EditEntryMode nMode) } break; - case EditEntryMode::RMV_IDX: case EditEntryMode::DELETE: { if( pBase ) diff --git a/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui b/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui index 266e388d8549..88583e0d90b0 100644 --- a/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui +++ b/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui @@ -99,14 +99,6 @@ </object> </child> <child> - <object class="GtkMenuItem" id="401"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes" context="navigatorcontextmenu|STR_REMOVE_INDEX">_Remove Index</property> - <property name="use-underline">True</property> - </object> - </child> - <child> <object class="GtkMenuItem" id="402"> <property name="visible">True</property> <property name="can-focus">False</property> |