aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/area/AreaTreeModel.java22
-rw-r--r--src/java/org/apache/fop/area/AreaTreeParser.java26
-rw-r--r--src/java/org/apache/fop/area/PageSequence.java78
-rw-r--r--src/java/org/apache/fop/area/PageViewport.java15
-rw-r--r--src/java/org/apache/fop/area/RenderPagesModel.java10
5 files changed, 138 insertions, 13 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeModel.java b/src/java/org/apache/fop/area/AreaTreeModel.java
index 75783def8..74e2eb562 100644
--- a/src/java/org/apache/fop/area/AreaTreeModel.java
+++ b/src/java/org/apache/fop/area/AreaTreeModel.java
@@ -39,7 +39,8 @@ import org.apache.commons.logging.LogFactory;
public class AreaTreeModel {
private List pageSequenceList = null;
private int currentPageSequenceIndex = -1;
- private List currentPageSequencePageList;
+ /** the current page sequence */
+ protected PageSequence currentPageSequence;
private List offDocumentItems = new java.util.ArrayList();
protected static Log log = LogFactory.getLog(AreaTreeModel.class);
@@ -56,8 +57,8 @@ public class AreaTreeModel {
* @param title the title of the new page sequence
*/
public void startPageSequence(LineArea title) {
- currentPageSequencePageList = new java.util.ArrayList();
- pageSequenceList.add(currentPageSequencePageList);
+ currentPageSequence = new PageSequence(title);
+ pageSequenceList.add(currentPageSequence);
currentPageSequenceIndex = pageSequenceList.size() - 1;
}
@@ -66,13 +67,14 @@ public class AreaTreeModel {
* @param page the page to add to the model.
*/
public void addPage(PageViewport page) {
- currentPageSequencePageList.add(page);
+ currentPageSequence.addPage(page);
int pageIndex = 0;
for (int i = 0; i < currentPageSequenceIndex; i++) {
- pageIndex += ((List)pageSequenceList.get(i)).size();
+ pageIndex += ((PageSequence)pageSequenceList.get(i)).getPageCount();
}
- pageIndex += currentPageSequencePageList.size() - 1;
+ pageIndex += currentPageSequence.getPageCount() - 1;
page.setPageIndex(pageIndex);
+ page.setPageSequence(currentPageSequence);
}
/**
@@ -101,8 +103,8 @@ public class AreaTreeModel {
* @return returns the number of pages in a page sequence
*/
public int getPageCount(int seq) {
- List sequence = (List) pageSequenceList.get(seq - 1);
- return sequence.size();
+ PageSequence sequence = (PageSequence)pageSequenceList.get(seq - 1);
+ return sequence.getPageCount();
}
/**
@@ -112,7 +114,7 @@ public class AreaTreeModel {
* @return the PageViewport for the particular page
*/
public PageViewport getPage(int seq, int count) {
- List sequence = (List) pageSequenceList.get(seq - 1);
- return (PageViewport) sequence.get(count);
+ PageSequence sequence = (PageSequence)pageSequenceList.get(seq - 1);
+ return sequence.getPage(count);
}
}
diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java
index 13643f5ef..e4f1292d2 100644
--- a/src/java/org/apache/fop/area/AreaTreeParser.java
+++ b/src/java/org/apache/fop/area/AreaTreeParser.java
@@ -55,7 +55,6 @@ import org.apache.fop.fo.ElementMappingRegistry;
import org.apache.fop.fo.extensions.ExtensionAttachment;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.image.FopImage;
import org.apache.fop.image.ImageFactory;
import org.apache.fop.traits.BorderProps;
@@ -127,6 +126,7 @@ public class AreaTreeParser {
private PageViewport currentPageViewport;
private Stack areaStack = new Stack();
private boolean firstFlow;
+ private boolean pendingStartPageSequence;
private Stack delegateStack = new Stack();
private ContentHandler delegate;
@@ -141,6 +141,7 @@ public class AreaTreeParser {
makers.put("areaTree", new AreaTreeMaker());
makers.put("page", new PageMaker());
makers.put("pageSequence", new PageSequenceMaker());
+ makers.put("title", new TitleMaker());
makers.put("pageViewport", new PageViewportMaker());
makers.put("regionViewport", new RegionViewportMaker());
makers.put("regionBefore", new RegionBeforeMaker());
@@ -324,13 +325,34 @@ public class AreaTreeParser {
private class PageSequenceMaker extends AbstractMaker {
public void startElement(Attributes attributes) {
- treeModel.startPageSequence(null);
+ pendingStartPageSequence = true;
+ //treeModel.startPageSequence(null); Done after title or on the first viewport
}
}
+ private class TitleMaker extends AbstractMaker {
+
+ public void startElement(Attributes attributes) {
+ LineArea line = new LineArea();
+ areaStack.push(line);
+ }
+
+ public void endElement() {
+ LineArea line = (LineArea)areaStack.pop();
+ treeModel.startPageSequence(line);
+ pendingStartPageSequence = false;
+ }
+
+
+ }
+
private class PageViewportMaker extends AbstractMaker {
public void startElement(Attributes attributes) {
+ if (pendingStartPageSequence) {
+ treeModel.startPageSequence(null);
+ pendingStartPageSequence = false;
+ }
if (currentPageViewport != null) {
throw new IllegalStateException("currentPageViewport must be null");
}
diff --git a/src/java/org/apache/fop/area/PageSequence.java b/src/java/org/apache/fop/area/PageSequence.java
new file mode 100644
index 000000000..39cb72214
--- /dev/null
+++ b/src/java/org/apache/fop/area/PageSequence.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.area;
+
+import java.util.List;
+
+/**
+ * Represents a page sequence in the area tree.
+ */
+public class PageSequence {
+
+ private List pages = new java.util.ArrayList();
+ private LineArea title;
+
+ /**
+ * Main constructor
+ * @param title the title for the page-sequence, may be null
+ */
+ public PageSequence(LineArea title) {
+ this.title = title;
+ }
+
+ /**
+ * @return the title of the page sequence in form of a line area, or null if there's no title
+ */
+ public LineArea getTitle() {
+ return this.title;
+ }
+
+ /**
+ * Adds a new page to the page sequence
+ * @param page the page to be added
+ */
+ public void addPage(PageViewport page) {
+ this.pages.add(page);
+ }
+
+ /**
+ * @return the number of pages currently in this page sequence
+ */
+ public int getPageCount() {
+ return this.pages.size();
+ }
+
+ /**
+ * Returns the page at the given index.
+ * @param idx the index of the requested page
+ * @return the requested page or null if it was not found
+ */
+ public PageViewport getPage(int idx) {
+ return (PageViewport)this.pages.get(idx);
+ }
+
+ /**
+ * Indicates whether a page is the first in this page sequence.
+ * @param page the page to be inspected
+ * @return true if the page is the first in this page sequence, false otherwise
+ */
+ public boolean isFirstPage(PageViewport page) {
+ return page.equals(getPage(0));
+ }
+}
diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java
index f1c12495d..f2fbd0555 100644
--- a/src/java/org/apache/fop/area/PageViewport.java
+++ b/src/java/org/apache/fop/area/PageViewport.java
@@ -52,6 +52,8 @@ public class PageViewport implements Resolvable, Cloneable {
private String pageNumberString = null;
private int pageIndex = -1; //-1 = undetermined
private boolean blank;
+
+ private transient PageSequence pageSequence;
// list of id references and the rectangle on the page
//private Map idReferences = null;
@@ -134,6 +136,19 @@ public class PageViewport implements Resolvable, Cloneable {
}
/**
+ * Sets the page sequence this page belongs to
+ * @param seq the page sequence
+ */
+ public void setPageSequence(PageSequence seq) {
+ this.pageSequence = seq;
+ }
+
+ /** @return the page sequence this page belongs to */
+ public PageSequence getPageSequence() {
+ return this.pageSequence;
+ }
+
+ /**
* Get the view area rectangle of this viewport.
* @return the rectangle for this viewport
*/
diff --git a/src/java/org/apache/fop/area/RenderPagesModel.java b/src/java/org/apache/fop/area/RenderPagesModel.java
index f4ae85fe7..afb55e22e 100644
--- a/src/java/org/apache/fop/area/RenderPagesModel.java
+++ b/src/java/org/apache/fop/area/RenderPagesModel.java
@@ -90,7 +90,9 @@ public class RenderPagesModel extends AreaTreeModel {
*/
public void startPageSequence(LineArea title) {
super.startPageSequence(title);
- renderer.startPageSequence(title);
+ if (renderer.supportsOutOfOrder()) {
+ renderer.startPageSequence(title);
+ }
}
/**
@@ -110,6 +112,9 @@ public class RenderPagesModel extends AreaTreeModel {
// could be referenced
boolean ready = renderer.supportsOutOfOrder() && page.isResolved();
if (ready) {
+ if (!renderer.supportsOutOfOrder() && page.getPageSequence().isFirstPage(page)) {
+ renderer.startPageSequence(this.currentPageSequence.getTitle());
+ }
try {
renderer.renderPage(page);
} catch (Exception e) {
@@ -149,6 +154,9 @@ public class RenderPagesModel extends AreaTreeModel {
for (Iterator iter = prepared.iterator(); iter.hasNext();) {
PageViewport p = (PageViewport)iter.next();
if (p.isResolved() || renderUnresolved) {
+ if (!renderer.supportsOutOfOrder() && p.getPageSequence().isFirstPage(p)) {
+ renderer.startPageSequence(this.currentPageSequence.getTitle());
+ }
try {
renderer.renderPage(p);
if (!p.isResolved()) {