diff options
author | Glen Mazza <gmazza@apache.org> | 2005-02-17 00:27:54 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2005-02-17 00:27:54 +0000 |
commit | 7ff677faf4d40f711d0c36ed38c612947127fde5 (patch) | |
tree | db063ad99b930189953adf4de0c2dee790a26105 /src/java/org/apache/fop/layoutmgr | |
parent | 7674b9cdff836e9ea2f1011a7b7343a6ab0dd468 (diff) | |
download | xmlgraphics-fop-7ff677faf4d40f711d0c36ed38c612947127fde5.tar.gz xmlgraphics-fop-7ff677faf4d40f711d0c36ed38c612947127fde5.zip |
PR:
Obtained from:
Submitted by:
Reviewed by:
Cleanup of page number handling throughout application. Removed old code
from PageSequence.java.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198434 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr')
5 files changed, 21 insertions, 19 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index 4edd78c3e..4e6c6221f 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -314,8 +314,8 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants * * @see org.apache.fop.layoutmgr.LayoutManager */ - public String getCurrentPageNumber() { - return parentLM.getCurrentPageNumber(); + public String getCurrentPageNumberString() { + return parentLM.getCurrentPageNumberString(); } /** diff --git a/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java index 52d351a2e..06cd94230 100644 --- a/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java @@ -234,8 +234,8 @@ public class ContentLayoutManager implements InlineLevelLayoutManager { Position bp2) { } /** @see org.apache.fop.layoutmgr.LayoutManager */ - public String getCurrentPageNumber() { - return parentLM.getCurrentPageNumber(); + public String getCurrentPageNumberString() { + return parentLM.getCurrentPageNumberString(); } /** @see org.apache.fop.layoutmgr.LayoutManager */ diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManager.java b/src/java/org/apache/fop/layoutmgr/LayoutManager.java index edd283dbc..93b674281 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManager.java @@ -172,7 +172,7 @@ public interface LayoutManager { * * @return the string for the current page number */ - String getCurrentPageNumber(); + String getCurrentPageNumberString(); /** * Resolve the id reference. diff --git a/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java index e2b8d6935..89298bb69 100644 --- a/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java @@ -46,7 +46,7 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { public InlineArea get(LayoutContext context) { // get page string from parent, build area TextArea inline = new TextArea(); - String str = parentLM.getCurrentPageNumber(); + String str = parentLM.getCurrentPageNumberString(); int width = 0; for (int count = 0; count < str.length(); count++) { width += font.getCharWidth(str.charAt(count)); diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index ce86164e9..922a9e207 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -75,7 +75,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { } } - private int pageCount = 1; + private int startPageNum = 0; + private int currentPageNum = 0; private String pageNumberString; private boolean isFirstPage = true; @@ -177,9 +178,9 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { * which creates and adds all the pages to the area tree. */ public void activateLayout() { - pageSeq.initPageNumber(); - pageCount = pageSeq.getCurrentPageNumber(); - pageNumberString = pageSeq.makeFormattedPageNumber(pageCount); + startPageNum = pageSeq.getStartingPageNumber(); + currentPageNum = startPageNum; + pageNumberString = pageSeq.makeFormattedPageNumber(currentPageNum); LineArea title = null; if (pageSeq.getTitleFO() != null) { @@ -203,14 +204,15 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { // finish page and add to area tree finishPage(); - pageCount++; - pageNumberString = pageSeq.makeFormattedPageNumber(pageCount); + currentPageNum++; + pageNumberString = pageSeq.makeFormattedPageNumber(currentPageNum); } } - pageCount--; + // TODO: Don't decrement currentPageNum when no pages are generated + currentPageNum--; log.debug("Ending layout"); finishPage(); - pageSeq.setCurrentPageNumber(pageCount); + pageSeq.getRoot().reportAdditionalPagesGenerated((currentPageNum - startPageNum) + 1); } /** @see org.apache.fop.layoutmgr.LayoutManager#isBogus() */ @@ -257,7 +259,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { * * @return the formatted page number string */ - public String getCurrentPageNumber() { + public String getCurrentPageNumberString() { return pageNumberString; } @@ -464,7 +466,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { try { // create a new page currentSimplePageMaster = pageSeq.getSimplePageMasterToUse( - pageCount, isFirstPage, bIsBlank); + currentPageNum, isFirstPage, bIsBlank); Region body = currentSimplePageMaster.getRegion(FO_REGION_BODY); if (!pageSeq.getMainFlow().getFlowName().equals(body.getRegionName())) { throw new FOPException("Flow '" + pageSeq.getMainFlow().getFlowName() @@ -477,7 +479,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { throw new IllegalArgumentException("Cannot create page: " + fopex.getMessage()); } - curPage.setPageNumberString(getCurrentPageNumber()); + curPage.setPageNumberString(pageNumberString); if (log.isDebugEnabled()) { log.debug("[" + curPage.getPageNumberString() + "]"); } @@ -669,7 +671,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { } else { /* IF we are on the kind of page we need, we'll need a new page. */ - if (pageCount%2 != 0) { + if (currentPageNum%2 != 0) { // Current page is odd return (breakValue == Constants.EN_ODD_PAGE); } @@ -687,7 +689,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { if (breakValue == Constants.EN_PAGE) { return false; } - else if (pageCount%2 != 0) { + else if (currentPageNum%2 != 0) { // Current page is odd return (breakValue == Constants.EN_EVEN_PAGE); } |