Kaydet (Commit) ad5427c0 authored tarafından Miklos Vajna's avatar Miklos Vajna

sw: detect copy&paste from classified to non-classified documents

It still allows copy&paste between different classification levels,
though.

Change-Id: I142b6c2ab752a5b786fe6a16e29a89e549254d0f
üst f16ceae4
...@@ -647,4 +647,9 @@ String STR_SRTERR ...@@ -647,4 +647,9 @@ String STR_SRTERR
Text [ en-US ] = "Cannot sort selection" ; Text [ en-US ] = "Cannot sort selection" ;
}; };
String STR_TARGET_DOC_NOT_CLASSIFIED
{
Text [ en-US ] = "This document must be classified before the clipboard can be pasted." ;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -127,6 +127,7 @@ ...@@ -127,6 +127,7 @@
#include <vcl/GraphicNativeTransform.hxx> #include <vcl/GraphicNativeTransform.hxx>
#include <vcl/GraphicNativeMetadata.hxx> #include <vcl/GraphicNativeMetadata.hxx>
#include <comphelper/lok.hxx> #include <comphelper/lok.hxx>
#include <sfx2/classificationhelper.hxx>
#include <memory> #include <memory>
...@@ -3208,6 +3209,31 @@ void SwTransferable::DragFinished( sal_Int8 nAction ) ...@@ -3208,6 +3209,31 @@ void SwTransferable::DragFinished( sal_Int8 nAction )
m_pWrtShell->GetViewOptions()->SetIdle( m_bOldIdle ); m_pWrtShell->GetViewOptions()->SetIdle( m_bOldIdle );
} }
namespace
{
bool lcl_checkClassification(SwDoc* pSourceDoc, SwDoc* pDestinationDoc)
{
if (!pSourceDoc || !pDestinationDoc)
return true;
SwDocShell* pSourceShell = pSourceDoc->GetDocShell();
SwDocShell* pDestinationShell = pDestinationDoc->GetDocShell();
if (!pSourceShell || !pDestinationShell)
return true;
// Paste from a classified document to a non-classified one -> deny.
if (SfxClassificationHelper::IsClassified(*pSourceShell) && !SfxClassificationHelper::IsClassified(*pDestinationShell))
{
ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SW_RES(STR_TARGET_DOC_NOT_CLASSIFIED), VCL_MESSAGE_INFO)->Execute();
return false;
}
return true;
}
}
bool SwTransferable::PrivatePaste( SwWrtShell& rShell ) bool SwTransferable::PrivatePaste( SwWrtShell& rShell )
{ {
// first, ask for the SelectionType, then action-bracketing !!!! // first, ask for the SelectionType, then action-bracketing !!!!
...@@ -3265,7 +3291,9 @@ bool SwTransferable::PrivatePaste( SwWrtShell& rShell ) ...@@ -3265,7 +3291,9 @@ bool SwTransferable::PrivatePaste( SwWrtShell& rShell )
} }
} }
bool bRet = rShell.Paste( m_pClpDocFac->GetDoc() ); bool bRet = true;
if (lcl_checkClassification(m_pWrtShell->GetDoc(), rShell.GetDoc()))
bRet = rShell.Paste(m_pClpDocFac->GetDoc());
if( bKillPaMs ) if( bKillPaMs )
rShell.KillPams(); rShell.KillPams();
......
...@@ -91,8 +91,9 @@ ...@@ -91,8 +91,9 @@
#define STR_ERR_TABLE_MERGE (RC_APP_BEGIN + 137) #define STR_ERR_TABLE_MERGE (RC_APP_BEGIN + 137)
#define STR_WRONG_TABLENAME (RC_APP_BEGIN + 138) #define STR_WRONG_TABLENAME (RC_APP_BEGIN + 138)
#define STR_SRTERR (RC_APP_BEGIN + 139) #define STR_SRTERR (RC_APP_BEGIN + 139)
#define STR_TARGET_DOC_NOT_CLASSIFIED (RC_APP_BEGIN + 140)
#define APP_ACT_END STR_SRTERR #define APP_ACT_END STR_TARGET_DOC_NOT_CLASSIFIED
#if APP_ACT_END > RC_APP_END #if APP_ACT_END > RC_APP_END
#error Resource-Id Ueberlauf in #file, #line #error Resource-Id Ueberlauf in #file, #line
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment