set explicit parent for signing warning messages

Change-Id: Ifbd1aaec13e2f3a51963c4942face64847eefc07
Reviewed-on: https://gerrit.libreoffice.org/55989
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2018-06-18 10:39:35 +01:00
parent 294e66018d
commit 4b57652007
7 changed files with 25 additions and 24 deletions

View File

@@ -1033,7 +1033,7 @@ void ModulWindow::ExecuteGlobal (SfxRequest& rReq)
DocumentSignature aSignature(m_aDocument); DocumentSignature aSignature(m_aDocument);
if (aSignature.supportsSignatures()) if (aSignature.supportsSignatures())
{ {
aSignature.signScriptingContent(); aSignature.signScriptingContent(rReq.GetFrameWeld());
if (SfxBindings* pBindings = GetBindingsPtr()) if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate(SID_SIGNATURE); pBindings->Invalidate(SID_SIGNATURE);
} }

View File

@@ -69,11 +69,11 @@ namespace basctl
return ( m_pImpl->pShell != nullptr ); return ( m_pImpl->pShell != nullptr );
} }
void DocumentSignature::signScriptingContent() const void DocumentSignature::signScriptingContent(weld::Window* pDialogParent) const
{ {
OSL_PRECOND( supportsSignatures(), "DocumentSignature::signScriptingContent: signatures not supported by this document!" ); OSL_PRECOND( supportsSignatures(), "DocumentSignature::signScriptingContent: signatures not supported by this document!" );
if ( m_pImpl->pShell ) if ( m_pImpl->pShell )
m_pImpl->pShell->SignScriptingContent(); m_pImpl->pShell->SignScriptingContent(pDialogParent);
} }
SignatureState DocumentSignature::getScriptingSignatureState() const SignatureState DocumentSignature::getScriptingSignatureState() const

View File

