summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/classificationhelper.hxx2
-rw-r--r--sfx2/source/view/classificationhelper.cxx29
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx24
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx38
4 files changed, 35 insertions, 58 deletions
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index 9ce8933d9449..5cf0cdd2613f 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -45,6 +45,8 @@ public:
/// Checks if pasting from xSource to xDestination would leak information.
static SfxClassificationCheckPasteResult CheckPaste(const css::uno::Reference<css::document::XDocumentProperties>& xSource,
const css::uno::Reference<css::document::XDocumentProperties>& xDestination);
+ /// Wrapper around CheckPaste(): informs the user if necessary and finds out if the paste can be continued or not.
+ static bool ShowPasteInfo(SfxClassificationCheckPasteResult eResult);
SfxClassificationHelper(const css::uno::Reference<css::document::XDocumentProperties>& xDocumentProperties);
~SfxClassificationHelper();
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 2abcff8eda27..fc1d236d54b1 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -32,6 +32,7 @@
#include <sfx2/viewfrm.hxx>
#include <tools/datetime.hxx>
#include <unotools/datetime.hxx>
+#include <vcl/layout.hxx>
#include <config_folders.h>
using namespace com::sun::star;
@@ -454,6 +455,34 @@ SfxClassificationCheckPasteResult SfxClassificationHelper::CheckPaste(const uno:
return SfxClassificationCheckPasteResult::None;
}
+bool SfxClassificationHelper::ShowPasteInfo(SfxClassificationCheckPasteResult eResult)
+{
+ switch (eResult)
+ {
+ case SfxClassificationCheckPasteResult::None:
+ {
+ return true;
+ }
+ break;
+ case SfxClassificationCheckPasteResult::TargetDocNotClassified:
+ {
+ if (!Application::IsHeadlessModeEnabled())
+ ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SfxResId(STR_TARGET_DOC_NOT_CLASSIFIED), VCL_MESSAGE_INFO)->Execute();
+ return false;
+ }
+ break;
+ case SfxClassificationCheckPasteResult::DocClassificationTooLow:
+ {
+ if (!Application::IsHeadlessModeEnabled())
+ ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SfxResId(STR_DOC_CLASSIFICATION_TOO_LOW), VCL_MESSAGE_INFO)->Execute();
+ return false;
+ }
+ break;
+ }
+
+ return true;
+}
+
SfxClassificationHelper::SfxClassificationHelper(const uno::Reference<document::XDocumentProperties>& xDocumentProperties)
: m_pImpl(o3tl::make_unique<Impl>(xDocumentProperties))
{
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 6d47e8f50873..5dc3dfd68b91 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -3226,28 +3226,8 @@ bool lcl_checkClassification(SwDoc* pSourceDoc, SwDoc* pDestinationDoc)
if (!pSourceShell || !pDestinationShell)
return true;
- switch (SfxClassificationHelper::CheckPaste(pSourceShell->getDocProperties(), pDestinationShell->getDocProperties()))
- {
- case SfxClassificationCheckPasteResult::None:
- {
- return true;
- }
- break;
- case SfxClassificationCheckPasteResult::TargetDocNotClassified:
- {
- ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SfxResId(STR_TARGET_DOC_NOT_CLASSIFIED), VCL_MESSAGE_INFO)->Execute();
- return false;
- }
- break;
- case SfxClassificationCheckPasteResult::DocClassificationTooLow:
- {
- ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SfxResId(STR_DOC_CLASSIFICATION_TOO_LOW), VCL_MESSAGE_INFO)->Execute();
- return false;
- }
- break;
- }
-
- return true;
+ SfxClassificationCheckPasteResult eResult = SfxClassificationHelper::CheckPaste(pSourceShell->getDocProperties(), pDestinationShell->getDocProperties());
+ return SfxClassificationHelper::ShowPasteInfo(eResult);
}
}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index c51ea1407fc8..021d802b8f4f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -5131,39 +5131,6 @@ bool lcl_containsProperty(const uno::Sequence<beans::Property>& rProperties, con
}) != rProperties.end();
}
-namespace
-{
-
-RTFError lcl_checkClassification(const uno::Reference<document::XDocumentProperties>& xSource, const uno::Reference<document::XDocumentProperties>& xDestination)
-{
- switch (SfxClassificationHelper::CheckPaste(xSource, xDestination))
- {
- case SfxClassificationCheckPasteResult::None:
- {
- return RTFError::OK;
- }
- break;
- case SfxClassificationCheckPasteResult::TargetDocNotClassified:
- {
- if (!Application::IsHeadlessModeEnabled())
- ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SfxResId(STR_TARGET_DOC_NOT_CLASSIFIED), VCL_MESSAGE_INFO)->Execute();
- return RTFError::CLASSIFICATION;
- }
- break;
- case SfxClassificationCheckPasteResult::DocClassificationTooLow:
- {
- if (!Application::IsHeadlessModeEnabled())
- ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SfxResId(STR_DOC_CLASSIFICATION_TOO_LOW), VCL_MESSAGE_INFO)->Execute();
- return RTFError::CLASSIFICATION;
- }
- break;
- }
-
- return RTFError::OK;
-}
-
-}
-
RTFError RTFDocumentImpl::popState()
{
//SAL_INFO("writerfilter", OSL_THIS_FUNC << " before pop: m_pTokenizer->getGroup() " << m_pTokenizer->getGroup() <<
@@ -5985,9 +5952,8 @@ RTFError RTFDocumentImpl::popState()
if (!m_bIsNewDoc)
{
// Check classification.
- RTFError nError = lcl_checkClassification(xDocumentProperties, m_xDocumentProperties);
- if (nError != RTFError::OK)
- return nError;
+ if (!SfxClassificationHelper::ShowPasteInfo(SfxClassificationHelper::CheckPaste(xDocumentProperties, m_xDocumentProperties)))
+ return RTFError::CLASSIFICATION;
}
uno::Reference<beans::XPropertyContainer> xClipboardPropertyContainer = xDocumentProperties->getUserDefinedProperties();