You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by gm...@apache.org on 2005/05/13 02:41:29 UTC
cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr AbstractLayoutManager.java PageSequenceLayoutManager.java
gmazza 2005/05/12 17:41:29
Modified: src/java/org/apache/fop/layoutmgr Tag:
Temp_KnuthStylePageBreaking
AbstractLayoutManager.java
PageSequenceLayoutManager.java
Log:
Better consolidation of the RetrieveMarker handling code.
Revision Changes Path
No revision
No revision
1.41.2.12 +14 -60 xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
Index: AbstractLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java,v
retrieving revision 1.41.2.11
retrieving revision 1.41.2.12
diff -u -r1.41.2.11 -r1.41.2.12
--- AbstractLayoutManager.java 11 May 2005 15:29:29 -0000 1.41.2.11
+++ AbstractLayoutManager.java 13 May 2005 00:41:29 -0000 1.41.2.12
@@ -24,7 +24,6 @@
import org.apache.fop.area.PageViewport;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.RetrieveMarker;
-import org.apache.fop.fo.flow.Marker;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,7 +35,7 @@
import java.util.Map;
/**
- * The base class for all LayoutManagers.
+ * The base class for most LayoutManagers.
*/
public abstract class AbstractLayoutManager implements LayoutManager, Constants {
protected LayoutManager parentLM = null;
@@ -50,7 +49,7 @@
/**
* Used during addAreas(): signals that a BreakPoss is not generating areas
- * and therefore doesn't add IDs and markers to the current page.
+ * and therefore shouldn't add IDs and markers to the current page.
* @see org.apache.fop.layoutmgr.AbstractLayoutManager#isBogus
*/
protected boolean bBogus = false;
@@ -110,38 +109,6 @@
return this.parentLM;
}
- // /**
- // * Ask the parent LayoutManager to add the current (full) area to the
- // * appropriate parent area.
- // * @param bFinished If true, this area is finished, either because it's
- // * completely full or because there is no more content to put in it.
- // * If false, we are in the middle of this area. This can happen,
- // * for example, if we find floats in a line. We stop the current area,
- // * and add it (temporarily) to its parent so that we can see if there
- // * is enough space to place the float(s) anchored in the line.
- // */
- // protected void flush(Area area, boolean bFinished) {
- // if (area != null) {
- // // area.setFinished(true);
- // parentLM.addChildArea(area, bFinished); // ????
- // if (bFinished) {
- // setCurrentArea(null);
- // }
- // }
- // }
-
- /**
- * Return an Area which can contain the passed childArea. The childArea
- * may not yet have any content, but it has essential traits set.
- * In general, if the LayoutManager already has an Area it simply returns
- * it. Otherwise, it makes a new Area of the appropriate class.
- * It gets a parent area for its area by calling its parent LM.
- * Finally, based on the dimensions of the parent area, it initializes
- * its own area. This includes setting the content IPD and the maximum
- * BPD.
- */
-
-
/** @see org.apache.fop.layoutmgr.LayoutManager#generatesInlineAreas() */
public boolean generatesInlineAreas() {
return false;
@@ -324,7 +291,14 @@
}
/**
- * @see org.apache.fop.layoutmgr.LayoutManager#getParentArea(org.apache.fop.area.Area)
+ * Return an Area which can contain the passed childArea. The childArea
+ * may not yet have any content, but it has essential traits set.
+ * In general, if the LayoutManager already has an Area it simply returns
+ * it. Otherwise, it makes a new Area of the appropriate class.
+ * It gets a parent area for its area by calling its parent LM.
+ * Finally, based on the dimensions of the parent area, it initializes
+ * its own area. This includes setting the content IPD and the maximum
+ * BPD.
*/
public Area getParentArea(Area childArea) {
return null;
@@ -334,29 +308,6 @@
}
/**
- * Handles retrieve-marker nodes as they occur.
- * @param foNode FO node to check
- * @return the original foNode or in case of a retrieve-marker the replaced
- * FO node. null if the the replacement results in no nodes to be
- * processed.
- */
- private FONode handleRetrieveMarker(FONode foNode) {
- if (foNode instanceof RetrieveMarker) {
- RetrieveMarker rm = (RetrieveMarker) foNode;
- Marker marker = getPSLM().retrieveMarker(rm.getRetrieveClassName(),
- rm.getRetrievePosition(),
- rm.getRetrieveBoundary());
- if (marker == null) {
- return null;
- }
- rm.bindMarker(marker);
- return rm;
- } else {
- return foNode;
- }
- }
-
- /**
* Convenience method: preload a number of child LMs
* @param size the requested number of child LMs
* @return the list with the preloaded child LMs
@@ -370,7 +321,10 @@
Object theobj = fobjIter.next();
if (theobj instanceof FONode) {
FONode foNode = (FONode) theobj;
- foNode = handleRetrieveMarker(foNode);
+ if (foNode instanceof RetrieveMarker) {
+ foNode = getPSLM().resolveRetrieveMarker(
+ (RetrieveMarker) foNode);
+ }
if (foNode != null) {
getPSLM().getLayoutManagerMaker().
makeLayoutManagers(foNode, newLMs);
1.50.2.29 +14 -9 xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
Index: PageSequenceLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v
retrieving revision 1.50.2.28
retrieving revision 1.50.2.29
diff -u -r1.50.2.28 -r1.50.2.29
--- PageSequenceLayoutManager.java 11 May 2005 15:29:29 -0000 1.50.2.28
+++ PageSequenceLayoutManager.java 13 May 2005 00:41:29 -0000 1.50.2.29
@@ -32,6 +32,7 @@
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.Marker;
+import org.apache.fop.fo.flow.RetrieveMarker;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.Region;
import org.apache.fop.fo.pagination.SideRegion;
@@ -328,7 +329,7 @@
}
/**
- * Retrieve a marker from this layout manager.
+ * Bind the RetrieveMarker to the corresponding Marker subtree.
* If the boundary is page then it will only check the
* current page. For page-sequence and document it will
* lookup preceding pages from the area tree and try to find
@@ -339,13 +340,16 @@
* Therefore we use last-ending-within-page (Constants.EN_LEWP)
* as the position.
*
- * @param name the marker class name to lookup
- * @param pos the position to locate the marker
- * @param boundary the boundary for locating the marker
- * @return the layout manager for the marker contents
+ * @param rm the RetrieveMarker instance whose properties are to
+ * used to find the matching Marker.
+ * @return a bound RetrieveMarker instance, or null if no Marker
+ * could be found.
*/
- public Marker retrieveMarker(String name, int pos, int boundary) {
+ public RetrieveMarker resolveRetrieveMarker(RetrieveMarker rm) {
AreaTreeModel areaTreeModel = areaTreeHandler.getAreaTreeModel();
+ String name = rm.getRetrieveClassName();
+ int pos = rm.getRetrievePosition();
+ int boundary = rm.getRetrieveBoundary();
// get marker from the current markers on area tree
Marker mark = (Marker)curPV.getMarker(name, pos);
@@ -363,7 +367,8 @@
PageViewport pv = areaTreeModel.getPage(seq, page);
mark = (Marker)pv.getMarker(name, Constants.EN_LEWP);
if (mark != null) {
- return mark;
+ rm.bindMarker(mark);
+ return rm;
}
page--;
if (page < 0 && doc && seq > 1) {
@@ -377,7 +382,7 @@
log.debug("found no marker with name: " + name);
}
- return mark;
+ return null;
}
private PageViewport makeNewPage(boolean bIsBlank, boolean bIsFirst, boolean bIsLast) {
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org