From: Jeremias Maerki Date: Tue, 7 Sep 2010 13:45:39 +0000 (+0000) Subject: Bugzilla #49885: X-Git-Tag: fop-1_1rc1old~446 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=144138a6473966a619277390719122ad35b7f097;p=xmlgraphics-fop.git 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 --- 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()); diff --git a/status.xml b/status.xml index 1f0916753..57b7a94b3 100644 --- a/status.xml +++ b/status.xml @@ -58,6 +58,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Fixed retrieval of available BPD for cases spanning columns and multiple pages with differing page masters. + Removed old Renderer implementations for those output formats that have a version based on the new DocumentHandler architecture available (AFP, PCL, PDF, PS). diff --git a/test/layoutengine/standard-testcases/region-body_column-count_span_4.xml b/test/layoutengine/standard-testcases/region-body_column-count_span_4.xml new file mode 100644 index 000000000..8bc4652ce --- /dev/null +++ b/test/layoutengine/standard-testcases/region-body_column-count_span_4.xml @@ -0,0 +1,84 @@ + + + + + +

+ This test checks multi-column documents. Check that spanned section that are broken over + to multiple pages still respect the span setting. This particular test makes sure that pages with different region-body + height are handled properly. +

+
+ + + + + + + + + + + + + + + + + + + + Line 1 + Line 2 + Line 3 + Line 4 + Line 5 + Line 6 + Line 7 + Line 8 + Line 9 + Line 10 + Line 11 + Line 12 + Line 13 + Line 14 + Line 15 + Line 16 + Line 17 + Line 18 + Line 19 + Line 20 + Line 21 + Line 22 + + + + + + + + + + + + + + + + +