summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-08 12:18:24 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-07 17:42:34 +0200
commitbaf4b2ff42e3343f9602e3d45d4e2a482fe35ede (patch)
treebb4faff6cd84c7faa86bf290f2bed786768ee023 /sw/source/uibase
parent4dacaa8898665162d96627b645f459d33524ad46 (diff)
sw: detect copy&paste from classified to non-classified documents
It still allows copy&paste between different classification levels, though. Change-Id: I142b6c2ab752a5b786fe6a16e29a89e549254d0f (cherry picked from commit ad5427c03cf4d6506039a994cfb8a51d3ecda3e2)
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx30
-rw-r--r--sw/source/uibase/inc/app.hrc3
2 files changed, 31 insertions, 2 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 89214109f81b..71153635d99b 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -127,6 +127,7 @@
#include <vcl/GraphicNativeTransform.hxx>
#include <vcl/GraphicNativeMetadata.hxx>
#include <comphelper/lok.hxx>
+#include <sfx2/classificationhelper.hxx>
#include <memory>
@@ -3224,6 +3225,31 @@ void SwTransferable::DragFinished( sal_Int8 nAction )
m_pWrtShell->GetViewOptions()->SetIdle( m_bOldIdle );
}
+namespace
+{
+
+bool lcl_checkClassification(SwDoc* pSourceDoc, SwDoc* pDestinationDoc)
+{
+ if (!pSourceDoc || !pDestinationDoc)
+ return true;
+
+ SwDocShell* pSourceShell = pSourceDoc->GetDocShell();
+ SwDocShell* pDestinationShell = pDestinationDoc->GetDocShell();
+ if (!pSourceShell || !pDestinationShell)
+ return true;
+
+ // Paste from a classified document to a non-classified one -> deny.
+ if (SfxClassificationHelper::IsClassified(*pSourceShell) && !SfxClassificationHelper::IsClassified(*pDestinationShell))
+ {
+ ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SW_RES(STR_TARGET_DOC_NOT_CLASSIFIED), VCL_MESSAGE_INFO)->Execute();
+ return false;
+ }
+
+ return true;
+}
+
+}
+
bool SwTransferable::PrivatePaste( SwWrtShell& rShell )
{
// first, ask for the SelectionType, then action-bracketing !!!!
@@ -3281,7 +3307,9 @@ bool SwTransferable::PrivatePaste( SwWrtShell& rShell )
}
}
- bool bRet = rShell.Paste( m_pClpDocFac->GetDoc() );
+ bool bRet = true;
+ if (lcl_checkClassification(m_pWrtShell->GetDoc(), rShell.GetDoc()))
+ bRet = rShell.Paste(m_pClpDocFac->GetDoc());
if( bKillPaMs )
rShell.KillPams();
diff --git a/sw/source/uibase/inc/app.hrc b/sw/source/uibase/inc/app.hrc
index ff5e12d89051..cc8b80b17879 100644
--- a/sw/source/uibase/inc/app.hrc
+++ b/sw/source/uibase/inc/app.hrc
@@ -102,8 +102,9 @@
#define STR_ERR_TABLE_MERGE (RC_APP_BEGIN + 137)
#define STR_WRONG_TABLENAME (RC_APP_BEGIN + 138)
#define STR_SRTERR (RC_APP_BEGIN + 139)
+#define STR_TARGET_DOC_NOT_CLASSIFIED (RC_APP_BEGIN + 140)
-#define APP_ACT_END STR_SRTERR
+#define APP_ACT_END STR_TARGET_DOC_NOT_CLASSIFIED
#if APP_ACT_END > RC_APP_END
#error Resource-Id Ueberlauf in #file, #line