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 lf...@apache.org on 2007/01/30 17:37:12 UTC

svn commit: r501453 - in /xmlgraphics/fop/trunk: ./ src/java/org/apache/fop/layoutmgr/ src/java/org/apache/fop/layoutmgr/inline/ test/layoutengine/standard-testcases/

Author: lfurini
Date: Tue Jan 30 08:37:11 2007
New Revision: 501453

URL: http://svn.apache.org/viewvc?view=rev&rev=501453
Log:
Fix for bug 41019, minor changes to a few testcases as now a different set of break is created.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
    xmlgraphics/fop/trunk/status.xml
    xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml
    xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_background-color.xml
    xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java?view=diff&rev=501453&r1=501452&r2=501453
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java Tue Jan 30 08:37:11 2007
@@ -491,6 +491,17 @@
                     log.debug("Could not find a set of breaking points " + threshold);
                     return 0;
                 }
+                // lastDeactivated was a "good" break, while lastTooShort and lastTooLong 
+                // were "bad" breaks since the beginning;
+                // if it is not the node we just restarted from, lastDeactivated can 
+                // replace either lastTooShort or lastTooLong
+                if (lastDeactivated != null && lastDeactivated != lastForced) {
+                    if (lastDeactivated.adjustRatio > 0) {
+                        lastTooShort = lastDeactivated;
+                    } else {
+                        lastTooLong = lastDeactivated;
+                    }
+                }
                 if (lastTooShort == null || lastForced.position == lastTooShort.position) {
                     if (isPartOverflowRecoveryActivated()) {
                         if (this.lastRecovered == null) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?view=diff&rev=501453&r1=501452&r2=501453
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java Tue Jan 30 08:37:11 2007
@@ -1308,7 +1308,7 @@
             // the word fragment ends with a character that acts as a hyphen
             // if a break occurs the width does not increase,
             // otherwise there is one more letter space
-            wordElements.addAll(createElementsForAHyphen(alignment, 0, letterSpaceWidth, false));
+            wordElements.addAll(createElementsForAHyphen(alignment, 0, letterSpaceWidth, true));
         }
         return wordElements;
     }
@@ -1316,7 +1316,7 @@
     // static final int SOFT_HYPHEN_PENALTY = KnuthPenalty.FLAGGED_PENALTY / 10;
     static final int SOFT_HYPHEN_PENALTY = 1;
     private LinkedList createElementsForAHyphen(int alignment,
-            int widthIfBreakOccurs, MinOptMax widthIfNoBreakOccurs, boolean softHyphen) {
+            int widthIfBreakOccurs, MinOptMax widthIfNoBreakOccurs, boolean unflagged) {
         if (widthIfNoBreakOccurs == null) {
             widthIfNoBreakOccurs = ZERO_MINOPTMAX;
         }
@@ -1348,11 +1348,14 @@
                         new LeafPosition(this, -1), false));
             */
             hyphenElements.add
