aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-12-21 10:20:56 +0000
committerJeremias Maerki <jeremias@apache.org>2005-12-21 10:20:56 +0000
commitde1fb96b25101d6a98bcd8f6b654c157ef954649 (patch)
tree837f04125653bd68c4e9d13cebab83fbb5acacb7 /src/java/org/apache
parent1a6c78d1f1d83622ce5b095807bef63c4fe2588b (diff)
downloadxmlgraphics-fop-de1fb96b25101d6a98bcd8f6b654c157ef954649.tar.gz
xmlgraphics-fop-de1fb96b25101d6a98bcd8f6b654c157ef954649.zip
Further decoupling the area tree from the FO tree.
Created a new class org.apache.fop.layoutmgr.Page that holds a reference to the generating SimplePageMaster and the PageViewport. A deserialized area tree doesn't need a reference to the SimplePageMaster. Renamed PageViewportProvider to PageProvider as it now returns Page instances, not (directly) PageViewports. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@358254 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/area/Page.java14
-rw-r--r--src/java/org/apache/fop/area/PageViewport.java89
-rw-r--r--src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java20
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractBreaker.java8
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java9
-rw-r--r--src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/Page.java48
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java183
-rw-r--r--src/java/org/apache/fop/render/ps/PSRenderer.java6
11 files changed, 230 insertions, 163 deletions
diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java
index 3f03bfa8a..cc920b993 100644
--- a/src/java/org/apache/fop/area/Page.java
+++ b/src/java/org/apache/fop/area/Page.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 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.
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-/* $Id: Page.java,v 1.4 2004/02/27 17:41:26 jeremias Exp $ */
+/* $Id$ */
package org.apache.fop.area;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.LengthBase;
@@ -54,7 +54,7 @@ public class Page implements Serializable, Cloneable {
private RegionViewport regionAfter = null;
// temporary map of unresolved objects used when serializing the page
- private HashMap unresolved = null;
+ private Map unresolved = null;
/** Set to true to make this page behave as if it were not empty. */
private boolean fakeNonEmpty = false;
@@ -269,9 +269,9 @@ public class Page implements Serializable, Cloneable {
/**
* Set the unresolved references on this page for serializing.
*
- * @param unres the HashMap of unresolved objects
+ * @param unres the Map of unresolved objects
*/
- public void setUnresolvedReferences(HashMap unres) {
+ public void setUnresolvedReferences(Map unres) {
unresolved = unres;
}
@@ -282,7 +282,7 @@ public class Page implements Serializable, Cloneable {
*
* @return the de-serialized HashMap of unresolved objects
*/
- public HashMap getUnresolvedReferences() {
+ public Map getUnresolvedReferences() {
return unresolved;
}
diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java
index 2cced4a5f..f1daaa2f1 100644
--- a/src/java/org/apache/fop/area/PageViewport.java
+++ b/src/java/org/apache/fop/area/PageViewport.java
@@ -46,19 +46,18 @@ public class PageViewport implements Resolvable, Cloneable {
private Page page;
private Rectangle2D viewArea;
- private boolean clip = false;
+ private String simplePageMasterName;
private String pageNumberString = null;
private int pageIndex = -1; //-1 = undetermined
- private SimplePageMaster spm = null;
private boolean blank;
// list of id references and the rectangle on the page
- private Map idReferences = null;
+ //private Map idReferences = null;
// this keeps a list of currently unresolved areas or extensions
// once an idref is resolved it is removed
// when this is empty the page can be rendered
- private HashMap unresolvedIDRefs = new HashMap();
+ private Map unresolvedIDRefs = new java.util.HashMap();
private Map pendingResolved = null;
@@ -69,6 +68,10 @@ public class PageViewport implements Resolvable, Cloneable {
private Map markerFirstAny = null;
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 extensionAttachments = null;
/**
* logging instance
@@ -82,7 +85,8 @@ public class PageViewport implements Resolvable, Cloneable {
* @param blank true if this is a blank page
*/
public PageViewport(SimplePageMaster spm, String pageStr, boolean blank) {
- this.spm = spm;
+ this.simplePageMasterName = spm.getMasterName();
+ this.extensionAttachments = spm.getExtensionAttachments();
this.blank = blank;
int pageWidth = spm.getPageWidth().getValue();
int pageHeight = spm.getPageHeight().getValue();
@@ -93,25 +97,14 @@ public class PageViewport implements Resolvable, Cloneable {
}
/**
- * Create a page viewport
- * @param spm SimplePageMaster indicating the page and region dimensions
- * @param pageStr the page number as string.
- * @param p Page Reference Area
- * @param bounds Page Viewport dimensions
+ * Copy constructor.
+ * @param original the original PageViewport to copy from
*/
- public PageViewport(SimplePageMaster spm, String pageStr, Page p, Rectangle2D bounds) {
- this.spm = spm;
- this.pageNumberString = pageStr;
- this.page = p;
- this.viewArea = bounds;
- }
-
- /**
- * Set if this viewport should clip.
- * @param c true if this viewport should clip
- */
- public void setClip(boolean c) {
- clip = c;
+ public PageViewport(PageViewport original) {
+ this.extensionAttachments = new java.util.ArrayList(original.extensionAttachments);
+ this.pageNumberString = original.pageNumberString;
+ this.page = (Page)original.page.clone();
+ this.viewArea = (Rectangle2D)original.viewArea.clone();
}
/**
@@ -280,11 +273,17 @@ public class PageViewport implements Resolvable, Cloneable {
Object key = iter.next();
if (!markerFirstStart.containsKey(key)) {
markerFirstStart.put(key, marks.get(key));
- log.trace("page " + pageNumberString + ": " + "Adding marker " + key + " to FirstStart");
+ if (log.isTraceEnabled()) {
+ log.trace("page " + pageNumberString + ": "
+ + "Adding marker " + key + " to FirstStart");
+ }
}
if (!markerFirstAny.containsKey(key)) {
markerFirstAny.put(key, marks.get(key));
- log.trace("page " + pageNumberString + ": " + "Adding marker " + key + " to FirstAny");
+ if (log.isTraceEnabled()) {
+ log.trace("page " + pageNumberString + ": "
+ + "Adding marker " + key + " to FirstAny");
+ }
}
}
if (markerLastStart == null) {
@@ -292,7 +291,10 @@ public class PageViewport implements Resolvable, Cloneable {
}
// last on page: replace all
markerLastStart.putAll(marks);
- log.trace("page " + pageNumberString + ": " + "Adding all markers to LastStart");
+ if (log.isTraceEnabled()) {
+ log.trace("page " + pageNumberString + ": "
+ + "Adding all markers to LastStart");
+ }
} else {
if (markerFirstAny == null) {
markerFirstAny = new HashMap();
@@ -302,7 +304,10 @@ public class PageViewport implements Resolvable, Cloneable {
Object key = iter.next();
if (!markerFirstAny.containsKey(key)) {
markerFirstAny.put(key, marks.get(key));
- log.trace("page " + pageNumberString + ": " + "Adding marker " + key + " to FirstAny");
+ if (log.isTraceEnabled()) {
+ log.trace("page " + pageNumberString + ": "
+ + "Adding marker " + key + " to FirstAny");
+ }
}
}
}
@@ -314,14 +319,20 @@ public class PageViewport implements Resolvable, Cloneable {
}
// last on page: replace all
markerLastEnd.putAll(marks);
- log.trace("page " + pageNumberString + ": " + "Adding all markers to LastEnd");
+ if (log.isTraceEnabled()) {
+ log.trace("page " + pageNumberString + ": "
+ + "Adding all markers to LastEnd");
+ }
}
if (markerLastAny == null) {
markerLastAny = new HashMap();
}
// last on page: replace all
markerLastAny.putAll(marks);
- log.trace("page " + pageNumberString + ": " + "Adding all markers to LastAny");
+ if (log.isTraceEnabled()) {
+ log.trace("page " + pageNumberString + ": "
+ + "Adding all markers to LastAny");
+ }
}
}
@@ -436,11 +447,7 @@ public class PageViewport implements Resolvable, Cloneable {
* @return a copy of this page and associated viewports
*/
public Object clone() {
- Page p = (Page)page.clone();
- PageViewport ret = new PageViewport(spm, pageNumberString,
- p, (Rectangle2D)viewArea.clone());
- ret.pageNumberString = pageNumberString;
- return ret;
+ return new PageViewport(this);
}
/**
@@ -461,11 +468,15 @@ public class PageViewport implements Resolvable, Cloneable {
sb.append(getPageNumberString());
return sb.toString();
}
- /**
- * @return Returns the spm.
- */
- public SimplePageMaster getSPM() {
- return spm;
+
+ /** @return the name of the simple-page-master that created this page */
+ public String getSimplePageMasterName() {
+ return this.simplePageMasterName;
+ }
+
+ /** @return the list of extension attachments for this page */
+ public List getExtensionAttachments() {
+ return this.extensionAttachments;
}
/** @return True if this is a blank page. */
diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
index 7b5eae941..630d73ecf 100644
--- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
+++ b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 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.
@@ -30,11 +30,14 @@ import java.util.List;
* from an id reference.
*/
public class UnresolvedPageNumber extends TextArea implements Resolvable {
+
private boolean resolved = false;
private String pageIDRef;
- private Font font;
private String text;
+ //Transient fields
+ private transient Font font;
+
/**
* Create a new unresolvable page number.
*
@@ -74,7 +77,7 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable {
removeText();
addWord(page.getPageNumberString(), 0);
// update ipd
- updateIPD(getStringWidth(text));
+ updateIPD(font.getWordWidth(text));
// set the Font object to null, as we don't need it any more
font = null;
}
@@ -101,15 +104,4 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable {
return true;
}
- /**
- * @param str string to be measured
- * @return width of the string
- */
- private int getStringWidth(String str) {
- int width = 0;
- for (int count = 0; count < str.length(); count++) {
- width += font.getCharWidth(str.charAt(count));
- }
- return width;
- }
}
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
index 83f3c3afb..729f153f1 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
@@ -115,12 +115,12 @@ public abstract class AbstractBreaker {
}
/**
- * Returns the PageViewportProvider if any. PageBreaker overrides this method because each
+ * Returns the PageProvider if any. PageBreaker overrides this method because each
* page may have a different available BPD which needs to be accessible to the breaking
* algorithm.
- * @return the applicable PageViewportProvider, or null if not applicable
+ * @return the applicable PageProvider, or null if not applicable
*/
- protected PageSequenceLayoutManager.PageViewportProvider getPageViewportProvider() {
+ protected PageSequenceLayoutManager.PageProvider getPageProvider() {
return null;
}
@@ -222,7 +222,7 @@ public abstract class AbstractBreaker {
log.debug("PLM> start of algorithm (" + this.getClass().getName()
+ "), flow BPD =" + flowBPD);
PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(),
- getPageViewportProvider(),
+ getPageProvider(),
alignment, alignmentLast, footnoteSeparatorLength,
isPartOverflowRecoveryActivated());
int iOptPageCount;
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
index 80b49aafb..085fe9a69 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
@@ -264,10 +264,15 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
}
/**
- * @see org.apache.fop.layoutmgr.PageSequenceLayoutManager#getCurrentPV
+ * @see org.apache.fop.layoutmgr.PageSequenceLayoutManager#getCurrentPage
*/
+ public Page getCurrentPage() {
+ return getPSLM().getCurrentPage();
+ }
+
+ /** @return the current page viewport */
public PageViewport getCurrentPV() {
- return getPSLM().getCurrentPV();
+ return getPSLM().getCurrentPage().getPageViewport();
}
/**
diff --git a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
index 77c8b43c4..944ba9da4 100644
--- a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
@@ -35,12 +35,12 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm {
private int idealPartLen;
public BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM,
- PageSequenceLayoutManager.PageViewportProvider pvProvider,
+ PageSequenceLayoutManager.PageProvider pageProvider,
int alignment, int alignmentLast,
MinOptMax footnoteSeparatorLength,
boolean partOverflowRecovery,
int columnCount) {
- super(topLevelLM, pvProvider, alignment, alignmentLast,
+ super(topLevelLM, pageProvider, alignment, alignmentLast,
footnoteSeparatorLength, partOverflowRecovery);
this.columnCount = columnCount;
this.considerTooShort = true; //This is important!
diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
index 3ec814bd2..70da380fc 100644
--- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
@@ -92,7 +92,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
LayoutContext childLC = new LayoutContext(0);
childLC.setStackLimit(context.getStackLimit());
childLC.setRefIPD(context.getRefIPD());
- childLC.setWritingMode(getCurrentPV().getSPM().getWritingMode());
+ childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode());
// get elements from curLM
returnedList = curLM.getNextKnuthElements(childLC, alignment);
diff --git a/src/java/org/apache/fop/layoutmgr/Page.java b/src/java/org/apache/fop/layoutmgr/Page.java
new file mode 100644
index 000000000..568defb0b
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/Page.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2005 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.layoutmgr;
+
+import org.apache.fop.area.PageViewport;
+import org.apache.fop.fo.pagination.SimplePageMaster;
+
+/**
+ * This object is used by the layout engine to represent a page. It provides access to the
+ * simple-page-master that was used as a template for this page and it provides access to the
+ * PageViewport which is the top-level area tree element. This class helps to decouple the
+ * FO tree from the area tree to make the latter easily serializable.
+ */
+public class Page {
+
+ private SimplePageMaster spm;
+ private PageViewport pageViewport;
+
+ public Page(SimplePageMaster spm, String pageStr, boolean blank) {
+ this.spm = spm;
+ this.pageViewport = new PageViewport(spm, pageStr, blank);
+ }
+
+ public SimplePageMaster getSimplePageMaster() {
+ return this.spm;
+ }
+
+ public PageViewport getPageViewport() {
+ return this.pageViewport;
+ }
+
+}
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
index ced5d620a..ec456c030 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
@@ -31,7 +31,7 @@ import org.apache.fop.traits.MinOptMax;
class PageBreakingAlgorithm extends BreakingAlgorithm {
private LayoutManager topLevelLM;
- private PageSequenceLayoutManager.PageViewportProvider pageViewportProvider;
+ private PageSequenceLayoutManager.PageProvider pageProvider;
private LinkedList pageBreaks = null;
private ArrayList footnotesList = null;
@@ -66,13 +66,13 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
private boolean storedValue = false;
public PageBreakingAlgorithm(LayoutManager topLevelLM,
- PageSequenceLayoutManager.PageViewportProvider pageViewportProvider,
+ PageSequenceLayoutManager.PageProvider pageProvider,
int alignment, int alignmentLast,
MinOptMax footnoteSeparatorLength,
boolean partOverflowRecovery) {
super(alignment, alignmentLast, true, partOverflowRecovery, 0);
this.topLevelLM = topLevelLM;
- this.pageViewportProvider = pageViewportProvider;
+ this.pageProvider = pageProvider;
best = new BestPageRecords();
this.footnoteSeparatorLength = (MinOptMax) footnoteSeparatorLength.clone();
// add some stretch, to avoid a restart for every page containing footnotes
@@ -798,8 +798,8 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
/** @see org.apache.fop.layoutmgr.BreakingAlgorithm#getLineWidth(int) */
protected int getLineWidth(int line) {
int bpd;
- if (pageViewportProvider != null) {
- bpd = pageViewportProvider.getAvailableBPD(line);
+ if (pageProvider != null) {
+ bpd = pageProvider.getAvailableBPD(line);
} else {
bpd = super.getLineWidth(line);
}
diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
index 4e7b1af92..b5f69f613 100644
--- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
@@ -69,13 +69,13 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
*/
private PageSequence pageSeq;
- private PageViewportProvider pvProvider;
+ private PageProvider pageProvider;
/**
- * Current page-viewport-area being filled by
+ * Current page with page-viewport-area being filled by
* the PSLM.
*/
- private PageViewport curPV = null;
+ private Page curPage = null;
/**
* The FlowLayoutManager object, which processes
@@ -98,7 +98,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
super(pseq);
this.areaTreeHandler = ath;
this.pageSeq = pseq;
- this.pvProvider = new PageViewportProvider(this.pageSeq);
+ this.pageProvider = new PageProvider(this.pageSeq);
}
/**
@@ -109,9 +109,9 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
return areaTreeHandler.getLayoutManagerMaker();
}
- /** @return the PageViewportProvider applicable to this page-sequence. */
- public PageViewportProvider getPageViewportProvider() {
- return this.pvProvider;
+ /** @return the PageProvider applicable to this page-sequence. */
+ public PageProvider getPageProvider() {
+ return this.pageProvider;
}
/**
@@ -135,7 +135,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
areaTreeHandler.getAreaTreeModel().startPageSequence(title);
log.debug("Starting layout");
- curPV = makeNewPage(false, false);
+ curPage = makeNewPage(false, false);
addIDToPage(pageSeq.getId());
Flow mainFlow = pageSeq.getMainFlow();
@@ -143,7 +143,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
makeFlowLayoutManager(this, mainFlow);
PageBreaker breaker = new PageBreaker(this);
- int flowBPD = (int) curPV.getBodyRegion().getRemainingBPD();
+ int flowBPD = (int)getCurrentPV().getBodyRegion().getRemainingBPD();
breaker.doLayout(flowBPD);
finishPage();
@@ -169,7 +169,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
/** @see org.apache.fop.layoutmgr.AbstractBreaker */
protected void updateLayoutContext(LayoutContext context) {
- int flowIPD = curPV.getCurrentSpan().getColumnWidth();
+ int flowIPD = getCurrentPV().getCurrentSpan().getColumnWidth();
context.setRefIPD(flowIPD);
}
@@ -177,9 +177,9 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
return null; // unneeded for PSLM
}
- /** @see org.apache.fop.layoutmgr.AbstractBreaker#getPageViewportProvider() */
- protected PageSequenceLayoutManager.PageViewportProvider getPageViewportProvider() {
- return pvProvider;
+ /** @see org.apache.fop.layoutmgr.AbstractBreaker#getPageProvider() */
+ protected PageSequenceLayoutManager.PageProvider getPageProvider() {
+ return pageProvider;
}
/** @see org.apache.fop.layoutmgr.AbstractBreaker */
@@ -210,8 +210,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
}
firstPart = false;
pageBreakHandled = true;
- pvProvider.setStartOfNextElementList(currentPageNum,
- curPV.getCurrentSpan().getCurrentFlowIndex());
+ pageProvider.setStartOfNextElementList(currentPageNum,
+ getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
return super.getNextBlockList(childLC, nextSequenceStartsOn, blockLists);
}
@@ -280,7 +280,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
}
protected int getCurrentDisplayAlign() {
- return curPV.getSPM().getRegion(Constants.FO_REGION_BODY).getDisplayAlign();
+ return curPage.getSimplePageMaster().getRegion(
+ Constants.FO_REGION_BODY).getDisplayAlign();
}
protected boolean hasMoreContent() {
@@ -293,7 +294,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
"xsl-footnote-separator");
// create a Block area that will contain the separator areas
separatorArea = new Block();
- separatorArea.setIPD(curPV.getRegionReference(Constants.FO_REGION_BODY).getIPD());
+ separatorArea.setIPD(
+ getCurrentPV().getRegionReference(Constants.FO_REGION_BODY).getIPD());
// create a StaticContentLM for the footnote separator
footnoteSeparatorLM = (StaticContentLayoutManager)
getLayoutManagerMaker().makeStaticContentLayoutManager(
@@ -309,7 +311,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
if (needColumnBalancing) {
AbstractBreaker.log.debug("Column balancing now!!!");
AbstractBreaker.log.debug("===================================================");
- int restartPoint = pvProvider.getStartingPartIndexForLastPage(partCount);
+ int restartPoint = pageProvider.getStartingPartIndexForLastPage(partCount);
if (restartPoint > 0) {
addAreas(alg, restartPoint, originalList, effectiveList);
}
@@ -331,13 +333,13 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
}
pageBreakHandled = true;
//Update so the available BPD is reported correctly
- pvProvider.setStartOfNextElementList(currentPageNum,
- curPV.getCurrentSpan().getCurrentFlowIndex());
+ pageProvider.setStartOfNextElementList(currentPageNum,
+ getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
//Restart last page
PageBreakingAlgorithm algRestart = new BalancingColumnBreakingAlgorithm(
getTopLevelLM(),
- getPageViewportProvider(),
+ getPageProvider(),
alignment, Constants.EN_START, footnoteSeparatorLength,
isPartOverflowRecoveryActivated(),
getCurrentPV().getBodyRegion().getColumnCount());
@@ -367,8 +369,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
protected void startPart(BlockSequence list, int breakClass) {
AbstractBreaker.log.debug("startPart() breakClass=" + breakClass);
- if (curPV == null) {
- throw new IllegalStateException("curPV must not be null");
+ if (curPage == null) {
+ throw new IllegalStateException("curPage must not be null");
}
if (!pageBreakHandled) {
@@ -382,8 +384,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
// otherwise, we may simply need a new page
handleBreakTrait(breakClass);
}
- pvProvider.setStartOfNextElementList(currentPageNum,
- curPV.getCurrentSpan().getCurrentFlowIndex());
+ pageProvider.setStartOfNextElementList(currentPageNum,
+ getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
}
pageBreakHandled = false;
// add static areas and resolve any new id areas
@@ -393,7 +395,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
/** @see org.apache.fop.layoutmgr.AbstractBreaker#handleEmptyContent() */
protected void handleEmptyContent() {
- curPV.getPage().fakeNonEmpty();
+ getCurrentPV().getPage().fakeNonEmpty();
}
protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) {
@@ -417,7 +419,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
}
// set the offset from the top margin
Footnote parentArea = (Footnote) getCurrentPV().getBodyRegion().getFootnote();
- int topOffset = (int) curPV.getBodyRegion().getBPD() - parentArea.getBPD();
+ int topOffset = (int) getCurrentPV().getBodyRegion().getBPD() - parentArea.getBPD();
if (separatorArea != null) {
topOffset -= separatorArea.getBPD();
}
@@ -441,13 +443,21 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
/**
* Provides access to the current page.
- * @return the current PageViewport
+ * @return the current Page
*/
- public PageViewport getCurrentPV() {
- return curPV;
+ public Page getCurrentPage() {
+ return curPage;
}
/**
+ * Provides access to the current page viewport.
+ * @return the current PageViewport
+ *//*
+ public PageViewport getCurrentPageViewport() {
+ return curPage.getPageViewport();
+ }*/
+
+ /**
* Provides access to this object
* @return this PageSequenceLayoutManager instance
*/
@@ -480,7 +490,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
*/
public void addIDToPage(String id) {
if (id != null && id.length() > 0) {
- areaTreeHandler.associateIDWithPageViewport(id, curPV);
+ areaTreeHandler.associateIDWithPageViewport(id, curPage.getPageViewport());
}
}
@@ -501,8 +511,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
* @param res the resolvable object that needs resolving
*/
public void addUnresolvedArea(String id, Resolvable res) {
- curPV.addUnresolvedIDRef(id, res);
- areaTreeHandler.addUnresolvedIDRef(id, curPV);
+ curPage.getPageViewport().addUnresolvedIDRef(id, res);
+ areaTreeHandler.addUnresolvedIDRef(id, curPage.getPageViewport());
}
/**
@@ -529,7 +539,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
int boundary = rm.getRetrieveBoundary();
// get marker from the current markers on area tree
- Marker mark = (Marker)curPV.getMarker(name, pos);
+ Marker mark = (Marker)getCurrentPV().getMarker(name, pos);
if (mark == null && boundary != EN_PAGE) {
// go back over pages until mark found
// if document boundary then keep going
@@ -563,24 +573,25 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
}
}
- private PageViewport makeNewPage(boolean bIsBlank, boolean bIsLast) {
- if (curPV != null) {
+ private Page makeNewPage(boolean bIsBlank, boolean bIsLast) {
+ if (curPage != null) {
finishPage();
}
currentPageNum++;
- curPV = pvProvider.getPageViewport(bIsBlank,
- currentPageNum, PageViewportProvider.RELTO_PAGE_SEQUENCE);
+ curPage = pageProvider.getPage(bIsBlank,
+ currentPageNum, PageProvider.RELTO_PAGE_SEQUENCE);
if (log.isDebugEnabled()) {
- log.debug("[" + curPV.getPageNumberString() + (bIsBlank ? "*" : "") + "]");
+ log.debug("[" + curPage.getPageViewport().getPageNumberString()
+ + (bIsBlank ? "*" : "") + "]");
}
- return curPV;
+ return curPage;
}
private void layoutSideRegion(int regionID) {
- SideRegion reg = (SideRegion)curPV.getSPM().getRegion(regionID);
+ SideRegion reg = (SideRegion)curPage.getSimplePageMaster().getRegion(regionID);
if (reg == null) {
return;
}
@@ -596,7 +607,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
}
private void finishPage() {
- curPV.dumpMarkers();
+ curPage.getPageViewport().dumpMarkers();
// Layout side regions
layoutSideRegion(FO_REGION_BEFORE);
layoutSideRegion(FO_REGION_AFTER);
@@ -605,14 +616,14 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
// Try to resolve any unresolved IDs for the current page.
//
- areaTreeHandler.tryIDResolution(curPV);
+ areaTreeHandler.tryIDResolution(curPage.getPageViewport());
// Queue for ID resolution and rendering
- areaTreeHandler.getAreaTreeModel().addPage(curPV);
+ areaTreeHandler.getAreaTreeModel().addPage(curPage.getPageViewport());
if (log.isDebugEnabled()) {
- log.debug("page finished: " + curPV.getPageNumberString()
+ log.debug("page finished: " + curPage.getPageViewport().getPageNumberString()
+ ", current num: " + currentPageNum);
}
- curPV = null;
+ curPage = null;
}
/**
@@ -624,26 +635,26 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
private void handleBreakTrait(int breakVal) {
if (breakVal == Constants.EN_ALL) {
//break due to span change in multi-column layout
- curPV.createSpan(true);
+ curPage.getPageViewport().createSpan(true);
return;
} else if (breakVal == Constants.EN_NONE) {
- curPV.createSpan(false);
+ curPage.getPageViewport().createSpan(false);
return;
} else if (breakVal == Constants.EN_COLUMN || breakVal <= 0) {
- if (curPV.getCurrentSpan().hasMoreFlows()) {
- curPV.getCurrentSpan().moveToNextFlow();
+ if (curPage.getPageViewport().getCurrentSpan().hasMoreFlows()) {
+ curPage.getPageViewport().getCurrentSpan().moveToNextFlow();
} else {
- curPV = makeNewPage(false, false);
+ curPage = makeNewPage(false, false);
}
return;
}
log.debug("handling break-before after page " + currentPageNum
+ " breakVal=" + breakVal);
if (needBlankPageBeforeNew(breakVal)) {
- curPV = makeNewPage(true, false);
+ curPage = makeNewPage(true, false);
}
if (needNewPage(breakVal)) {
- curPV = makeNewPage(false, false);
+ curPage = makeNewPage(false, false);
}
}
@@ -653,7 +664,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
* @param breakVal - value of break-before or break-after trait.
*/
private boolean needBlankPageBeforeNew(int breakVal) {
- if (breakVal == Constants.EN_PAGE || (curPV.getPage().isEmpty())) {
+ if (breakVal == Constants.EN_PAGE || (curPage.getPageViewport().getPage().isEmpty())) {
// any page is OK or we already have an empty page
return false;
} else {
@@ -671,7 +682,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
* @param breakVal - value of break-before or break-after trait.
*/
private boolean needNewPage(int breakVal) {
- if (curPV.getPage().isEmpty()) {
+ if (curPage.getPageViewport().getPage().isEmpty()) {
if (breakVal == Constants.EN_PAGE) {
return false;
} else if (currentPageNum % 2 == 0) { // even page
@@ -686,7 +697,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
/**
- * <p>This class delivers PageViewport instances. It also caches them as necessary.
+ * <p>This class delivers Page instances. It also caches them as necessary.
* </p>
* <p>Additional functionality makes sure that surplus instances that are requested by the
* page breaker are properly discarded, especially in situations where hard breaks cause
@@ -694,9 +705,9 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
* additional pages since it doesn't know exactly until the end how many pages it really needs.
* </p>
*/
- public class PageViewportProvider {
+ public class PageProvider {
- private Log log = LogFactory.getLog(PageViewportProvider.class);
+ private Log log = LogFactory.getLog(PageProvider.class);
/** Indices are evaluated relative to the first page in the page-sequence. */
public static final int RELTO_PAGE_SEQUENCE = 0;
@@ -706,7 +717,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
private int startPageOfPageSequence;
private int startPageOfCurrentElementList;
private int startColumnOfCurrentElementList;
- private List cachedPageViewports = new java.util.ArrayList();
+ private List cachedPages = new java.util.ArrayList();
//Cache to optimize getAvailableBPD() calls
private int lastRequestedIndex = -1;
@@ -716,7 +727,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
* Main constructor.
* @param ps The page-sequence the provider operates on
*/
- public PageViewportProvider(PageSequence ps) {
+ public PageProvider(PageSequence ps) {
this.startPageOfPageSequence = ps.getStartingPageNumber();
}
@@ -754,20 +765,20 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
int c = index;
int pageIndex = 0;
int colIndex = startColumnOfCurrentElementList;
- PageViewport pv = getPageViewport(
+ Page page = getPage(
false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
while (c > 0) {
colIndex++;
- if (colIndex >= pv.getCurrentSpan().getColumnCount()) {
+ if (colIndex >= page.getPageViewport().getCurrentSpan().getColumnCount()) {
colIndex = 0;
pageIndex++;
- pv = getPageViewport(
+ page = getPage(
false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
}
c--;
}
this.lastRequestedIndex = index;
- this.lastReportedBPD = pv.getBodyRegion().getRemainingBPD();
+ this.lastReportedBPD = page.getPageViewport().getBodyRegion().getRemainingBPD();
if (log.isTraceEnabled()) {
log.trace("getAvailableBPD(" + index + ") -> " + lastReportedBPD);
}
@@ -785,13 +796,13 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
int idx = 0;
int pageIndex = 0;
int colIndex = startColumnOfCurrentElementList;
- PageViewport pv = getPageViewport(
+ Page page = getPage(
false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
while (idx < partCount) {
- if ((colIndex >= pv.getCurrentSpan().getColumnCount())) {
+ if ((colIndex >= page.getPageViewport().getCurrentSpan().getColumnCount())) {
colIndex = 0;
pageIndex++;
- pv = getPageViewport(
+ page = getPage(
false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
result = idx;
}
@@ -802,29 +813,29 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
}
/**
- * Returns a PageViewport.
+ * Returns a Page.
* @param bIsBlank true if this page is supposed to be blank.
* @param index Index of the page (see relativeTo)
* @param relativeTo Defines which value the index parameter should be evaluated relative
- * to. (One of PageViewportProvider.RELTO_*)
- * @return the requested PageViewport
+ * to. (One of PageProvider.RELTO_*)
+ * @return the requested Page
*/
- public PageViewport getPageViewport(boolean bIsBlank, int index, int relativeTo) {
+ public Page getPage(boolean bIsBlank, int index, int relativeTo) {
if (relativeTo == RELTO_PAGE_SEQUENCE) {
- return getPageViewport(bIsBlank, index);
+ return getPage(bIsBlank, index);
} else if (relativeTo == RELTO_CURRENT_ELEMENT_LIST) {
int effIndex = startPageOfCurrentElementList + index;
effIndex += startPageOfPageSequence - 1;
- return getPageViewport(bIsBlank, effIndex);
+ return getPage(bIsBlank, effIndex);
} else {
throw new IllegalArgumentException(
"Illegal value for relativeTo: " + relativeTo);
}
}
- private PageViewport getPageViewport(boolean bIsBlank, int index) {
+ private Page getPage(boolean bIsBlank, int index) {
if (log.isTraceEnabled()) {
- log.trace("getPageViewport(" + index + " " + bIsBlank);
+ log.trace("getPage(" + index + " " + bIsBlank);
}
int intIndex = index - startPageOfPageSequence;
if (log.isTraceEnabled()) {
@@ -832,27 +843,27 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
log.trace("blank page requested: " + index);
}
}
- while (intIndex >= cachedPageViewports.size()) {
+ while (intIndex >= cachedPages.size()) {
if (log.isTraceEnabled()) {
log.trace("Caching " + index);
}
- cacheNextPageViewport(index, bIsBlank);
+ cacheNextPage(index, bIsBlank);
}
- PageViewport pv = (PageViewport)cachedPageViewports.get(intIndex);
- if (pv.isBlank() != bIsBlank) {
+ Page page = (Page)cachedPages.get(intIndex);
+ if (page.getPageViewport().isBlank() != bIsBlank) {
log.debug("blank condition doesn't match. Replacing PageViewport.");
- while (intIndex < cachedPageViewports.size()) {
- this.cachedPageViewports.remove(cachedPageViewports.size() - 1);
+ while (intIndex < cachedPages.size()) {
+ this.cachedPages.remove(cachedPages.size() - 1);
if (!pageSeq.goToPreviousSimplePageMaster()) {
log.warn("goToPreviousSimplePageMaster() on the first page called!");
}
}
- cacheNextPageViewport(index, bIsBlank);
+ cacheNextPage(index, bIsBlank);
}
- return pv;
+ return page;
}
- private void cacheNextPageViewport(int index, boolean bIsBlank) {
+ private void cacheNextPage(int index, boolean bIsBlank) {
try {
String pageNumberString = pageSeq.makeFormattedPageNumber(index);
SimplePageMaster spm = pageSeq.getNextSimplePageMaster(
@@ -867,8 +878,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
+ spm.getMasterName() + "'. FOP presently "
+ "does not support this.");
}
- PageViewport pv = new PageViewport(spm, pageNumberString, bIsBlank);
- cachedPageViewports.add(pv);
+ Page page = new Page(spm, pageNumberString, bIsBlank);
+ cachedPages.add(page);
} catch (FOPException e) {
//TODO Maybe improve. It'll mean to propagate this exception up several
//methods calls.
diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java
index 39ce0c9b7..8d7dfd207 100644
--- a/src/java/org/apache/fop/render/ps/PSRenderer.java
+++ b/src/java/org/apache/fop/render/ps/PSRenderer.java
@@ -721,14 +721,14 @@ public class PSRenderer extends AbstractPathOrientedRenderer {
}
gen.writeDSCComment(DSCConstants.PAGE_RESOURCES,
new Object[] {PSGenerator.ATEND});
- gen.commentln("%FOPSimplePageMaster: " + page.getSPM().getMasterName());
+ gen.commentln("%FOPSimplePageMaster: " + page.getSimplePageMasterName());
gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
//Handle PSSetupCode instances on simple-page-master
- if (page.getSPM().getExtensionAttachments().size() > 0) {
+ if (page.getExtensionAttachments().size() > 0) {
List list = new java.util.ArrayList();
//Extract all PSSetupCode instances from the attachment list on the s-p-m
- Iterator i = page.getSPM().getExtensionAttachments().iterator();
+ Iterator i = page.getExtensionAttachments().iterator();
while (i.hasNext()) {
ExtensionAttachment attachment = (ExtensionAttachment)i.next();
if (PSSetupCode.CATEGORY.equals(attachment.getCategory())) {