diff options
author | Glen Mazza <gmazza@apache.org> | 2004-03-07 17:52:43 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-03-07 17:52:43 +0000 |
commit | 239a590e9819edadc30d82695ba9e1c8af9627a9 (patch) | |
tree | dd6ce49bfdec1fb615e17f3875d9d01c0f261542 /src/java/org/apache | |
parent | db21c02ee758f5dee1d004c4db321b343f9124be (diff) | |
download | xmlgraphics-fop-239a590e9819edadc30d82695ba9e1c8af9627a9.tar.gz xmlgraphics-fop-239a590e9819edadc30d82695ba9e1c8af9627a9.zip |
Fix of leading-space problem in HEAD. (A single leading space of the first
inline child of the block object was being incorrectly retained.)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197421 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r-- | src/java/org/apache/fop/fo/FOText.java | 4 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/Block.java | 17 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index 4e0a84de3..ea25beeef 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -168,10 +168,6 @@ public class FOText extends FObj { } else if (curIndex == length) { curIndex = --length; } -// Temporary until leading space problem in 1.0 fixed -// System.out.println("\n\nremove called: ca = \"" + -// new String(ca) + "\", length/node length: " + length -// + ", " + ca.length); } diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index ffb992181..63f694b36 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -246,6 +246,11 @@ public class Block extends FObjMixed { if (firstInlineChild != null) { boolean bInWS = false; boolean bPrevWasLF = false; + + /* bSeenNonWSYet is an indicator used for trimming all leading + whitespace for the first inline child of the block + */ + boolean bSeenNonWSYet = false; RecursiveCharIterator charIter = new RecursiveCharIterator(this, firstInlineChild); LFchecker lfCheck = new LFchecker(charIter); @@ -279,7 +284,13 @@ public class Block extends FObjMixed { && (bPrevWasLF || lfCheck.nextIsLF()))) { charIter.remove(); } else { + // this is to retain a single space between words bInWS = true; + // remove the space if no word in block + // encountered yet + if (!bSeenNonWSYet) { + charIter.remove(); + } } } break; @@ -300,6 +311,11 @@ public class Block extends FObjMixed { } else { if (bWScollapse) { bInWS = true; + // remove the linefeed if no word in block + // encountered yet + if (!bSeenNonWSYet) { + charIter.remove(); + } } charIter.replaceChar('\u0020'); } @@ -323,6 +339,7 @@ public class Block extends FObjMixed { case CharUtilities.NONWHITESPACE: /* Any other character */ bInWS = bPrevWasLF = false; + bSeenNonWSYet = true; lfCheck.reset(); break; } |