diff options
author | Karen Lease <klease@apache.org> | 2001-11-21 22:13:36 +0000 |
---|---|---|
committer | Karen Lease <klease@apache.org> | 2001-11-21 22:13:36 +0000 |
commit | 4a45db76cee354948589f04c075dc0bdc943c9ca (patch) | |
tree | c1c904e9eb7d1350f6acd78ad39971153a6886c6 /src/org/apache/fop/fo/FOText.java | |
parent | 427d4fb27ee610cb77c29a637ca59356a3d54842 (diff) | |
download | xmlgraphics-fop-4a45db76cee354948589f04c075dc0bdc943c9ca.tar.gz xmlgraphics-fop-4a45db76cee354948589f04c075dc0bdc943c9ca.zip |
Remove extra whitespace during FO tree construction
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194572 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/fo/FOText.java')
-rw-r--r-- | src/org/apache/fop/fo/FOText.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java index 84b9c667b..a3a2bb393 100644 --- a/src/org/apache/fop/fo/FOText.java +++ b/src/org/apache/fop/fo/FOText.java @@ -19,6 +19,8 @@ import org.apache.fop.system.BufferManager; import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.TextLayoutManager; +import java.util.NoSuchElementException; + /** * a text node in the formatting object tree * @@ -89,7 +91,54 @@ public class FOText extends FObj { } public LayoutManager getLayoutManager() { + // What if nothing left (length=0)? + if (length < ca.length) { + char[] tmp = ca; + ca = new char[length]; + System.arraycopy(tmp, 0, ca, 0, length); + } return new TextLayoutManager(this, ca, textInfo); } + + public CharIterator charIterator() { + return new TextCharIterator(); + } + + private class TextCharIterator extends AbstractCharIterator { + int curIndex = 0; + public boolean hasNext() { + return (curIndex < length); + } + + public char nextChar() { + if (curIndex < length) { + // Just a char class? Don't actually care about the value! + return ca[curIndex++]; + } + else throw new NoSuchElementException(); + } + + public void remove() { + if (curIndex>0 && curIndex < length) { + // copy from curIndex to end to curIndex-1 + System.arraycopy(ca, curIndex, ca, curIndex-1, + length-curIndex); + length--; + curIndex--; + } + else if (curIndex == length) { + curIndex = --length; + } + } + + + public void replaceChar(char c) { + if (curIndex>0 && curIndex <= length) { + ca[curIndex-1]=c; + } + } + + + } } |