You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by cb...@apache.org on 2007/06/22 12:26:46 UTC

svn commit: r549767 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/fo/pagination/ src/java/org/apache/fop/layoutmgr/ test/layoutengine/standard-testcases/

Author: cbowditch
Date: Fri Jun 22 03:26:39 2007
New Revision: 549767

URL: http://svn.apache.org/viewvc?view=rev&rev=549767
Log:
Bugzilla #42576
Fix bug in force-page-count
Submitted by Adrian Cumiskey <dev.at.cumiskey.com>

Added:
    xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-sequence-force-page-count_bug42576.xml   (with props)
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java?view=diff&rev=549767&r1=549766&r2=549767
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java Fri Jun 22 03:26:39 2007
@@ -127,8 +127,6 @@
                 throw new ValidationException("master-reference '" + masterReference
                    + "' for fo:page-sequence matches no"
                    + " simple-page-master or page-sequence-master", locator);
-            } else {
-                pageSequenceMaster.reset();
             }
         }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java?view=diff&rev=549767&r1=549766&r2=549767
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java Fri Jun 22 03:26:39 2007
@@ -43,7 +43,7 @@
     private LayoutMasterSet layoutMasterSet;
     private List subSequenceSpecifiers;
     private SubSequenceSpecifier currentSubSequence;
-    private int currentSubSequenceNumber;
+    private int currentSubSequenceNumber = -1;
 
     // The terminology may be confusing. A 'page-sequence-master' consists
     // of a sequence of what the XSL spec refers to as
