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;
* @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) {
+ " isBlank=" + isBlank + ")");
}
return pageSequenceMaster.getNextSimplePageMaster(isOddPage,
- isFirstPage, isLastPage, isBlank, getMainFlow().getFlowName());
+ isFirstPage, isLastPage, isBlank, getMainFlow().getFlowName(),
+ skipPagePositionOnly && forcePageCount != Constants.EN_ODD);
}
/**
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");
}
SimplePageMaster pageMaster = currentSubSequence
- .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage);
+ .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage, skipPagePositionOnly);
boolean canRecover = true;
}
pageMaster = currentSubSequence
- .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage);
+ .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage, skipPagePositionOnly);
}
return pageMaster;
}
/** {@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;
}
for (ConditionalPageMasterReference cpmr : conditionalPageMasterRefs) {
if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isBlankPage)) {
+ if (cpmr.getPagePosition() == EN_ONLY && skipPagePositionOnly) {
+ continue;
+ }
return cpmr.getMaster();
}
}
public SimplePageMaster getNextPageMaster(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
- boolean isEmptyPage) {
+ boolean isEmptyPage, boolean skipPagePositionOnly) {
if (getMaximumRepeats() != INFINITE && numberConsumed >= getMaximumRepeats()) {
return null;
}
public SimplePageMaster getLastPageMaster(boolean isOddPage, boolean isFirstPage, boolean isEmptyPage,
BlockLevelEventProducer blockLevelEventProducer) {
- return getNextPageMaster(isOddPage, isFirstPage, true, isEmptyPage);
+ return getNextPageMaster(isOddPage, isFirstPage, true, isEmptyPage, false);
}
/**
public SimplePageMaster getNextPageMaster(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
- boolean isBlankPage) {
+ boolean isBlankPage, boolean skipPagePositionOnly) {
if (this.state == FIRST) {
this.state = DONE;
return master;
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} */
* @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)
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
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);
}
}
}
//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));
when(mockRegion.getRegionName()).thenReturn(emptyFlowRegionName);
when(mockSinglePageMasterReference.getNextPageMaster(anyBoolean(), anyBoolean(),
- anyBoolean(), anyBoolean()))
+ anyBoolean(), anyBoolean(), anyBoolean()))
.thenReturn(null, mockEmptySPM);
PageSequenceMaster pageSequenceMaster = createPageSequenceMaster(mockLayoutMasterSet,
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
<!-- $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>
</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>
--- /dev/null
+<?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>