diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2017-05-29 15:53:19 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-05-30 15:38:29 +0200 |
commit | e744e9f4492d3013742fcdb6254cd76528870e9d (patch) | |
tree | f5ce5d33ae50ea208bb9c396e13e25005f07ec8e /sfx2/source/doc | |
parent | 3dda91dda8764adb3f6cc229236281bb270bba92 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sfx2/source/doc')
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 60 |
1 files changed, 60 insertions, 0 deletions
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 <unotools/saveopt.hxx> #include <svtools/asynclink.hxx> #include <comphelper/documentconstants.hxx> +#include <tools/link.hxx> #include <sfx2/app.hxx> #include <sfx2/signaturestate.hxx> @@ -90,6 +91,7 @@ #include <sfx2/msgpool.hxx> #include <sfx2/objface.hxx> #include <sfx2/checkin.hxx> +#include <sfx2/infobar.hxx> #include "app.hrc" #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp> @@ -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<PushButton> 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<sal_uInt16>(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) { |