[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/sfx2 sd/source sfx2/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 26 06:53:10 UTC 2020


 include/sfx2/objsh.hxx         |    3 +++
 sd/source/ui/view/drviews7.cxx |   10 ++++++++++
 sfx2/source/doc/objserv.cxx    |   12 ++++++++++++
 sfx2/source/view/viewfrm.cxx   |   21 ++-------------------
 4 files changed, 27 insertions(+), 19 deletions(-)

New commits:
commit 29bec3144999f82e22d71c0d68e92a8d24e92190
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Jun 5 15:40:34 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jun 26 08:52:35 2020 +0200

    sd signature line: limit this to PDF signing for now
    
    The intent is to use this to add a visible signature to an existing PDF,
    disable the command in sd/ for other cases that would not work at the
    moment, anyway.
    
    (cherry picked from commit 2c46c24e75dbd39ef1c6aa72d7c3a00d04b873e6)
    
    Change-Id: I78aa68d91126a9981c1240c7dd257d793e7eaba8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97173
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 19c615f8d7c1..b3627a6b8788 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -758,6 +758,9 @@ public:
 
     /** override this if you have a XmlIdRegistry. */
     virtual const sfx2::IXmlIdRegistry* GetXmlIdRegistry() const { return nullptr; }
+
+    /// Is this read-only object shell opened via .uno:SignPDF?
+    bool IsSignPDF() const;
 };
 
 #define SFX_GLOBAL_CLASSID \
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index dc4b959fd39d..f1a412fd56b1 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1588,6 +1588,16 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
     if (GetViewShell()->isExportLocked())
         rSet.DisableItem(SID_PRESENTATION_MINIMIZER);
 
+    if (rSet.GetItemState(SID_INSERT_SIGNATURELINE) == SfxItemState::DEFAULT)
+    {
+        if (!GetObjectShell()->IsSignPDF())
+        {
+            // Currently SID_INSERT_SIGNATURELINE assumes a PDF that was opened for signing, disable
+            // it otherwise.
+            rSet.DisableItem(SID_INSERT_SIGNATURELINE);
+        }
+    }
+
     GetModeSwitchingMenuState (rSet);
 }
 
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 929f26098644..96c23314a5cb 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -411,6 +411,18 @@ uno::Sequence< document::CmisVersion > SfxObjectShell::GetCmisVersions( ) const
     return uno::Sequence< document::CmisVersion > ( );
 }
 
+bool SfxObjectShell::IsSignPDF() const
+{
+    if (pMedium && !pMedium->IsOriginallyReadOnly())
+    {
+        const std::shared_ptr<const SfxFilter>& pFilter = pMedium->GetFilter();
+        if (pFilter && pFilter->GetName() == "draw_pdf_import")
+            return true;
+    }
+
+    return false;
+}
+
 void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
 {
     weld::Window* pDialogParent = rReq.GetFrameWeld();
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index b3390e15bead..3a115ac59a3b 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -226,23 +226,6 @@ private:
     }
 };
 
-/// Is this read-only object shell opened via .uno:SignPDF?
-bool IsSignPDF(const SfxObjectShellRef& xObjSh)
-{
-    if (!xObjSh.is())
-        return false;
-
-    SfxMedium* pMedium = xObjSh->GetMedium();
-    if (pMedium && !pMedium->IsOriginallyReadOnly())
-    {
-        const std::shared_ptr<const SfxFilter>& pFilter = pMedium->GetFilter();
-        if (pFilter && pFilter->GetName() == "draw_pdf_import")
-            return true;
-    }
-
-    return false;
-}
-
 bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const OUString& aPath, const std::shared_ptr<const SfxFilter>& pFilter, sal_uInt32 nPasswordHash, const uno::Sequence< beans::PropertyValue >& aInfo )
 {
     // TODO/LATER: In future the info should replace the direct hash completely
@@ -1342,7 +1325,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 = IsSignPDF(m_xObjSh);
+                    bool bSignPDF = m_xObjSh->IsSignPDF();
 
                     auto pInfoBar = AppendInfoBar("readonly", "", SfxResId(bSignPDF ? STR_READONLY_PDF : STR_READONLY_DOCUMENT), InfobarType::INFO);
                     if (pInfoBar)
@@ -1496,7 +1479,7 @@ IMPL_LINK_NOARG(SfxViewFrame, DonationHandler, Button*, void)
 
 IMPL_LINK(SfxViewFrame, SwitchReadOnlyHandler, Button*, pButton, void)
 {
-    if (m_xObjSh.is() && IsSignPDF(m_xObjSh))
+    if (m_xObjSh.is() && m_xObjSh->IsSignPDF())
     {
         SfxEditDocumentDialog aDialog(pButton->GetFrameWeld());
         if (aDialog.run() != RET_OK)


More information about the Libreoffice-commits mailing list