Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion fop-core/src/main/java/org/apache/fop/fo/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,14 @@ public interface Constants {
int EN_FIRST_INCLUDING_CARRYOVER = 204;
/** Enumeration constant -- for auto-toggle */
int EN_SELECT_FIRST_FITTING = 205;
/** Enumeration constant -- non-standard force-page-count property value */
int EN_DOUBLY_EVEN = 206;
/** Enumeration constant -- non-standard force-page-count property value */
int EN_END_ON_DOUBLY_EVEN = 207;
/** Enumeration constant -- non-standard force-page-count property value */
int EN_DOUBLY_ODD = 208;
/** Enumeration constant -- non-standard force-page-count property value */
int EN_END_ON_DOUBLY_ODD = 209;
/** Number of enumeration constants defined */
int ENUM_COUNT = 205;
int ENUM_COUNT = 209;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,10 @@ private void createPaginationAndLayoutProperties() {
m.addEnum("odd", getEnumProperty(EN_ODD, "ODD"));
m.addEnum("end-on-even", getEnumProperty(EN_END_ON_EVEN, "END_ON_EVEN"));
m.addEnum("end-on-odd", getEnumProperty(EN_END_ON_ODD, "END_ON_ODD"));
m.addEnum("doubly-even", getEnumProperty(EN_DOUBLY_EVEN, "DOUBLY_EVEN"));
m.addEnum("end-on-doubly-even", getEnumProperty(EN_END_ON_DOUBLY_EVEN, "END_ON_DOUBLY_EVEN"));
m.addEnum("doubly-odd", getEnumProperty(EN_DOUBLY_ODD, "DOUBLY_ODD"));
m.addEnum("end-on-doubly-odd", getEnumProperty(EN_END_ON_DOUBLY_ODD, "END_ON_DOUBLY_ODD"));
m.addEnum("no-force", getEnumProperty(EN_NO_FORCE, "NO_FORCE"));
m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
m.setDefault("auto");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,22 @@ public void doForcePageCount(Numeric nextPageSeqInitialPageNumber) {
if (currentPageNum % 2 == 0) { // we are now on an even page
curPage = makeNewPage(true);
}
} else if (forcePageCount == Constants.EN_DOUBLY_EVEN) {
while ((this.currentPageNum - this.startPageNum + 1) % 4 != 0) {
this.curPage = makeNewPage(true);
}
} else if (forcePageCount == Constants.EN_END_ON_DOUBLY_EVEN) {
while (this.currentPageNum % 4 != 0) {
this.curPage = makeNewPage(true);
}
} else if (forcePageCount == Constants.EN_DOUBLY_ODD) {
while ((this.currentPageNum - this.startPageNum + 1) % 4 != 3) {
this.curPage = makeNewPage(true);
}
} else if (forcePageCount == Constants.EN_END_ON_DOUBLY_ODD) {
while (this.currentPageNum % 4 != 3) {
this.curPage = makeNewPage(true);
}
} /* else if (forcePageCount == Constants.EN_NO_FORCE) {
// i hope: nothing special at all
} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,18 @@ protected int getForcedLastPageNum(final int lastPageNum) {
if (lastPageNum % 2 == 0) {
forcedLastPageNum++;
}
} else if ((lastPageNum - startPageNum + 1) % 4 != 0
&& getPageSequence().getForcePageCount() == Constants.EN_DOUBLY_EVEN) {
forcedLastPageNum += 4 - (lastPageNum - startPageNum + 1) % 4;
} else if (lastPageNum % 4 != 0
&& getPageSequence().getForcePageCount() == Constants.EN_END_ON_DOUBLY_EVEN) {
forcedLastPageNum += 4 - lastPageNum % 4;
} else if ((lastPageNum - startPageNum + 1) % 4 != 3
&& getPageSequence().getForcePageCount() == Constants.EN_DOUBLY_ODD) {
forcedLastPageNum += 4 - (lastPageNum - startPageNum + 2) % 4;
} else if (lastPageNum % 4 != 3
&& getPageSequence().getForcePageCount() == Constants.EN_END_ON_DOUBLY_ODD) {
forcedLastPageNum += 4 - (lastPageNum + 1) % 4;
}
return forcedLastPageNum;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?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 the non-standard value doubly-even and
end-on-doubly-even of the force-page-count property.
</p>
</info>
<fo>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="first" page-width="210mm" page-height="297mm">
<fo:region-body background-color="red" margin-bottom="2cm"/>
<fo:region-after extent="2cm" region-name="bottom-first"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="rest" page-width="210mm" page-height="297mm">
<fo:region-body background-color="yellow" margin-bottom="2cm"/>
<fo:region-after extent="2cm" region-name="bottom-rest"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="last" page-width="210mm" page-height="297mm">
<fo:region-body background-color="green" margin-bottom="2cm"/>
<fo:region-after extent="2cm" region-name="bottom-last"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="ps">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first" page-position="first" odd-or-even="any"/>
<fo:conditional-page-master-reference master-reference="rest" page-position="rest" odd-or-even="any"/>
<fo:conditional-page-master-reference master-reference="last" page-position="last" odd-or-even="any"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="ps">
<fo:static-content flow-name="bottom-first">
<fo:block border-top-width=".1mm" border-top-style="solid">
first-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-rest">
<fo:block border-top-width=".1mm" border-top-style="solid">
rest-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-last">
<fo:block border-top-width=".1mm" border-top-style="solid">
last-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>Page 1</fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="ps" force-page-count="doubly-even">
<fo:static-content flow-name="bottom-first">
<fo:block border-top-width=".1mm" border-top-style="solid">
first-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-rest">
<fo:block border-top-width=".1mm" border-top-style="solid">
rest-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-last">
<fo:block border-top-width=".1mm" border-top-style="solid">
last-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>Page 2</fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="ps" force-page-count="end-on-doubly-even">
<fo:static-content flow-name="bottom-first">
<fo:block border-top-width=".1mm" border-top-style="solid">
first-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-rest">
<fo:block border-top-width=".1mm" border-top-style="solid">
rest-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-last">
<fo:block border-top-width=".1mm" border-top-style="solid">
last-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>Page 6</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</fo>
<checks>
<eval expected="first" xpath="(//pageViewport)[1]/@simple-page-master-name"/>
<eval expected="first" xpath="(//pageViewport)[2]/@simple-page-master-name"/>
<eval expected="rest" xpath="(//pageViewport)[3]/@simple-page-master-name"/>
<eval expected="rest" xpath="(//pageViewport)[4]/@simple-page-master-name"/>
<eval expected="last" xpath="(//pageViewport)[5]/@simple-page-master-name"/>
<eval expected="first" xpath="(//pageViewport)[6]/@simple-page-master-name"/>
<eval expected="rest" xpath="(//pageViewport)[7]/@simple-page-master-name"/>
<eval expected="last" xpath="(//pageViewport)[8]/@simple-page-master-name"/>
<eval expected="8" xpath="count(//pageViewport)"/>
</checks>
</testcase>
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?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 the non-standard value doubly-odd and end-on-doubly-odd
of the force-page-count property.
</p>
</info>
<fo>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="first" page-width="210mm" page-height="297mm">
<fo:region-body background-color="red" margin-bottom="2cm"/>
<fo:region-after extent="2cm" region-name="bottom-first"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="rest" page-width="210mm" page-height="297mm">
<fo:region-body background-color="yellow" margin-bottom="2cm"/>
<fo:region-after extent="2cm" region-name="bottom-rest"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="last" page-width="210mm" page-height="297mm">
<fo:region-body background-color="green" margin-bottom="2cm"/>
<fo:region-after extent="2cm" region-name="bottom-last"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="ps">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first" page-position="first" odd-or-even="any"/>
<fo:conditional-page-master-reference master-reference="rest" page-position="rest" odd-or-even="any"/>
<fo:conditional-page-master-reference master-reference="last" page-position="last" odd-or-even="any"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="ps">
<fo:static-content flow-name="bottom-first">
<fo:block border-top-width=".1mm" border-top-style="solid">
first-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-rest">
<fo:block border-top-width=".1mm" border-top-style="solid">
rest-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-last">
<fo:block border-top-width=".1mm" border-top-style="solid">
last-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>Page 1</fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="ps" force-page-count="doubly-odd">
<fo:static-content flow-name="bottom-first">
<fo:block border-top-width=".1mm" border-top-style="solid">
first-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-rest">
<fo:block border-top-width=".1mm" border-top-style="solid">
rest-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-last">
<fo:block border-top-width=".1mm" border-top-style="solid">
last-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>Page 2</fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="ps">
<fo:static-content flow-name="bottom-first">
<fo:block border-top-width=".1mm" border-top-style="solid">
first-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-rest">
<fo:block border-top-width=".1mm" border-top-style="solid">
rest-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-last">
<fo:block border-top-width=".1mm" border-top-style="solid">
last-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>Page 5</fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="ps" force-page-count="end-on-doubly-odd">
<fo:static-content flow-name="bottom-first">
<fo:block border-top-width=".1mm" border-top-style="solid">
first-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-rest">
<fo:block border-top-width=".1mm" border-top-style="solid">
rest-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="bottom-last">
<fo:block border-top-width=".1mm" border-top-style="solid">
last-<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>Page 6</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</fo>
<checks>
<eval expected="first" xpath="(//pageViewport)[1]/@simple-page-master-name"/>
<eval expected="first" xpath="(//pageViewport)[2]/@simple-page-master-name"/>
<eval expected="rest" xpath="(//pageViewport)[3]/@simple-page-master-name"/>
<eval expected="last" xpath="(//pageViewport)[4]/@simple-page-master-name"/>
<eval expected="first" xpath="(//pageViewport)[5]/@simple-page-master-name"/>
<eval expected="first" xpath="(//pageViewport)[6]/@simple-page-master-name"/>
<eval expected="last" xpath="(//pageViewport)[7]/@simple-page-master-name"/>
<eval expected="7" xpath="count(//pageViewport)"/>
</checks>
</testcase>