From: Luca Furini Date: Tue, 30 Jan 2007 16:37:11 +0000 (+0000) Subject: Fix for bug 41019, minor changes to a few testcases as now a different set of break... X-Git-Tag: fop-0_94~232 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=23ee8b822e45d72a349ce073c4690966fcd7d0eb;p=xmlgraphics-fop.git 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 --- 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; } @@ -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 { } + diff --git a/status.xml b/status.xml index 4117095fc..8b2ab8127 100644 --- a/status.xml +++ b/status.xml @@ -28,6 +28,10 @@ + + Fix incorrect behaviour of the BreakingAlgorithm when some inline content is wider than + the available ipd, causing a restart. + 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 @@ - + - + @@ -76,9 +76,11 @@ - + - + + + 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 @@ - + - + - + - + - + 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 @@ - - + + @@ -260,8 +260,8 @@ - - + + @@ -271,8 +271,8 @@ - - + + @@ -292,15 +292,15 @@ - - + + - - + +