From 79fb0a5e60d927dccdebf8d3b8fe96b649abe6e7 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Tue, 24 Mar 2009 10:46:59 +0000 Subject: Simplified the setting of filters in the AbstractPDFStream hierarchy. Instead of unnecessarily re-defining the setupFilterList method, sub-classes just define a getDefaultFilterName method git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@757712 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/pdf/AbstractPDFFontStream.java | 5 ++--- src/java/org/apache/fop/pdf/AbstractPDFStream.java | 20 +++++++++++--------- src/java/org/apache/fop/pdf/PDFImageXObject.java | 9 +++------ src/java/org/apache/fop/pdf/PDFMetadata.java | 5 ++--- 4 files changed, 18 insertions(+), 21 deletions(-) (limited to 'src/java') diff --git a/src/java/org/apache/fop/pdf/AbstractPDFFontStream.java b/src/java/org/apache/fop/pdf/AbstractPDFFontStream.java index f3d005bd3..34c9c5dee 100644 --- a/src/java/org/apache/fop/pdf/AbstractPDFFontStream.java +++ b/src/java/org/apache/fop/pdf/AbstractPDFFontStream.java @@ -33,9 +33,8 @@ public abstract class AbstractPDFFontStream extends AbstractPDFStream { } /** {@inheritDoc} */ - protected void setupFilterList() { - addDefaultFilter(PDFFilterList.FONT_FILTER); - super.setupFilterList(); + protected String getDefaultFilterName() { + return PDFFilterList.FONT_FILTER; } } diff --git a/src/java/org/apache/fop/pdf/AbstractPDFStream.java b/src/java/org/apache/fop/pdf/AbstractPDFStream.java index fc853b512..4107c7e7a 100644 --- a/src/java/org/apache/fop/pdf/AbstractPDFStream.java +++ b/src/java/org/apache/fop/pdf/AbstractPDFStream.java @@ -47,21 +47,23 @@ public abstract class AbstractPDFStream extends PDFDictionary { * from outside. */ protected void setupFilterList() { - addDefaultFilter(PDFFilterList.DEFAULT_FILTER); + if (!getFilterList().isInitialized()) { + getFilterList().addDefaultFilters( + getDocumentSafely().getFilterMap(), + getDefaultFilterName()); + } prepareImplicitFilters(); getDocument().applyEncryption(this); } /** - * Adds the default filter to the filter list if the filter list hasn't been initialized, yet. - * @param filterName the name of the default filter to use + * Returns the name of a suitable filter for this PDF object. + * + * @return the default filter + * @see PDFFilterList */ - protected void addDefaultFilter(String filterName) { - if (!getFilterList().isInitialized()) { - getFilterList().addDefaultFilters( - getDocumentSafely().getFilterMap(), - filterName); - } + protected String getDefaultFilterName() { + return PDFFilterList.DEFAULT_FILTER; } /** diff --git a/src/java/org/apache/fop/pdf/PDFImageXObject.java b/src/java/org/apache/fop/pdf/PDFImageXObject.java index a69d9e8de..9ec8f1595 100644 --- a/src/java/org/apache/fop/pdf/PDFImageXObject.java +++ b/src/java/org/apache/fop/pdf/PDFImageXObject.java @@ -159,14 +159,11 @@ public class PDFImageXObject extends PDFXObject { } /** - * This sets up the default filters for XObjects. It uses the PDFImage - * instance to determine what default filters to apply. * {@inheritDoc} + * This class uses the PDFImage instance to determine the default filter. */ - protected void setupFilterList() { - addDefaultFilter(pdfimage.getFilterHint()); - super.setupFilterList(); + protected String getDefaultFilterName() { + return pdfimage.getFilterHint(); } - } diff --git a/src/java/org/apache/fop/pdf/PDFMetadata.java b/src/java/org/apache/fop/pdf/PDFMetadata.java index 5008183ef..92796c0d1 100644 --- a/src/java/org/apache/fop/pdf/PDFMetadata.java +++ b/src/java/org/apache/fop/pdf/PDFMetadata.java @@ -59,9 +59,8 @@ public class PDFMetadata extends PDFStream { } /** {@inheritDoc} */ - protected void setupFilterList() { - addDefaultFilter(PDFFilterList.METADATA_FILTER); - super.setupFilterList(); + protected String getDefaultFilterName() { + return PDFFilterList.METADATA_FILTER; } /** -- cgit v1.2.3