@@ -20,9 +20,9 @@
#define INCLUDED_BASCTL_SOURCE_INC_DOCSIGNATURE_HXX #define INCLUDED_BASCTL_SOURCE_INC_DOCSIGNATURE_HXX
#include <sfx2/signaturestate.hxx> #include <sfx2/signaturestate.hxx>
#include <vcl/weld.hxx>
#include <memory> #include <memory>
namespace basctl namespace basctl
{ {
@@ -53,7 +53,7 @@ namespace basctl
@precond @precond
isValid returns <TRUE/> isValid returns <TRUE/>
*/ */
void signScriptingContent() const; void signScriptingContent(weld::Window* pDialogParent) const;
/** retrieves the state of the signature of the scripting content inside the document /** retrieves the state of the signature of the scripting content inside the document

View File

@@ -146,8 +146,8 @@ void SignSignatureLineDialog::Apply()
SfxObjectShell* pShell = SfxObjectShell::Current(); SfxObjectShell* pShell = SfxObjectShell::Current();
Reference<XGraphic> xValidGraphic = getSignedGraphic(true); Reference<XGraphic> xValidGraphic = getSignedGraphic(true);
Reference<XGraphic> xInvalidGraphic = getSignedGraphic(false); Reference<XGraphic> xInvalidGraphic = getSignedGraphic(false);
pShell->SignSignatureLine(m_aSignatureLineId, m_xSelectedCertifate, xValidGraphic, pShell->SignSignatureLine(m_xDialog.get(), m_aSignatureLineId, m_xSelectedCertifate,
xInvalidGraphic, m_xEditComment->get_text()); xValidGraphic, xInvalidGraphic, m_xEditComment->get_text());
} }
const css::uno::Reference<css::graphic::XGraphic> const css::uno::Reference<css::graphic::XGraphic>

View File

@@ -355,19 +355,19 @@ public:
bool ExportTo( SfxMedium &rMedium ); bool ExportTo( SfxMedium &rMedium );
/** Returns to if preparing was succesful, else false. */ /** Returns to if preparing was succesful, else false. */
bool PrepareForSigning(); bool PrepareForSigning(weld::Window* pDialogParent);
bool CheckIsReadonly(bool bSignScriptingContent); bool CheckIsReadonly(bool bSignScriptingContent);
void AfterSigning(bool bSignSuccess, bool bSignScriptingContent); void AfterSigning(bool bSignSuccess, bool bSignScriptingContent);
bool HasValidSignatures(); bool HasValidSignatures();
SignatureState GetDocumentSignatureState(); SignatureState GetDocumentSignatureState();
void SignDocumentContent(); void SignDocumentContent(weld::Window* pDialogParent);
void SignSignatureLine(const OUString& aSignatureLineId, void SignSignatureLine(weld::Window* pDialogParent, const OUString& aSignatureLineId,
const css::uno::Reference<css::security::XCertificate> xCert, const css::uno::Reference<css::security::XCertificate> xCert,
const css::uno::Reference<css::graphic::XGraphic> xValidGraphic, const css::uno::Reference<css::graphic::XGraphic> xValidGraphic,
const css::uno::Reference<css::graphic::XGraphic> xInvalidGraphic, const css::uno::Reference<css::graphic::XGraphic> xInvalidGraphic,
const OUString& aComment); const OUString& aComment);
SignatureState GetScriptingSignatureState(); SignatureState GetScriptingSignatureState();
void SignScriptingContent(); void SignScriptingContent(weld::Window* pDialogParent);
DECL_LINK(SignDocumentHandler, Button*, void); DECL_LINK(SignDocumentHandler, Button*, void);
virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog( const SfxItemSet& ); virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog( const SfxItemSet& );

View File

@@ -838,7 +838,7 @@ IMPL_LINK_NOARG(SfxDocumentPage, SignatureHdl, Button*, void)
SfxObjectShell* pDoc = SfxObjectShell::Current(); SfxObjectShell* pDoc = SfxObjectShell::Current();
if( pDoc ) if( pDoc )
{ {
pDoc->SignDocumentContent(); pDoc->SignDocumentContent(GetFrameWeld());
ImplUpdateSignatures(); ImplUpdateSignatures();
} }

View File

@@ -396,7 +396,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
if( SID_SIGNATURE == nId || SID_MACRO_SIGNATURE == nId ) if( SID_SIGNATURE == nId || SID_MACRO_SIGNATURE == nId )
{ {
if ( QueryHiddenInformation( HiddenWarningFact::WhenSigning, nullptr ) == RET_YES ) if ( QueryHiddenInformation( HiddenWarningFact::WhenSigning, nullptr ) == RET_YES )
( SID_SIGNATURE == nId ) ? SignDocumentContent() : SignScriptingContent(); ( SID_SIGNATURE == nId ) ? SignDocumentContent(rReq.GetFrameWeld()) : SignScriptingContent(rReq.GetFrameWeld());
return; return;
} }
@@ -1363,7 +1363,7 @@ SignatureState SfxObjectShell::ImplGetSignatureState( bool bScriptingContent )
return *pState; return *pState;
} }
bool SfxObjectShell::PrepareForSigning() bool SfxObjectShell::PrepareForSigning(weld::Window* pDialogParent)
{ {
// Check if it is stored in OASIS format... // Check if it is stored in OASIS format...
if ( GetMedium() if ( GetMedium()
@@ -1375,7 +1375,7 @@ bool SfxObjectShell::PrepareForSigning()
) )
{ {
// Only OASIS and OOo6.x formats will be handled further // Only OASIS and OOo6.x formats will be handled further
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pDialogParent,
VclMessageType::Info, VclButtonsType::Ok, SfxResId(STR_INFO_WRONGDOCFORMAT))); VclMessageType::Info, VclButtonsType::Ok, SfxResId(STR_INFO_WRONGDOCFORMAT)));
xBox->run(); xBox->run();
@@ -1411,7 +1411,7 @@ bool SfxObjectShell::PrepareForSigning()
if ( nVersion >= SvtSaveOptions::ODFVER_012 ) if ( nVersion >= SvtSaveOptions::ODFVER_012 )
{ {
OUString sQuestion(bHasSign ? SfxResId(STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN) : SfxResId(RID_SVXSTR_XMLSEC_QUERY_SAVEBEFORESIGN)); OUString sQuestion(bHasSign ? SfxResId(STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN) : SfxResId(RID_SVXSTR_XMLSEC_QUERY_SAVEBEFORESIGN));
std::unique_ptr<weld::MessageDialog> xQuestion(Application::CreateMessageDialog(nullptr, std::unique_ptr<weld::MessageDialog> xQuestion(Application::CreateMessageDialog(pDialogParent,
VclMessageType::Question, VclButtonsType::YesNo, sQuestion)); VclMessageType::Question, VclButtonsType::YesNo, sQuestion));
@@ -1431,7 +1431,7 @@ bool SfxObjectShell::PrepareForSigning()
|| SotStorage::GetVersion( GetMedium()->GetStorage() ) <= SOFFICE_FILEFORMAT_60 ) ) || SotStorage::GetVersion( GetMedium()->GetStorage() ) <= SOFFICE_FILEFORMAT_60 ) )
{ {
// Only OASIS format will be handled further // Only OASIS format will be handled further
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pDialogParent,
VclMessageType::Info, VclButtonsType::Ok, SfxResId(STR_INFO_WRONGDOCFORMAT))); VclMessageType::Info, VclButtonsType::Ok, SfxResId(STR_INFO_WRONGDOCFORMAT)));
xBox->run(); xBox->run();
return false; return false;
@@ -1448,7 +1448,7 @@ bool SfxObjectShell::PrepareForSigning()
} }
else else
{ {
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pDialogParent,
VclMessageType::Warning, VclButtonsType::Ok, SfxResId(STR_XMLSEC_ODF12_EXPECTED))); VclMessageType::Warning, VclButtonsType::Ok, SfxResId(STR_XMLSEC_ODF12_EXPECTED)));
xBox->run(); xBox->run();
return false; return false;
@@ -1549,9 +1549,9 @@ SignatureState SfxObjectShell::GetDocumentSignatureState()
return ImplGetSignatureState(); return ImplGetSignatureState();
} }
void SfxObjectShell::SignDocumentContent() void SfxObjectShell::SignDocumentContent(weld::Window* pDialogParent)
{ {
if (!PrepareForSigning()) if (!PrepareForSigning(pDialogParent))
return; return;
if (CheckIsReadonly(false)) if (CheckIsReadonly(false))
@@ -1562,13 +1562,14 @@ void SfxObjectShell::SignDocumentContent()
AfterSigning(bSignSuccess, false); AfterSigning(bSignSuccess, false);
} }
void SfxObjectShell::SignSignatureLine(const OUString& aSignatureLineId, void SfxObjectShell::SignSignatureLine(weld::Window* pDialogParent,
const OUString& aSignatureLineId,
const Reference<XCertificate> xCert, const Reference<XCertificate> xCert,
const Reference<XGraphic> xValidGraphic, const Reference<XGraphic> xValidGraphic,
const Reference<XGraphic> xInvalidGraphic, const Reference<XGraphic> xInvalidGraphic,
const OUString& aComment) const OUString& aComment)
{ {
if (!PrepareForSigning()) if (!PrepareForSigning(pDialogParent))
return; return;
if (CheckIsReadonly(false)) if (CheckIsReadonly(false))
@@ -1585,9 +1586,9 @@ SignatureState SfxObjectShell::GetScriptingSignatureState()
return ImplGetSignatureState( true ); return ImplGetSignatureState( true );
} }
void SfxObjectShell::SignScriptingContent() void SfxObjectShell::SignScriptingContent(weld::Window* pDialogParent)
{ {
if (!PrepareForSigning()) if (!PrepareForSigning(pDialogParent))
return; return;
if (CheckIsReadonly(true)) if (CheckIsReadonly(true))