Skip to content

Commit f9404c6

Browse files
FOP-3192: Redo layout for multipage columns for change in column count
1 parent eb335e3 commit f9404c6

File tree

3 files changed

+149
-4
lines changed

3 files changed

+149
-4
lines changed

fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ private void handleBreakTrait(int breakVal, boolean emptyContent) {
621621
&& pv.getCurrentSpan().getColumnCount() == 1);
622622

623623
if (forceNewPageWithSpan) {
624+
checkPagePositionOnly();
624625
log.trace("Forcing new page with span");
625626
curPage = pslm.makeNewPage(false);
626627
curPage.getPageViewport().createSpan(true);
@@ -632,10 +633,7 @@ private void handleBreakTrait(int breakVal, boolean emptyContent) {
632633
log.trace("Moving to next flow");
633634
pv.getCurrentSpan().moveToNextFlow();
634635
} else {
635-
if (pslm.getCurrentPage().isPagePositionOnly
636-
&& !pslm.fobj.getUserAgent().isLegacySkipPagePositionOnly()) {
637-
throw new PagePositionOnlyException();
638-
}
636+
checkPagePositionOnly();
639637
log.trace("Making new page");
640638
pslm.makeNewPage(false, emptyContent);
641639
}
@@ -647,14 +645,22 @@ private void handleBreakTrait(int breakVal, boolean emptyContent) {
647645
}
648646
}
649647

