]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla 46489:
authorAndreas L. Delmelle <adelmelle@apache.org>
Sun, 22 Mar 2009 19:18:14 +0000 (19:18 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Sun, 22 Mar 2009 19:18:14 +0000 (19:18 +0000)
Issue when combining page-position="last" with a block with break-before as a descendant of a table.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@757239 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/PageBreaker.java
status.xml
test/layoutengine/standard-testcases/page-position-last_break-before_bugzilla46489.xml [new file with mode: 0644]

index 5dc1576c77b9df511af9b48c95a5009cd1c214aa..1137065ab59d0c142f8938c6b50cb7a147724dcc 100644 (file)
@@ -273,7 +273,8 @@ public class PageBreaker extends AbstractBreaker {
             //Get page break from which we restart
             PageBreakPosition pbp = (PageBreakPosition)
                     alg.getPageBreaks().get(restartPoint - 1);
-            newStartPos = pbp.getLeafPos();
+            //Set starting position to the first element *after* the page-break
+            newStartPos = pbp.getLeafPos() + 1;
             //Handle page break right here to avoid any side-effects
             if (newStartPos > 0) {
                 handleBreakTrait(Constants.EN_PAGE);
@@ -306,16 +307,15 @@ public class PageBreaker extends AbstractBreaker {
                     1, true, BreakingAlgorithm.ALL_BREAKS);
         AbstractBreaker.log.debug("restart: iOptPageCount= " + iOptPageCount
                 + " pageBreaks.size()= " + algRestart.getPageBreaks().size());
+        //Make sure we only add the areas we haven't added already
+        effectiveList.ignoreAtStart = newStartPos;
         boolean replaceLastPage
                 = iOptPageCount <= pslm.getCurrentPV().getBodyRegion().getColumnCount();
         if (replaceLastPage) {
             //Replace last page
             pslm.setCurrentPage(pageProvider.getPage(false, currentPageNum));
-            //Make sure we only add the areas we haven't added already
-            effectiveList.ignoreAtStart = newStartPos;
             addAreas(algRestart, iOptPageCount, originalList, effectiveList);
         } else {
-            effectiveList.ignoreAtStart = newStartPos;
             addAreas(alg, restartPoint, partCount - restartPoint, originalList, effectiveList);
             //Add blank last page
             pageProvider.setLastPageIndex(currentPageNum + 1);
@@ -430,8 +430,8 @@ public class PageBreaker extends AbstractBreaker {
                         childLC);
             }
             // set the offset from the top margin
-            Footnote parentArea = (Footnote) pslm.getCurrentPV().getBodyRegion().getFootnote();
-            int topOffset = (int) pslm.getCurrentPV().getBodyRegion().getBPD() - parentArea.getBPD();
+            Footnote parentArea = pslm.getCurrentPV().getBodyRegion().getFootnote();
+            int topOffset = pslm.getCurrentPV().getBodyRegion().getBPD() - parentArea.getBPD();
             if (separatorArea != null) {
                 topOffset -= separatorArea.getBPD();
             }
@@ -451,7 +451,7 @@ public class PageBreaker extends AbstractBreaker {
     /** {@inheritDoc} */
     protected void observeElementList(List elementList) {
         ElementListObserver.observe(elementList, "breaker",
-                ((PageSequence)pslm.getFObj()).getId());
+                pslm.getFObj().getId());
     }
 
     /**
index 5c28c8005a6bf18df4c388cdf584c965c3c083d3..ec311f6a672fc4360455c589371c2d0ae0366236 100644 (file)
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Layout" dev="AD" type="fix" fixes-bug="46489">
+        Fixed a bug when combining a forced break with a "last" page-master. The restart
+        of the algorithm would start at the index of the penalty corresponding to the last
+        page-break. This has been changed to the index of the first element after the last
+        page-break.
+      </action>
       <action context="Fonts" dev="JM" type="add">
         Added a command-line tool to list all configured fonts
         (org.apache.fop.tools.fontlist.FontListMain).
diff --git a/test/layoutengine/standard-testcases/page-position-last_break-before_bugzilla46489.xml b/test/layoutengine/standard-testcases/page-position-last_break-before_bugzilla46489.xml
new file mode 100644 (file)
index 0000000..d3c1068
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+  Licensed to the Apache Software Foundation (ASF) under one or more\r
+  contributor license agreements.  See the NOTICE file distributed with\r
+  this work for additional information regarding copyright ownership.\r
+  The ASF licenses this file to You under the Apache License, Version 2.0\r
+  (the "License"); you may not use this file except in compliance with\r
+  the License.  You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+  Unless required by applicable law or agreed to in writing, software\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+-->\r
+<!-- $Id$ -->\r
+<testcase>\r
+  <info>\r
+    <p>\r
+      This test checks page-masters (reference orientation).\r
+    </p>\r
+  </info>\r
+  <fo>\r
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">\r
+      <fo:layout-master-set>\r
+        <fo:simple-page-master master-name="OTCTermsheetPageMasterFrontPage" page-width="210mm" page-height="297mm" margin-bottom="12.7mm" margin-right="12.7mm" margin-top="12.7mm" margin-left="12.7mm">\r
+          <fo:region-body margin-bottom="30mm" margin-top="42.3mm" region-name="PageBody"/>\r
+          <fo:region-before region-name="PageHeaderFrontPage" extent="42.3mm"/>\r
+          <fo:region-after precedence="true" region-name="PageFooter" extent="30mm"/>\r
+        </fo:simple-page-master>\r
+        <fo:simple-page-master master-name="OTCTermsheetPageMasterFollowing" page-width="210mm" page-height="297mm" margin-bottom="12.7mm" margin-right="12.7mm" margin-top="12.7mm" margin-left="12.7mm">\r
+          <fo:region-body margin-bottom="30mm" margin-top="20mm" region-name="PageBody"/>\r
+          <fo:region-before region-name="PageHeaderFollowing" extent="20mm"/>\r
+          <fo:region-after precedence="true" region-name="PageFooter" extent="30mm"/>\r
+        </fo:simple-page-master>\r
+        <fo:page-sequence-master master-name="OTCTermsheetPageSeq">\r
+          <fo:repeatable-page-master-alternatives>\r
+            <fo:conditional-page-master-reference page-position="first" master-reference="OTCTermsheetPageMasterFrontPage"/>\r
+            <fo:conditional-page-master-reference page-position="rest" master-reference="OTCTermsheetPageMasterFollowing"/>\r
+            <fo:conditional-page-master-reference page-position="last" master-reference="OTCTermsheetPageMasterFollowing"/>                            \r
+          </fo:repeatable-page-master-alternatives>\r
+        </fo:page-sequence-master>\r
+      </fo:layout-master-set>\r
+      <fo:page-sequence initial-page-number="1" force-page-count="no-force" master-reference="OTCTermsheetPageSeq">\r
+        <fo:flow flow-name="PageBody" font-family="Times New Roman" font-size="10pt" line-height="12pt">\r
+          <fo:block>\r
+            <fo:table table-layout="fixed" width="100%">\r
+              <fo:table-column column-width="proportional-column-width(32.36)" column-number="1"/>\r
+              <fo:table-column column-width="proportional-column-width(67.64)" column-number="2"/>\r
+              <fo:table-body>\r
+                <fo:table-row>\r
+                  <fo:table-cell padding="4pt">\r
+                    <fo:block>\r
+                      <fo:block>\r
+                        <fo:inline color="#6D6E71">Some text</fo:inline>\r
+                      </fo:block>\r
+                    </fo:block>\r
+                  </fo:table-cell>\r
+                  <fo:table-cell padding="4pt">\r
+                    <fo:block>\r
+                      <fo:block text-align="justify">More text before break. More text before break. More text before break.</fo:block>\r
+                      <fo:block>\r
+                        <fo:leader/>\r
+                      </fo:block>\r
+                    </fo:block>\r
+                  </fo:table-cell>\r
+                </fo:table-row>\r
+              </fo:table-body>\r
+            </fo:table>\r
+            <fo:table table-layout="fixed" width="100%">\r
+              <fo:table-column column-width="proportional-column-width(100)" column-number="1"/>\r
+              <fo:table-body>\r
+                <fo:table-row>\r
+                  <fo:table-cell padding="4pt">\r
+                    <fo:block>\r
+                      <fo:block id="the-block" line-height="14pt" color="#6D6E71" font-size="11pt" font-family="Arial" text-align="left" page-break-before="always">TEXT AFTER BREAK</fo:block>\r
+                      <fo:block>\r
+                        <fo:leader/>\r
+                      </fo:block>\r
+                    </fo:block>\r
+                  </fo:table-cell>\r
+                </fo:table-row>\r
+              </fo:table-body>\r
+            </fo:table>\r
+            <fo:table table-layout="fixed" width="100%">\r
+              <fo:table-column column-width="proportional-column-width(100)" column-number="1"/>\r
+              <fo:table-body>\r
+                <fo:table-row>\r
+                  <fo:table-cell padding="4pt">\r
+                    <fo:block>\r
+                      <fo:block>\r
+                        <fo:leader/>\r
+                      </fo:block>\r
+                      <fo:block>\r
+                        <fo:leader/>\r
+                      </fo:block>\r
+                      <fo:block text-align="justify">blah blah blah</fo:block>\r
+                      <fo:block>\r
+                        <fo:leader/>\r
+                      </fo:block>\r
+                      <fo:block text-align="justify">blah blah blah</fo:block>\r
+                    </fo:block>\r
+                  </fo:table-cell>\r
+                </fo:table-row>\r
+              </fo:table-body>\r
+            </fo:table>\r
+          </fo:block>\r
+        </fo:flow>\r
+      </fo:page-sequence>\r
+    </fo:root>\r
+  </fo>\r
+  <checks>\r
+    <true xpath="count(//page) = 2" />\r
+  </checks>\r
+</testcase>\r