[Libreoffice-commits] core.git: sw/inc sw/source
Katarina Behrens (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 3 12:13:54 UTC 2020
sw/inc/strings.hrc | 1 +
sw/source/ui/misc/bookmark.cxx | 13 +++++++------
sw/source/uibase/inc/bookmark.hxx | 1 +
sw/source/uibase/inc/conttree.hxx | 1 +
sw/source/uibase/shells/textsh1.cxx | 2 +-
sw/source/uibase/utlui/content.cxx | 32 ++++++++++++++++++++++----------
6 files changed, 33 insertions(+), 17 deletions(-)
New commits:
commit cb5d18871b46ef4f7bc47eb4d71df5374d712575
Author: Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Fri Jan 24 18:40:24 2020 +0100
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Mon Feb 3 13:13:21 2020 +0100
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 at cib.de>
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 755bcc58e47c..a1297ed14d6e 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -684,6 +684,7 @@
#define STR_POSTIT_HIDE NC_("STR_POSTIT_HIDE", "Hide All")
#define STR_POSTIT_DELETE NC_("STR_POSTIT_DELETE", "Delete All")
#define STR_RESOLVED NC_("STR_RESOLVED", "RESOLVED")
+#define STR_PROTECTED NC_("STR_PROTECTED", "Protected")
#define STR_MARGIN_TOOLTIP_LEFT NC_("STR_MARGIN_TOOLTIP_LEFT", "Left: ")
#define STR_MARGIN_TOOLTIP_RIGHT NC_("STR_MARGIN_TOOLTIP_RIGHT", ". Right: ")
diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx
index 9243f6c02c34..d480068b1865 100644
--- a/sw/source/ui/misc/bookmark.cxx
+++ b/sw/source/ui/misc/bookmark.cxx
@@ -32,6 +32,7 @@
#include <ndtxt.hxx>
#include <strings.hrc>
#include <svtools/miscopt.hxx>
+#include <IDocumentSettingAccess.hxx>
using namespace ::com::sun::star;
@@ -78,12 +79,12 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, ModifyHdl, weld::Entry&, void)
}
// allow to add new bookmark only if one name provided and it's not taken
- m_xInsertBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 0 && !bHasForbiddenChars);
+ m_xInsertBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 0 && !bHasForbiddenChars && !m_bAreProtected);
// allow to delete only if all bookmarks are recognized
- m_xDeleteBtn->set_sensitive(nEntries > 0 && nSelectedEntries == nEntries);
+ m_xDeleteBtn->set_sensitive(nEntries > 0 && nSelectedEntries == nEntries && !m_bAreProtected);
m_xGotoBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 1);
- m_xRenameBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 1);
+ m_xRenameBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 1 && !m_bAreProtected);
}
// callback to delete a text mark
@@ -160,13 +161,12 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, SelectionChangedHdl, weld::TreeView&, void)
{
m_xInsertBtn->set_sensitive(false);
m_xGotoBtn->set_sensitive(nSelectedRows == 1);
- m_xRenameBtn->set_sensitive(nSelectedRows == 1);
- m_xDeleteBtn->set_sensitive(true);
+ m_xRenameBtn->set_sensitive(nSelectedRows == 1 && !m_bAreProtected);
m_xEditBox->set_text(sEditBoxText.makeStringAndClear());
}
else
{
- m_xInsertBtn->set_sensitive(true);
+ m_xInsertBtn->set_sensitive(!m_bAreProtected);
m_xGotoBtn->set_sensitive(false);
m_xRenameBtn->set_sensitive(false);
m_xDeleteBtn->set_sensitive(false);
@@ -340,6 +340,7 @@ SwInsertBookmarkDlg::SwInsertBookmarkDlg(weld::Window* pParent, SwWrtShell& rS,
m_xConditionED->set_visible( false );
}
+ m_bAreProtected = rSh.getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_BOOKMARKS);
}
IMPL_LINK(SwInsertBookmarkDlg, HeaderBarClick, int, nColumn, void)
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();
More information about the Libreoffice-commits
mailing list