include/sfx2/strings.hrc | 1 include/sfx2/viewfrm.hxx | 1 sd/source/ui/func/fuconrec.cxx | 8 +++ sfx2/source/view/viewfrm.cxx | 108 +++++++++++++++++++++++++++++------------ 4 files changed, 89 insertions(+), 29 deletions(-)
New commits: commit 745c27088f90eff8bf17dd959a2731fcda5da0e3 Author: Miklos Vajna <[email protected]> AuthorDate: Wed Jun 10 18:09:55 2020 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jun 26 08:55:15 2020 +0200 sd signature line: inform infobar if a cert is already selected In case a pdf is opened for signing, the infobar has a button to start the signing. If a signature line is already inserted and the user picked a certificate, then let's call the infobar button's action "finish signing", since the signature list and the certificate chooser won't appear in this case. (The actual behavior when you click on the button is still unchanged, though.) (cherry picked from commit a201ab6f47c2d5a7ba4c5f998b0aa231cae82010) Conflicts: sfx2/source/view/viewfrm.cxx Change-Id: I50ee2455c91cdee26612a6b8239dbb6772401877 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97180 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc index 7e9757e61a78..b6ad69a604cf 100644 --- a/include/sfx2/strings.hrc +++ b/include/sfx2/strings.hrc @@ -290,6 +290,7 @@ #define STR_CHECKOUT NC_("STR_CHECKOUT", "Check Out") #define STR_READONLY_EDIT NC_("STR_READONLY_EDIT", "Edit Document") #define STR_READONLY_SIGN NC_("STR_READONLY_SIGN", "Sign Document") +#define STR_READONLY_FINISH_SIGN NC_("STR_READONLY_FINISH_SIGN", "Finish Signing") #define STR_SIGNATURE_BROKEN NC_("STR_SIGNATURE_BROKEN", "This document has an invalid signature.") #define STR_SIGNATURE_INVALID NC_("STR_SIGNATURE_INVALID", "The signature was valid, but the document has been modified") #define STR_SIGNATURE_NOTVALIDATED NC_("STR_SIGNATURE_NOTVALIDATED", "The signature is OK, but the certificate could not be validated.") diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx index 5335e0d000f2..250515eea0de 100644 --- a/include/sfx2/viewfrm.hxx +++ b/include/sfx2/viewfrm.hxx @@ -165,6 +165,7 @@ public: const OUString& sSecondaryMessage, InfobarType eType); bool HasInfoBarWithID(const OUString& sId); + void AppendReadOnlyInfobar(); SAL_DLLPRIVATE void GetDocNumber_Impl(); SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell *pVSh ); diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index 91ed61ad3d63..c79753285642 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -491,6 +491,14 @@ void FuConstructRectangle::Deactivate() } svx::SignatureLineHelper::setShapeCertificate(mpView, xCertificate); + + // Update infobar to offer "finish signing". + SfxViewFrame* pFrame = mpViewShell->GetViewFrame(); + if (pFrame && pFrame->HasInfoBarWithID("readonly")) + { + pFrame->RemoveInfoBar("readonly"); + pFrame->AppendReadOnlyInfobar(); + } } namespace { diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 3a115ac59a3b..8d0d94a6181d 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/frame/XLoadable.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/drawing/XShapes.hpp> #include <officecfg/Office/Common.hxx> #include <officecfg/Setup.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -97,6 +98,7 @@ #include <boost/optional.hpp> #include <unotools/configmgr.hxx> +#include <comphelper/sequenceashashmap.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1236,6 +1238,82 @@ const SvBorder& SfxViewFrame::GetBorderPixelImpl() const return m_pImpl->aBorder; } +namespace +{ +/// Does the current selection have a shape with an associated signing certificate? +bool IsSignWithCert(SfxViewShell* pViewShell) +{ + uno::Reference<frame::XModel> xModel = pViewShell->GetCurrentDocument(); + if (!xModel.is()) + { + return false; + } + + uno::Reference<drawing::XShapes> xShapes(xModel->getCurrentSelection(), uno::UNO_QUERY); + if (!xShapes.is() || xShapes->getCount() < 1) + { + return false; + } + + uno::Reference<beans::XPropertySet> xShapeProps(xShapes->getByIndex(0), uno::UNO_QUERY); + if (!xShapeProps.is()) + { + return false; + } + + comphelper::SequenceAsHashMap aMap(xShapeProps->getPropertyValue("InteropGrabBag")); + return aMap.find("SignatureCertificate") != aMap.end(); +} +} + +void SfxViewFrame::AppendReadOnlyInfobar() +{ + bool bSignPDF = m_xObjSh->IsSignPDF(); + bool bSignWithCert = false; + if (bSignPDF) + { + bSignWithCert = IsSignWithCert(GetViewShell()); + } + + auto pInfoBar = AppendInfoBar("readonly", "", + SfxResId(bSignPDF ? STR_READONLY_PDF : STR_READONLY_DOCUMENT), + InfobarType::INFO); + if (pInfoBar) + { + if (bSignPDF) + { + // SID_SIGNPDF opened a read-write PDF + // read-only for signing purposes. + VclPtrInstance<PushButton> xSignButton(&GetWindow()); + if (bSignWithCert) + { + xSignButton->SetText(SfxResId(STR_READONLY_FINISH_SIGN)); + } + else + { + xSignButton->SetText(SfxResId(STR_READONLY_SIGN)); + } + + xSignButton->SetSizePixel(xSignButton->GetOptimalSize()); + xSignButton->SetClickHdl(LINK(this, SfxViewFrame, SignDocumentHandler)); + pInfoBar->addButton(xSignButton); + } + + bool showEditDocumentButton = true; + if (m_xObjSh->GetViewShell() && m_xObjSh->GetViewShell()->isEditDocLocked()) + showEditDocumentButton = false; + + if (showEditDocumentButton) + { + VclPtrInstance<PushButton> xBtn(&GetWindow()); + xBtn->SetText(SfxResId(STR_READONLY_EDIT)); + xBtn->SetSizePixel(xBtn->GetOptimalSize()); + xBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler)); + pInfoBar->addButton(xBtn); + } + } +} + void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { if(m_pImpl->bIsDowning) @@ -1325,35 +1403,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) ( m_xObjSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED || (( pVSh = m_xObjSh->GetViewShell()) && (pFSh = pVSh->GetFormShell()) && pFSh->IsDesignMode()))) { - bool bSignPDF = m_xObjSh->IsSignPDF(); - - auto pInfoBar = AppendInfoBar("readonly", "", SfxResId(bSignPDF ? STR_READONLY_PDF : STR_READONLY_DOCUMENT), InfobarType::INFO); - if (pInfoBar) - { - if (bSignPDF) - { - // SID_SIGNPDF opened a read-write PDF - // read-only for signing purposes. - VclPtrInstance<PushButton> xSignButton(&GetWindow()); - xSignButton->SetText(SfxResId(STR_READONLY_SIGN)); - xSignButton->SetSizePixel(xSignButton->GetOptimalSize()); - xSignButton->SetClickHdl(LINK(this, SfxViewFrame, SignDocumentHandler)); - pInfoBar->addButton(xSignButton); - } - - bool showEditDocumentButton = true; - if (m_xObjSh->GetViewShell() && m_xObjSh->GetViewShell()->isEditDocLocked()) - showEditDocumentButton = false; - - if (showEditDocumentButton) - { - VclPtrInstance<PushButton> xBtn(&GetWindow()); - xBtn->SetText(SfxResId(STR_READONLY_EDIT)); - xBtn->SetSizePixel(xBtn->GetOptimalSize()); - xBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler)); - pInfoBar->addButton(xBtn); - } - } + AppendReadOnlyInfobar(); } if (vcl::CommandInfoProvider::GetModuleIdentifier(GetFrame().GetFrameInterface()) == "com.sun.star.text.TextDocument") _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
