aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java6
-rw-r--r--fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java7
-rw-r--r--fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java10
-rw-r--r--fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java4
-rw-r--r--fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java4
-rw-r--r--fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java7
-rw-r--r--fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java4
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java4
-rw-r--r--fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java8
-rw-r--r--fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml5
-rw-r--r--test/layoutengine/standard-testcases/page-position_only_3.xml53
11 files changed, 82 insertions, 30 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java b/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java
index 79955ff74..79481c400 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java
@@ -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 AbstractPageSequence implements WritingModeTra
* @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 AbstractPageSequence implements WritingModeTra
+ " isBlank=" + isBlank + ")");
}
return pageSequenceMaster.getNextSimplePageMaster(isOddPage,
- isFirstPage, isLastPage, isBlank, getMainFlow().getFlowName());
+ isFirstPage, isLastPage, isBlank, getMainFlow().getFlowName(),
+ skipPagePositionOnly && forcePageCount != Constants.EN_ODD);
}
/**
diff --git a/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
index b9840e006..9e040d03d 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
@@ -198,7 +198,8 @@ public class PageSequenceMaster extends FObj {
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 FObj {
}
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 FObj {
}
pageMaster = currentSubSequence
- .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage);
+ .getNextPageMaster(isOddPage, isFirstPage, isLastPage, isBlankPage, skipPagePositionOnly);
}
return pageMaster;
diff --git a/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
index 2914fb9a8..4cc8647fc 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
@@ -116,11 +116,8 @@ public class RepeatablePageMasterAlternatives extends FObj
}
/** {@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 RepeatablePageMasterAlternatives extends FObj
for (ConditionalPageMasterReference cpmr : conditionalPageMasterRefs) {
if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isBlankPage)) {
+ if (cpmr.getPagePosition() == EN_ONLY && skipPagePositionOnly) {
+ continue;
+ }
return cpmr.getMaster();
}
}
diff --git a/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
index 5e43c02b1..5fc8bbd15 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
@@ -93,7 +93,7 @@ public class RepeatablePageMasterReference extends FObj
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 RepeatablePageMasterReference extends FObj
public SimplePageMaster getLastPageMaster(boolean isOddPage, boolean isFirstPage, boolean isEmptyPage,
BlockLevelEventProducer blockLevelEventProducer) {
- return getNextPageMaster(isOddPage, isFirstPage, true, isEmptyPage);
+ return getNextPageMaster(isOddPage, isFirstPage, true, isEmptyPage, false);
}
/**
diff --git a/fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
index 2600909cb..75d0785f1 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
@@ -91,7 +91,7 @@ public class SinglePageMasterReference extends FObj
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 extends FObj
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} */
diff --git a/fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java b/fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
index 0905ee8a8..12fe517e3 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
@@ -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)
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java
index 266a7d9b9..7926ba756 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java
@@ -359,10 +359,10 @@ public class PageProvider implements Constants {
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
diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java b/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java
index a4a63afc6..3a2d80d5e 100644
--- a/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -219,8 +219,8 @@ public class RTFHandler extends FOEventHandler {
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);
}
}
}
diff --git a/fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java b/fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java
index d1f8433cf..584593e22 100644
--- a/fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java
@@ -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
diff --git a/fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml b/fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml
index 589c3a21f..cded06e72 100644
--- a/fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml
+++ b/fop/test/layoutengine/standard-testcases/page-position_only_too-small.xml
@@ -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>
diff --git a/test/layoutengine/standard-testcases/page-position_only_3.xml b/test/layoutengine/standard-testcases/page-position_only_3.xml
new file mode 100644
index 000000000..bc3b33214
--- /dev/null
+++ b/test/layoutengine/standard-testcases/page-position_only_3.xml
@@ -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>