diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-08 12:18:24 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-08 13:36:43 +0100 |
commit | ad5427c03cf4d6506039a994cfb8a51d3ecda3e2 (patch) | |
tree | 404d3001d65c8b7682d44d3e4cecaac084f28ff5 | |
parent | f16ceae46dd8f3974a379c6fb07feaffb8012b25 (diff) |
sw: detect copy&paste from classified to non-classified documents
It still allows copy&paste between different classification levels,
though.
Change-Id: I142b6c2ab752a5b786fe6a16e29a89e549254d0f
-rw-r--r-- | sw/source/ui/app/app.src | 5 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 30 | ||||
-rw-r--r-- | sw/source/uibase/inc/app.hrc | 3 |
3 files changed, 36 insertions, 2 deletions
diff --git a/sw/source/ui/app/app.src b/sw/source/ui/app/app.src index 74c3ce18916f..94b64d7d84db 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 3976cbf425b9..84b1af628573 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 b5264d69f7e9..9962d0cdd1ec 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 |