summaryrefslogtreecommitdiff
path: root/sfx2/source/view
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2019-11-12 21:52:05 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-11-13 12:45:39 +0100
commita474e2267cdcb1707333acdea1353d883d58c801 (patch)
tree77b87df1a132a48ffc1616b1a00e3102f9e49abb /sfx2/source/view
parent21c29a756c5d01cada2a09dd6d55fdc482807bb4 (diff)
Add document level option to lock down edit doc command
Change-Id: I431fa4cd0daa52c885030dbadcc4052b5a890d34 Reviewed-on: https://gerrit.libreoffice.org/82553 Reviewed-by: Serge Krot (CIB) <Serge.Krot@cib.de> Tested-by: Serge Krot (CIB) <Serge.Krot@cib.de> Reviewed-on: https://gerrit.libreoffice.org/82576 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2/source/view')
-rw-r--r--sfx2/source/view/viewfrm.cxx22
-rw-r--r--sfx2/source/view/viewsh.cxx9
2 files changed, 26 insertions, 5 deletions
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index e3f39e3aab40..6dccb522c14b 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -306,6 +306,10 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ))
break;
+ SfxViewShell* pViewSh = GetViewShell();
+ if (pViewSh && pViewSh->isEditDocLocked())
+ break;
+
// Only change read-only UI and remove info bar when we succeed
struct ReadOnlyUIGuard
{
@@ -919,6 +923,7 @@ void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet )
const SfxShell *pFSh;
if ( !pSh->HasName() ||
!( pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) ||
+ (GetViewShell() && GetViewShell()->isEditDocLocked()) ||
( pSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED &&
( !(pVSh = pSh->GetViewShell()) ||
!(pFSh = pVSh->GetFormShell()) ||
@@ -1405,11 +1410,18 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
pInfoBar->addButton(xSignButton);
}
- VclPtrInstance<PushButton> xBtn(&GetWindow());
- xBtn->SetText(SfxResId(STR_READONLY_EDIT));
- xBtn->SetSizePixel(xBtn->GetOptimalSize());
- xBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler));
- pInfoBar->addButton(xBtn);
+ bool showEditDocumentButton = true;
+ if (m_xObjSh->GetViewShell() && m_xObjSh->GetViewShell()->isEditDocLocked())
+ showEditDocumentButton = false;
+
+ if (showEditDocumentButton)
+ {
+ VclPtrInstance<PushButton> xBtn(&GetWindow());
+ xBtn->SetText(SfxResId(STR_READONLY_EDIT));
+ xBtn->SetSizePixel(xBtn->GetOptimalSize());
+ xBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler));
+ pInfoBar->addButton(xBtn);
+ }
}
}
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 1d75d7d354b5..a0598191f3f7 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1776,6 +1776,15 @@ bool SfxViewShell::isPrintLocked()
return aArgs.getOrDefault("LockPrint", false);
}
+bool SfxViewShell::isEditDocLocked()
+{
+ Reference<XModel> xModel = GetCurrentDocument();
+ if (!xModel.is())
+ return false;
+ comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ return aArgs.getOrDefault("LockEditDoc", false);
+}
+
bool SfxViewShell::isSaveLocked()
{
Reference<XModel> xModel = GetCurrentDocument();