diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2020-01-24 18:40:24 +0100 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2020-03-25 20:50:17 +0100 |
commit | c322064eac9a7d562f1a4501df7bb1ddd3ab843f (patch) | |
tree | e9d4d61f5afc6178fe58654d7d7cc262856356ce | |
parent | 603e4d11a25b30b4b0c9d455420cc5f9b365a5e9 (diff) |
sw: Optionally disable bookmark manipulation GUIs
If the ProtectBookmarks bit is set, don't allow bookmark
changes, neither via the bookmark dialog nor the navigator.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87361
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit cb5d18871b46ef4f7bc47eb4d71df5374d712575)
Omit new strings for backport to 6.1 branch, was only shown as
disabled context menu item anyway.
Change-Id: I035faaf3871c7107dd1aac38c4e6867291827346
-rw-r--r-- | sw/source/ui/misc/bookmark.cxx | 15 | ||||
-rw-r--r-- | sw/source/uibase/inc/bookmark.hxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 26 |
4 files changed, 27 insertions, 17 deletions
diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 309892627b47..3372dd3eb375 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -36,6 +36,7 @@ #include <docsh.hxx> #include <globals.hrc> #include <strings.hrc> +#include <IDocumentSettingAccess.hxx> using namespace ::com::sun::star; @@ -84,12 +85,12 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, ModifyHdl, Edit&, void) } // allow to add new bookmark only if one name provided and it's not taken - m_pInsertBtn->Enable(nEntries == 1 && nSelectedEntries == 0); + m_pInsertBtn->Enable(nEntries == 1 && nSelectedEntries == 0 && !m_bAreProtected); // allow to delete only if all bookmarks are recognized - m_pDeleteBtn->Enable(nEntries > 0 && nSelectedEntries == nEntries); + m_pDeleteBtn->Enable(nEntries > 0 && nSelectedEntries == nEntries && !m_bAreProtected); m_pGotoBtn->Enable(nEntries == 1 && nSelectedEntries == 1); - m_pRenameBtn->Enable(nEntries == 1 && nSelectedEntries == 1); + m_pRenameBtn->Enable(nEntries == 1 && nSelectedEntries == 1 && !m_bAreProtected); } // callback to delete a text mark @@ -161,13 +162,13 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, SelectionChangedHdl, SvTreeListBox*, void) { m_pInsertBtn->Disable(); m_pGotoBtn->Enable(m_pBookmarksBox->GetSelectionCount() == 1); - m_pRenameBtn->Enable(m_pBookmarksBox->GetSelectionCount() == 1); - m_pDeleteBtn->Enable(); + m_pRenameBtn->Enable(m_pBookmarksBox->GetSelectionCount() == 1 && !m_bAreProtected); + m_pDeleteBtn->Enable(!m_bAreProtected); m_pEditBox->SetText(sEditBoxText); } else { - m_pInsertBtn->Enable(); + m_pInsertBtn->Enable(!m_bAreProtected); m_pGotoBtn->Disable(); m_pRenameBtn->Disable(); m_pDeleteBtn->Disable(); @@ -327,6 +328,8 @@ SwInsertBookmarkDlg::SwInsertBookmarkDlg(vcl::Window* pParent, SwWrtShell& rS, S m_pEditBox->SetCursorAtLast(); sRemoveWarning = SwResId(STR_REMOVE_WARNING); + + m_bAreProtected = rSh.getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_BOOKMARKS); } SwInsertBookmarkDlg::~SwInsertBookmarkDlg() diff --git a/sw/source/uibase/inc/bookmark.hxx b/sw/source/uibase/inc/bookmark.hxx index e8554052b9aa..5f94efd7bb01 100644 --- a/sw/source/uibase/inc/bookmark.hxx +++ b/sw/source/uibase/inc/bookmark.hxx @@ -60,6 +60,7 @@ class SwInsertBookmarkDlg: public SvxStandardDialog SfxRequest& rReq; std::vector<std::pair<sw::mark::IMark*, OUString>> aTableBookmarks; sal_Int32 m_nLastBookmarksCount; + bool m_bAreProtected; DECL_LINK(ModifyHdl, Edit&, void); DECL_LINK(InsertHdl, Button*, void); diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 503f52b502fc..f19ff11b9af8 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -715,7 +715,7 @@ void SwTextShell::Execute(SfxRequest &rReq) } case FN_DELETE_BOOKMARK: { - if ( pItem ) + if (pItem && !rWrtSh.getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_BOOKMARKS)) { IDocumentMarkAccess* const pMarkAccess = rWrtSh.getIDocumentMarkAccess(); pMarkAccess->deleteMark( pMarkAccess->findMark(static_cast<const SfxStringItem*>(pItem)->GetValue()) ); diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 9c6c26c1e47b..2784bb0da14a 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -51,6 +51,7 @@ #include <navicfg.hxx> #include <edtwin.hxx> #include <doc.hxx> +#include <IDocumentSettingAccess.hxx> #include <IDocumentDrawModelAccess.hxx> #include <IDocumentOutlineNodes.hxx> #include <unotools.hxx> @@ -317,7 +318,9 @@ void SwContentType::Init(bool* pbInvalidateWindow) pMarkAccess->getBookmarksEnd(), &lcl_IsUiVisibleBookmark); sTypeToken.clear(); - bEdit = true; + const bool bProtectedBM = pWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_BOOKMARKS); + bEdit = !bProtectedBM; + bDelete = !bProtectedBM; } break; case ContentTypeId::REGION : @@ -1217,19 +1220,21 @@ VclPtr<PopupMenu> SwContentTree::CreateContextMenu() assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData()))); const SwContentType* pContType = static_cast<SwContent*>(pEntry->GetUserData())->GetParent(); const ContentTypeId nContentType = pContType->GetType(); - bool bReadonly = m_pActiveShell->GetView().GetDocShell()->IsReadOnly(); - bool bVisible = !static_cast<SwContent*>(pEntry->GetUserData())->IsInvisible(); - bool bProtected = static_cast<SwContent*>(pEntry->GetUserData())->IsProtect(); - bool bEditable = pContType->IsEditable() && - ((bVisible && !bProtected) ||ContentTypeId::REGION == nContentType); - bool bDeletable = pContType->IsDeletable() && - ((bVisible && !bProtected) ||ContentTypeId::REGION == nContentType); - bool bRenamable = bEditable && !bReadonly && + const bool bReadonly = m_pActiveShell->GetView().GetDocShell()->IsReadOnly(); + const bool bVisible = !static_cast<SwContent*>(pEntry->GetUserData())->IsInvisible(); + const bool bProtected = static_cast<SwContent*>(pEntry->GetUserData())->IsProtect(); + const bool bProtectBM = (ContentTypeId::BOOKMARK == nContentType) + && m_pActiveShell->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_BOOKMARKS); + const bool bEditable = pContType->IsEditable() && + ((bVisible && !bProtected && !bProtectBM) || ContentTypeId::REGION == nContentType); + const bool bDeletable = pContType->IsDeletable() && + ((bVisible && !bProtected && !bProtectBM) || ContentTypeId::REGION == nContentType); + const bool bRenamable = bEditable && !bReadonly && (ContentTypeId::TABLE == nContentType || ContentTypeId::FRAME == nContentType || ContentTypeId::GRAPHIC == nContentType || ContentTypeId::OLE == nContentType || - ContentTypeId::BOOKMARK == nContentType || + (ContentTypeId::BOOKMARK == nContentType && !bProtectBM) || ContentTypeId::REGION == nContentType|| ContentTypeId::INDEX == nContentType); @@ -3276,6 +3281,7 @@ void SwContentTree::EditEntry(SvTreeListEntry const * pEntry, EditEntryMode nMod nSlot = FN_FORMAT_FRAME_DLG; break; case ContentTypeId::BOOKMARK : + assert(!m_pActiveShell->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_BOOKMARKS)); if(nMode == EditEntryMode::DELETE) { IDocumentMarkAccess* const pMarkAccess = m_pActiveShell->getIDocumentMarkAccess(); |