diff options
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/classificationhelper.cxx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index ab913b537d3f..6950048fae82 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -426,6 +426,35 @@ bool SfxClassificationHelper::IsClassified(SfxObjectShell& rObjectShell) return false; } +SfxClassificationCheckPasteResult SfxClassificationHelper::CheckPaste(SfxObjectShell& rSource, SfxObjectShell& rDestination) +{ + bool bSourceClassified = SfxClassificationHelper::IsClassified(rSource); + if (!bSourceClassified) + // No classification on the source side. Return early, regardless the + // state of the destination side. + return SfxClassificationCheckPasteResult::None; + + bool bDestinationClassified = SfxClassificationHelper::IsClassified(rDestination); + if (bSourceClassified && !bDestinationClassified) + { + // Paste from a classified document to a non-classified one -> deny. + return SfxClassificationCheckPasteResult::TargetDocNotClassified; + } + + // Remaining case: paste between two classified documents. + SfxClassificationHelper aSource(rSource); + SfxClassificationHelper aDestination(rDestination); + if (aSource.GetImpactScale() != aDestination.GetImpactScale()) + // It's possible to compare them if they have the same scale. + return SfxClassificationCheckPasteResult::None; + + if (aSource.GetImpactLevel() > aDestination.GetImpactLevel()) + // Paste from a doc that has higher classification -> deny. + return SfxClassificationCheckPasteResult::DocClassificationTooLow; + + return SfxClassificationCheckPasteResult::None; +} + SfxClassificationHelper::SfxClassificationHelper(SfxObjectShell& rObjectShell) : m_pImpl(o3tl::make_unique<Impl>(rObjectShell)) { |