From e744e9f4492d3013742fcdb6254cd76528870e9d Mon Sep 17 00:00:00 2001 From: Katarina Behrens Date: Mon, 29 May 2017 15:53:19 +0200 Subject: tdf#105566: Add/remove infobar when the signature status changes this time without stack overflow. Updating existing infobar needs some work still This patch is partially based on work of samuel_m Change-Id: I2c44c14e27cf85a1014b01e5588b7b53990033b9 Reviewed-on: https://gerrit.libreoffice.org/38148 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- sfx2/source/doc/objserv.cxx | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'sfx2/source/doc') diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 6e1f008627df..edebf6a3cae5 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -90,6 +91,7 @@ #include #include #include +#include #include "app.hrc" #include @@ -1033,6 +1035,60 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) } case SID_SIGNATURE: { + SfxViewFrame *pFrame = SfxViewFrame::Current(); + if ( pFrame ) + { + SignatureState eState = GetDocumentSignatureState(); + InfoBarType aInfoBarType(InfoBarType::Info); + OUString sMessage(""); + + switch (eState) + { + case SignatureState::BROKEN: + sMessage = SfxResId(STR_SIGNATURE_BROKEN); + aInfoBarType = InfoBarType::Danger; + break; + case SignatureState::NOTVALIDATED: + sMessage = SfxResId(STR_SIGNATURE_NOTVALIDATED); + aInfoBarType = InfoBarType::Warning; + break; + case SignatureState::PARTIAL_OK: + sMessage = SfxResId(STR_SIGNATURE_PARTIAL_OK); + aInfoBarType = InfoBarType::Warning; + break; + case SignatureState::OK: + sMessage = SfxResId(STR_SIGNATURE_OK); + aInfoBarType = InfoBarType::Info; + break; + default: + break; + } + + // new info bar + if ( !pFrame->HasInfoBarWithID("signature") ) + { + + if (!sMessage.isEmpty()) + { + auto pInfoBar = pFrame->AppendInfoBar("signature", sMessage, aInfoBarType); + if (pInfoBar == nullptr) + return; + VclPtrInstance xBtn(&(pFrame->GetWindow())); + xBtn->SetText(SfxResId(STR_SIGNATURE_SHOW)); + xBtn->SetSizePixel(xBtn->GetOptimalSize()); + xBtn->SetClickHdl(LINK(this, SfxObjectShell, SignDocumentHandler)); + pInfoBar->addButton(xBtn); + } + } + else // signature info bar exists already + { + if (eState == SignatureState::NOSIGNATURES ) + pFrame->RemoveInfoBar("signature"); + //FIXME: Update existing info bar + } + + } + rSet.Put( SfxUInt16Item( SID_SIGNATURE, static_cast(GetDocumentSignatureState()) ) ); break; } @@ -1049,6 +1105,10 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) } } +IMPL_LINK_NOARG(SfxObjectShell, SignDocumentHandler, Button*, void) +{ + GetDispatcher()->Execute(SID_SIGNATURE); +} void SfxObjectShell::ExecProps_Impl(SfxRequest &rReq) { -- cgit