summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-11-07 10:24:41 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-11-07 13:46:57 +0100
commit055be3f4be764e445064effabf06de9d1ed819f7 (patch)
tree0b2f908a8bc6ffb34ff6f2ae7472dfc4a7e95cc2 /sfx2
parente53168c6875223d718df49e23b733ad6f40e0b7f (diff)
sfx2: introduce a new .uno:SignPDF
It's similar to File -> Open, but the file picker only offers PDF files in this case, and the import is read-only -- i.e. it's the import equivalent of .uno:ExportToPDF. Change-Id: I7be9d6711e0ea93643e538575c0604d41cff9b26
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/sdi/docslots.sdi4
-rw-r--r--sfx2/sdi/sfx.sdi18
-rw-r--r--sfx2/source/appl/app.src4
-rw-r--r--sfx2/source/appl/appopen.cxx19
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx14
-rw-r--r--sfx2/source/doc/docfile.cxx5
6 files changed, 58 insertions, 6 deletions
diff --git a/sfx2/sdi/docslots.sdi b/sfx2/sdi/docslots.sdi
index 8a54a6c689a5..18bd74133624 100644
--- a/sfx2/sdi/docslots.sdi
+++ b/sfx2/sdi/docslots.sdi
@@ -30,6 +30,10 @@ interface Documents
[
ExecMethod = OpenRemoteExec_Impl ;
]
+ SID_SIGNPDF
+ [
+ ExecMethod = SignPDFExec_Impl ;
+ ]
SID_OPENHYPERLINK // ole(no) api(final/play/rec)
[
ExecMethod = OpenDocExec_Impl ;
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index e45cf6da194c..dda5c788c5e5 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -2826,6 +2826,24 @@ SfxObjectItem OpenRemote SID_OPENREMOTE
GroupId = GID_APPLICATION;
]
+SfxObjectItem SignPDF SID_SIGNPDF
+(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem OpenFlags SID_OPTIONS,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxInt16Item Version SID_VERSION,SfxStringItem Referer SID_REFERER,SfxStringItem SuggestedSaveAsDir SID_DEFAULTFILEPATH,SfxStringItem SuggestedSaveAsName SID_DEFAULTFILENAME)
+[
+ AutoUpdate = FALSE,
+ FastCall = FALSE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = TRUE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Asynchron;
+
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_APPLICATION;
+]
+
SfxObjectItem WebHtml SID_WEBHTML
()
[
diff --git a/sfx2/source/appl/app.src b/sfx2/source/appl/app.src
index 3384f4a5a677..21c5f9175f2e 100644
--- a/sfx2/source/appl/app.src
+++ b/sfx2/source/appl/app.src
@@ -333,6 +333,10 @@ String STR_SFX_FILTERNAME_ALL
{
Text [ en-US ] = "All files" ;
};
+String STR_SFX_FILTERNAME_PDF
+{
+ Text [ en-US ] = "PDF files" ;
+};
String RID_SVXSTR_EDITGRFLINK
{
Text [ en-US ] = "Link Image" ;
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 5b0fddd80e78..caec98f9e705 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -624,6 +624,15 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
if ( pRemoteDialogItem && pRemoteDialogItem->GetValue())
nDialog = SFX2_IMPL_DIALOG_REMOTE;
+ sal_Int16 nDialogType = ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION;
+ FileDialogFlags eDialogFlags = FileDialogFlags::MultiSelection;
+ const SfxBoolItem* pSignPDFItem = rReq.GetArg<SfxBoolItem>(SID_SIGNPDF);
+ if (pSignPDFItem && pSignPDFItem->GetValue())
+ {
+ eDialogFlags |= FileDialogFlags::SignPDF;
+ nDialogType = ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
+ }
+
OUString sStandardDir;
const SfxStringItem* pStandardDirItem = rReq.GetArg<SfxStringItem>(SID_STANDARD_DIR);
@@ -638,8 +647,8 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
sal_uIntPtr nErr = sfx2::FileOpenDialog_Impl(
- ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
- FileDialogFlags::MultiSelection, OUString(), aURLList,
+ nDialogType,
+ eDialogFlags, OUString(), aURLList,
aFilter, pSet, &aPath, nDialog, sStandardDir, aBlackList );
if ( nErr == ERRCODE_ABORT )
@@ -1127,4 +1136,10 @@ void SfxApplication::OpenRemoteExec_Impl( SfxRequest& rReq )
GetDispatcher_Impl()->Execute( SID_OPENDOC, SfxCallMode::SYNCHRON, *rReq.GetArgs() );
}
+void SfxApplication::SignPDFExec_Impl(SfxRequest& rReq)
+{
+ rReq.AppendItem(SfxBoolItem(SID_SIGNPDF, true));
+ GetDispatcher_Impl()->Execute(SID_OPENDOC, SfxCallMode::SYNCHRON, *rReq.GetArgs());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 7771124e98a8..c54a0df748a4 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2593,16 +2593,24 @@ ErrCode FileOpenDialog_Impl( sal_Int16 nDialogType,
const css::uno::Sequence< OUString >& rBlackList )
{
ErrCode nRet;
- FileDialogHelper aDialog( nDialogType, nFlags,
- rFact, nDialog, SfxFilterFlags::NONE, SfxFilterFlags::NONE, rStandardDir, rBlackList );
+ std::unique_ptr<FileDialogHelper> pDialog;
+ // Sign existing PDF: only works with PDF files and they are opened
+ // read-only to discourage editing (which would invalidate existing
+ // signatures).
+ if (nFlags & FileDialogFlags::SignPDF)
+ pDialog.reset(new FileDialogHelper(nDialogType, nFlags, SfxResId(STR_SFX_FILTERNAME_PDF).toString(), "pdf", rStandardDir, rBlackList));
+ else
+ pDialog.reset(new FileDialogHelper(nDialogType, nFlags, rFact, nDialog, SfxFilterFlags::NONE, SfxFilterFlags::NONE, rStandardDir, rBlackList));
OUString aPath;
if ( pPath )
aPath = *pPath;
- nRet = aDialog.Execute( rpURLList, rpSet, rFilter, aPath );
+ nRet = pDialog->Execute(rpURLList, rpSet, rFilter, aPath);
DBG_ASSERT( rFilter.indexOf(": ") == -1, "Old filter name used!");
+ if (rpSet && nFlags & FileDialogFlags::SignPDF)
+ rpSet->Put(SfxBoolItem(SID_DOC_READONLY, true));
return nRet;
}
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 40f19ea74583..0a4f02e0374b 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -3502,7 +3502,10 @@ bool SfxMedium::SignContents_Impl( bool bScriptingContent, const OUString& aODFV
comphelper::getProcessComponentContext(), aODFVersion, bHasValidDocumentSignature ) );
uno::Reference< embed::XStorage > xWriteableZipStor;
- if ( !IsReadOnly() )
+ // Signing is not modification of the document, as seen by the user
+ // ("only a saved document can be signed"). So allow signing in the
+ // "opened read-only, but not physically-read-only" case.
+ if (!IsOriginallyReadOnly())
{
// we can reuse the temporary file if there is one already
CreateTempFile( false );