@@ -135,8 +135,10 @@
     public void reset() {
         currentSubSequenceNumber = -1;
         currentSubSequence = null;
-        for (int i = 0; i < subSequenceSpecifiers.size(); i++) {
-            ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset();
+        if (subSequenceSpecifiers != null) {
+            for (int i = 0; i < subSequenceSpecifiers.size(); i++) {
+                ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset();
+            }
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java?view=diff&rev=549767&r1=549766&r2=549767
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java Fri Jun 22 03:26:39 2007
@@ -40,6 +40,7 @@
 
 import org.apache.fop.fo.pagination.Flow;
 import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.PageSequenceMaster;
 import org.apache.fop.fo.pagination.Region;
 import org.apache.fop.fo.pagination.RegionBody;
 import org.apache.fop.fo.pagination.SideRegion;
@@ -143,10 +144,11 @@
         }
 
         areaTreeHandler.getAreaTreeModel().startPageSequence(title);
-        log.debug("Starting layout");
+        if (log.isDebugEnabled()) {
+            log.debug("Starting layout");
+        }
 
         curPage = makeNewPage(false, false);
-
         
         Flow mainFlow = pageSeq.getMainFlow();
         childFLM = getLayoutManagerMaker().
@@ -172,7 +174,19 @@
         areaTreeHandler.notifyPageSequenceFinished(pageSeq,
                 (currentPageNum - startPageNum) + 1);
         pageSeq.releasePageSequence();
-        log.debug("Ending layout");
+        
+        // If this sequence has a page sequence master so we must reset
+        // it in preparation for the next sequence
+        String masterReference = pageSeq.getMasterReference();
+        PageSequenceMaster pageSeqMaster
+            = pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(masterReference);
+        if (pageSeqMaster != null) {
+            pageSeqMaster.reset();
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Ending layout");
+        }
     }
 
 
@@ -772,7 +786,9 @@
     }
 
     private void finishPage() {
-        curPage.getPageViewport().dumpMarkers();
+        if (log.isTraceEnabled()) {
+            curPage.getPageViewport().dumpMarkers();
+        }
         // Layout side regions
         layoutSideRegion(FO_REGION_BEFORE); 
         layoutSideRegion(FO_REGION_AFTER);
@@ -1123,7 +1139,6 @@
         // If there is no next page-sequence 
         // or if the value of its initial-page-number is "auto" do not force any page.
             
-
         // if force-page-count is auto then set the value of forcePageCount 
         // depending on the initial-page-number of the next page-sequence
         if (nextPageSeqInitialPageNumber != null && forcePageCount == Constants.EN_AUTO) {
@@ -1150,19 +1165,19 @@
         }
 
         if (forcePageCount == Constants.EN_EVEN) {
-            if ((currentPageNum - startPageNum + 1) % 2 != 0) { // we have a odd number of pages
+            if ((currentPageNum - startPageNum + 1) % 2 != 0) { // we have an odd number of pages
                 curPage = makeNewPage(true, false);
             }
         } else if (forcePageCount == Constants.EN_ODD) {
-            if ((currentPageNum - startPageNum + 1) % 2 == 0) { // we have a even number of pages
+            if ((currentPageNum - startPageNum + 1) % 2 == 0) { // we have an even number of pages
                 curPage = makeNewPage(true, false);
             }
         } else if (forcePageCount == Constants.EN_END_ON_EVEN) {
-            if (currentPageNum % 2 != 0) { // we are now on a odd page
+            if (currentPageNum % 2 != 0) { // we are now on an odd page
                 curPage = makeNewPage(true, false);
             }
         } else if (forcePageCount == Constants.EN_END_ON_ODD) {
-            if (currentPageNum % 2 == 0) { // we are now on a even page
+            if (currentPageNum % 2 == 0) { // we are now on an even page
                 curPage = makeNewPage(true, false);
             }
         } else if (forcePageCount == Constants.EN_NO_FORCE) {

Added: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-sequence-force-page-count_bug42576.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-sequence-force-page-count_bug42576.xml?view=auto&rev=549767
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-sequence-force-page-count_bug42576.xml (added)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-sequence-force-page-count_bug42576.xml Fri Jun 22 03:26:39 2007
@@ -0,0 +1,152 @@
+<?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 force-page-count property
+      using three identical page sequences refering to the same
+      page sequence master, odd pages should be blank.
+    </p>
+  </info>
+  <variables>
+    <img>../../resources/images/bgimg300dpi.jpg</img>
+  </variables>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="first" page-height="297mm" page-width="210mm" margin-top="20mm" margin-bottom="20mm" margin-left="25mm" margin-right="25mm">
+          <fo:region-body margin-bottom="20mm"/>
+          <fo:region-before region-name="header-first" extent="10mm"/>
+        </fo:simple-page-master>
+        <fo:simple-page-master master-name="normal" page-height="297mm" page-width="210mm" margin-top="20mm" margin-bottom="20mm" margin-left="25mm" margin-right="25mm">
+          <fo:region-body margin-bottom="20mm"/>
+          <fo:region-before region-name="header-normal" extent="10mm"/>
+          <fo:region-after region-name="footer-normal" extent="10mm"/>
+        </fo:simple-page-master>
+        <fo:simple-page-master master-name="blank" page-height="297mm" page-width="210mm" margin-top="20mm" margin-bottom="20mm" margin-left="25mm" margin-right="25mm">
+          <fo:region-body/>
+          <fo:region-before region-name="header-blank" extent="297mm"/>
+        </fo:simple-page-master>
+        <fo:page-sequence-master master-name="document">
+          <fo:single-page-master-reference master-reference="first"/>
+          <fo:repeatable-page-master-alternatives>
+            <fo:conditional-page-master-reference blank-or-not-blank="not-blank" master-reference="normal"/>
+            <fo:conditional-page-master-reference blank-or-not-blank="blank" master-reference="blank"/>
+          </fo:repeatable-page-master-alternatives>
+        </fo:page-sequence-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="document" force-page-count="end-on-even">
+        <fo:static-content flow-name="footer-normal">
+          <fo:block text-align="center">Normal footer</fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="header-first">
+          <fo:block text-align="center">FIRST PAGE OF SEQUENCE</fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="header-normal">
+          <fo:block text-align="center">Normal Non-blank page</fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="header-blank">
+          <fo:block space-before="100mm" text-align-last="center">
+       Intentionally left blank.</fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block break-after="page">
+       TEST PAGE 1
+     </fo:block>
+          <fo:block break-after="page">
+       TEST PAGE 2
+     </fo:block>
+          <fo:block>
+       TEST PAGE 3
+     </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+      <fo:page-sequence master-reference="document" force-page-count="end-on-even">
+        <fo:static-content flow-name="footer-normal">
+          <fo:block text-align="center">Normal footer</fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="header-first">
+          <fo:block text-align="center">FIRST PAGE OF SEQUENCE</fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="header-normal">
+          <fo:block text-align="center">Normal Non-blank page</fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="header-blank">
+          <fo:block space-before="100mm" text-align-last="center">
+       Intentionally left blank.</fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block break-after="page">
+       TEST PAGE 1
+     </fo:block>
+          <fo:block break-after="page">
+       TEST PAGE 2
+     </fo:block>
+          <fo:block>
+       TEST PAGE 3
+     </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+      <fo:page-sequence master-reference="document" force-page-count="end-on-even">
+        <fo:static-content flow-name="footer-normal">
+          <fo:block text-align="center">Normal footer</fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="header-first">
+          <fo:block text-align="center">FIRST PAGE OF SEQUENCE</fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="header-normal">
+          <fo:block text-align="center">Normal Non-blank page</fo:block>
+        </fo:static-content>
+        <fo:static-content flow-name="header-blank">
+          <fo:block space-before="100mm" text-align-last="center">
+       Intentionally left blank.</fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block break-after="page">
+       TEST PAGE 1
+     </fo:block>
+          <fo:block break-after="page">
+       TEST PAGE 2
+     </fo:block>
+          <fo:block>
+       TEST PAGE 3
+     </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="3" xpath="count(//pageSequence)"/>
+    <eval expected="3" xpath="count(//pageSequence/pageViewport[@simple-page-master-name='first'])"/>
+    <eval expected="6" xpath="count(//pageSequence/pageViewport[@simple-page-master-name='normal'])"/>
+    <eval expected="3" xpath="count(//pageSequence/pageViewport[@simple-page-master-name='blank'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=1 and @simple-page-master-name='first'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=2 and @simple-page-master-name='normal'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=3 and @simple-page-master-name='normal'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=4 and @simple-page-master-name='blank'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=5 and @simple-page-master-name='first'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=6 and @simple-page-master-name='normal'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=7 and @simple-page-master-name='normal'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=8 and @simple-page-master-name='blank'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=9 and @simple-page-master-name='first'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=10 and @simple-page-master-name='normal'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=11 and @simple-page-master-name='normal'])"/>
+    <eval expected="1" xpath="count(//pageSequence/pageViewport[@nr=12 and @simple-page-master-name='blank'])"/>
+  </checks>
+</testcase>

Propchange: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-sequence-force-page-count_bug42576.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-sequence-force-page-count_bug42576.xml
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Re: svn commit: r549767 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/fo/pagination/ src/java/org/apache/fop/layoutmgr/ test/layoutengine/standard-testcases/

Posted by Simon Pepping <sp...@leverkruid.eu>.
On Fri, Jun 22, 2007 at 10:26:46AM -0000, cbowditch@apache.org wrote:
> Author: cbowditch
> Date: Fri Jun 22 03:26:39 2007
> New Revision: 549767
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=549767
> Log:
> Bugzilla #42576
> Fix bug in force-page-count
> Submitted by Adrian Cumiskey <dev.at.cumiskey.com>

> -        log.debug("Starting layout");
> +        if (log.isDebugEnabled()) {
> +            log.debug("Starting layout");
> +        }

I believe this is a bit overdone. log.isDebugEnabled() is useful to
avoid an appreciable amount of work in cases where the result is not
used. Here the amount of work of the avoided debug message is equal to
the amount of work to test the condition.

Simon Pepping

-- 
Simon Pepping
home page: http://www.leverkruid.eu