aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/area
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2002-11-03 16:24:22 +0000
committerKeiron Liddle <keiron@apache.org>2002-11-03 16:24:22 +0000
commit0dafe4daaa3857d147ab4bfa41f54bb817213356 (patch)
tree9a557cc19b0816f005d0bb05947d6ab6681d590c /src/org/apache/fop/area
parent2efc29b2fe29ea1ea0e0b425bddae586c4fe4692 (diff)
downloadxmlgraphics-fop-0dafe4daaa3857d147ab4bfa41f54bb817213356.tar.gz
xmlgraphics-fop-0dafe4daaa3857d147ab4bfa41f54bb817213356.zip
fixed link/resolving problem
made sure area tree is serializable git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195405 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/area')
-rw-r--r--src/org/apache/fop/area/AreaTree.java31
-rw-r--r--src/org/apache/fop/area/CachedRenderPagesModel.java46
-rw-r--r--src/org/apache/fop/area/PageViewport.java11
-rw-r--r--src/org/apache/fop/area/Trait.java4
4 files changed, 60 insertions, 32 deletions
diff --git a/src/org/apache/fop/area/AreaTree.java b/src/org/apache/fop/area/AreaTree.java
index b82368c0d..8d03f6a0f 100644
--- a/src/org/apache/fop/area/AreaTree.java
+++ b/src/org/apache/fop/area/AreaTree.java
@@ -397,23 +397,31 @@ public class AreaTree {
public void addPage(PageViewport page) {
super.addPage(page);
- // check prepared pages
- boolean cont = checkPreparedPages();
-
- // if page finished
- if (cont && page.isResolved()) {
+ // for links the renderer needs to prepare the page
+ // it is more appropriate to do this after queued pages but
+ // it will mean that the renderer has not prepared a page that
+ // could be referenced
+ boolean done = renderer.supportsOutOfOrder() && page.isResolved();
+ if (done) {
try {
renderer.renderPage(page);
} catch (Exception e) {
// use error handler to handle this FOP or IO Exception
+ e.printStackTrace();
}
page.clear();
} else {
preparePage(page);
}
- renderExtensions(pendingExt);
- pendingExt.clear();
+
+ // check prepared pages
+ boolean cont = checkPreparedPages(page);
+
+ if (cont) {
+ renderExtensions(pendingExt);
+ pendingExt.clear();
+ }
}
/**
@@ -422,7 +430,7 @@ public class AreaTree {
* false if the renderer doesn't support out of order
* rendering and there are pending pages
*/
- protected boolean checkPreparedPages() {
+ protected boolean checkPreparedPages(PageViewport newpage) {
for (Iterator iter = prepared.iterator(); iter.hasNext();) {
PageViewport p = (PageViewport)iter.next();
if (p.isResolved()) {
@@ -430,6 +438,7 @@ public class AreaTree {
renderer.renderPage(p);
} catch (Exception e) {
// use error handler to handle this FOP or IO Exception
+ e.printStackTrace();
}
p.clear();
iter.remove();
@@ -491,7 +500,11 @@ public class AreaTree {
*/
public void endDocument() {
// render any pages that had unresolved ids
- checkPreparedPages();
+ checkPreparedPages(null);
+
+ renderExtensions(pendingExt);
+ pendingExt.clear();
+
renderExtensions(endDocExt);
}
}
diff --git a/src/org/apache/fop/area/CachedRenderPagesModel.java b/src/org/apache/fop/area/CachedRenderPagesModel.java
index f706a8de4..43c35f91b 100644
--- a/src/org/apache/fop/area/CachedRenderPagesModel.java
+++ b/src/org/apache/fop/area/CachedRenderPagesModel.java
@@ -45,30 +45,33 @@ public class CachedRenderPagesModel extends AreaTree.RenderPagesModel {
* false if the renderer doesn't support out of order
* rendering and there are pending pages
*/
- protected boolean checkPreparedPages() {
+ protected boolean checkPreparedPages(PageViewport newpage) {
for (Iterator iter = prepared.iterator(); iter.hasNext();) {
PageViewport p = (PageViewport)iter.next();
if (p.isResolved()) {
- try {
- // load page from cache
- String name = (String)pageMap.get(p);
- File temp = new File(name);
- System.out.println("page serialized to: " + temp.length());
- ObjectInputStream in = new ObjectInputStream(
- new BufferedInputStream(
- new FileInputStream(temp)));
- p.loadPage(in);
- in.close();
- temp.delete();
- pageMap.remove(p);
- } catch (Exception e) {
- e.printStackTrace();
+ if(p != newpage) {
+ try {
+ // load page from cache
+ String name = (String)pageMap.get(p);
+ File temp = new File(name);
+ System.out.println("page serialized to: " + temp.length());
+ ObjectInputStream in = new ObjectInputStream(
+ new BufferedInputStream(
+ new FileInputStream(temp)));
+ p.loadPage(in);
+ in.close();
+ temp.delete();
+ pageMap.remove(p);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
try {
renderer.renderPage(p);
} catch (Exception e) {
// use error handler to handle this FOP or IO Exception
+ e.printStackTrace();
}
p.clear();
iter.remove();
@@ -78,18 +81,19 @@ public class CachedRenderPagesModel extends AreaTree.RenderPagesModel {
}
}
}
+ if(newpage != null && newpage.getPage() != null) {
+ savePage(newpage);
+ }
return renderer.supportsOutOfOrder() || prepared.isEmpty();
}
/**
- * Prepare a page.
- * This uses the parent to prepare the page.
- * It then saves the contents of the page to a file.
+ * Save a page.
+ * It saves the contents of the page to a file.
+ *
* @param page the page to prepare
*/
- protected void preparePage(PageViewport page) {
- super.preparePage(page);
-
+ protected void savePage(PageViewport page) {
try {
// save page to cache
ObjectOutputStream tempstream;
diff --git a/src/org/apache/fop/area/PageViewport.java b/src/org/apache/fop/area/PageViewport.java
index e1e15dba0..aaf495d14 100644
--- a/src/org/apache/fop/area/PageViewport.java
+++ b/src/org/apache/fop/area/PageViewport.java
@@ -90,6 +90,17 @@ public class PageViewport implements Resolveable, Cloneable {
}
/**
+ * Get the key for this page viewport.
+ * This is used so that a serializable key can be used to
+ * lookup the page or some other reference.
+ *
+ * @return a unique page viewport key for this area tree
+ */
+ public String getKey() {
+ return toString();
+ }
+
+ /**
* Add an unresolved id to this page.
* All unresolved ids for the contents of this page are
* added to this page. This is so that the resolvers can be
diff --git a/src/org/apache/fop/area/Trait.java b/src/org/apache/fop/area/Trait.java
index b9ebd8f76..a8943e577 100644
--- a/src/org/apache/fop/area/Trait.java
+++ b/src/org/apache/fop/area/Trait.java
@@ -117,7 +117,7 @@ public class Trait implements Serializable {
shmTraitInfo = new HashMap();
shmTraitInfo.put(ID_LINK, new TraitInfo("id-link", String.class));
shmTraitInfo.put(INTERNAL_LINK,
- new TraitInfo("internal-link", PageViewport.class));
+ new TraitInfo("internal-link", String.class));
shmTraitInfo.put(EXTERNAL_LINK,
new TraitInfo("external-link", String.class));
shmTraitInfo.put(FONT_NAME,
@@ -229,7 +229,7 @@ public class Trait implements Serializable {
return null;
}
- public static class Background {
+ public static class Background implements Serializable {
public ColorType color = null;
public String url = null;
public int repeat;