From b7446dd31c308015a1414d375beb221d566169e9 Mon Sep 17 00:00:00 2001 From: Matthias Reischenbacher Date: Mon, 13 Jul 2015 18:08:19 +0000 Subject: [PATCH] FOP-2498: Fix "last" page master usage with force-page-count=end-on-even/-odd git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1690781 13f79535-47bb-0310-9956-ffa450edef68 --- .../layoutmgr/PageSequenceLayoutManager.java | 24 ++++-- ...-sequence-force-page-count-end-on-even.xml | 77 +++++++++++++++++++ 2 files changed, 93 insertions(+), 8 deletions(-) create mode 100644 test/layoutengine/standard-testcases/page-sequence-force-page-count-end-on-even.xml diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 7d84a91ff..2e2bd0a22 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -225,14 +225,22 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager protected int getForcedLastPageNum(final int lastPageNum) { int forcedLastPageNum = lastPageNum; int relativeLastPage = lastPageNum - startPageNum + 1; - if (relativeLastPage % 2 != 0 - && (getPageSequence().getForcePageCount() == Constants.EN_EVEN - || getPageSequence().getForcePageCount() == Constants.EN_END_ON_EVEN)) { - forcedLastPageNum++; - } else if (relativeLastPage % 2 == 0 && ( - getPageSequence().getForcePageCount() == Constants.EN_ODD - || getPageSequence().getForcePageCount() == Constants.EN_END_ON_ODD)) { - forcedLastPageNum++; + if (getPageSequence().getForcePageCount() == Constants.EN_EVEN) { + if (relativeLastPage % 2 != 0) { + forcedLastPageNum++; + } + } else if (getPageSequence().getForcePageCount() == Constants.EN_ODD) { + if (relativeLastPage % 2 == 0) { + forcedLastPageNum++; + } + } else if (getPageSequence().getForcePageCount() == Constants.EN_END_ON_EVEN) { + if (lastPageNum % 2 != 0) { + forcedLastPageNum++; + } + } else if (getPageSequence().getForcePageCount() == Constants.EN_END_ON_ODD) { + if (lastPageNum % 2 == 0) { + forcedLastPageNum++; + } } return forcedLastPageNum; } diff --git a/test/layoutengine/standard-testcases/page-sequence-force-page-count-end-on-even.xml b/test/layoutengine/standard-testcases/page-sequence-force-page-count-end-on-even.xml new file mode 100644 index 000000000..42fa263d6 --- /dev/null +++ b/test/layoutengine/standard-testcases/page-sequence-force-page-count-end-on-even.xml @@ -0,0 +1,77 @@ + + + + + +

+ This checks that when force-page-count=end-on-even that the last simple- + page-master is used when a single page overflows to a second + page and the page count is forced to end-on-even. +

+
+ + + + + + + + + + + + + + + + + + + + + Last-Page-3 + + + + Page 1 + Page 2 + + + + + + Last-Page-5 + + + + Page-4 + + + + + + + + + + +
-- 2.39.5