aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/area
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2009-01-16 15:55:58 +0000
committerJeremias Maerki <jeremias@apache.org>2009-01-16 15:55:58 +0000
commit6217309d81ef8d8cbecc59840b2b84355fd7c9d4 (patch)
tree4c02dd438e931b68ba1e4cd16d3f605ee48aef75 /src/java/org/apache/fop/area
parent1cf035b8733c3fa00d3d9a19e40e41fdea5db13d (diff)
parentbb61ea868317c73715c05a1b40c88488758e5049 (diff)
downloadxmlgraphics-fop-6217309d81ef8d8cbecc59840b2b84355fd7c9d4.tar.gz
xmlgraphics-fop-6217309d81ef8d8cbecc59840b2b84355fd7c9d4.zip
Merge from Trunk revisions 731480 - 735028.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@735038 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/area')
-rw-r--r--src/java/org/apache/fop/area/AreaTreeObject.java39
-rw-r--r--src/java/org/apache/fop/area/PageViewport.java35
2 files changed, 35 insertions, 39 deletions
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/*<ExtensionAttachment>*/ 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/*<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();
+ }
+
}
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/*<ExtensionAttachment>*/ 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/*<ExtensionAttachment>*/(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/*<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 @@ 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();
- }
}