Author: ssteiner Date: Thu Jan 6 14:18:11 2022 New Revision: 1896753 URL: http://svn.apache.org/viewvc?rev=1896753&view=rev Log: FOP-3046: Don't use page position only on redo of layout
Added: xmlgraphics/fop/trunk/test/ xmlgraphics/fop/trunk/test/layoutengine/ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-position_only_3.xml (with props) Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java Thu Jan 6 14:18:11 2022 @@ -30,6 +30,7 @@ import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; import org.apache.fop.complexscripts.bidi.DelimitedTextRange; import org.apache.fop.datatypes.Numeric; +import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; @@ -280,7 +281,7 @@ public class PageSequence extends Abstra * @throws PageProductionException if there's a problem determining the page master */ public SimplePageMaster getNextSimplePageMaster( - int page, boolean isFirstPage, boolean isLastPage, boolean isBlank) + int page, boolean isFirstPage, boolean isLastPage, boolean isBlank, boolean skipPagePositionOnly) throws PageProductionException { if (pageSequenceMaster == null) { @@ -295,7 +296,8 @@ public class PageSequence extends Abstra + " isBlank=" + isBlank + ")"); } return pageSequenceMaster.getNextSimplePageMaster(isOddPage, - isFirstPage, isLastPage, isBlank, getMainFlow().getFlowName()); + isFirstPage, isLastPage, isBlank, getMainFlow().getFlowName(), + skipPagePositionOnly && forcePageCount != Constants.EN_ODD); } /** Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java Thu Jan 6 14:18:11 2022 @@ -198,7 +198,8 @@ public class PageSequenceMaster extends boolean isFirstPage, boolean isLastPage, boolean isBlankPage, - String mainFlowName) + String mainFlowName, + boolean skipPagePositionOnly) throws PageProductionException { if (onlyTryInfinite && currentSubSequence != null && !currentSubSequence.isInfinite()) { throw new PageProductionException("Limited to infinite"); @@ -216,7 +217,7 @@ public class PageSequenceMaster extends } SimplePageMaster pageMaster = currentSubSequence - .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage); + .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage, skipPagePositionOnly); boolean canRecover = true; @@ -238,7 +239,7 @@ public class PageSequenceMaster extends } pageMaster = currentSubSequence - .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage); + .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage, skipPagePositionOnly); } return pageMaster; Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java Thu Jan 6 14:18:11 2022 @@ -116,11 +116,8 @@ public class RepeatablePageMasterAlterna } /** {@inheritDoc} */ - public SimplePageMaster getNextPageMaster(boolean isOddPage, - boolean isFirstPage, - boolean isLastPage, - boolean isBlankPage) { - + public SimplePageMaster getNextPageMaster(boolean isOddPage, boolean isFirstPage, boolean isLastPage, + boolean isBlankPage, boolean skipPagePositionOnly) { if (!isInfinite() && numberConsumed >= getMaximumRepeats()) { return null; } @@ -129,6 +126,9 @@ public class RepeatablePageMasterAlterna for (ConditionalPageMasterReference cpmr : conditionalPageMasterRefs) { if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isBlankPage)) { + if (cpmr.getPagePosition() == EN_ONLY && skipPagePositionOnly) { + continue; + } return cpmr.getMaster(); } } Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java Thu Jan 6 14:18:11 2022 @@ -93,7 +93,7 @@ public class RepeatablePageMasterReferen public SimplePageMaster getNextPageMaster(boolean isOddPage, boolean isFirstPage, boolean isLastPage, - boolean isEmptyPage) { + boolean isEmptyPage, boolean skipPagePositionOnly) { if (getMaximumRepeats() != INFINITE && numberConsumed >= getMaximumRepeats()) { return null; } @@ -103,7 +103,7 @@ public class RepeatablePageMasterReferen public SimplePageMaster getLastPageMaster(boolean isOddPage, boolean isFirstPage, boolean isEmptyPage, BlockLevelEventProducer blockLevelEventProducer) { - return getNextPageMaster(isOddPage, isFirstPage, true, isEmptyPage); + return getNextPageMaster(isOddPage, isFirstPage, true, isEmptyPage, false); } /** Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java Thu Jan 6 14:18:11 2022 @@ -91,7 +91,7 @@ public class SinglePageMasterReference e public SimplePageMaster getNextPageMaster(boolean isOddPage, boolean isFirstPage, boolean isLastPage, - boolean isBlankPage) { + boolean isBlankPage, boolean skipPagePositionOnly) { if (this.state == FIRST) { this.state = DONE; return master; @@ -102,7 +102,7 @@ public class SinglePageMasterReference e public SimplePageMaster getLastPageMaster(boolean isOddPage, boolean isFirstPage, boolean isBlankPage, BlockLevelEventProducer blockLevelEventProducer) { - return getNextPageMaster(isOddPage, isFirstPage, true, isBlankPage); + return getNextPageMaster(isOddPage, isFirstPage, true, isBlankPage, false); } /** {@inheritDoc} */ Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java Thu Jan 6 14:18:11 2022 @@ -38,11 +38,8 @@ public interface SubSequenceSpecifier { * @return the page master name * @throws PageProductionException if there's a problem determining the next page master */ - SimplePageMaster getNextPageMaster(boolean isOddPage, - boolean isFirstPage, - boolean isLastPage, - boolean isBlankPage) - throws PageProductionException; + SimplePageMaster getNextPageMaster(boolean isOddPage, boolean isFirstPage, boolean isLastPage, boolean isBlankPage, + boolean skipPagePositionOnly) throws PageProductionException; SimplePageMaster getLastPageMaster(boolean isOddPage, boolean isFirstPage, boolean isBlankPage, BlockLevelEventProducer blockLevelEventProducer) Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java Thu Jan 6 14:18:11 2022 @@ -359,10 +359,10 @@ public class PageProvider implements Con String pageNumberString = pageSeq.makeFormattedPageNumber(index); boolean isFirstPage = (startPageOfPageSequence == index); SimplePageMaster spm = pageSeq.getNextSimplePageMaster( - index, isFirstPage, isLastPage, isBlank); + index, isFirstPage, isLastPage, isBlank, skipPagePositionOnly); boolean isPagePositionOnly = pageSeq.hasPagePositionOnly() && !skipPagePositionOnly; if (isPagePositionOnly) { - spm = pageSeq.getNextSimplePageMaster(index, isFirstPage, true, isBlank); + spm = pageSeq.getNextSimplePageMaster(index, isFirstPage, true, isBlank, skipPagePositionOnly); } Page page = new Page(spm, index, pageNumberString, isBlank, spanAll, isPagePositionOnly); //Set unique key obtained from the AreaTreeHandler Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java Thu Jan 6 14:18:11 2022 @@ -219,8 +219,8 @@ public class RTFHandler extends FOEventH PageSequenceMaster master = pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(reference); if (pageSeq.getMainFlow() != null) { - this.pagemaster = master.getNextSimplePageMaster( - false, false, false, false, pageSeq.getMainFlow().getFlowName()); + this.pagemaster = master.getNextSimplePageMaster(false, false, false, + false, pageSeq.getMainFlow().getFlowName(), false); } } } Modified: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java Thu Jan 6 14:18:11 2022 @@ -76,14 +76,14 @@ public class PageSequenceMasterTestCase //Setup to mock the exhaustion of the last sub-sequence specifier when(mockSinglePageMasterReference.getNextPageMaster(anyBoolean(), anyBoolean(), - anyBoolean(), anyBoolean())).thenReturn(null, spm); + anyBoolean(), anyBoolean(), anyBoolean())).thenReturn(null, spm); //Need this for the method to return normally when(mockSinglePageMasterReference.canProcess(nullable(String.class))).thenReturn(true); when(mockSinglePageMasterReference.isReusable()).thenReturn(canResume); - pageSequenceMaster.getNextSimplePageMaster(false, false, false, false, null); + pageSequenceMaster.getNextSimplePageMaster(false, false, false, false, null, false); verify(mockBlockLevelEventProducer).pageSequenceMasterExhausted(nullable(Object.class), nullable(String.class), eq(canResume), nullable(Locator.class)); @@ -116,7 +116,7 @@ public class PageSequenceMasterTestCase when(mockRegion.getRegionName()).thenReturn(emptyFlowRegionName); when(mockSinglePageMasterReference.getNextPageMaster(anyBoolean(), anyBoolean(), - anyBoolean(), anyBoolean())) + anyBoolean(), anyBoolean(), anyBoolean())) .thenReturn(null, mockEmptySPM); PageSequenceMaster pageSequenceMaster = createPageSequenceMaster(mockLayoutMasterSet, @@ -127,7 +127,7 @@ public class PageSequenceMasterTestCase try { pageSequenceMaster.getNextSimplePageMaster(false, false, false, false, - mainFlowRegionName); + mainFlowRegionName, false); fail("The next simple page master does not refer to the main flow"); } catch (PageProductionException ppe) { //Passed test Modified: xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml?rev=1896753&r1=1896752&r2=1896753&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml (original) +++ xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml Thu Jan 6 14:18:11 2022 @@ -18,7 +18,7 @@ <!-- $Id$ --> <testcase> <info> - <p>When the page-master for page-position="only" cannot accommodate the content, two default + <p>When the page-master for page-position="only" cannot accommodate the content, one default pages must be used instead.</p> </info> <fo> @@ -51,8 +51,7 @@ </fo:root> </fo> <checks> - <eval expected="2" xpath="count(//pageSequence[1]/pageViewport)"/> + <eval expected="1" xpath="count(//pageSequence[1]/pageViewport)"/> <eval expected="default" xpath="//pageSequence[1]/pageViewport[1]/@simple-page-master-name"/> - <eval expected="default" xpath="//pageSequence[1]/pageViewport[2]/@simple-page-master-name"/> </checks> </testcase> Added: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-position_only_3.xml URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-position_only_3.xml?rev=1896753&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-position_only_3.xml (added) +++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-position_only_3.xml Thu Jan 6 14:18:11 2022 @@ -0,0 +1,53 @@ +<?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 for the use of an 'only' conditional-page-master-reference (XSL 1.1) + </p> + </info> + <fo> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> + <fo:layout-master-set> + <fo:simple-page-master master-name="SinglePage" page-width="210mm" page-height="297mm"> + <fo:region-body margin-top="100mm" region-name="Body"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="Page_Rest_Even" page-width="210mm" page-height="297mm" > + <fo:region-body region-name="Body" background-color="orange"/> + </fo:simple-page-master> + <fo:page-sequence-master master-name="CertificatePagesMaster"> + <fo:repeatable-page-master-alternatives> + <fo:conditional-page-master-reference master-reference="SinglePage" page-position="only"/> + <fo:conditional-page-master-reference page-position="first" master-reference="Page_Rest_Even"/> + <fo:conditional-page-master-reference page-position="rest" master-reference="Page_Rest_Even"/> + <fo:conditional-page-master-reference page-position="last" master-reference="Page_Rest_Even"/> + </fo:repeatable-page-master-alternatives> + </fo:page-sequence-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="CertificatePagesMaster"> + <fo:flow flow-name="Body"> + <fo:block font-size="80pt">test test test test test test test test test test test test test test test test test test test test test test test test test test </fo:block> + </fo:flow> + </fo:page-sequence> +</fo:root> + </fo> + <checks> + <eval expected="1" xpath="count(//page)"/> + </checks> +</testcase> Propchange: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-position_only_3.xml ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org