summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-09 10:58:25 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-07 17:42:36 +0200
commit7142bdb9e06d18f70e02d5fc0b3c6ac8a32c89b2 (patch)
treeaaf41d3624491e459d18ead160110e86fff08168 /sw
parentc7a988413e79a830f775dfe37055e25d5f6320d1 (diff)
Move copy/paste classification check from sw to sfx2
So that it's easy to unit test it and other apps can use it as well in the future. Change-Id: I38d601924b7fbb17615ff6e9c031a71b40777c4c (cherry picked from commit 76e2cede5a415df8d3e7a874f56be7a0b5953e12)
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx29
1 files changed, 11 insertions, 18 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index a6ec09f609c1..932ecf1276da 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -3238,33 +3238,26 @@ bool lcl_checkClassification(SwDoc* pSourceDoc, SwDoc* pDestinationDoc)
if (!pSourceShell || !pDestinationShell)
return true;
- bool bSourceClassified = SfxClassificationHelper::IsClassified(*pSourceShell);
- if (!bSourceClassified)
- // No classification on the source side. Return early, regardless the
- // state of the destination side.
+ switch (SfxClassificationHelper::CheckPaste(*pSourceShell, *pDestinationShell))
+ {
+ case SfxClassificationCheckPasteResult::None:
+ {
return true;
-
- bool bDestinationClassified = SfxClassificationHelper::IsClassified(*pDestinationShell);
- if (bSourceClassified && !bDestinationClassified)
+ }
+ break;
+ case SfxClassificationCheckPasteResult::TargetDocNotClassified:
{
- // 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())
+ break;
+ case SfxClassificationCheckPasteResult::DocClassificationTooLow:
{
- // 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;
}
+ break;
+ }
return true;
}