diff options
-rw-r--r-- | include/sfx2/strings.hrc | 1 | ||||
-rw-r--r-- | include/sfx2/viewfrm.hxx | 1 | ||||
-rw-r--r-- | sd/source/ui/func/fuconrec.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 108 |
4 files changed, 89 insertions, 29 deletions
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc index 0c76294bd1f5..e845c514049a 100644 --- a/include/sfx2/strings.hrc +++ b/include/sfx2/strings.hrc @@ -282,6 +282,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 0a40a4179afc..e3a3ddaffb2e 100644 --- a/include/sfx2/viewfrm.hxx +++ b/include/sfx2/viewfrm.hxx @@ -163,6 +163,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 190d10d7e323..e7bb57bc9c29 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> @@ -88,6 +89,7 @@ #include <optional> #include <unotools/configmgr.hxx> +#include <comphelper/sequenceashashmap.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1219,6 +1221,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->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) @@ -1364,35 +1442,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->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") |