Author: adelmelle
Date: Wed Nov 19 14:45:06 2008
New Revision: 719110

URL: http://svn.apache.org/viewvc?rev=719110&view=rev
Log:
Bugzilla 46240:
Fixed a bug in combining break-before with a span change.

Added:
    
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug46240.xml
   (with props)
Modified:
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
    xmlgraphics/fop/trunk/status.xml

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=719110&r1=719109&r2=719110&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java 
(original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java 
Wed Nov 19 14:45:06 2008
@@ -50,8 +50,6 @@
     /** Array of areas currently being filled stored by area class */
     private BlockParent[] currentAreas = new BlockParent[Area.CLASS_MAX];
 
-    private int currentSpan = EN_NONE;
-
     /**
      * This is the top level layout manager.
      * It is created by the PageSequence FO.
@@ -89,10 +87,11 @@
             } else if (curLM instanceof BlockContainerLayoutManager) {
                 span = 
((BlockContainerLayoutManager)curLM).getBlockContainerFO().getSpan();
             }
+
+            int currentSpan = context.getCurrentSpan();
             if (currentSpan != span) {
                 log.debug("span change from " + currentSpan + " to " + span);
                 context.signalSpanChange(span);
-                currentSpan = span;
                 SpaceResolver.resolveElementList(returnList);
                 return returnList;
             }
@@ -228,7 +227,7 @@
             oldElement = (KnuthElement)oldListIterator.next();
             if (oldElement.getPosition() instanceof NonLeafPosition) {
                 // oldElement was created by a descendant of this FlowLM
-                
oldElement.setPosition(((NonLeafPosition)oldElement.getPosition()).getPosition());
+                
oldElement.setPosition((oldElement.getPosition()).getPosition());
             } else {
                 // thisElement was created by this FlowLM, remove it
                 oldListIterator.remove();
@@ -344,7 +343,7 @@
      * @return the BPD of the content area
      */
     public int getContentAreaBPD() {
-        return (int) getCurrentPV().getBodyRegion().getBPD();
+        return getCurrentPV().getBodyRegion().getBPD();
     }
 
 }

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java?rev=719110&r1=719109&r2=719110&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java 
Wed Nov 19 14:45:06 2008
@@ -88,7 +88,8 @@
      */
     private MinOptMax stackLimitIP;
 
-    /** True if current element list is spanning in multi-column layout. */
+    /** to keep track of spanning in multi-column layout */
+    private int currentSpan = Constants.NOT_SET;
     private int nextSpan = Constants.NOT_SET;
 
     /** inline-progression-dimension of nearest ancestor reference area */
@@ -522,22 +523,37 @@
     }
 
     /**
-     * @return true if the current element list ends early because of a span 
change
-     * in multi-column layout.
+     * @return one of: [EMAIL PROTECTED] Constants#NOT_SET}, [EMAIL PROTECTED] 
Constants#EN_NONE}
+     *                  [EMAIL PROTECTED] Constants#EN_ALL}
      */
     public int getNextSpan() {
         return nextSpan;
     }
 
     /**
+     * @return one of: [EMAIL PROTECTED] Constants#NOT_SET}, [EMAIL PROTECTED] 
Constants#EN_NONE}
+     *                  [EMAIL PROTECTED] Constants#EN_ALL}
+     */
+    public int getCurrentSpan() {
+        return (currentSpan == Constants.NOT_SET)
+                ? Constants.EN_NONE : currentSpan;
+    }
+
+    /**
      * Used to signal the PSLM that the element list ends early because of a 
span change in
      * multi-column layout.
      * @param span the new span value (legal values: NOT_SET, EN_NONE, EN_ALL)
      */
     public void signalSpanChange(int span) {
-        if (span == Constants.NOT_SET || span == Constants.EN_NONE || span == 
Constants.EN_ALL) {
+        switch (span) {
+        case Constants.NOT_SET:
+        case Constants.EN_NONE:
+        case Constants.EN_ALL:
+            this.currentSpan = this.nextSpan;
             this.nextSpan = span;
-        } else {
+            break;
+        default:
+            assert false;
             throw new IllegalArgumentException("Illegal value on 
signalSpanChange() for span: "
                     + span);
         }

Modified: xmlgraphics/fop/trunk/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=719110&r1=719109&r2=719110&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Wed Nov 19 14:45:06 2008
@@ -53,6 +53,9 @@
 
   <changes>
     <release version="FOP Trunk" date="TBD">
+      <action context="Layout" dev="AD" type="fix" fixes-bug="46240">
+        Fixed a bug when combining break-before with a span change.
+      </action>
       <action context="Code" dev="AD" type="fix" fixes-bug="46211" 
due-to="rogov.AT.devexperts.com">
         Fixed some multi-threading issues in FontCache.java:
         <ul>

Added: 
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug46240.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug46240.xml?rev=719110&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug46240.xml
 (added)
+++ 
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug46240.xml
 Wed Nov 19 14:45:06 2008
@@ -0,0 +1,59 @@
+<?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>
+      Test for Bugzilla #46240: break-before breaks span-change.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
+      <fo:layout-master-set>
+        <fo:simple-page-master page-height="841.8898pt" 
page-width="595.27563pt" master-name="page">
+          <fo:region-body margin-right="49.6063pt" margin-left="29.763779pt" 
margin-bottom="46.771652pt" margin-top="36.850395pt" column-count="2"/>
+        </fo:simple-page-master>
+        <fo:page-sequence-master master-name="contents">
+          <fo:single-page-master-reference master-reference="page"/>
+        </fo:page-sequence-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="contents" initial-page-number="2">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block id="block-1" span="all" break-before="odd-page" 
break-after="even-page">
+            <fo:inline font-size="16.0pt">xxx xxx xxx xxx xxx xxx xxx xxx xxx 
xxx xxx xxx </fo:inline>
+          </fo:block>
+          <fo:block />
+        </fo:flow>
+      </fo:page-sequence>
+      <fo:page-sequence master-reference="contents">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block id="block-2" span="all" break-before="even-page">
+            <fo:inline font-size="16.0pt">xxx xxx xxx xxx xxx xxx xxx xxx xxx 
xxx xxx xxx </fo:inline>
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="5" xpath="count(//pageViewport)" />
+    <eval expected="3" xpath="count(//pageSequence[1]/pageViewport)" />
+    <eval expected="1" xpath="count(//[EMAIL PROTECTED]'block-1']/lineArea)" />
+    <eval expected="2" xpath="count(//pageSequence[2]/pageViewport)" />
+    <eval expected="1" xpath="count(//[EMAIL PROTECTED]'block-2']/lineArea)" />
+  </checks>
+</testcase>

Propchange: 
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug46240.xml
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to