Author: vhennebert
Date: Mon Jul 13 18:24:12 2009
New Revision: 793648

URL: http://svn.apache.org/viewvc?rev=793648&view=rev
Log:
Restored vertical justification of content on page before ipd change.
Restored support for spaces on pages following the ipd change.
Added basic tests for borders.

Modified:
    
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
    
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
    
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
    
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
    
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
    
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/LayoutManager.java
    
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
    
xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_1.xml

Modified: 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java?rev=793648&r1=793647&r2=793648&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
 Mon Jul 13 18:24:12 2009
@@ -21,6 +21,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FObj;
@@ -253,4 +254,9 @@
         return fobj;
     }
 
+    /** {...@inheritdoc} */
+    public void reset() {
+        throw new UnsupportedOperationException("Not implemented");
+    }
+
 }

Modified: 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=793648&r1=793647&r2=793648&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
 Mon Jul 13 18:24:12 2009
@@ -130,13 +130,6 @@
         } while (curChildLM != childLM);
     }
 
-    protected void resetChildLMs() {
-        curChildLM = null;
-        while (childLMiter.hasPrevious()) {
-            childLMiter.previous();
-        }
-    }
-
     /**
      * Return indication if getChildLM will return another LM.
      * @return true if another child LM is still available
@@ -465,4 +458,22 @@
         return (super.toString() + (fobj != null ? "[fobj=" + fobj.toString() 
+ "]" : ""));
     }
 
+    /** {...@inheritdoc} */
+    public void reset() {
+        isFinished = false;
+        curChildLM = null;
+        childLMiter = new LMiter(this);
+        /*
+         * Reset the children LM. Can't rely on childLMiter since it may have
+         * been set to null in checkEndOfLayout.
+         */
+        for (LMiter iter = new LMiter(this); iter.hasNext();) {
+            ((LayoutManager) iter.next()).reset();
+        }
+        if (fobj != null) {
+            markers = fobj.getMarkers();
+        }
+        lastGeneratedPosition = -1;
+    }
+
 }

Modified: 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java?rev=793648&r1=793647&r2=793648&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
 Mon Jul 13 18:24:12 2009
@@ -382,4 +382,9 @@
         }
     }
 
+    /** {...@inheritdoc} */
+    public void reset() {
+        throw new IllegalStateException();
+    }
+
 }

Modified: 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=793648&r1=793647&r2=793648&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
 Mon Jul 13 18:24:12 2009
@@ -446,7 +446,7 @@
         }
 
         while ((currentChildLM = (LayoutManager) getChildLM()) != null) {
-            ((AbstractLayoutManager) currentChildLM).resetChildLMs(); // TODO 
won't work with forced breaks
+            currentChildLM.reset(); // TODO won't work with forced breaks
 
             childLC = new LayoutContext(0);
 
@@ -1750,5 +1750,13 @@
         return -1;
     }
 
+    /** {...@inheritdoc} */
+    public void reset() {
+        super.reset();
+        breakBeforeServed = false;
+        firstVisibleMarkServed = false;
+        // TODO startIndent, endIndent
+    }
+
 }
 

Modified: 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=793648&r1=793647&r2=793648&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
 Mon Jul 13 18:24:12 2009
@@ -111,7 +111,7 @@
         }
 
         while ((currentChildLM = getChildLM()) != null) {
-            ((AbstractLayoutManager) currentChildLM).resetChildLMs(); // TODO 
won't work with forced breaks
+            currentChildLM.reset(); // TODO won't work with forced breaks
             if (addChildElements(elements, currentChildLM, context, alignment) 
!= null) {
                 return elements;
             }

Modified: 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/LayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/LayoutManager.java?rev=793648&r1=793647&r2=793648&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/LayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/LayoutManager.java
 Mon Jul 13 18:24:12 2009
@@ -219,4 +219,10 @@
      * @return the same Position but with a position index
      */
     Position notifyPos(Position pos);
+
+    /**
+     * Re-initializes this layout manager in order to re-generate its Knuth
+     * elements according to a new IPD value.
+     */
+    void reset();
 }

Modified: 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=793648&r1=793647&r2=793648&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
 Mon Jul 13 18:24:12 2009
