diff options
author | Jeremias Maerki <jeremias@apache.org> | 2010-09-07 13:45:39 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2010-09-07 13:45:39 +0000 |
commit | 144138a6473966a619277390719122ad35b7f097 (patch) | |
tree | 4787f4c7fa65b2d4e207bafc035382690a5e65d7 /src/java | |
parent | df2ce762e05d5ad83b18bd1f720a7fde2171e7d5 (diff) | |
download | xmlgraphics-fop-144138a6473966a619277390719122ad35b7f097.tar.gz xmlgraphics-fop-144138a6473966a619277390719122ad35b7f097.zip |
Bugzilla #49885:
Fixed retrieval of available BPD for cases spanning columns and multiple pages with differing page masters.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@993357 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/org/apache/fop/area/PageViewport.java | 17 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/Page.java | 6 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/PageBreaker.java | 14 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/PageProvider.java | 20 |
4 files changed, 42 insertions, 15 deletions
diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index 63740386e..bccae8754 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.java @@ -95,8 +95,10 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl * @param pageNumber the page number * @param pageStr String representation of the page number * @param blank true if this is a blank page + * @param spanAll true if the first span area spans all columns */ - public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank) { + public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, + boolean blank, boolean spanAll) { this.simplePageMasterName = spm.getMasterName(); setExtensionAttachments(spm.getExtensionAttachments()); setForeignAttributes(spm.getForeignAttributes()); @@ -107,7 +109,18 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl this.pageNumberString = pageStr; this.viewArea = new Rectangle(0, 0, pageWidth, pageHeight); this.page = new Page(spm); - createSpan(false); + createSpan(spanAll); + } + + /** + * Create a page viewport. + * @param spm SimplePageMaster indicating the page and region dimensions + * @param pageNumber the page number + * @param pageStr String representation of the page number + * @param blank true if this is a blank page + */ + public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank) { + this(spm, pageNumber, pageStr, blank, false); } /** diff --git a/src/java/org/apache/fop/layoutmgr/Page.java b/src/java/org/apache/fop/layoutmgr/Page.java index b183efa01..d8ec66e82 100644 --- a/src/java/org/apache/fop/layoutmgr/Page.java +++ b/src/java/org/apache/fop/layoutmgr/Page.java @@ -41,10 +41,12 @@ public class Page { * @param pageNumber the page number (as an int) * @param pageNumberStr the page number (as a String) * @param blank true if this is a blank page + * @param spanAll true if the first span area spans all columns */ - public Page(SimplePageMaster spm, int pageNumber, String pageNumberStr, boolean blank) { + public Page(SimplePageMaster spm, int pageNumber, String pageNumberStr, + boolean blank, boolean spanAll) { this.spm = spm; - this.pageViewport = new PageViewport(spm, pageNumber, pageNumberStr, blank); + this.pageViewport = new PageViewport(spm, pageNumber, pageNumberStr, blank, spanAll); } /** diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java index b65433bd7..3a41eb191 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.java @@ -45,6 +45,7 @@ public class PageBreaker extends AbstractBreaker { private boolean needColumnBalancing; private PageProvider pageProvider; private Block separatorArea; + private boolean spanAllActive; /** * The FlowLayoutManager object, which processes @@ -148,8 +149,9 @@ public class PageBreaker extends AbstractBreaker { } firstPart = false; pageBreakHandled = true; + pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), - pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); + pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(), this.spanAllActive); return super.getNextBlockList(childLC, nextSequenceStartsOn, positionAtIPDChange, restartLM, firstElements); } @@ -342,8 +344,9 @@ public class PageBreaker extends AbstractBreaker { pageBreakHandled = true; //Update so the available BPD is reported correctly int currentPageNum = pslm.getCurrentPageNum(); + pageProvider.setStartOfNextElementList(currentPageNum, - pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); + pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(), this.spanAllActive); //Make sure we only add the areas we haven't added already effectiveList.ignoreAtStart = newStartPos; @@ -387,7 +390,7 @@ public class PageBreaker extends AbstractBreaker { boolean fitsOnePage = optimalPageCount <= pslm.getCurrentPV() - .getBodyRegion().getMainReference().getCurrentSpan().getColumnCount(); + .getBodyRegion().getMainReference().getCurrentSpan().getColumnCount(); if (needColumnBalancing) { if (!fitsOnePage) { @@ -435,7 +438,8 @@ public class PageBreaker extends AbstractBreaker { handleBreakTrait(breakClass); } pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), - pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex()); + pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(), + this.spanAllActive); } pageBreakHandled = false; // add static areas and resolve any new id areas @@ -503,9 +507,11 @@ public class PageBreaker extends AbstractBreaker { case Constants.EN_ALL: //break due to span change in multi-column layout curPage.getPageViewport().createSpan(true); + this.spanAllActive = true; return; case Constants.EN_NONE: curPage.getPageViewport().createSpan(false); + this.spanAllActive = false; return; case Constants.EN_COLUMN: case Constants.EN_AUTO: diff --git a/src/java/org/apache/fop/layoutmgr/PageProvider.java b/src/java/org/apache/fop/layoutmgr/PageProvider.java index 2e531a8d8..8caafa72b 100644 --- a/src/java/org/apache/fop/layoutmgr/PageProvider.java +++ b/src/java/org/apache/fop/layoutmgr/PageProvider.java @@ -51,6 +51,7 @@ public class PageProvider implements Constants { private int startPageOfPageSequence; private int startPageOfCurrentElementList; private int startColumnOfCurrentElementList; + private boolean spanAllForCurrentElementList; private List cachedPages = new java.util.ArrayList(); private int lastPageIndex = -1; @@ -88,12 +89,17 @@ public class PageProvider implements Constants { * on so it can later retrieve PageViewports relative to this first page. * @param startPage the number of the first page for the element list. * @param startColumn the starting column number for the element list. + * @param spanAll true if the current element list is for a column-spanning section */ - public void setStartOfNextElementList(int startPage, int startColumn) { - log.debug("start of the next element list is:" - + " page=" + startPage + " col=" + startColumn); + public void setStartOfNextElementList(int startPage, int startColumn, boolean spanAll) { + if (log.isDebugEnabled()) { + log.debug("start of the next element list is:" + + " page=" + startPage + " col=" + startColumn + + (spanAll ? ", column-spanning" : "")); + } this.startPageOfCurrentElementList = startPage - startPageOfPageSequence + 1; this.startColumnOfCurrentElementList = startColumn; + this.spanAllForCurrentElementList = spanAll; //Reset Cache this.lastRequestedIndex = -1; this.lastReportedBPD = -1; @@ -290,7 +296,7 @@ public class PageProvider implements Constants { if (log.isTraceEnabled()) { log.trace("Caching " + index); } - cacheNextPage(index, isBlank, isLastPage); + cacheNextPage(index, isBlank, isLastPage, this.spanAllForCurrentElementList); } Page page = (Page)cachedPages.get(intIndex); boolean replace = false; @@ -306,7 +312,7 @@ public class PageProvider implements Constants { } if (replace) { discardCacheStartingWith(intIndex); - page = cacheNextPage(index, isBlank, isLastPage); + page = cacheNextPage(index, isBlank, isLastPage, this.spanAllForCurrentElementList); } return page; } @@ -320,7 +326,7 @@ public class PageProvider implements Constants { } } - private Page cacheNextPage(int index, boolean isBlank, boolean isLastPage) { + private Page cacheNextPage(int index, boolean isBlank, boolean isLastPage, boolean spanAll) { String pageNumberString = pageSeq.makeFormattedPageNumber(index); boolean isFirstPage = (startPageOfPageSequence == index); SimplePageMaster spm = pageSeq.getNextSimplePageMaster( @@ -335,7 +341,7 @@ public class PageProvider implements Constants { eventProducer.flowNotMappingToRegionBody(this, pageSeq.getMainFlow().getFlowName(), spm.getMasterName(), spm.getLocator()); } - Page page = new Page(spm, index, pageNumberString, isBlank); + Page page = new Page(spm, index, pageNumberString, isBlank, spanAll); //Set unique key obtained from the AreaTreeHandler page.getPageViewport().setKey(areaTreeHandler.generatePageViewportKey()); page.getPageViewport().setForeignAttributes(spm.getForeignAttributes()); |