summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/app/app.src5
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx25
-rw-r--r--sw/source/uibase/inc/app.hrc3
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