aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/area
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/area')
-rw-r--r--src/java/org/apache/fop/area/Area.java62
-rw-r--r--src/java/org/apache/fop/area/RegionViewport.java7
2 files changed, 64 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java
index b0916abda..51c95f0ca 100644
--- a/src/java/org/apache/fop/area/Area.java
+++ b/src/java/org/apache/fop/area/Area.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,13 +20,15 @@ package org.apache.fop.area;
import java.io.Serializable;
+import java.util.Collections;
+import java.util.Iterator;
import java.util.Map;
-import java.util.HashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.traits.BorderProps;
+import org.apache.fop.util.QName;
// If the area appears more than once in the output
// or if the area has external data it is cached
@@ -129,8 +131,11 @@ public class Area implements Serializable {
/**
* Traits for this area stored in a HashMap
*/
- protected HashMap props = null;
+ protected Map props = null;
+ /** Foreign attributes */
+ protected Map foreignAttributes = null;
+
/**
* logging instance
*/
@@ -462,6 +467,57 @@ public class Area implements Serializable {
}
}
+ /**
+ * Sets a foreign attribute.
+ * @param name the qualified name of the attribute
+ * @param value the attribute value
+ */
+ public void setForeignAttribute(QName name, String value) {
+ if (this.foreignAttributes == null) {
+ this.foreignAttributes = new java.util.HashMap();
+ }
+ this.foreignAttributes.put(name, value);
+ }
+
+ /**
+ * Set foreign attributes from a Map.
+ * @param atts a Map with attributes (keys: QName, values: String)
+ */
+ public void setForeignAttributes(Map atts) {
+ if (atts.size() == 0) {
+ return;
+ }
+ Iterator iter = atts.keySet().iterator();
+ while (iter.hasNext()) {
+ QName qName = (QName)iter.next();
+ String value = (String)atts.get(qName);
+ //The casting is only to ensure type safety (too bad we can't use generics, yet)
+ setForeignAttribute(qName, value);
+ }
+ }
+
+ /**
+ * Returns the value of a foreign attribute on the area.
+ * @param name the qualified name of the attribute
+ * @return the attribute value or null if it isn't set
+ */
+ public String getForeignAttributeValue(QName name) {
+ if (this.foreignAttributes != null) {
+ return (String)this.foreignAttributes.get(name);
+ } else {
+ return null;
+ }
+ }
+
+ /** @return the foreign attributes associated with this area */
+ public Map getForeignAttributes() {
+ if (this.foreignAttributes != null) {
+ return Collections.unmodifiableMap(this.foreignAttributes);
+ } else {
+ return Collections.EMPTY_MAP;
+ }
+ }
+
/** @see java.lang.Object#toString() */
public String toString() {
StringBuffer sb = new StringBuffer(super.toString());
diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java
index ff3146e17..23017fded 100644
--- a/src/java/org/apache/fop/area/RegionViewport.java
+++ b/src/java/org/apache/fop/area/RegionViewport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -115,7 +115,10 @@ public class RegionViewport extends Area implements Cloneable {
RegionViewport rv = new RegionViewport((Rectangle2D)viewArea.clone());
rv.regionReference = (RegionReference)regionReference.clone();
if (props != null) {
- rv.props = (HashMap)props.clone();
+ rv.props = new HashMap(props);
+ }
+ if (foreignAttributes != null) {
+ rv.foreignAttributes = new HashMap(foreignAttributes);
}
return rv;
}