Author: jeremias
Date: Fri Jan 16 06:29:39 2009
New Revision: 735026

URL: http://svn.apache.org/viewvc?rev=735026&view=rev
Log:
Removed duplicated extension attachment list on PageViewport (which is an 
AreaTreeObject subclass and therefore already has that list).

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeObject.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeObject.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeObject.java?rev=735026&r1=735025&r2=735026&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeObject.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeObject.java Fri 
Jan 16 06:29:39 2009
@@ -26,6 +26,8 @@
 
 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 @@
 
     /** Extension attachments */
     protected List/*<ExtensionAttachment>*/ extensionAttachments = null;
-    
+
     /**
      * Sets a foreign attribute.
      * @param name the qualified name of the attribute
@@ -87,21 +89,46 @@
             return Collections.EMPTY_MAP;
         }
     }
-    
+
+    private void prepareExtensionAttachmentContainer() {
+        if (this.extensionAttachments == null) {
+            this.extensionAttachments = new 
java.util.ArrayList/*<ExtensionAttachment>*/();
+        }
+    }
+
     /**
-     * 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();
+    }
+
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java?rev=735026&r1=735025&r2=735026&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageViewport.java Fri 
Jan 16 06:29:39 2009
@@ -25,7 +25,6 @@
 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.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 @@
     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/*<ExtensionAttachment>*/ extensionAttachments = null;
-
     /**
      * logging instance
      */
@@ -105,7 +99,7 @@
      */
     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 PageViewport(PageViewport original) {
         if (original.extensionAttachments != null) {
-            this.extensionAttachments
-                = new 
java.util.ArrayList/*<ExtensionAttachment>*/(original.extensionAttachments);
+            setExtensionAttachments(original.extensionAttachments);
         }
         this.pageIndex = original.pageIndex;
         this.pageNumber = original.pageNumber;
@@ -583,26 +576,6 @@
         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/*<ExtensionAttachment>*/();
-        }
-        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 @@
         return getPage().getRegionViewport(id).getRegionReference();
     }
 
-    /** @return whether this page viewport has any extension attachments */
-    public boolean hasExtensionAttachments() {
-        return this.extensionAttachments != null && 
!this.extensionAttachments.isEmpty();
-    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to