sfx2: let .uno:SignPDF add a matching button to the infobar

When the user uses .uno:SignPDF to open a PDF file in read-only mode,
then the infobar now has a "Sign Document" button, which is a shortcut
for the File -> Digital Signatures -> Digital Signatures menu item.

Change-Id: I2953a5cb1252c5ff1c395d45c54db1a97b39433e
This commit is contained in:
Miklos Vajna 2016-11-08 09:12:47 +01:00
parent b2318479c8
commit b58e3de0cd
4 changed files with 27 additions and 0 deletions

View file

@ -153,6 +153,7 @@
#define STR_CLASSIFIED_INTELLECTUAL_PROPERTY (RID_SFX_START+134)
#define STR_CLASSIFIED_NATIONAL_SECURITY (RID_SFX_START+135)
#define STR_CLASSIFIED_EXPORT_CONTROL (RID_SFX_START+136)
#define STR_READONLY_SIGN (RID_SFX_START+137)
#define STR_ACCTITLE_PRODUCTIVITYTOOLS (RID_SFX_START+157)
#define SFX_THUMBNAIL_TEXT (RID_SFX_START+158)

View file

@ -78,6 +78,7 @@ protected:
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
DECL_LINK( SwitchReadOnlyHandler, Button*, void );
DECL_LINK(SignDocumentHandler, Button*, void);
SAL_DLLPRIVATE void KillDispatcher_Impl();
virtual ~SfxViewFrame() override;

View file

@ -131,4 +131,9 @@ String STR_READONLY_EDIT
Text[ en-US ] = "Edit Document";
};
String STR_READONLY_SIGN
{
Text[ en-US ] = "Sign Document";
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -1152,6 +1152,22 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
SfxInfoBarWindow* pInfoBar = AppendInfoBar("readonly", SfxResId(STR_READONLY_DOCUMENT));
if (pInfoBar)
{
SfxMedium* pMedium = m_xObjSh->GetMedium();
if (pMedium && !pMedium->IsOriginallyReadOnly())
{
std::shared_ptr<const SfxFilter> pFilter = pMedium->GetFilter();
if (pFilter && pFilter->GetName() == "draw_pdf_import")
{
// 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);
}
}
VclPtrInstance<PushButton> xBtn(&GetWindow());
xBtn->SetText(SfxResId(STR_READONLY_EDIT));
xBtn->SetSizePixel(xBtn->GetOptimalSize());
@ -1251,6 +1267,10 @@ IMPL_LINK_NOARG(SfxViewFrame, SwitchReadOnlyHandler, Button*, void)
GetDispatcher()->Execute(SID_EDITDOC);
}
IMPL_LINK_NOARG(SfxViewFrame, SignDocumentHandler, Button*, void)
{
GetDispatcher()->Execute(SID_SIGNATURE);
}
void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh )
{