diff options
author | Simon Steiner <ssteiner@apache.org> | 2017-11-06 11:36:57 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2017-11-06 11:36:57 +0000 |
commit | 6c3d447872cae55061776b44f895f5fa881c343d (patch) | |
tree | 3e7942b2f390dc24b52927e507d5acc5cc867593 | |
parent | a2382d7d247ad4bc12df79a691b21d58077f689b (diff) | |
download | xmlgraphics-fop-6c3d447872cae55061776b44f895f5fa881c343d.tar.gz xmlgraphics-fop-6c3d447872cae55061776b44f895f5fa881c343d.zip |
FOP-2755: Unmapped XSL-FO Region can cause extra pages
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1814394 13f79535-47bb-0310-9956-ffa450edef68
4 files changed, 102 insertions, 19 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java index 4139ee094..d57148290 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -320,7 +320,7 @@ public abstract class AbstractBreaker { * @param list a block sequence * @param breakClass a break class */ - protected void startPart(BlockSequence list, int breakClass) { + protected void startPart(BlockSequence list, int breakClass, boolean emptyContent) { //nop } @@ -656,7 +656,7 @@ public abstract class AbstractBreaker { + ", break at pos " + endElementIndex + ", break class = " + getBreakClassName(lastBreakClass)); - startPart(effectiveList, lastBreakClass); + startPart(effectiveList, lastBreakClass, startElementIndex > endElementIndex); int displayAlign = getCurrentDisplayAlign(); diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java index 6096fef93..b325ffe0e 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java @@ -146,7 +146,7 @@ public class PageBreaker extends AbstractBreaker { } if (needColumnBalancing) { - AbstractBreaker.log.debug( + log.debug( "Column balancing necessary for the next element list!!!"); } return nextSequenceStartsOn; @@ -401,7 +401,7 @@ public class PageBreaker extends AbstractBreaker { } } - AbstractBreaker.log.debug("Restarting at " + restartPoint + log.debug("Restarting at " + restartPoint + ", new start position: " + newStartPos); pageBreakHandled = true; @@ -416,8 +416,8 @@ public class PageBreaker extends AbstractBreaker { PageBreakingAlgorithm algRestart; if (needColumnBalancing) { - AbstractBreaker.log.debug("Column balancing now!!!"); - AbstractBreaker.log.debug("==================================================="); + log.debug("Column balancing now!!!"); + log.debug("==================================================="); //Restart last page algRestart = new BalancingColumnBreakingAlgorithm( @@ -425,7 +425,7 @@ public class PageBreaker extends AbstractBreaker { alignment, Constants.EN_START, footnoteSeparatorLength, isPartOverflowRecoveryActivated(), pslm.getCurrentPV().getBodyRegion().getColumnCount()); - AbstractBreaker.log.debug("==================================================="); + log.debug("==================================================="); } else { // Handle special page-master for last page BodyRegion currentBody = pageProvider.getPage(false, currentPageNum) @@ -436,21 +436,21 @@ public class PageBreaker extends AbstractBreaker { BodyRegion lastBody = pageProvider.getPage(false, currentPageNum) .getPageViewport().getBodyRegion(); lastBody.getMainReference().setSpans(currentBody.getMainReference().getSpans()); - AbstractBreaker.log.debug("Last page handling now!!!"); - AbstractBreaker.log.debug("==================================================="); + log.debug("Last page handling now!!!"); + log.debug("==================================================="); //Restart last page algRestart = new PageBreakingAlgorithm( getTopLevelLM(), getPageProvider(), createLayoutListener(), alg.getAlignment(), alg.getAlignmentLast(), footnoteSeparatorLength, isPartOverflowRecoveryActivated(), false, false); - AbstractBreaker.log.debug("==================================================="); + log.debug("==================================================="); } int optimalPageCount = algRestart.findBreakingPoints(effectiveList, newStartPos, 1, true, BreakingAlgorithm.ALL_BREAKS); - AbstractBreaker.log.debug("restart: optimalPageCount= " + optimalPageCount + log.debug("restart: optimalPageCount= " + optimalPageCount + " pageBreaks.size()= " + algRestart.getPageBreaks().size()); boolean fitsOnePage @@ -459,7 +459,7 @@ public class PageBreaker extends AbstractBreaker { if (needColumnBalancing) { if (!fitsOnePage) { - AbstractBreaker.log.warn( + log.warn( "Breaking algorithm produced more columns than are available."); /* reenable when everything works throw new IllegalStateException( @@ -493,8 +493,8 @@ public class PageBreaker extends AbstractBreaker { } /** {@inheritDoc} */ - protected void startPart(BlockSequence list, int breakClass) { - AbstractBreaker.log.debug("startPart() breakClass=" + getBreakClassName(breakClass)); + protected void startPart(BlockSequence list, int breakClass, boolean emptyContent) { + log.debug("startPart() breakClass=" + getBreakClassName(breakClass)); if (pslm.getCurrentPage() == null) { throw new IllegalStateException("curPage must not be null"); } @@ -508,7 +508,7 @@ public class PageBreaker extends AbstractBreaker { // the current BlockSequence, it could have a break // condition that must be satisfied; // otherwise, we may simply need a new page - handleBreakTrait(breakClass); + handleBreakTrait(breakClass, emptyContent); } pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(), pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(), @@ -588,6 +588,10 @@ public class PageBreaker extends AbstractBreaker { * @param breakVal - value of break-before or break-after trait. */ private void handleBreakTrait(int breakVal) { + handleBreakTrait(breakVal, false); + } + + private void handleBreakTrait(int breakVal, boolean emptyContent) { Page curPage = pslm.getCurrentPage(); switch (breakVal) { case Constants.EN_ALL: @@ -626,7 +630,7 @@ public class PageBreaker extends AbstractBreaker { pv.getCurrentSpan().moveToNextFlow(); } else { log.trace("Making new page"); - pslm.makeNewPage(false); + pslm.makeNewPage(false, emptyContent); } } } @@ -838,7 +842,7 @@ public class PageBreaker extends AbstractBreaker { + ", break at pos " + endElementIndex + ", break class = " + getBreakClassName(lastBreakClass)); - startPart(effectiveList, lastBreakClass); + startPart(effectiveList, lastBreakClass, false); int displayAlign = getCurrentDisplayAlign(); diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 75bfe5e60..1f0b50162 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -185,12 +185,15 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager @Override protected Page makeNewPage(boolean isBlank) { + return makeNewPage(isBlank, false); + } + + protected Page makeNewPage(boolean isBlank, boolean emptyContent) { Page newPage = super.makeNewPage(isBlank); // Empty pages (pages that have been generated from a SPM that has an un-mapped flow name) // cannot layout areas from the main flow. Blank pages can be created from empty pages. - - if (!isBlank) { + if (!isBlank && !emptyContent) { int i = 0; while (!flowNameEquals(newPage, i > 0)) { newPage = super.makeNewPage(isBlank); diff --git a/fop/test/layoutengine/standard-testcases/page-breaking_7.xml b/fop/test/layoutengine/standard-testcases/page-breaking_7.xml new file mode 100644 index 000000000..6af8ab7b8 --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/page-breaking_7.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!-- $Id$ --> +<testcase> + <info> + <p> + This test checks breaking behaviour in environments where there is not much space. + </p> + </info> + <fo> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="FirstOddPages" page-width="8.5in" page-height="11in" margin-bottom="0.25in" margin-right="0.4in" margin-top="0.25in" margin-left="0.4in"> + <fo:region-body region-name="Body" background-color="red"/> + </fo:simple-page-master> + <fo:simple-page-master margin-right="0.4in" margin-left="0.4in" margin-top="0.25in" margin-bottom="0.25in" master-name="BackEvenPages" page-width="8.5in" page-height="11in"> + <fo:region-body margin-top="10.5in" background-color="yellow"/> + </fo:simple-page-master> + <fo:page-sequence-master master-name="AllPages"> + <fo:repeatable-page-master-alternatives> + <fo:conditional-page-master-reference odd-or-even="odd" master-reference="FirstOddPages"/> + <fo:conditional-page-master-reference odd-or-even="even" master-reference="BackEvenPages"/> + </fo:repeatable-page-master-alternatives> + </fo:page-sequence-master> + </fo:layout-master-set> + <fo:page-sequence initial-page-number="auto" force-page-count="end-on-even" master-reference="AllPages"> + + <fo:flow flow-name="Body"> + <fo:block> + + <fo:block>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</fo:block> + <fo:block>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</fo:block> + <fo:block>Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</fo:block> + <fo:block>Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</fo:block> + <fo:block>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.</fo:block> + <fo:block>Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</fo:block> + <fo:block>Heading</fo:block> + <fo:block>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</fo:block> + <fo:block>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</fo:block> + <fo:block>Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</fo:block> + <fo:block>Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</fo:block> + <fo:block>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.</fo:block> + <fo:block>Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</fo:block> + <fo:block>Heading</fo:block> + <fo:block>Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</fo:block> + <fo:block>Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</fo:block> + <fo:block>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.</fo:block> + <fo:block color="red" font-size="8pt">EndRegion: Body</fo:block> + + </fo:block> + + </fo:flow> + </fo:page-sequence> +</fo:root> + </fo> + <checks> + <eval expected="Lorem" xpath="//pageViewport[1]//word[1]"/> + <eval expected="Duis" xpath="//pageViewport[3]//word[1]"/> + <eval expected="EndRegion:" xpath="//pageViewport[5]//word[1]"/> + </checks> +</testcase> |