diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-10-23 08:24:31 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-10-23 15:22:16 +0200 |
commit | e37b70442ebf9e1628e7da16b7b6acf498897dee (patch) | |
tree | 4c02f4b4be6c10d4ff2a8b99f4ab057670e4d80b /sfx2 | |
parent | d5d96e04ad8014f3e68351ccb54221d9610b565b (diff) |
Add document-level option to lock down save
Change-Id: I40b5e8c780894645e467e3891062c499707d69c7
Reviewed-on: https://gerrit.libreoffice.org/81359
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 18 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 9 |
4 files changed, 38 insertions, 4 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 79247883dcfc..c633978076d9 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -172,6 +172,7 @@ static char const sImageFilter[] = "ImageFilter"; static char const sLockContentExtraction[] = "LockContentExtraction"; static char const sLockExport[] = "LockExport"; static char const sLockPrint[] = "LockPrint"; +static char const sLockSave[] = "LockSave"; static bool isMediaDescriptor( sal_uInt16 nSlotId ) { @@ -870,6 +871,14 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if (bOK) rSet.Put( SfxBoolItem( SID_LOCK_PRINT, bVal ) ); } + else if (aName == sLockSave) + { + bool bVal = false; + bool bOK = (rProp.Value >>= bVal); + DBG_ASSERT( bOK, "invalid type for LockSave" ); + if (bOK) + rSet.Put( SfxBoolItem( SID_LOCK_SAVE, bVal ) ); + } #ifdef DBG_UTIL else --nFoundArgs; @@ -1093,6 +1102,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b nAdditional++; if ( rSet.GetItemState( SID_LOCK_PRINT ) == SfxItemState::SET ) nAdditional++; + if ( rSet.GetItemState( SID_LOCK_SAVE ) == SfxItemState::SET ) + nAdditional++; // consider additional arguments nProps += nAdditional; @@ -1256,6 +1267,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b continue; if ( nId == SID_LOCK_PRINT ) continue; + if ( nId == SID_LOCK_SAVE ) + continue; } OString aDbg = "Unknown item detected: " + OString::number(static_cast<sal_Int32>(nId)); @@ -1663,6 +1676,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b pValue[nActProp].Name = sLockPrint; pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ; } + if ( rSet.GetItemState( SID_LOCK_SAVE, false, &pItem ) == SfxItemState::SET ) + { + pValue[nActProp].Name = sLockSave; + pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ; + } } rArgs = aSequ; diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 8c7c5ab3f8af..6aa2b644b8f3 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1203,11 +1203,13 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) } case SID_SAVEDOC: { - if ( !IsReadOnly() ) - rSet.Put(SfxStringItem( - nWhich, SfxResId(STR_SAVEDOC))); - else + SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this); + if ( IsReadOnly() || (pFrame && pFrame->GetViewShell()->isSaveLocked())) + { rSet.DisableItem(nWhich); + break; + } + rSet.Put(SfxStringItem(nWhich, SfxResId(STR_SAVEDOC))); } break; diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 67bacd79502d..395672aaae97 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1089,6 +1089,11 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs) rArg.Value >>= bValue; pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_PRINT, bValue)); } + else if (rArg.Name == "LockSave") + { + rArg.Value >>= bValue; + pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_SAVE, bValue)); + } else { throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name, diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 123aa18dcb58..236d173ef140 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::isSaveLocked() +{ + Reference<XModel> xModel = GetCurrentDocument(); + if (!xModel.is()) + return false; + comphelper::NamedValueCollection aArgs(xModel->getArgs()); + return aArgs.getOrDefault("LockSave", true); +} + Reference < XController > SfxViewShell::GetController() const { return pImpl->m_pController.get(); |