aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/area
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2002-05-17 14:47:13 +0000
committerKeiron Liddle <keiron@apache.org>2002-05-17 14:47:13 +0000
commit419405d1934e8a9b7ba9cc9e44fb967c39cafa19 (patch)
tree56be2377226eb9aea407f7487e516b40a2a6462f /src/org/apache/fop/area
parent7be7b7e54762346f41ab92f4b92bae326811df95 (diff)
downloadxmlgraphics-fop-419405d1934e8a9b7ba9cc9e44fb967c39cafa19.tar.gz
xmlgraphics-fop-419405d1934e8a9b7ba9cc9e44fb967c39cafa19.zip
cleaned up bookmark extension a bit
make multi page sequences work properly git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194825 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/area')
-rw-r--r--src/org/apache/fop/area/AreaTree.java35
-rw-r--r--src/org/apache/fop/area/BodyRegion.java9
-rw-r--r--src/org/apache/fop/area/Page.java23
-rw-r--r--src/org/apache/fop/area/PageViewport.java12
-rw-r--r--src/org/apache/fop/area/Region.java41
-rw-r--r--src/org/apache/fop/area/RegionReference.java8
-rw-r--r--src/org/apache/fop/area/RegionViewport.java10
-rw-r--r--src/org/apache/fop/area/Resolveable.java26
-rw-r--r--src/org/apache/fop/area/TreeExt.java16
-rw-r--r--src/org/apache/fop/area/inline/Unresolved.java13
-rw-r--r--src/org/apache/fop/area/inline/UnresolvedPageNumber.java16
11 files changed, 150 insertions, 59 deletions
diff --git a/src/org/apache/fop/area/AreaTree.java b/src/org/apache/fop/area/AreaTree.java
index 67b6ecdd6..387646815 100644
--- a/src/org/apache/fop/area/AreaTree.java
+++ b/src/org/apache/fop/area/AreaTree.java
@@ -10,6 +10,7 @@ package org.apache.fop.area;
import org.apache.fop.render.Renderer;
import java.util.ArrayList;
+import java.util.HashMap;
/**
* Area tree for formatting objects.
@@ -33,6 +34,12 @@ public class AreaTree {
// in different situations
AreaTreeModel model;
+ // hashmap of arraylists containing pages with id area
+ HashMap idLocations = new HashMap();
+ // list of id's yet to be resolved and arraylists of pages
+ HashMap resolve = new HashMap();
+ ArrayList treeExtensions = new ArrayList();
+
public RenderPagesModel createRenderPagesModel(Renderer rend) {
return new RenderPagesModel(rend);
}
@@ -53,6 +60,28 @@ public class AreaTree {
model.addPage(page);
}
+ public void addTreeExtension(TreeExt ext) {
+ treeExtensions.add(ext);
+ if(ext.isResolveable()) {
+ Resolveable res = (Resolveable)ext;
+ String[] ids = res.getIDs();
+ for(int count = 0; count < ids.length; count++) {
+ if(idLocations.containsKey(ids[count])) {
+ res.resolve(ids[count], (ArrayList)idLocations.get(ids[count]));
+ } else {
+ ArrayList todo = (ArrayList)resolve.get(ids[count]);
+ if(todo == null) {
+ todo = new ArrayList();
+ todo.add(ext);
+ resolve.put(ids[count], todo);
+ } else {
+ todo.add(ext);
+ }
+ }
+ }
+ }
+ }
+
// this is the model for the area tree object
public static abstract class AreaTreeModel {
public abstract void startPageSequence(Title title);
@@ -119,7 +148,11 @@ public class AreaTree {
public void addPage(PageViewport page) {
super.addPage(page);
// if page finished
- //renderer.renderPage(page);
+ try {
+ renderer.renderPage(page);
+ } catch(Exception e) {
+ // use error handler to handle this FOP or IO Exception
+ }
page.clear();
// else prepare
//renderer.preparePage(page);
diff --git a/src/org/apache/fop/area/BodyRegion.java b/src/org/apache/fop/area/BodyRegion.java
index e9dcd11f6..5897a27cd 100644
--- a/src/org/apache/fop/area/BodyRegion.java
+++ b/src/org/apache/fop/area/BodyRegion.java
@@ -80,4 +80,13 @@ public class BodyRegion extends RegionReference {
public MinOptMax getMaxBPD() {
return maxBPD;
}
+
+ public Object clone() {
+ BodyRegion br = new BodyRegion();
+ br.setCTM(getCTM());
+ br.setIPD(getIPD());
+ br.columnGap = columnGap;
+ br.columnCount = columnCount;
+ return br;
+ }
}
diff --git a/src/org/apache/fop/area/Page.java b/src/org/apache/fop/area/Page.java
index 1ee53bccc..3289fdaf3 100644
--- a/src/org/apache/fop/area/Page.java
+++ b/src/org/apache/fop/area/Page.java
@@ -8,8 +8,9 @@
package org.apache.fop.area;
import java.io.Serializable;
+import java.util.HashMap;
-public class Page implements Serializable {
+public class Page implements Serializable, Cloneable {
// contains before, start, body, end and after regions
RegionViewport regionBefore = null;
RegionViewport regionStart = null;
@@ -17,6 +18,11 @@ public class Page implements Serializable {
RegionViewport regionEnd = null;
RegionViewport regionAfter = null;
+ // hashmap of markers for this page
+ // start and end are added by the fo that contains the markers
+ HashMap markerStart = null;
+ HashMap markerEnd = null;
+
public void setRegion(int areaclass, RegionViewport port) {
if (areaclass == RegionReference.BEFORE) {
regionBefore = port;
@@ -46,4 +52,19 @@ public class Page implements Serializable {
return null;
}
+ public Object clone() {
+ Page p = new Page();
+ if(regionBefore != null)
+ p.regionBefore = (RegionViewport)regionBefore.clone();
+ if(regionStart != null)
+ p.regionStart = (RegionViewport)regionStart.clone();
+ if(regionBody != null)
+ p.regionBody = (RegionViewport)regionBody.clone();
+ if(regionEnd != null)
+ p.regionEnd = (RegionViewport)regionEnd.clone();
+ if(regionAfter != null)
+ p.regionAfter = (RegionViewport)regionAfter.clone();
+
+ return p;
+ }
}
diff --git a/src/org/apache/fop/area/PageViewport.java b/src/org/apache/fop/area/PageViewport.java
index 3fdab2b60..09f5b71b3 100644
--- a/src/org/apache/fop/area/PageViewport.java
+++ b/src/org/apache/fop/area/PageViewport.java
@@ -14,7 +14,7 @@ import java.util.ArrayList;
// this is the level that creates the page
// the page (reference area) is then rendered inside the page object
-public class PageViewport {
+public class PageViewport implements Cloneable {
Page page;
Rectangle2D viewArea;
boolean clip = false;
@@ -29,7 +29,7 @@ public class PageViewport {
ArrayList idReferences = null;
// this keeps a list of currently unresolved areas or extensions
- // once the things is resolved it is removed
+ // once the thing is resolved it is removed
// when this is empty the page can be rendered
ArrayList unresolved = null;
@@ -55,9 +55,15 @@ public class PageViewport {
page = (Page) in.readObject();
}
+ public Object clone() {
+ Page p = (Page)page.clone();
+ PageViewport ret = new PageViewport(p, (Rectangle2D)viewArea.clone());
+ return ret;
+ }
+
/**
* Clear the page contents to save memory.
- * THis objects is kept for the life of the area tree since
+ * This object is kept for the life of the area tree since
* it holds id information and is used as a key.
*/
public void clear() {
diff --git a/src/org/apache/fop/area/Region.java b/src/org/apache/fop/area/Region.java
deleted file mode 100644
index 47f2dbfd9..000000000
--- a/src/org/apache/fop/area/Region.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.area;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Region implements Serializable {
- public static final int BEFORE = 0;
- public static final int START = 1;
- public static final int BODY = 2;
- public static final int END = 3;
- public static final int AFTER = 4;
- int regionClass = BEFORE;
-
- public Region(int type) {
- regionClass = type;
- }
-
- // the list of block areas from the static flow
- ArrayList blocks = new ArrayList();
-
- public List getBlocks() {
- return blocks;
- }
-
- public int getRegionClass() {
- return regionClass;
- }
-
- public void addBlock(Block block) {
- blocks.add(block);
- }
-
-}
diff --git a/src/org/apache/fop/area/RegionReference.java b/src/org/apache/fop/area/RegionReference.java
index f63889c7e..7d1f60674 100644
--- a/src/org/apache/fop/area/RegionReference.java
+++ b/src/org/apache/fop/area/RegionReference.java
@@ -11,7 +11,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-public class RegionReference extends Area implements Serializable {
+public class RegionReference extends Area implements Serializable, Cloneable {
public static final int BEFORE = 0;
public static final int START = 1;
public static final int BODY = 2;
@@ -55,4 +55,10 @@ public class RegionReference extends Area implements Serializable {
blocks.add(block);
}
+ public Object clone() {
+ RegionReference rr = new RegionReference(regionClass);
+ rr.ctm = ctm;
+ rr.setIPD(getIPD());
+ return rr;
+ }
}
diff --git a/src/org/apache/fop/area/RegionViewport.java b/src/org/apache/fop/area/RegionViewport.java
index 260f6ab45..85c8bf8a3 100644
--- a/src/org/apache/fop/area/RegionViewport.java
+++ b/src/org/apache/fop/area/RegionViewport.java
@@ -11,7 +11,7 @@ import java.awt.geom.Rectangle2D;
import java.io.Serializable;
import java.io.IOException;
-public class RegionViewport extends Area implements Serializable {
+public class RegionViewport extends Area implements Serializable, Cloneable {
// this rectangle is relative to the page
RegionReference region;
Rectangle2D viewArea;
@@ -19,7 +19,7 @@ public class RegionViewport extends Area implements Serializable {
public RegionViewport(Rectangle2D viewArea) {
- this.viewArea =viewArea;
+ this.viewArea = viewArea;
}
public void setRegion(RegionReference reg) {
@@ -57,4 +57,10 @@ public class RegionViewport extends Area implements Serializable {
setRegion( (RegionReference) in.readObject());
}
+ public Object clone() {
+ RegionViewport rv = new RegionViewport((Rectangle2D)viewArea.clone());
+ rv.region = (RegionReference)region.clone();
+ rv.region.setParent(rv);
+ return rv;
+ }
}
diff --git a/src/org/apache/fop/area/Resolveable.java b/src/org/apache/fop/area/Resolveable.java
new file mode 100644
index 000000000..d0eeabc51
--- /dev/null
+++ b/src/org/apache/fop/area/Resolveable.java
@@ -0,0 +1,26 @@
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+
+package org.apache.fop.area;
+
+import java.util.ArrayList;
+
+public interface Resolveable {
+
+ public boolean isResolved();
+
+ public String[] getIDs();
+
+ /**
+ * This resolves reference with a list of pages.
+ * The pages (PageViewport) contain the rectangle of the area.
+ * @param id the id to resolve
+ * @param pages the list of pages with the id area
+ * may be null if not found
+ */
+ public void resolve(String id, ArrayList pages);
+}
diff --git a/src/org/apache/fop/area/TreeExt.java b/src/org/apache/fop/area/TreeExt.java
new file mode 100644
index 000000000..49fc2beaa
--- /dev/null
+++ b/src/org/apache/fop/area/TreeExt.java
@@ -0,0 +1,16 @@
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+
+package org.apache.fop.area;
+
+/**
+ */
+public interface TreeExt {
+ public boolean isResolveable();
+ public String getMimeType();
+ public String getName();
+}
diff --git a/src/org/apache/fop/area/inline/Unresolved.java b/src/org/apache/fop/area/inline/Unresolved.java
index 2169c9410..8af0c9f0c 100644
--- a/src/org/apache/fop/area/inline/Unresolved.java
+++ b/src/org/apache/fop/area/inline/Unresolved.java
@@ -7,14 +7,13 @@
package org.apache.fop.area.inline;
-public class Unresolved extends InlineArea {
- boolean resolved = false;
-
- // id ref
- // resolve
- // resolve without area
+import org.apache.fop.area.Resolveable;
- public void resolve() {
+public abstract class Unresolved extends InlineArea implements Resolveable {
+ boolean resolved = false;
+ public boolean isResolved() {
+ return resolved;
}
+
}
diff --git a/src/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/org/apache/fop/area/inline/UnresolvedPageNumber.java
index c8ac17d3a..ddc85d327 100644
--- a/src/org/apache/fop/area/inline/UnresolvedPageNumber.java
+++ b/src/org/apache/fop/area/inline/UnresolvedPageNumber.java
@@ -7,10 +7,20 @@
package org.apache.fop.area.inline;
+import java.util.ArrayList;
+
public class UnresolvedPageNumber extends Unresolved {
+ String pageRefId;
+
+ public UnresolvedPageNumber(String id) {
+ pageRefId = id;
+ }
- // id ref
- // resolve
- // resolve without area
+ public String[] getIDs() {
+ return new String[] {pageRefId};
+ }
+ public void resolve(String id, ArrayList pages) {
+ resolved = true;
+ }
}