aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Furini <lfurini@apache.org>2007-01-30 16:37:11 +0000
committerLuca Furini <lfurini@apache.org>2007-01-30 16:37:11 +0000
commit23ee8b822e45d72a349ce073c4690966fcd7d0eb (patch)
treeb9da83d1043068a0781e5591138a67b2e32f71e4
parentd490e2d0f660fac29aaaae3352c73d5755c91244 (diff)
downloadxmlgraphics-fop-23ee8b822e45d72a349ce073c4690966fcd7d0eb.tar.gz
xmlgraphics-fop-23ee8b822e45d72a349ce073c4690966fcd7d0eb.zip
Fix for bug 41019, minor changes to a few testcases as now a different set of break is created.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@501453 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java11
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java28
-rw-r--r--status.xml4
-rw-r--r--test/layoutengine/standard-testcases/block-container_content_size_percentage.xml10
-rw-r--r--test/layoutengine/standard-testcases/inline_background-color.xml10
-rw-r--r--test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml20
6 files changed, 57 insertions, 26 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
index baa0013c3..8da241395 100644
--- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
@@ -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) {
diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
index 117a7a3f9..7e14f49da 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
@@ -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;
}
@@ -1348,11 +1348,14 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
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 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
*/
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 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
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 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
*/
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 {
}
+
diff --git a/status.xml b/status.xml
index 4117095fc..8b2ab8127 100644
--- a/status.xml
+++ b/status.xml
@@ -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.
diff --git a/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml b/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml
index b7e0505ab..14d09a5d6 100644
--- a/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml
+++ b/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml
@@ -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>
diff --git a/test/layoutengine/standard-testcases/inline_background-color.xml b/test/layoutengine/standard-testcases/inline_background-color.xml
index f7eede3b0..7b488ee4c 100644
--- a/test/layoutengine/standard-testcases/inline_background-color.xml
+++ b/test/layoutengine/standard-testcases/inline_background-color.xml
@@ -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"/>
diff --git a/test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml b/test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml
index fd706d2f0..d6e594ec1 100644
--- a/test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml
+++ b/test/layoutengine/standard-testcases/inline_border_padding_conditionality_2.xml
@@ -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"/>