[Libreoffice-commits] core.git: sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Mar 8 12:37:07 UTC 2016
sw/source/ui/app/app.src | 5 +++++
sw/source/uibase/dochdl/swdtflvr.cxx | 30 +++++++++++++++++++++++++++++-
sw/source/uibase/inc/app.hrc | 3 ++-
3 files changed, 36 insertions(+), 2 deletions(-)
New commits:
commit ad5427c03cf4d6506039a994cfb8a51d3ecda3e2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Mar 8 12:18:24 2016 +0100
sw: detect copy&paste from classified to non-classified documents
It still allows copy&paste between different classification levels,
though.
Change-Id: I142b6c2ab752a5b786fe6a16e29a89e549254d0f
diff --git a/sw/source/ui/app/app.src b/sw/source/ui/app/app.src
index 74c3ce1..94b64d7 100644
--- a/sw/source/ui/app/app.src
+++ b/sw/source/ui/app/app.src
@@ -647,4 +647,9 @@ String STR_SRTERR
Text [ en-US ] = "Cannot sort selection" ;
};
+String STR_TARGET_DOC_NOT_CLASSIFIED
+{
+ Text [ en-US ] = "This document must be classified before the clipboard can be pasted." ;
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 3976cbf..84b1af6 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>
@@ -3208,6 +3209,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 !!!!
@@ -3265,7 +3291,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 b5264d6..9962d0c 100644
--- a/sw/source/uibase/inc/app.hrc
+++ b/sw/source/uibase/inc/app.hrc
@@ -91,8 +91,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
More information about the Libreoffice-commits
mailing list