diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2020-01-24 18:40:24 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-02-03 13:13:21 +0100 |
commit | cb5d18871b46ef4f7bc47eb4d71df5374d712575 (patch) | |
tree | 8ea494866e1761716dcdeed6eab981ebf535ecff /sw/source/uibase | |
parent | 56a89f475570d6937e8e2b9d00a72a19c2dd7665 (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.
Change-Id: I035faaf3871c7107dd1aac38c4e6867291827346
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87361
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/inc/bookmark.hxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/inc/conttree.hxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 32 |
4 files changed, 25 insertions, 11 deletions
diff --git a/sw/source/uibase/inc/bookmark.hxx b/sw/source/uibase/inc/bookmark.hxx index 7522dbe9bc12..3a8ee1506d58 100644 --- a/sw/source/uibase/inc/bookmark.hxx +++ b/sw/source/uibase/inc/bookmark.hxx @@ -69,6 +69,7 @@ class SwInsertBookmarkDlg : public SfxDialogController std::vector<std::pair<sw::mark::IMark*, OUString>> aTableBookmarks; sal_Int32 m_nLastBookmarksCount; bool m_bSorted; + bool m_bAreProtected; std::unique_ptr<weld::Entry> m_xEditBox; std::unique_ptr<weld::Button> m_xInsertBtn; diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index 89333bf5f228..e9c227875c22 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -88,6 +88,7 @@ class SwContentTree final OUString const m_sPostItShow; OUString const m_sPostItHide; OUString const m_sPostItDelete; + OUString const m_sProtected; SwWrtShell* m_pHiddenShell; // dropped Doc SwWrtShell* m_pActiveShell; // the active or a const. open view diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 17b15bdf87da..f8bd62cab79c 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -677,7 +677,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 1b9d2ee70525..2a7826babbdf 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 <unotxvw.hxx> @@ -335,7 +336,9 @@ void SwContentType::Init(bool* pbInvalidateWindow) pMarkAccess->getBookmarksEnd(), &lcl_IsUiVisibleBookmark); m_sTypeToken.clear(); - m_bEdit = true; + const bool bProtectedBM = m_pWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_BOOKMARKS); + m_bEdit = !bProtectedBM; + m_bDelete = !bProtectedBM; } break; case ContentTypeId::REGION : @@ -862,6 +865,7 @@ SwContentTree::SwContentTree(vcl::Window* pParent, SwNavigationPI* pDialog) , m_sPostItShow(SwResId(STR_POSTIT_SHOW)) , m_sPostItHide(SwResId(STR_POSTIT_HIDE)) , m_sPostItDelete(SwResId(STR_POSTIT_DELETE)) + , m_sProtected(SwResId(STR_PROTECTED)) , m_pHiddenShell(nullptr) , m_pActiveShell(nullptr) , m_pConfig(SW_MOD()->GetNavigationConfig()) @@ -1277,19 +1281,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 || ContentTypeId::DRAWOBJECT == nContentType); @@ -1365,6 +1371,11 @@ VclPtr<PopupMenu> SwContentTree::CreateContextMenu() if(bRenamable) pPop->InsertItem(502, m_sRename); } + else if (bProtectBM) + { + pPop->InsertItem(503, m_sProtected); + pPop->EnableItem(503, false); + } pPop->SetAccelKey(501, vcl::KeyCode(KEY_DELETE, false, false, false, false)); } else if( pEntry ) @@ -3615,6 +3626,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(); |