+                (new KnuthPenalty(0, KnuthElement.INFINITE, false,
+                        new LeafPosition(this, -1), true));
+            hyphenElements.add
                 (new KnuthGlue(lineEndBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                                new LeafPosition(this, -1), true));
             hyphenElements.add
                 (new KnuthPenalty(hyphIPD,
-                        softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+                        unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
                         new LeafPosition(this, -1), false));
             hyphenElements.add
                 (new KnuthGlue(-(lineEndBAP + lineStartBAP),
@@ -1387,11 +1390,14 @@
             */
             if (lineStartBAP != 0 || lineEndBAP != 0) {
                 hyphenElements.add
+                    (new KnuthPenalty(0, KnuthElement.INFINITE, false,
+                            new LeafPosition(this, -1), true));
+                hyphenElements.add
                     (new KnuthGlue(lineEndBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                                    new LeafPosition(this, -1), false));
                 hyphenElements.add
                     (new KnuthPenalty(widthIfBreakOccurs,
-                            softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+                            unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
                             new LeafPosition(this, -1), false));
                 hyphenElements.add
                     (new KnuthGlue(widthIfNoBreakOccurs.opt - (lineStartBAP + lineEndBAP),
@@ -1408,11 +1414,14 @@
                                    new LeafPosition(this, -1), false));
             } else {
                 hyphenElements.add
+                    (new KnuthPenalty(0, KnuthElement.INFINITE, false,
+                            new LeafPosition(this, -1), true));
+                hyphenElements.add
                     (new KnuthGlue(0, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                             new LeafPosition(this, -1), false));
                 hyphenElements.add
                     (new KnuthPenalty(widthIfBreakOccurs,
-                            softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+                            unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
                             new LeafPosition(this, -1), false));
                 hyphenElements.add
                     (new KnuthGlue(widthIfNoBreakOccurs.opt,
@@ -1432,11 +1441,15 @@
             */
             if (lineStartBAP != 0 || lineEndBAP != 0) {
                 hyphenElements.add
+                    (new KnuthPenalty(0, KnuthElement.INFINITE, false,
+                            new LeafPosition(this, -1), true));
+
+                hyphenElements.add
                     (new KnuthGlue(lineEndBAP, 0, 0,
                                    new LeafPosition(this, -1), false));
                 hyphenElements.add
                     (new KnuthPenalty(widthIfBreakOccurs,
-                            softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+                            unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
                             new LeafPosition(this, -1), false));
                 // extra elements representing a letter space that is suppressed
                 // if a break occurs
@@ -1464,7 +1477,7 @@
             } else {
                 hyphenElements.add
                     (new KnuthPenalty(widthIfBreakOccurs,
-                            softHyphen ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, true,
+                            unflagged ? SOFT_HYPHEN_PENALTY : KnuthPenalty.FLAGGED_PENALTY, !unflagged,
                             new LeafPosition(this, -1), false));
                 // extra elements representing a letter space that is suppressed
                 // if a break occurs
@@ -1483,4 +1496,5 @@
     }
     
 }
+
 

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?view=diff&rev=501453&r1=501452&r2=501453
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue Jan 30 08:37:11 2007
@@ -28,6 +28,10 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="LF" type="fix" fixes-bug="41019">
+        Fix incorrect behaviour of the BreakingAlgorithm when some inline content is wider than
+        the available ipd, causing a restart.
+      </action>
       <action context="Code" dev="JM" type="fix">
         Fix for PDF corruption when a TrueType font with spaces in its name is embedded and no 
         XML font metrics file for that font is used.

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml?view=diff&rev=501453&r1=501452&r2=501453
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml Tue Jan 30 08:37:11 2007
@@ -61,9 +61,9 @@
     <!-- from the spec: If that dimension is not specified explicitly (i.e., it depends on 
          content's blockprogression-dimension), the value is interpreted as "auto". -->
     <!-- The 10% are ignored in this case. -->
-    <eval expected="28800" xpath="//flow/block[2]/@bpd"/> <!-- 2 lines -->
+    <eval expected="43200" xpath="//flow/block[2]/@bpd"/> <!-- 3 lines -->
     <eval expected="100000" xpath="//flow/block[2]/@ipd"/>
-    <eval expected="28800" xpath="//flow/block[2]/block[1]/block[1]/@bpd"/>
+    <eval expected="43200" xpath="//flow/block[2]/block[1]/block[1]/@bpd"/>
     <eval expected="50000" xpath="//flow/block[2]/block[1]/block[1]/@ipd"/>
 
     <!-- absolute -->
@@ -76,9 +76,11 @@
     <!-- from the spec: If that dimension is not specified explicitly (i.e., it depends on 
          content's blockprogression-dimension), the value is interpreted as "auto". -->
     <!-- The 10% are ignored in this case. -->
-    <eval expected="43200" xpath="//flow/block[4]/@bpd"/> <!-- 3 lines -->
+    <eval expected="57600" xpath="//flow/block[4]/@bpd"/> <!-- 4 lines -->
     <eval expected="100000" xpath="//flow/block[4]/@ipd"/>
-    <eval expected="43200" xpath="//flow/block[4]/block[1]/block[1]/@bpd"/>
+    <eval expected="28800" xpath="//flow/block[4]/block[1]/block[1]/@bpd"/> <!-- the first 2 lines ... -->
     <eval expected="50000" xpath="//flow/block[4]/block[1]/block[1]/@ipd"/>
+    <eval expected="28800" xpath="//flow/block[4]/block[1]/block[2]/@bpd"/> <!-- ... and the other 2 lines -->
+    <eval expected="50000" xpath="//flow/block[4]/block[1]/block[2]/@ipd"/>
   </checks>
 </testcase>

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_background-color.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_background-color.xml?view=diff&rev=501453&r1=501452&r2=501453
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_background-color.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_background-color.xml Tue Jan 30 08:37:11 2007
@@ -97,23 +97,23 @@
 
     <eval expected="188950" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipd"/>
     <eval expected="color=#ffff00" xpath="//flow/block[5]/lineArea[1]/inlineparent/@background"/>
-    <eval expected="313470" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>
+    <eval expected="335700" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>
     <eval expected="color=#ffff00" xpath="//flow/block[5]/lineArea[2]/inlineparent/@background"/>
-    <eval expected="145610" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>
+    <eval expected="126160" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>
     <eval expected="color=#ffff00" xpath="//flow/block[5]/lineArea[3]/inlineparent/@background"/>
 
     <eval expected="188950" xpath="//flow/block[6]/lineArea[1]/inlineparent/@ipd"/>
     <eval expected="color=#ffff00" xpath="//flow/block[6]/lineArea[1]/inlineparent/@background"/>
-    <eval expected="313470" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>
+    <eval expected="335700" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>
     <eval expected="color=#ffff00" xpath="//flow/block[6]/lineArea[2]/inlineparent/@background"/>
-    <eval expected="109650" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>
+    <eval expected="90200" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>
     <eval expected="color=#ffff00" xpath="//flow/block[6]/lineArea[3]/inlineparent/@background"/>
 
     <eval expected="199793" xpath="//flow/block[7]/lineArea[1]/inlineparent/@ipd"/>
     <eval expected="color=#ffff00" xpath="//flow/block[7]/lineArea[1]/inlineparent/@background"/>
     <eval expected="350000" xpath="//flow/block[7]/lineArea[2]/inlineparent/@ipd"/>
     <eval expected="color=#ffff00" xpath="//flow/block[7]/lineArea[2]/inlineparent/@background"/>
-    <eval expected="118530" xpath="//flow/block[7]/lineArea[3]/inlineparent/@ipd"/>
+    <eval expected="99080" xpath="//flow/block[7]/lineArea[3]/inlineparent/@ipd"/>
     <eval expected="color=#ffff00" xpath="//flow/block[7]/lineArea[3]/inlineparent/@background"/>
 
     <eval expected="128370" xpath="//flow/block[8]/lineArea[1]/inlineparent/@ipd"/>

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml?view=diff&rev=501453&r1=501452&r2=501453
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml Tue Jan 30 08:37:11 2007
@@ -249,8 +249,8 @@
     <eval expected="3000" xpath="//flow/block[4]/lineArea[3]/inlineparent/@padding-end"/>
     <eval expected="5000" xpath="//flow/block[4]/lineArea[3]/inlineparent/@padding-start"/>
 
-    <eval expected="149500" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipd"/>
-    <eval expected="159500" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipda"/>
+    <eval expected="172840" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipd"/>
+    <eval expected="182840" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipda"/>
     <eval expected="0" xpath="//flow/block[5]/lineArea[1]/inlineparent/@offset"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[1]/inlineparent/@border-after"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[1]/inlineparent/@border-before"/>
@@ -260,8 +260,8 @@
     <eval expected="1000" xpath="//flow/block[5]/lineArea[1]/inlineparent/@padding-before"/>
     <eval expected="3000" xpath="//flow/block[5]/lineArea[1]/inlineparent/@padding-end"/>
     <eval expected="5000" xpath="//flow/block[5]/lineArea[1]/inlineparent/@padding-start"/>
-    <eval expected="237340" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>
-    <eval expected="247340" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipda"/>
+    <eval expected="231230" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>
+    <eval expected="241230" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipda"/>
     <eval expected="0" xpath="//flow/block[5]/lineArea[2]/inlineparent/@offset"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[2]/inlineparent/@border-after"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[2]/inlineparent/@border-before"/>
@@ -271,8 +271,8 @@
     <eval expected="1000" xpath="//flow/block[5]/lineArea[2]/inlineparent/@padding-before"/>
     <eval expected="3000" xpath="//flow/block[5]/lineArea[2]/inlineparent/@padding-end"/>
     <eval expected="5000" xpath="//flow/block[5]/lineArea[2]/inlineparent/@padding-start"/>
-    <eval expected="239550" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>
-    <eval expected="249550" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipda"/>
+    <eval expected="222320" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>
+    <eval expected="232320" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipda"/>
     <eval expected="0" xpath="//flow/block[5]/lineArea[3]/inlineparent/@offset"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[3]/inlineparent/@border-after"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[3]/inlineparent/@border-before"/>
@@ -292,15 +292,15 @@
     <eval expected="1000" xpath="//flow/block[6]/lineArea[1]/inlineparent/@padding-after"/>
     <eval expected="1000" xpath="//flow/block[6]/lineArea[1]/inlineparent/@padding-before"/>
     <eval expected="5000" xpath="//flow/block[6]/lineArea[1]/inlineparent/@padding-start"/>
-    <eval expected="237340" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>
-    <eval expected="237340" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipda"/>
+    <eval expected="254570" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>
+    <eval expected="254570" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipda"/>
     <eval expected="0" xpath="//flow/block[6]/lineArea[2]/inlineparent/@offset"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[2]/inlineparent/@border-after"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[2]/inlineparent/@border-before"/>
     <eval expected="1000" xpath="//flow/block[6]/lineArea[2]/inlineparent/@padding-after"/>
     <eval expected="1000" xpath="//flow/block[6]/lineArea[2]/inlineparent/@padding-before"/>
-    <eval expected="239550" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>
-    <eval expected="243550" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipda"/>
+    <eval expected="222320" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>
+    <eval expected="226320" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipda"/>
     <eval expected="0" xpath="//flow/block[6]/lineArea[3]/inlineparent/@offset"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[3]/inlineparent/@border-after"/>
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[3]/inlineparent/@border-before"/>



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