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;
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;
/**
* 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;
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;
}
/**
- * @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;
public void addChildArea(Area childArea) {
}
- /**
- * 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
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);
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;
}
/**
- * 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
* 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);
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) {
log.debug("found no marker with name: " + name);
}
- return mark;
+ return null;
}
private PageViewport makeNewPage(boolean bIsBlank, boolean bIsFirst, boolean bIsLast) {