From 4aa732439c8abdea8ba94e6555553088b664f1df Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Mon, 14 Mar 2005 01:34:26 +0000 Subject: [PATCH] More simplifications to PSLM. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198493 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/BodyRegion.java | 18 ++++++ .../fop/layoutmgr/ContentLayoutManager.java | 37 +++--------- .../fop/layoutmgr/LeaderLayoutManager.java | 2 +- .../layoutmgr/PageSequenceLayoutManager.java | 59 ++++--------------- 4 files changed, 40 insertions(+), 76 deletions(-) diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java index 60f6d2736..c4223db8b 100644 --- a/src/java/org/apache/fop/area/BodyRegion.java +++ b/src/java/org/apache/fop/area/BodyRegion.java @@ -19,6 +19,7 @@ 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 @@ -43,6 +44,23 @@ public class BodyRegion extends RegionReference { 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 * diff --git a/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java index d6d9bb963..515196e3f 100644 --- a/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java @@ -63,15 +63,17 @@ public class ContentLayoutManager implements InlineLevelLayoutManager { * * @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()); @@ -84,14 +86,6 @@ public class ContentLayoutManager implements InlineLevelLayoutManager { 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; @@ -209,6 +203,10 @@ public class ContentLayoutManager implements InlineLevelLayoutManager { 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; @@ -283,28 +281,11 @@ public class ContentLayoutManager implements InlineLevelLayoutManager { } /** - * 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(); } /** diff --git a/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java index 8fef3f18e..667a2d59b 100644 --- a/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java @@ -121,7 +121,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { // get breaks then add areas to FilledArea FilledArea fa = new FilledArea(); - clm = new ContentLayoutManager(fa); + clm = new ContentLayoutManager(fa, this); clm.setUserAgent(fobj.getUserAgent()); addChildLM(clm); diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index a6c1d55a8..c178528d2 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -107,12 +107,6 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { */ 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 @@ -155,8 +149,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { 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 } @@ -172,7 +165,6 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { 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++; @@ -728,6 +720,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { 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(); @@ -735,16 +728,18 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { 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 @@ -762,46 +757,16 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { 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) { -- 2.39.5