From: Glen Mazza Date: Sun, 6 Feb 2005 08:14:07 +0000 (+0000) Subject: PR: X-Git-Tag: Root_Temp_KnuthStylePageBreaking~127 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=53e0eb6fda134dd1097feed0e6cc315e2220f846;p=xmlgraphics-fop.git PR: Obtained from: Submitted by: Reviewed by: Minor variable renaming in PSLM, removed pageCount variable from ATH. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198380 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index 60fb63ee2..f51db4e41 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -77,9 +77,6 @@ public class AreaTreeHandler extends FOEventHandler { // the LayoutManager maker private LayoutManagerMaker lmMaker; - // count of number of pages rendered - private int pageCount; - // AreaTreeModel in use private AreaTreeModel model; @@ -209,7 +206,6 @@ public class AreaTreeHandler extends FOEventHandler { public void startDocument() throws SAXException { //Initialize statistics if (outputStatistics) { - pageCount = 0; initialMemory = runtime.totalMemory() - runtime.freeMemory(); startTime = System.currentTimeMillis(); } @@ -268,11 +264,12 @@ public class AreaTreeHandler extends FOEventHandler { long memoryNow = runtime.totalMemory() - runtime.freeMemory(); long memoryUsed = (memoryNow - initialMemory) / 1024L; long timeUsed = System.currentTimeMillis() - startTime; + int pageCount = rootFObj.getRunningPageNumberCounter(); log.debug("Initial heap size: " + (initialMemory / 1024L) + "Kb"); log.debug("Current heap size: " + (memoryNow / 1024L) + "Kb"); log.debug("Total memory used: " + memoryUsed + "Kb"); log.debug("Total time used: " + timeUsed + "ms"); - log.debug("Pages rendered: " + rootFObj.getRunningPageNumberCounter()); + log.debug("Pages rendered: " + pageCount); if (pageCount > 0) { log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page"); } @@ -306,14 +303,5 @@ public class AreaTreeHandler extends FOEventHandler { model.handleOffDocumentItem(odi); } } - - /** - * Called by the PageSequenceLayoutManager to notify the AreaTreeHandler - * of a new page being started. - * @param pageNumber page number - */ - public void notifyNewPage(String pageNumber) { - pageCount++; - } } diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java index 2384a779b..14c3bd437 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumber.java +++ b/src/java/org/apache/fop/fo/flow/PageNumber.java @@ -150,6 +150,11 @@ public class PageNumber extends FObj { return id; } + /** @return the "text-decoration" property. */ + public CommonTextDecoration getTextDecoration() { + return textDecoration; + } + /** * @see org.apache.fop.fo.FONode#getName() */ @@ -163,10 +168,4 @@ public class PageNumber extends FObj { public int getNameId() { return FO_PAGE_NUMBER; } - - /** @return the "text-decoration" property. */ - public CommonTextDecoration getTextDecoration() { - return textDecoration; - } - } diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 1257df4f0..20b34d6e8 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -65,7 +65,7 @@ import org.apache.fop.traits.MinOptMax; * It manages all page-related layout. */ public class PageSequenceLayoutManager extends AbstractLayoutManager { - private PageSequence fobj; + private PageSequence pageSeq; private static class BlockBreakPosition extends LeafPosition { protected BreakPoss breakps; @@ -128,11 +128,11 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { * * @param pageseq the page sequence fo */ - public PageSequenceLayoutManager(PageSequence pageseq) { - super(pageseq); - fobj = pageseq; - if (fobj.getPageSequenceMaster() != null) { - fobj.getPageSequenceMaster().reset(); + public PageSequenceLayoutManager(PageSequence pageSeq) { + super(pageSeq); + this.pageSeq = pageSeq; + if (pageSeq.getPageSequenceMaster() != null) { + pageSeq.getPageSequenceMaster().reset(); } } @@ -153,19 +153,6 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { return areaTreeHandler; } - /** - * Set the page counting for this page sequence. - * This sets the initial page number and the page number formatter. - * - * @param pc the starting page number - * @param generator the page number generator - */ - private void setPageCounting(int pc, PageNumberGenerator generator) { - pageCount = pc; - pageNumberGenerator = generator; - pageNumberString = pageNumberGenerator.makeFormattedPageNumber(pageCount); - } - /** * Get the page count. * Used to get the last page number for reference for @@ -205,13 +192,14 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { * which creates and adds all the pages to the area tree. */ public void activateLayout() { - fobj.initPageNumber(); - setPageCounting(fobj.getCurrentPageNumber(), - fobj.getPageNumberGenerator()); + pageSeq.initPageNumber(); + pageCount = pageSeq.getCurrentPageNumber(); + pageNumberGenerator = pageSeq.getPageNumberGenerator(); + pageNumberString = pageNumberGenerator.makeFormattedPageNumber(pageCount); LineArea title = null; - if (fobj.getTitleFO() != null) { - title = getTitleArea(fobj.getTitleFO()); + if (pageSeq.getTitleFO() != null) { + title = getTitleArea(pageSeq.getTitleFO()); } areaTreeModel.startPageSequence(title); @@ -239,7 +227,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { pageCount--; log.debug("Ending layout"); flush(); - fobj.setCurrentPageNumber(getPageCount()); + pageSeq.setCurrentPageNumber(getPageCount()); } /** @@ -262,8 +250,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { childLC.setRefIPD(flowIPD); if (!curLM.isFinished()) { - fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, flowIPD); - fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, flowBPD); + pageSeq.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, flowIPD); + pageSeq.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, flowBPD); bp = curLM.getNextBreakPoss(childLC); } if (bp != null) { @@ -496,7 +484,6 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { if (log.isDebugEnabled()) { log.debug("[" + curPage.getPageNumber() + "]"); } - areaTreeHandler.notifyNewPage(curPage.getPageNumber()); RegionViewport rv = curPage.getPage().getRegionViewport( FO_REGION_BODY); curBody = (BodyRegion) rv.getRegion(); @@ -510,7 +497,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { if (region == null) { return; } - StaticContent flow = fobj.getStaticContent(region.getRegionName()); + StaticContent flow = pageSeq.getStaticContent(region.getRegionName()); if (flow == null) { return; } @@ -775,8 +762,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { throws FOPException { currentSimplePageMaster = getSimplePageMasterToUse(bIsBlank); Region body = currentSimplePageMaster.getRegion(FO_REGION_BODY); - if (!fobj.getMainFlow().getFlowName().equals(body.getRegionName())) { - throw new FOPException("Flow '" + fobj.getMainFlow().getFlowName() + if (!pageSeq.getMainFlow().getFlowName().equals(body.getRegionName())) { + throw new FOPException("Flow '" + pageSeq.getMainFlow().getFlowName() + "' does not map to the region-body in page-master '" + currentSimplePageMaster.getMasterName() + "'"); } @@ -796,11 +783,11 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { private SimplePageMaster getSimplePageMasterToUse(boolean bIsBlank) throws FOPException { - if (fobj.getPageSequenceMaster() == null) { - return fobj.getSimplePageMaster(); + if (pageSeq.getPageSequenceMaster() == null) { + return pageSeq.getSimplePageMaster(); } boolean isOddPage = ((pageCount % 2) == 1); - return fobj.getPageSequenceMaster() + return pageSeq.getPageSequenceMaster() .getNextSimplePageMaster(isOddPage, isFirstPage, bIsBlank); } @@ -809,8 +796,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { int pageHeight = spm.getPageHeight().getValue(); // Set the page dimension as the toplevel containing block for margin. - ((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_IPD, pageWidth); - ((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_BPD, pageHeight); + ((FObj) pageSeq.getParent()).setLayoutDimension(PercentBase.BLOCK_IPD, pageWidth); + ((FObj) pageSeq.getParent()).setLayoutDimension(PercentBase.BLOCK_BPD, pageHeight); // Get absolute margin properties (top, left, bottom, right) CommonMarginBlock mProps = spm.getCommonMarginBlock();