648+
private void checkPagePositionOnly() {
649+
if (pslm.getCurrentPage().isPagePositionOnly && !pslm.fobj.getUserAgent().isLegacySkipPagePositionOnly()) {
650+
throw new PagePositionOnlyException();
651+
}
652+
}
653+
650654
private void handleBreakBeforeFollowingPage(int breakVal) {
651655
log.debug("handling break-before after page " + pslm.getCurrentPageNum() + " breakVal="
652656
+ getBreakClassName(breakVal));
653657
if (needBlankPageBeforeNew(breakVal)) {
658+
checkPagePositionOnly();
654659
log.trace("Inserting blank page");
655660
/* curPage = */pslm.makeNewPage(true);
656661
}
657662
if (needNewPage(breakVal)) {
663+
checkPagePositionOnly();
658664
log.trace("Making new page");
659665
/* curPage = */pslm.makeNewPage(false);
660666
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<!-- $Id$ -->
19+
<testcase>
20+
<info>
21+
<p>
22+
This test checks the page-position only is not used as there is more than 1 page
23+
</p>
24+
</info>
25+
<fo>
26+
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
27+
<fo:layout-master-set>
28+
<fo:simple-page-master master-name="PageFrontSingle" page-width="8.5in" page-height="11in" margin-bottom="0.32in" margin-right="1in" margin-top="0.2in" margin-left="0.9in">
29+
<fo:region-body margin-bottom="1.35in" margin-top="0.5in" column-count="2" column-gap=".5in" region-name="letterPageBody"/>
30+
</fo:simple-page-master>
31+
<fo:simple-page-master master-name="PageFront" page-width="8.5in" page-height="11in" margin-bottom="0.32in" margin-right="1in" margin-top="0.2in" margin-left="0.9in">
32+
<fo:region-body margin-bottom="0.7in" margin-top="0.5in" column-gap=".5in" column-count="2" region-name="letterPageBody"/>
33+
</fo:simple-page-master>
34+
<fo:simple-page-master master-name="PageRest" page-width="8.5in" page-height="11in" margin-bottom="0.32in" margin-right="1in" margin-top="0.7in" margin-left="0.9in">
35+
<fo:region-body margin-bottom="0.7in" column-gap=".5in" column-count="2" region-name="letterPageBody"/>
36+
</fo:simple-page-master>
37+
<fo:simple-page-master master-name="PageLast" page-width="8.5in" page-height="11in" margin-bottom="0.32in" margin-right="1in" margin-top="0.7in" margin-left="0.9in">
38+
<fo:region-body margin-bottom="1.35in" region-name="letterPageBody"/>
39+
</fo:simple-page-master>
40+
<fo:page-sequence-master master-name="LetterPages">
41+
<fo:repeatable-page-master-alternatives>
42+
<fo:conditional-page-master-reference page-position="only" master-reference="PageFrontSingle"/>
43+
<fo:conditional-page-master-reference page-position="first" master-reference="PageFront"/>
44+
<fo:conditional-page-master-reference page-position="rest" master-reference="PageRest"/>
45+
<fo:conditional-page-master-reference page-position="last" master-reference="PageLast"/>
46+
</fo:repeatable-page-master-alternatives>
47+
</fo:page-sequence-master>
48+
</fo:layout-master-set>
49+
<fo:page-sequence format="1" id="th_default_sequence1" initial-page-number="auto" force-page-count="auto" master-reference="LetterPages">
50+
<fo:flow flow-name="letterPageBody">
51+
<fo:block span="all">
52+
<fo:block>test</fo:block>
53+
<fo:block break-after="column">
54+
<fo:leader/>
55+
</fo:block>
56+
<fo:block>test</fo:block>
57+
</fo:block>
58+
<fo:block>test</fo:block>
59+
</fo:flow>
60+
</fo:page-sequence>
61+
</fo:root>
62+
</fo>
63+
<checks>
64+
<eval expected="3" xpath="count(//word)"/>
65+
<eval expected="2" xpath="count(//page)"/>
66+
<eval expected="PageFront" xpath="//pageViewport/@simple-page-master-name"/>
67+
</checks>
68+
</testcase>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<!-- $Id$ -->
19+
<testcase>
20+
<info>
21+
<p>
22+
This test checks the page-position only is not used as there is more than 1 page
23+
</p>
24+
</info>
25+
<cfg>
26+
<legacy-skip-page-position-only>true</legacy-skip-page-position-only>
27+
</cfg>
28+
<fo>
29+
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
30+
<fo:layout-master-set>
31+
<fo:simple-page-master master-name="PageFrontSingle" page-width="8.5in" page-height="11in" margin-bottom="0.32in" margin-right="1in" margin-top="0.2in" margin-left="0.9in">
32+
<fo:region-body margin-bottom="1.35in" margin-top="0.5in" column-count="2" column-gap=".5in" region-name="letterPageBody"/>
33+
</fo:simple-page-master>
34+
<fo:simple-page-master master-name="PageFront" page-width="8.5in" page-height="11in" margin-bottom="0.32in" margin-right="1in" margin-top="0.2in" margin-left="0.9in">
35+
<fo:region-body margin-bottom="0.7in" margin-top="0.5in" column-gap=".5in" column-count="2" region-name="letterPageBody"/>
36+
</fo:simple-page-master>
37+
<fo:simple-page-master master-name="PageRest" page-width="8.5in" page-height="11in" margin-bottom="0.32in" margin-right="1in" margin-top="0.7in" margin-left="0.9in">
38+
<fo:region-body margin-bottom="0.7in" column-gap=".5in" column-count="2" region-name="letterPageBody"/>
39+
</fo:simple-page-master>
40+
<fo:simple-page-master master-name="PageLast" page-width="8.5in" page-height="11in" margin-bottom="0.32in" margin-right="1in" margin-top="0.7in" margin-left="0.9in">
41+
<fo:region-body margin-bottom="1.35in" region-name="letterPageBody"/>
42+
</fo:simple-page-master>
43+
<fo:page-sequence-master master-name="LetterPages">
44+
<fo:repeatable-page-master-alternatives>
45+
<fo:conditional-page-master-reference page-position="only" master-reference="PageFrontSingle"/>
46+
<fo:conditional-page-master-reference page-position="first" master-reference="PageFront"/>
47+
<fo:conditional-page-master-reference page-position="rest" master-reference="PageRest"/>
48+
<fo:conditional-page-master-reference page-position="last" master-reference="PageLast"/>
49+
</fo:repeatable-page-master-alternatives>
50+
</fo:page-sequence-master>
51+
</fo:layout-master-set>
52+
<fo:page-sequence format="1" id="th_default_sequence1" initial-page-number="auto" force-page-count="auto" master-reference="LetterPages">
53+
<fo:flow flow-name="letterPageBody">
54+
<fo:block span="all">
55+
<fo:block>test</fo:block>
56+
<fo:block break-after="column">
57+
<fo:leader/>
58+
</fo:block>
59+
<fo:block>test</fo:block>
60+
</fo:block>
61+
<fo:block>test</fo:block>
62+
</fo:flow>
63+
</fo:page-sequence>
64+
</fo:root>
65+
</fo>
66+
<checks>
67+
<eval expected="3" xpath="count(//word)"/>
68+
<eval expected="2" xpath="count(//page)"/>
69+
<eval expected="PageFront" xpath="//pageViewport/@simple-page-master-name"/>
70+
</checks>
71+
</testcase>

0 commit comments

Comments
 (0)