]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix for bug 41019, minor changes to a few testcases as now a different set of break...
authorLuca Furini <lfurini@apache.org>
Tue, 30 Jan 2007 16:37:11 +0000 (16:37 +0000)
committerLuca Furini <lfurini@apache.org>
Tue, 30 Jan 2007 16:37:11 +0000 (16:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@501453 13f79535-47bb-0310-9956-ffa450edef68

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

index baa0013c324b3617f1a685a6cc38d3abab9d21e5..8da24139522ad4ceda1f06a49d8482d77bd3b0bd 100644 (file)
@@ -491,6 +491,17 @@ public abstract class BreakingAlgorithm {
                     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) {
index 117a7a3f9078446c7fef6a3d5cc285d616f59123..7e14f49dac25b98b8aa36bdb186f6edfe385b455 100644 (file)
@@ -1308,7 +1308,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
             // 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 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
     // 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;
         }
@@ -1347,12 +1347,15 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
                 (new KnuthGlue(0, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
                         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),
@@ -1386,12 +1389,15 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
                         new LeafPosition(this, -1), false));
             */
             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),
@@ -1407,12 +1413,15 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
                     (new KnuthGlue(lineStartBAP, 0, 0,
                                    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,
@@ -1431,12 +1440,16 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
                         new LeafPosition(this, -1), false));
             */
             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 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
             } 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
@@ -1484,3 +1497,4 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
     
 }
 
+
index 4117095fc3d31ba33ef508f636d75fc3e2f587af..8b2ab81271ae6542270d33a65a645552f2fa4f25 100644 (file)
 
   <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.
index b7e0505ab03f96ed7f6f20f6b55c9ca9141f326a..14d09a5d699813e4aca1f56fc5a5496f63744290 100644 (file)
@@ -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 -->
     <!-- 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>
index f7eede3b060f3e0d7dd8195f3aa9bdeb890e15e9..7b488ee4c19d5525a6e35ca42e5a70a5ce6fea36 100644 (file)
 \r
     <eval expected="188950" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipd"/>\r
     <eval expected="color=#ffff00" xpath="//flow/block[5]/lineArea[1]/inlineparent/@background"/>\r
-    <eval expected="313470" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>\r
+    <eval expected="335700" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>\r
     <eval expected="color=#ffff00" xpath="//flow/block[5]/lineArea[2]/inlineparent/@background"/>\r
-    <eval expected="145610" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>\r
+    <eval expected="126160" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>\r
     <eval expected="color=#ffff00" xpath="//flow/block[5]/lineArea[3]/inlineparent/@background"/>\r
 \r
     <eval expected="188950" xpath="//flow/block[6]/lineArea[1]/inlineparent/@ipd"/>\r
     <eval expected="color=#ffff00" xpath="//flow/block[6]/lineArea[1]/inlineparent/@background"/>\r
-    <eval expected="313470" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>\r
+    <eval expected="335700" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>\r
     <eval expected="color=#ffff00" xpath="//flow/block[6]/lineArea[2]/inlineparent/@background"/>\r
-    <eval expected="109650" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>\r
+    <eval expected="90200" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>\r
     <eval expected="color=#ffff00" xpath="//flow/block[6]/lineArea[3]/inlineparent/@background"/>\r
 \r
     <eval expected="199793" xpath="//flow/block[7]/lineArea[1]/inlineparent/@ipd"/>\r
     <eval expected="color=#ffff00" xpath="//flow/block[7]/lineArea[1]/inlineparent/@background"/>\r
     <eval expected="350000" xpath="//flow/block[7]/lineArea[2]/inlineparent/@ipd"/>\r
     <eval expected="color=#ffff00" xpath="//flow/block[7]/lineArea[2]/inlineparent/@background"/>\r
-    <eval expected="118530" xpath="//flow/block[7]/lineArea[3]/inlineparent/@ipd"/>\r
+    <eval expected="99080" xpath="//flow/block[7]/lineArea[3]/inlineparent/@ipd"/>\r
     <eval expected="color=#ffff00" xpath="//flow/block[7]/lineArea[3]/inlineparent/@background"/>\r
 \r
     <eval expected="128370" xpath="//flow/block[8]/lineArea[1]/inlineparent/@ipd"/>\r
