public char[] ca;
/**
- * The actual length of the text to be rendered within ca,
- * starting from position 0 of the array.
+ * The starting valid index of the ca array
+ * to be processed.
*
- * This value is originally equal to ca.length, but becomes decremented
- * during whitespace removal by the flow.Block class, via the
- * TextCharIterator.remove() method below.
+ * This value is originally equal to ca.length, but becomes
+ * incremented during whitespace removal by the flow.Block class,
+ * via the TextCharIterator.remove() method below.
*/
- public int length;
+ public int start = 0;
/**
* The TextInfo object attached to the text
*/
public FOText(char[] chars, int start, int end, TextInfo ti, FONode parent) {
super(parent);
- length = end - start;
+ int length = end - start;
this.ca = new char[length];
System.arraycopy(chars, start, ca, 0, length);
textInfo = ti;
*/
public boolean willCreateArea() {
if (textInfo.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE
- && length > 0) {
+ && ca.length - start > 0) {
return true;
}
- for (int i = 0; i < length; i++) {
+ for (int i = start; i < ca.length; i++) {
char ch = ca[i];
if (!((ch == ' ')
|| (ch == '\n')
private int curIndex = 0;
public boolean hasNext() {
- return (curIndex < length);
+ return (curIndex < ca.length);
}
public char nextChar() {
- if (curIndex < length) {
+ if (curIndex < ca.length) {
// Just a char class? Don't actually care about the value!
return ca[curIndex++];
} else {
}
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;
+ if (start < ca.length) {
+ start++;
}
}
-
public void replaceChar(char c) {
- if (curIndex > 0 && curIndex <= length) {
+ if (curIndex > 0 && curIndex <= ca.length) {
ca[curIndex - 1] = c;
}
}
-
}
/**
* @return True if the character at this location is the start of a new
* word.
*/
- public boolean isStartOfWord (int i) {
+ private boolean isStartOfWord(int i) {
char prevChar = getRelativeCharInBlock(i, -1);
/* All we are really concerned about here is of what type prevChar
is. If inputChar is not part of a word, then the Java
* @return the character in the offset position within the block; \u0000 if
* the offset points to an area outside of the block.
*/
- public char getRelativeCharInBlock(int i, int offset) {
+ private char getRelativeCharInBlock(int i, int offset) {
// The easy case is where the desired character is in the same FOText
- if (((i + offset) >= 0) && ((i + offset) <= this.length)) {
+ if (((i + offset) >= 0) && ((i + offset) <= this.ca.length)) {
return ca[i + offset];
}
// For now, we can't look at following FOText nodes
* @param i the index into ca[]
* @return char with transformed value
*/
- public char charTransform(int i) {
+ private char charTransform(int i) {
switch (textInfo.textTransform) {
/* put NONE first, as this is probably the common case */
case TextTransform.NONE:
import java.util.ArrayList;
+import org.apache.fop.fo.FOText;
import org.apache.fop.fo.TextInfo;
import org.apache.fop.traits.SpaceVal;
import org.apache.fop.area.Trait;
* @param length length of the above array to be processed
* @param textInfo the text information for doing layout
*/
- public TextLayoutManager(char[] chars, int length, TextInfo textInfo) {
- this.textArray = chars;
- this.textArrayLength = length;
- this.textInfo = textInfo;
+ public TextLayoutManager(FOText node) {
+ super(node);
+ this.textArray = new char[node.ca.length - node.start];
+ System.arraycopy(node.ca, node.start, this.textArray, 0,
+ node.ca.length - node.start);
+ this.textArrayLength = node.ca.length - node.start;
+ this.textInfo = node.textInfo;
this.vecAreaInfo = new java.util.ArrayList();
// With CID fonts, space isn't neccesary currentFontState.width(32)