aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/pdf/PDFFactory.java
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2008-10-26 16:32:16 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2008-10-26 16:32:16 +0000
commit5f10442af0ea4cc6d672a6d77f49f831e358058e (patch)
tree216df69a82ae1eae64d6594bab6da459d8ea7e4e /src/java/org/apache/fop/pdf/PDFFactory.java
parent46c9aca22be22f20ed5bddbf21618ed1abdfe287 (diff)
downloadxmlgraphics-fop-5f10442af0ea4cc6d672a6d77f49f831e358058e.tar.gz
xmlgraphics-fop-5f10442af0ea4cc6d672a6d77f49f831e358058e.zip
Bugzilla 45113:
Added PDF /Launch action, which is used in case of references to URIs using the file:// protocol. Thanks to Alexander Stamenov (astamenov.AT.gmail.com) for the input! git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@708012 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf/PDFFactory.java')
-rw-r--r--src/java/org/apache/fop/pdf/PDFFactory.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java
index fc6e6b9fa..a5beb4ec7 100644
--- a/src/java/org/apache/fop/pdf/PDFFactory.java
+++ b/src/java/org/apache/fop/pdf/PDFFactory.java
@@ -1011,6 +1011,10 @@ public class PDFFactory {
// HTTP URL?
if (targetLo.startsWith("http://")) {
return new PDFUri(target);
+ // Non PDF files. Try to /Launch them.
+ } else if (targetLo.startsWith("file://")) {
+ target = target.substring("file://".length());
+ return getLaunchAction(target);
// Bare PDF file name?
} else if (targetLo.endsWith(".pdf")) {
return getGoToPDFAction(target, null, -1, newWindow);
@@ -1105,6 +1109,37 @@ public class PDFFactory {
}
/**
+ * Creates and returns a launch pdf document action using
+ * <code>file</code> to create a file spcifiaciton for
+ * the document/file to be opened with an external application.
+ *
+ * @param file the pdf file name
+ * @return the pdf launch object
+ */
+ private PDFLaunch getLaunchAction(String file) {
+ getDocument().getProfile().verifyActionAllowed();
+
+ PDFFileSpec fileSpec = new PDFFileSpec(file);
+ PDFFileSpec oldSpec = getDocument().findFileSpec(fileSpec);
+
+ if (oldSpec == null) {
+ getDocument().registerObject(fileSpec);
+ } else {
+ fileSpec = oldSpec;
+ }
+ PDFLaunch launch = new PDFLaunch(fileSpec);
+ PDFLaunch oldLaunch = getDocument().findLaunch(launch);
+
+ if (oldLaunch == null) {
+ getDocument().registerObject(launch);
+ } else {
+ launch = oldLaunch;
+ }
+
+ return launch;
+ }
+
+ /**
* Make an outline object and add it to the given parent
*
* @param parent the parent PDFOutline object (may be null)