summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-10-22 11:32:09 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-12-04 05:39:59 +0100
commitcca9216307591dfe25c0f6bbcb4acc1e881d43a8 (patch)
treea92b32310edfb76e4e13405226c8c07865c54f52 /sfx2
parent1274b5856c469beefc3af0520ca5851adc581391 (diff)
Add document-level option to lock down file export
Setting this option will disable any export command (File->Export*, File->Send*, graphic/chart export context menu, save as, mailmerge wizard, ...) Change-Id: I07a2a3b9179b494ac839e7d1e407194600679aa1 Reviewed-on: https://gerrit.libreoffice.org/81316 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Conflicts: sfx2/source/doc/objserv.cxx sfx2/source/view/viewsh.cxx
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appuno.cxx14
-rw-r--r--sfx2/source/doc/objserv.cxx16
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx5
-rw-r--r--sfx2/source/view/viewsh.cxx24
4 files changed, 54 insertions, 5 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index 1fdff5f2f3a6..2869e405886c 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -170,6 +170,7 @@ static char const sDocumentService[] = "DocumentService";
static char const sFilterProvider[] = "FilterProvider";
static char const sImageFilter[] = "ImageFilter";
static char const sLockContentExtraction[] = "LockContentExtraction";
+static char const sLockExport[] = "LockExport";
static bool isMediaDescriptor( sal_uInt16 nSlotId )
{
@@ -861,6 +862,14 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert
if (bOK)
rSet.Put( SfxBoolItem( SID_LOCK_CONTENT_EXTRACTION, bVal ) );
}
+ else if (aName == sLockExport)
+ {
+ bool bVal = false;
+ bool bOK = (rProp.Value >>= bVal);
+ DBG_ASSERT( bOK, "invalid type for LockExport" );
+ if (bOK)
+ rSet.Put( SfxBoolItem( SID_LOCK_EXPORT, bVal ) );
+ }
#ifdef DBG_UTIL
else
--nFoundArgs;
@@ -1639,6 +1648,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
pValue[nActProp].Name = sLockContentExtraction;
pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
}
+ if ( rSet.GetItemState( SID_LOCK_EXPORT, false, &pItem ) == SfxItemState::SET )
+ {
+ pValue[nActProp].Name = sLockExport;
+ 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 f78bec833f59..c0f0663bcf48 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1095,7 +1095,8 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
{
case SID_DOCTEMPLATE :
{
- if ( !GetFactory().GetTemplateFilter() )
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
+ if ( pFrame && pFrame->GetViewShell()->isExportLocked())
rSet.DisableItem( nWhich );
break;
}
@@ -1201,7 +1202,9 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
case SID_SAVEASDOC:
{
- if( !( pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) )
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
+ if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT)
+ || (pFrame && pFrame->GetViewShell()->isExportLocked()))
{
rSet.DisableItem( nWhich );
break;
@@ -1215,7 +1218,9 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
case SID_SAVEACOPY:
{
- if( !( pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) )
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
+ if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT)
+ || (pFrame && pFrame->GetViewShell()->isExportLocked()))
{
rSet.DisableItem( nWhich );
break;
@@ -1227,12 +1232,17 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
break;
}
+ case SID_EXPORTDOC:
case SID_EXPORTDOCASPDF:
case SID_DIRECTEXPORTDOCASPDF:
case SID_EXPORTDOCASEPUB:
case SID_DIRECTEXPORTDOCASEPUB:
case SID_REDACTDOC:
+ case SID_SAVEASREMOTE:
{
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
+ if (pFrame && pFrame->GetViewShell()->isExportLocked())
+ rSet.DisableItem( nWhich );
break;
}
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 7b4533501eb1..4fffa63f4f7c 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1079,6 +1079,11 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs)
rArg.Value >>= bValue;
pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_CONTENT_EXTRACTION, bValue));
}
+ else if (rArg.Name == "LockExport")
+ {
+ rArg.Value >>= bValue;
+ pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_EXPORT, bValue));
+ }
else
{
throw lang::IllegalArgumentException("Setting property not supported: " + aArgs[i].Name,
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 7b84bff4f387..4bab9fc7636a 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -673,16 +673,27 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
{
switch ( nSID )
{
-#if HAVE_FEATURE_MACOSX_SANDBOX
+
case SID_BLUETOOTH_SENDDOC:
case SID_MAIL_SENDDOC:
case SID_MAIL_SENDDOCASFORMAT:
case SID_MAIL_SENDDOCASMS:
case SID_MAIL_SENDDOCASOOO:
case SID_MAIL_SENDDOCASPDF:
+ {
+#if HAVE_FEATURE_MACOSX_SANDBOX
rSet.DisableItem(nSID);
- break;
#endif
+ if (isExportLocked())
+ rSet.DisableItem(nSID);
+ break;
+ }
+ case SID_WEBHTML:
+ {
+ if (isExportLocked())
+ rSet.DisableItem(nSID);
+ break;
+ }
// Printer functions
case SID_PRINTDOC:
case SID_PRINTDOCDIRECT:
@@ -1771,6 +1782,15 @@ bool SfxViewShell::isContentExtractionLocked()
return aArgs.getOrDefault("LockContentExtraction", false);
}
+bool SfxViewShell::isExportLocked()
+{
+ Reference<XModel> xModel = GetCurrentDocument();
+ if (!xModel.is())
+ return false;
+ comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ return aArgs.getOrDefault("LockExport", false);
+}
+
Reference < XController > SfxViewShell::GetController()
{
return pImpl->m_pController.get();