[Libreoffice-commits] core.git: include/sfx2 sd/source sfx2/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 11 00:03:38 UTC 2020


 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 a201ab6f47c2d5a7ba4c5f998b0aa231cae82010
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jun 10 18:09:55 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jun 11 02:03:01 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.)
    
    Change-Id: I50ee2455c91cdee26612a6b8239dbb6772401877
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96060
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

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")


More information about the Libreoffice-commits mailing list