@@ -902,7 +902,14 @@
     protected int handleIpdChange() {
         log.trace("Best node for ipd change:" + bestNodeForIPDChange);
         // TODO finish()
-        calculateBreakPoints(bestNodeForIPDChange, par, 
bestNodeForIPDChange.line);
+        /*
+         * The third parameter is used to determine if this is the last page, 
so
+         * if the content must be vertically justified or not. If we are here
+         * this means that there is further content and the next page has a
+         * different ipd. So tweak the parameter to fall into the non-last-page
+         * case.
+         */
+        calculateBreakPoints(bestNodeForIPDChange, par, 
bestNodeForIPDChange.line + 1);
         activeLines = null;
         return bestNodeForIPDChange.line;
     }

Modified: 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_1.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_1.xml?rev=793648&r1=793647&r2=793648&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_1.xml
 (original)
+++ 
xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_1.xml
 Mon Jul 13 18:24:12 2009
@@ -52,17 +52,18 @@
               there lived a king whose daughters were all beautiful, but the 
youngest was so 
               beautiful that the sun itself, which has seen so much, was 
astonished whenever it 
               shone in her face.</fo:block>
-            <fo:block space-before="inherit" id="b3">In olden times when 
wishing still helped one, 
-              there lived a king whose daughters were all beautiful, but the 
youngest was so 
+            <fo:block space-before="inherit" id="b3" border-top="1pt solid 
black" 
+              border-before-width.conditionality="retain">In olden times when 
wishing still helped 
+              one, there lived a king whose daughters were all beautiful, but 
the youngest was so 
               beautiful that the sun itself, which has seen so much, was 
astonished whenever it 
               shone in her face. In olden times when wishing still helped one, 
there lived a king 
               whose daughters were all beautiful, but the youngest was so 
beautiful that the sun 
               itself, which has seen so much, was astonished whenever it shone 
in her 
               face.</fo:block>
-            <fo:block space-before="inherit" id="b4">In olden times when 
wishing still helped one, 
-              there lived a king whose daughters were all beautiful, but the 
youngest was so 
-              beautiful that the sun itself, which has seen so much, was 
astonished whenever it 
-              shone in her face.</fo:block>
+            <fo:block space-before="inherit" id="b4" border-top="1pt solid 
black">In olden times 
+              when wishing still helped one, there lived a king whose 
daughters were all beautiful, 
+              but the youngest was so beautiful that the sun itself, which has 
seen so much, was 
+              astonished whenever it shone in her face.</fo:block>
             <fo:block space-before="inherit" id="b5">In olden times when 
wishing still helped one, 
               there lived a king whose daughters were all beautiful, but the 
youngest was so 
               beautiful that the sun itself, which has seen so much, was 
astonished whenever it 
@@ -73,14 +74,24 @@
     </fo:root>
   </fo>
   <checks>
+    <eval expected="13100"  
xpath="//pageViewport[1]//flow/block/block[2]/@space-before"/>
+    <eval expected="13100"  
xpath="//pageViewport[1]//flow/block/block[3]/@space-before"/>
+    <eval expected="(solid,#000000,1000)"
+                            
xpath="//pageViewport[1]//flow/block/block[3]/@border-before"/>
     <eval expected="In"     
xpath="//pageViewport[1]//flow/block/block[3]/lineArea[4]/text/word[position()=last()]"/>
     <eval expected="500000" xpath="//pageViewport[2]//flow/block/@ipd"/>
+    <eval expected="(solid,#000000,1000)"
+                            
xpath="//pageViewport[2]//flow/block/block[1]/@border-before"/>
     <eval expected="500000" 
xpath="//pageViewport[2]//flow/block/block[1]/@ipd"/>
     <eval expected="500000" 
xpath="//pageViewport[2]//flow/block/block[1]/lineArea[1]/@ipd"/>
     <eval expected="olden"  
xpath="//pageViewport[2]//flow/block/block[1]/lineArea[1]/text/word[1]"/>
     <eval expected="500000" 
xpath="//pageViewport[2]//flow/block/block[2]/@ipd"/>
+    <eval expected="12000"  
xpath="//pageViewport[2]//flow/block/block[2]/@space-before"/>
+    <eval expected="(solid,#000000,1000)"
+                            
xpath="//pageViewport[2]//flow/block/block[2]/@border-before"/>
     <eval expected="500000" 
xpath="//pageViewport[2]//flow/block/block[2]/lineArea[1]/@ipd"/>
     <eval expected="500000" 
xpath="//pageViewport[2]//flow/block/block[3]/@ipd"/>
+    <eval expected="12000"  
xpath="//pageViewport[2]//flow/block/block[3]/@space-before"/>
     <eval expected="500000" 
xpath="//pageViewport[2]//flow/block/block[3]/lineArea[1]/@ipd"/>
   </checks>
 </testcase>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to