diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-08 17:58:56 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-08 18:19:12 +0100 |
commit | 32c2a2f8dc04af8a49ad3580af0ea647c45eb877 (patch) | |
tree | ed72797d70f7258adc8cd7b7ccec99e98bef86b5 /sw | |
parent | 740a72e66ddf3efd4028d8268239f9a50f759499 (diff) |
sw: detect copy&paste between different classification levels
With this we cover all 4 cases of copy&paste between possibly classified
documents. When both are classified, then we also check the
classification level, if they have the same scale.
Change-Id: I8c02781fc9755114cd6a2fb93be11dca7b3441d0
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/app/app.src | 5 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 25 | ||||
-rw-r--r-- | sw/source/uibase/inc/app.hrc | 3 |
3 files changed, 30 insertions, 3 deletions
diff --git a/sw/source/ui/app/app.src b/sw/source/ui/app/app.src index 94b64d7d84db..0b56c96baff3 100644 --- a/sw/source/ui/app/app.src +++ b/sw/source/ui/app/app.src @@ -652,4 +652,9 @@ String STR_TARGET_DOC_NOT_CLASSIFIED Text [ en-US ] = "This document must be classified before the clipboard can be pasted." ; }; +String STR_DOC_CLASSIFICATION_TOO_LOW +{ + Text [ en-US ] = "This document has a lower classificaton level than the clipboard." ; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 84b1af628573..04c3ae1e25b8 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -3222,13 +3222,34 @@ bool lcl_checkClassification(SwDoc* pSourceDoc, SwDoc* pDestinationDoc) if (!pSourceShell || !pDestinationShell) return true; - // Paste from a classified document to a non-classified one -> deny. - if (SfxClassificationHelper::IsClassified(*pSourceShell) && !SfxClassificationHelper::IsClassified(*pDestinationShell)) + bool bSourceClassified = SfxClassificationHelper::IsClassified(*pSourceShell); + if (!bSourceClassified) + // No classification on the source side. Return early, regardless the + // state of the destination side. + return true; + + bool bDestinationClassified = SfxClassificationHelper::IsClassified(*pDestinationShell); + if (bSourceClassified && !bDestinationClassified) { + // Paste from a classified document to a non-classified one -> deny. ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SW_RES(STR_TARGET_DOC_NOT_CLASSIFIED), VCL_MESSAGE_INFO)->Execute(); return false; } + // Remaining case: paste between two classified documents. + SfxClassificationHelper aSource(*pSourceShell); + SfxClassificationHelper aDestination(*pDestinationShell); + if (aSource.GetImpactScale() != aDestination.GetImpactScale()) + // It's possible to compare them if they have the same scale. + return true; + + if (aSource.GetImpactLevel() > aDestination.GetImpactLevel()) + { + // Paste from a doc that has higher classification -> deny. + ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SW_RES(STR_DOC_CLASSIFICATION_TOO_LOW), VCL_MESSAGE_INFO)->Execute(); + return false; + } + return true; } diff --git a/sw/source/uibase/inc/app.hrc b/sw/source/uibase/inc/app.hrc index 9962d0cdd1ec..aab6fd9be9e2 100644 --- a/sw/source/uibase/inc/app.hrc +++ b/sw/source/uibase/inc/app.hrc @@ -92,8 +92,9 @@ #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 STR_DOC_CLASSIFICATION_TOO_LOW (RC_APP_BEGIN + 141) -#define APP_ACT_END STR_TARGET_DOC_NOT_CLASSIFIED +#define APP_ACT_END STR_DOC_CLASSIFICATION_TOO_LOW #if APP_ACT_END > RC_APP_END #error Resource-Id Ueberlauf in #file, #line |