From bcbc006c0c8c7dca492889df68a1fc52f220c457 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 30 Aug 2005 15:35:37 +0000 Subject: [PATCH] Fix for text-align2.xml (for real now). The alignment used to set up the element list was not properly determined. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@264797 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/inline/LineLayoutManager.java | 16 +++++++++++----- test/layoutengine/disabled-testcases.txt | 1 - test/layoutengine/testcases/text-align2.xml | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index f5a19c08f..eb669be69 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -75,13 +75,17 @@ public class LineLayoutManager extends InlineStackingLayoutManager hyphProps = fobj.getCommonHyphenation(); // + effectiveAlignment = getEffectiveAlignment(bTextAlignment, bTextAlignmentLast); + } + + private int getEffectiveAlignment(int alignment, int alignmentLast) { if (bTextAlignment != EN_JUSTIFY && bTextAlignmentLast == EN_JUSTIFY) { - effectiveAlignment = 0; + return 0; } else { - effectiveAlignment = bTextAlignment; + return bTextAlignment; } } - + /** * Private class to store information about inline breaks. * Each value holds the start and end indexes into a List of @@ -277,9 +281,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager */ private void removeElementsForTrailingSpaces() { KnuthElement removedElement; + int effectiveAlignment = getEffectiveAlignment(textAlignment, textAlignmentLast); while (this.size() > ignoreAtStart && ((KnuthElement) this.get(this.size() - 1)).isGlue()) { - if (textAlignmentLast == EN_CENTER) { + if (effectiveAlignment == EN_CENTER) { // centered text: the pattern is // removedElement = (KnuthGlue) this.remove(this.size() - 1); @@ -288,7 +293,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager removedElement = (KnuthGlue) this.remove(this.size() - 1); removedElement = (KnuthPenalty) this.remove(this.size() - 1); removedElement = (KnuthGlue) this.remove(this.size() - 1); - } else if (textAlignmentLast == EN_START || textAlignmentLast == EN_END) { + } else if (effectiveAlignment == EN_START || effectiveAlignment == EN_END) { // left- or right-aligned text: the pattern is // removedElement = (KnuthGlue) this.remove(this.size() - 1); @@ -1411,6 +1416,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager break; } } + // collect word fragments, ignoring auxiliary elements; // each word fragment was created by a different TextLM if (firstElement.isBox() && !firstElement.isAuxiliary()) { diff --git a/test/layoutengine/disabled-testcases.txt b/test/layoutengine/disabled-testcases.txt index ec859f27b..9d2b0e01a 100644 --- a/test/layoutengine/disabled-testcases.txt +++ b/test/layoutengine/disabled-testcases.txt @@ -34,7 +34,6 @@ table-border-collapse2.xml table-border-separate1.xml table-column4.xml table-fixed2.xml -text-align2.xml word-spacing1.xml word-spacing2.xml word-spacing3.xml diff --git a/test/layoutengine/testcases/text-align2.xml b/test/layoutengine/testcases/text-align2.xml index 1230bafa9..e6fdd55cd 100644 --- a/test/layoutengine/testcases/text-align2.xml +++ b/test/layoutengine/testcases/text-align2.xml @@ -46,6 +46,6 @@ - + -- 2.39.5