package org.apache.fop.area;
import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.pagination.RegionBody;
/**
* This class is a container for all areas that may be generated by
mainReference = new MainReference();
}
+ /**
+ * Constructor which can read traits directly
+ * from an fo:region-body formatting object.
+ */
+ public BodyRegion(RegionBody rb) {
+ this();
+ columnCount = rb.getColumnCount();
+ columnGap = rb.getColumnGap();
+ if ((columnCount > 1) && (rb.getOverflow() == Constants.EN_SCROLL)) {
+ // recover by setting 'column-count' to 1. This is allowed but
+ // not required by the spec.
+ log.error("Setting 'column-count' to 1 because "
+ + "'overflow' is set to 'scroll'");
+ columnCount = 1;
+ }
+ }
+
/**
* Set the number of columns for blocks when not spanning
*
*
* @param area The parent area
*/
- public ContentLayoutManager(Area area) {
+ public ContentLayoutManager(Area area, LayoutManager parentLM) {
holder = area;
+ this.parentLM = parentLM;
}
/**
* Constructor using a fo:title formatting object
*/
- public ContentLayoutManager(Title foTitle) {
+ public ContentLayoutManager(Title foTitle, LayoutManager parentLM) {
// get breaks then add areas to title
+ this.parentLM = parentLM;
holder = new LineArea();
setUserAgent(foTitle.getUserAgent());
fillArea(lm);
}
- /**
- * Set the FO object for this layout manager
- *
- * @param fo the fo for this layout manager
- */
- public void setFObj(FObj fo) {
- }
-
public void fillArea(LayoutManager curLM) {
int ipd = 1000000;
return userAgent;
}
+ /** @see org.apache.fop.layoutmgr.LayoutManager */
+ public void setFObj(FObj fobj) {
+ }
+
/** @see org.apache.fop.layoutmgr.LayoutManager */
public void setParent(LayoutManager lm) {
parentLM = lm;
}
/**
- * Set the AreaTreeHandler.
- * This is used by the PageSequenceLM for the Title,
- * because it does not set itself as the parentLM.
- * @param areaTreeHandler the area tree handler to add pages to
- */
- public void setAreaTreeHandler(AreaTreeHandler areaTreeHandler) {
- this.areaTreeHandler = areaTreeHandler;
- }
-
- /**
- * Either areaTreeHandler or parentLM should not be null.
- * If areaTreeHandler is null,
- * delegate getAreaTreeHandler to the parent layout manager.
- *
* @see org.apache.fop.layoutmgr.LayoutManager
* @return the AreaTreeHandler object.
*/
public AreaTreeHandler getAreaTreeHandler() {
- if (areaTreeHandler == null) {
- areaTreeHandler = parentLM.getAreaTreeHandler();
- }
- return areaTreeHandler;
+ return parentLM.getAreaTreeHandler();
}
/**
*/
private SimplePageMaster currentSimplePageMaster;
- /**
- * The collection of StaticContentLayoutManager objects that are associated
- * with this Page Sequence, keyed by flow-name.
- */
- //private HashMap staticContentLMs = new HashMap(4);
-
/**
* Constructor - activated by AreaTreeHandler for each
* fo:page-sequence in the input FO stream
if (pageSeq.getTitleFO() != null) {
ContentLayoutManager clm =
- new ContentLayoutManager(pageSeq.getTitleFO());
- clm.setAreaTreeHandler(areaTreeHandler);
+ new ContentLayoutManager(pageSeq.getTitleFO(), this);
title = (LineArea) clm.getParentArea(null); // can improve
}
if ((bp = getNextBreakPoss(childLC)) != null) {
addAreas((BlockBreakPosition)bp.getPosition());
// add static areas and resolve any new id areas
-
// finish page and add to area tree
finishPage();
currentPageNum++;
spm.getWritingMode(), pageRefRect, reldims);
// Create a RegionViewport/ reference area pair for each page region
+ RegionReference rr = null;
for (Iterator regenum = spm.getRegions().values().iterator();
regenum.hasNext();) {
Region r = (Region)regenum.next();
r.setLayoutDimension(PercentBase.BLOCK_IPD, rvp.getIPD());
r.setLayoutDimension(PercentBase.BLOCK_BPD, rvp.getBPD());
if (r.getNameId() == FO_REGION_BODY) {
- rvp.setRegion(makeRegionBodyReferenceArea((RegionBody) r, rvp.getViewArea()));
+ rr = new BodyRegion((RegionBody) r);
} else {
- rvp.setRegion(makeRegionReferenceArea(r, rvp.getViewArea()));
+ rr = new RegionReference(r.getNameId());
}
+ setRegionPosition(r, rr, rvp.getViewArea());
+ rvp.setRegion(rr);
page.setRegionViewport(r.getNameId(), rvp);
}
return new PageViewport(page, new Rectangle(0, 0, pageWidth, pageHeight));
- }
-
+ }
+
/**
* Creates a RegionViewport Area object for this pagination Region.
* @param reldims relative dimensions
TraitSetter.addBackground(rv, r.getCommonBorderPaddingBackground());
return rv;
}
-
- private BodyRegion makeRegionBodyReferenceArea(RegionBody r,
- Rectangle2D absRegVPRect) {
- // Should set some column stuff here I think, or put it elsewhere
- BodyRegion body = new BodyRegion();
- setRegionPosition(r, body, absRegVPRect);
- int columnCount = r.getColumnCount();
- if ((columnCount > 1) && (r.getOverflow() == EN_SCROLL)) {
- // recover by setting 'column-count' to 1. This is allowed but
- // not required by the spec.
- log.error("Setting 'column-count' to 1 because "
- + "'overflow' is set to 'scroll'");
- columnCount = 1;
- }
- body.setColumnCount(columnCount);
- body.setColumnGap(r.getColumnGap());
- return body;
- }
-
- /**
- * Create the region reference area for this region master.
- * @param absRegVPRect The region viewport rectangle is "absolute" coordinates
- * where x=distance from left, y=distance from bottom, width=right-left
- * height=top-bottom
- * @return a new region reference area
- */
- private RegionReference makeRegionReferenceArea(Region r,
- Rectangle2D absRegVPRect) {
- RegionReference rr = new RegionReference(r.getNameId());
- setRegionPosition(r, rr, absRegVPRect);
- return rr;
- }
-
+
/**
* Set the region position inside the region viewport.
* This sets the trasnform that is used to place the contents of
* the region.
*
* @param r the region reference area
- * @param absRegVPRect the rectangle to place the region contents
+ * @param absRegVPRect The region viewport rectangle in "absolute" coordinates
+ * where x=distance from left, y=distance from bottom, width=right-left
+ * height=top-bottom
*/
private void setRegionPosition(Region r, RegionReference rr,
Rectangle2D absRegVPRect) {