From bb61ea868317c73715c05a1b40c88488758e5049 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 16 Jan 2009 14:29:39 +0000 Subject: Removed duplicated extension attachment list on PageViewport (which is an AreaTreeObject subclass and therefore already has that list). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@735026 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/AreaTreeObject.java | 39 ++++++++++++++++++++---- src/java/org/apache/fop/area/PageViewport.java | 35 ++------------------- 2 files changed, 35 insertions(+), 39 deletions(-) (limited to 'src/java/org/apache/fop/area') diff --git a/src/java/org/apache/fop/area/AreaTreeObject.java b/src/java/org/apache/fop/area/AreaTreeObject.java index 5929e7c4e..bab27f411 100644 --- a/src/java/org/apache/fop/area/AreaTreeObject.java +++ b/src/java/org/apache/fop/area/AreaTreeObject.java @@ -26,6 +26,8 @@ import java.util.Map; import org.apache.xmlgraphics.util.QName; +import org.apache.fop.fo.extensions.ExtensionAttachment; + /** * Abstract base class for all area tree objects. */ @@ -36,7 +38,7 @@ public abstract class AreaTreeObject { /** Extension attachments */ protected List/**/ extensionAttachments = null; - + /** * Sets a foreign attribute. * @param name the qualified name of the attribute @@ -87,21 +89,46 @@ public abstract class AreaTreeObject { return Collections.EMPTY_MAP; } } - + + private void prepareExtensionAttachmentContainer() { + if (this.extensionAttachments == null) { + this.extensionAttachments = new java.util.ArrayList/**/(); + } + } + /** - * Set extension attachments from a List + * Adds a new ExtensionAttachment instance to this page. + * @param attachment the ExtensionAttachment + */ + public void addExtensionAttachment(ExtensionAttachment attachment) { + prepareExtensionAttachmentContainer(); + extensionAttachments.add(attachment); + } + + /** + * Set extension attachments from a List * @param extensionAttachments a List with extension attachments */ public void setExtensionAttachments(List extensionAttachments) { - this.extensionAttachments = extensionAttachments; + prepareExtensionAttachmentContainer(); + this.extensionAttachments.addAll(extensionAttachments); } /** @return the extension attachments associated with this area */ public List getExtensionAttachments() { - if (this.foreignAttributes != null) { + if (this.extensionAttachments != null) { return Collections.unmodifiableList(this.extensionAttachments); } else { return Collections.EMPTY_LIST; } - } + } + + /** + * Indicates whether this area tree object has any extension attachments. + * @return true if there are extension attachments + */ + public boolean hasExtensionAttachments() { + return this.extensionAttachments != null && !this.extensionAttachments.isEmpty(); + } + } diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index a7523530b..321ca4c03 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -36,7 +35,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.extensions.ExtensionAttachment; import org.apache.fop.fo.pagination.SimplePageMaster; /** @@ -87,10 +85,6 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl private Map markerLastEnd = null; private Map markerLastAny = null; - //Arbitrary attachments to the page from extensions that need to pass information - //down to the renderers. - private List/**/ extensionAttachments = null; - /** * logging instance */ @@ -105,7 +99,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl */ public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank) { this.simplePageMasterName = spm.getMasterName(); - this.extensionAttachments = spm.getExtensionAttachments(); + setExtensionAttachments(spm.getExtensionAttachments()); this.blank = blank; int pageWidth = spm.getPageWidth().getValue(); int pageHeight = spm.getPageHeight().getValue(); @@ -122,8 +116,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl */ public PageViewport(PageViewport original) { if (original.extensionAttachments != null) { - this.extensionAttachments - = new java.util.ArrayList/**/(original.extensionAttachments); + setExtensionAttachments(original.extensionAttachments); } this.pageIndex = original.pageIndex; this.pageNumber = original.pageNumber; @@ -583,26 +576,6 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl return this.simplePageMasterName; } - /** - * Adds a new ExtensionAttachment instance to this page. - * @param attachment the ExtensionAttachment - */ - public void addExtensionAttachment(ExtensionAttachment attachment) { - if (this.extensionAttachments == null) { - this.extensionAttachments = new java.util.ArrayList/**/(); - } - extensionAttachments.add(attachment); - } - - /** @return the list of extension attachments for this page */ - public List getExtensionAttachments() { - if (this.extensionAttachments == null) { - return Collections.EMPTY_LIST; - } else { - return this.extensionAttachments; - } - } - /** @return True if this is a blank page. */ public boolean isBlank() { return this.blank; @@ -671,8 +644,4 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl return getPage().getRegionViewport(id).getRegionReference(); } - /** @return whether this page viewport has any extension attachments */ - public boolean hasExtensionAttachments() { - return this.extensionAttachments != null && !this.extensionAttachments.isEmpty(); - } } -- cgit v1.2.3