summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-06-05 15:40:34 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-06-05 21:45:23 +0200
commit2c46c24e75dbd39ef1c6aa72d7c3a00d04b873e6 (patch)
tree38e4310c75e20323ff7a0678bc72cbb7041c30b8
parent642e630a6229785f9206f5db6e627577f3dc4c3b (diff)
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. Change-Id: I78aa68d91126a9981c1240c7dd257d793e7eaba8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95604 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--include/sfx2/objsh.hxx3
-rw-r--r--sd/source/ui/view/drviews7.cxx10
-rw-r--r--sfx2/source/doc/objserv.cxx12
-rw-r--r--sfx2/source/view/viewfrm.cxx21
4 files changed, 27 insertions, 19 deletions
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 98a00a44b3cb..97622b799852 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -769,6 +769,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 0a0165fc0cab..104d6f23801a 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 (GetObjectShell()->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 7e367a88e53e..af439df22a4d 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -393,6 +393,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 3a0572058932..190d10d7e323 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -210,23 +210,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
@@ -1381,7 +1364,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)
@@ -1535,7 +1518,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)