aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/pdf')
-rw-r--r--src/java/org/apache/fop/pdf/PDFEmbeddedFiles.java66
-rw-r--r--src/java/org/apache/fop/pdf/PDFNameTreeNode.java31
-rw-r--r--src/java/org/apache/fop/pdf/PDFNames.java10
3 files changed, 71 insertions, 36 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFEmbeddedFiles.java b/src/java/org/apache/fop/pdf/PDFEmbeddedFiles.java
new file mode 100644
index 000000000..8e89f5ada
--- /dev/null
+++ b/src/java/org/apache/fop/pdf/PDFEmbeddedFiles.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.pdf;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.SortedMap;
+
+/**
+ * Class representing an /EmbeddedFiles dictionary object (name tree).
+ */
+public class PDFEmbeddedFiles extends PDFNameTreeNode {
+
+ /**
+ * Create a /EmbeddedFiles dictionary.
+ */
+ public PDFEmbeddedFiles() {
+ super();
+ }
+
+ /** {@inheritDoc} */
+ protected void writeDictionary(OutputStream out, Writer writer) throws IOException {
+ sortNames(); //Sort the names before writing them out
+ super.writeDictionary(out, writer);
+ }
+
+ private void sortNames() {
+ PDFArray names = getNames();
+ SortedMap map = new java.util.TreeMap();
+ int i = 0;
+ int c = names.length();
+ while (i < c) {
+ Comparable key = (Comparable)names.get(i++); //Key must be a Comparable for sorting
+ Object value = names.get(i++);
+ map.put(key, value);
+ }
+ names.clear();
+ Iterator iter = map.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ names.add(entry.getKey());
+ names.add(entry.getValue());
+ }
+ }
+}
+
diff --git a/src/java/org/apache/fop/pdf/PDFNameTreeNode.java b/src/java/org/apache/fop/pdf/PDFNameTreeNode.java
index f294b0f68..4e1f1b71b 100644
--- a/src/java/org/apache/fop/pdf/PDFNameTreeNode.java
+++ b/src/java/org/apache/fop/pdf/PDFNameTreeNode.java
@@ -19,13 +19,6 @@
package org.apache.fop.pdf;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
/**
* Class representing a PDF name tree node.
@@ -124,29 +117,5 @@ public class PDFNameTreeNode extends PDFDictionary {
return limits;
}
- /** {@inheritDoc} */
- protected void writeDictionary(OutputStream out, Writer writer) throws IOException {
- sortNames(); //Sort the names before writing them out
- super.writeDictionary(out, writer);
- }
-
- private void sortNames() {
- PDFArray names = getNames();
- SortedMap map = new TreeMap();
- int i = 0;
- int c = names.length();
- while (i < c) {
- String key = (String)names.get(i++); //Key must be a String
- Object value = names.get(i++);
- map.put(key, value);
- }
- names.clear();
- Iterator iter = map.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- names.add(entry.getKey());
- names.add(entry.getValue());
- }
- }
}
diff --git a/src/java/org/apache/fop/pdf/PDFNames.java b/src/java/org/apache/fop/pdf/PDFNames.java
index aa6f64547..fbea0d3f5 100644
--- a/src/java/org/apache/fop/pdf/PDFNames.java
+++ b/src/java/org/apache/fop/pdf/PDFNames.java
@@ -55,16 +55,16 @@ public class PDFNames extends PDFDictionary {
* Returns the EmbeddedFiles object
* @return the EmbeddedFiles object, or null if it's not used
*/
- public PDFNameTreeNode getEmbeddedFiles() {
- return (PDFNameTreeNode)get(EMBEDDED_FILES);
+ public PDFEmbeddedFiles getEmbeddedFiles() {
+ return (PDFEmbeddedFiles)get(EMBEDDED_FILES);
}
/**
* Set the EmbeddedFiles object
- * @param dests the EmbeddedFiles object
+ * @param embeddedFiles the EmbeddedFiles object
*/
- public void setEmbeddedFiles(PDFNameTreeNode dests) {
- put(EMBEDDED_FILES, dests);
+ public void setEmbeddedFiles(PDFEmbeddedFiles embeddedFiles) {
+ put(EMBEDDED_FILES, embeddedFiles);
}
}