summaryrefslogtreecommitdiff
path: root/sfx2
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
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')
-rw-r--r--sfx2/source/appl/appuno.cxx18
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx5
-rw-r--r--sfx2/source/view/viewfrm.cxx22
-rw-r--r--sfx2/source/view/viewsh.cxx9
4 files changed, 49 insertions, 5 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index c633978076d9..bfbe90dc896b 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -173,6 +173,7 @@ static char const sLockContentExtraction[] = "LockContentExtraction";
static char const sLockExport[] = "LockExport";
static char const sLockPrint[] = "LockPrint";
static char const sLockSave[] = "LockSave";
+static char const sLockEditDoc[] = "LockEditDoc";
static bool isMediaDescriptor( sal_uInt16 nSlotId )
{
@@ -879,6 +880,14 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert
if (bOK)
rSet.Put( SfxBoolItem( SID_LOCK_SAVE, bVal ) );
}
+ else if (aName == sLockEditDoc)
+ {
+ bool bVal = false;
+ bool bOK = (rProp.Value >>= bVal);
+ DBG_ASSERT( bOK, "invalid type for LockEditDoc" );
+ if (bOK)
+ rSet.Put( SfxBoolItem( SID_LOCK_EDITDOC, bVal ) );
+ }
#ifdef DBG_UTIL
else
--nFoundArgs;
@@ -1104,6 +1113,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
nAdditional++;
if ( rSet.GetItemState( SID_LOCK_SAVE ) == SfxItemState::SET )
nAdditional++;
+ if ( rSet.GetItemState( SID_LOCK_EDITDOC ) == SfxItemState::SET )
+ nAdditional++;
// consider additional arguments
nProps += nAdditional;
@@ -1269,6 +1280,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
continue;
if ( nId == SID_LOCK_SAVE )
continue;
+ if ( nId == SID_LOCK_EDITDOC )
+ continue;
}
OString aDbg = "Unknown item detected: " + OString::number(static_cast<sal_Int32>(nId));
@@ -1681,6 +1694,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
pValue[nActProp].Name = sLockSave;
pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
}
+ if ( rSet.GetItemState( SID_LOCK_EDITDOC, false, &pItem ) == SfxItemState::SET )
+ {
+ pValue[nActProp].Name = sLockEditDoc;
+ pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ }
}
rArgs = aSequ;
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index b2bf405836d8..74b1497829bc 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1094,6 +1094,11 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs)
rArg.Value >>= bValue;
pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_SAVE, bValue));
}
+ else if (rArg.Name == "LockEditDoc")
+ {
+ rArg.Value >>= bValue;
+ pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_EDITDOC, bValue));
+ }
else
{
throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name,
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();