diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-10-10 08:13:51 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-10-14 08:15:31 +0200 |
commit | 075f20a4b696f9e85d11dc977806e41a49e6de61 (patch) | |
tree | 30827954123e3dd54764c74ccad37302f05b2816 /sfx2 | |
parent | 03ec3b7dd11656c8b64a94efb172e17d97ea662e (diff) |
Add document-level option to lock down content extraction
Setting this option will prevent copying/dragging any content from LO
to another program or even another LO window.
Change-Id: Ifbc032a4fa69ac1a17d4b500f5a30f5399d84ed7
Reviewed-on: https://gerrit.libreoffice.org/80586
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 14 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 12 |
3 files changed, 34 insertions, 1 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 649c18952701..6c70975db7a1 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -169,6 +169,7 @@ static char const sFailOnWarning[] = "FailOnWarning"; static char const sDocumentService[] = "DocumentService"; static char const sFilterProvider[] = "FilterProvider"; static char const sImageFilter[] = "ImageFilter"; +static char const sLockContentExtraction[] = "LockContentExtraction"; static bool isMediaDescriptor( sal_uInt16 nSlotId ) { @@ -845,6 +846,14 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if (bOK) rSet.Put(SfxStringItem(SID_FILTER_PROVIDER, aVal)); } + else if (aName == sLockContentExtraction) + { + bool bVal = false; + bool bOK = (rProp.Value >>= bVal); + DBG_ASSERT( bOK, "invalid type for LockContentExtraction" ); + if (bOK) + rSet.Put( SfxBoolItem( SID_LOCK_CONTENT_EXTRACTION, bVal ) ); + } #ifdef DBG_UTIL else --nFoundArgs; @@ -1614,6 +1623,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b pValue[nActProp].Name = sImageFilter; pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue(); } + if ( rSet.GetItemState( SID_LOCK_CONTENT_EXTRACTION, false, &pItem ) == SfxItemState::SET ) + { + pValue[nActProp].Name = sLockContentExtraction; + 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 cc2aae255542..f4019db6b98d 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1062,16 +1062,23 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs) for (const auto& rArg : aArgs) { OUString sValue; - rArg.Value >>= sValue; + bool bValue; if (rArg.Name == "SuggestedSaveAsName") { + rArg.Value >>= sValue; pMedium->GetItemSet()->Put(SfxStringItem(SID_SUGGESTEDSAVEASNAME, sValue)); } else if (rArg.Name == "SuggestedSaveAsDir") { + rArg.Value >>= sValue; pMedium->GetItemSet()->Put(SfxStringItem(SID_SUGGESTEDSAVEASDIR, sValue)); } + else if (rArg.Name == "LockContentExtraction") + { + rArg.Value >>= bValue; + pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_CONTENT_EXTRACTION, 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 a6f8567f8aac..4866fcabc4bc 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -39,11 +39,13 @@ #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <com/sun/star/container/XContainerQuery.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp> #include <com/sun/star/view/XRenderable.hpp> +#include <com/sun/star/uno/Reference.hxx> #include <cppuhelper/implbase.hxx> #include <osl/file.hxx> @@ -60,6 +62,7 @@ #include <basic/sbuno.hxx> #include <framework/actiontriggerhelper.hxx> #include <comphelper/lok.hxx> +#include <comphelper/namedvaluecollection.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequenceashashmap.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -1733,6 +1736,15 @@ void SfxViewShell::SetController( SfxBaseController* pController ) pImpl->xClipboardListener = new SfxClipboardChangeListener( this, GetClipboardNotifier() ); } +bool SfxViewShell::isContentExtractionLocked() +{ + Reference<XModel> xModel = GetCurrentDocument(); + if (!xModel.is()) + return false; + comphelper::NamedValueCollection aArgs(xModel->getArgs()); + return aArgs.getOrDefault("LockContentExtraction", false); +} + Reference < XController > SfxViewShell::GetController() const { return pImpl->m_pController.get(); |