index fd706d2f0cd4d5455c4d34c2653dd9f12717f530..d6e594ec19019806f47781422987ba535cfcc526 100644 (file)
     <eval expected="3000" xpath="//flow/block[4]/lineArea[3]/inlineparent/@padding-end"/>\r
     <eval expected="5000" xpath="//flow/block[4]/lineArea[3]/inlineparent/@padding-start"/>\r
 \r
-    <eval expected="149500" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipd"/>\r
-    <eval expected="159500" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipda"/>\r
+    <eval expected="172840" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipd"/>\r
+    <eval expected="182840" xpath="//flow/block[5]/lineArea[1]/inlineparent/@ipda"/>\r
     <eval expected="0" xpath="//flow/block[5]/lineArea[1]/inlineparent/@offset"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[1]/inlineparent/@border-after"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[1]/inlineparent/@border-before"/>\r
     <eval expected="1000" xpath="//flow/block[5]/lineArea[1]/inlineparent/@padding-before"/>\r
     <eval expected="3000" xpath="//flow/block[5]/lineArea[1]/inlineparent/@padding-end"/>\r
     <eval expected="5000" xpath="//flow/block[5]/lineArea[1]/inlineparent/@padding-start"/>\r
-    <eval expected="237340" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>\r
-    <eval expected="247340" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipda"/>\r
+    <eval expected="231230" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipd"/>\r
+    <eval expected="241230" xpath="//flow/block[5]/lineArea[2]/inlineparent/@ipda"/>\r
     <eval expected="0" xpath="//flow/block[5]/lineArea[2]/inlineparent/@offset"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[2]/inlineparent/@border-after"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[2]/inlineparent/@border-before"/>\r
     <eval expected="1000" xpath="//flow/block[5]/lineArea[2]/inlineparent/@padding-before"/>\r
     <eval expected="3000" xpath="//flow/block[5]/lineArea[2]/inlineparent/@padding-end"/>\r
     <eval expected="5000" xpath="//flow/block[5]/lineArea[2]/inlineparent/@padding-start"/>\r
-    <eval expected="239550" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>\r
-    <eval expected="249550" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipda"/>\r
+    <eval expected="222320" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipd"/>\r
+    <eval expected="232320" xpath="//flow/block[5]/lineArea[3]/inlineparent/@ipda"/>\r
     <eval expected="0" xpath="//flow/block[5]/lineArea[3]/inlineparent/@offset"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[3]/inlineparent/@border-after"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[5]/lineArea[3]/inlineparent/@border-before"/>\r
     <eval expected="1000" xpath="//flow/block[6]/lineArea[1]/inlineparent/@padding-after"/>\r
     <eval expected="1000" xpath="//flow/block[6]/lineArea[1]/inlineparent/@padding-before"/>\r
     <eval expected="5000" xpath="//flow/block[6]/lineArea[1]/inlineparent/@padding-start"/>\r
-    <eval expected="237340" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>\r
-    <eval expected="237340" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipda"/>\r
+    <eval expected="254570" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipd"/>\r
+    <eval expected="254570" xpath="//flow/block[6]/lineArea[2]/inlineparent/@ipda"/>\r
     <eval expected="0" xpath="//flow/block[6]/lineArea[2]/inlineparent/@offset"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[2]/inlineparent/@border-after"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[2]/inlineparent/@border-before"/>\r
     <eval expected="1000" xpath="//flow/block[6]/lineArea[2]/inlineparent/@padding-after"/>\r
     <eval expected="1000" xpath="//flow/block[6]/lineArea[2]/inlineparent/@padding-before"/>\r
-    <eval expected="239550" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>\r
-    <eval expected="243550" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipda"/>\r
+    <eval expected="222320" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipd"/>\r
+    <eval expected="226320" xpath="//flow/block[6]/lineArea[3]/inlineparent/@ipda"/>\r
     <eval expected="0" xpath="//flow/block[6]/lineArea[3]/inlineparent/@offset"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[3]/inlineparent/@border-after"/>\r
     <eval expected="(solid,#ff0000,1000)" xpath="//flow/block[6]/lineArea[3]/inlineparent/@border-before"/>\r