You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by gm...@apache.org on 2004/03/02 00:50:26 UTC
cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr AddLMVisitor.java TextLayoutManager.java
gmazza 2004/03/01 15:50:26
Modified: src/java/org/apache/fop/apps Driver.java
src/java/org/apache/fop/fo FOText.java FOTreeBuilder.java
FObjMixed.java
src/java/org/apache/fop/layoutmgr AddLMVisitor.java
TextLayoutManager.java
Log:
1.) Modified TextLayoutManager to take an additional length
parameter, indicating the maximum valid index of the passed-in
character array.
2.) Removed from AddLMVisitor (which calls the above class), the
re-fitting of the FOText character array to the size of the maximum
valid index.
3.) Various small cleanup issues.
Revision Changes Path
1.53 +1 -2 xml-fop/src/java/org/apache/fop/apps/Driver.java
Index: Driver.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Driver.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- Driver.java 27 Feb 2004 17:39:05 -0000 1.52
+++ Driver.java 1 Mar 2004 23:50:26 -0000 1.53
@@ -540,8 +540,7 @@
treeBuilder.setUserAgent(getUserAgent());
treeBuilder.setFOInputHandler(foInputHandler);
- treeBuilder.foTreeControl = currentDocument;
-
+ treeBuilder.setFOTreeControl(currentDocument);
return new ProxyContentHandler(treeBuilder) {
1.15 +11 -2 xml-fop/src/java/org/apache/fop/fo/FOText.java
Index: FOText.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOText.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- FOText.java 27 Feb 2004 17:57:40 -0000 1.14
+++ FOText.java 1 Mar 2004 23:50:26 -0000 1.15
@@ -44,7 +44,12 @@
public char[] ca;
/**
- * the length of the character array containing the text
+ * The actual length of the text to be rendered within ca,
+ * starting from position 0 of the array.
+ *
+ * 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.
*/
public int length;
@@ -87,7 +92,7 @@
/**
*
* @param chars array of chars which contains the text in this object (may
- * be a superset of the text in this object
+ * be a superset of the text in this object)
* @param start starting index into char[] for the text in this object
* @param end ending index into char[] for the text in this object
* @param ti TextInfo object for the text in this object
@@ -163,6 +168,10 @@
} 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);
}
1.23 +9 -1 xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java
Index: FOTreeBuilder.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- FOTreeBuilder.java 27 Feb 2004 17:57:40 -0000 1.22
+++ FOTreeBuilder.java 1 Mar 2004 23:50:26 -0000 1.23
@@ -77,7 +77,7 @@
private FOUserAgent userAgent;
/** The FOTreeControl object managing the FO Tree that is being built */
- public FOTreeControl foTreeControl;
+ private FOTreeControl foTreeControl;
/** The SAX locator object maneging the line and column counters */
private Locator locator;
@@ -103,6 +103,14 @@
private FOUserAgent getUserAgent() {
return userAgent;
+ }
+
+ /**
+ * Sets the FO Tree Control for this object
+ * @param fotc FOTreeControl instance
+ */
+ public void setFOTreeControl(FOTreeControl fotc) {
+ this.foTreeControl = fotc;
}
/**
1.21 +1 -1 xml-fop/src/java/org/apache/fop/fo/FObjMixed.java
Index: FObjMixed.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObjMixed.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- FObjMixed.java 27 Feb 2004 17:57:40 -0000 1.20
+++ FObjMixed.java 1 Mar 2004 23:50:26 -0000 1.21
@@ -55,7 +55,7 @@
ft.setName("text");
/* characters() processing empty for FOTreeHandler, not empty for RTF & MIFHandlers */
- getFOTreeControl().getFOInputHandler().characters(ft.ca, 0, ft.length);
+ getFOTreeControl().getFOInputHandler().characters(ft.ca, 0, ft.ca.length);
addChild(ft);
}
1.31 +5 -11 xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
Index: AddLMVisitor.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- AddLMVisitor.java 27 Feb 2004 17:49:25 -0000 1.30
+++ AddLMVisitor.java 1 Mar 2004 23:50:26 -0000 1.31
@@ -180,17 +180,11 @@
}
public void serveFOText(FOText node) {
- if (node.length == 0) {
- return;
+ if (node.length > 0) {
+ LayoutManager lm = new TextLayoutManager(node.ca, node.length, node.textInfo);
+ lm.setFObj(node);
+ currentLMList.add(lm);
}
- if (node.length < node.ca.length) {
- char[] tmp = node.ca;
- node.ca = new char[node.length];
- System.arraycopy(tmp, 0, node.ca, 0, node.length);
- }
- LayoutManager lm = new TextLayoutManager(node.ca, node.textInfo);
- lm.setFObj(node);
- currentLMList.add(lm);
}
public void serveFObjMixed(FObjMixed node) {
1.10 +34 -31 xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
Index: TextLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TextLayoutManager.java 27 Feb 2004 17:49:25 -0000 1.9
+++ TextLayoutManager.java 1 Mar 2004 23:50:26 -0000 1.10
@@ -62,7 +62,8 @@
/** Non-space characters on which we can end a line. */
private static final String BREAK_CHARS = "-/" ;
- private char[] chars;
+ private char[] textArray;
+ private int textArrayLength;
private TextInfo textInfo;
private static final char NEWLINE = '\n';
@@ -93,11 +94,13 @@
/**
* Create a Text layout manager.
*
- * @param chars the characters
+ * @param chars character array
+ * @param length length of the above array to be processed
* @param textInfo the text information for doing layout
*/
- public TextLayoutManager(char[] chars, TextInfo textInfo) {
- this.chars = chars;
+ public TextLayoutManager(char[] chars, int length, TextInfo textInfo) {
+ this.textArray = chars;
+ this.textArrayLength = length;
this.textInfo = textInfo;
this.vecAreaInfo = new java.util.ArrayList();
@@ -136,11 +139,11 @@
// Skip all leading spaces for hyphenation
int i;
for (i = ai.iStartIndex;
- i < ai.iBreakIndex && CharUtilities.isAnySpace(chars[i]) == true;
+ i < ai.iBreakIndex && CharUtilities.isAnySpace(textArray[i]) == true;
i++) {
//nop
}
- sbChars.append(new String(chars, i, ai.iBreakIndex - i));
+ sbChars.append(new String(textArray, i, ai.iBreakIndex - i));
}
/**
@@ -153,11 +156,11 @@
* @return true if can break before this text
*/
public boolean canBreakBefore(LayoutContext context) {
- char c = chars[iNextStart];
+ char c = textArray[iNextStart];
return ((c == NEWLINE) || (textInfo.bWrap
&& (CharUtilities.isBreakableSpace(c)
|| (BREAK_CHARS.indexOf(c) >= 0 && (iNextStart == 0
- || Character.isLetterOrDigit(chars[iNextStart-1]))))));
+ || Character.isLetterOrDigit(textArray[iNextStart-1]))))));
}
/**
@@ -198,14 +201,14 @@
boolean bCanHyphenate = true;
int iStopIndex = iNextStart + hc.getNextHyphPoint();
- if (chars.length < iStopIndex || textInfo.bCanHyphenate == false) {
- iStopIndex = chars.length;
+ if (textArrayLength < iStopIndex || textInfo.bCanHyphenate == false) {
+ iStopIndex = textArrayLength;
bCanHyphenate = false;
}
hc.updateOffset(iStopIndex - iNextStart);
for (; iNextStart < iStopIndex; iNextStart++) {
- char c = chars[iNextStart];
+ char c = textArray[iNextStart];
hyphIPD.opt += textInfo.fs.getCharWidth(c);
// letter-space?
}
@@ -254,11 +257,11 @@
* retained.
*/
if (context.suppressLeadingSpace()) {
- for (; iNextStart < chars.length
- && chars[iNextStart] == SPACE; iNextStart++) {
+ for (; iNextStart < textArrayLength
+ && textArray[iNextStart] == SPACE; iNextStart++) {
}
// If now at end, nothing to compose here!
- if (iNextStart >= chars.length) {
+ if (iNextStart >= textArrayLength) {
setFinished(true);
return null; // Or an "empty" BreakPoss?
}
@@ -279,8 +282,8 @@
short iWScount = 0; // Count of word spaces
boolean bSawNonSuppressible = false;
- for (; iNextStart < chars.length; iNextStart++) {
- char c = chars[iNextStart];
+ for (; iNextStart < textArrayLength; iNextStart++) {
+ char c = textArray[iNextStart];
if (CharUtilities.isAnySpace(c) == false) {
break;
}
@@ -317,7 +320,7 @@
}
}
- if (iNextStart < chars.length) {
+ if (iNextStart < textArrayLength) {
spaceIPD.add(pendingSpace.resolve(false));
} else {
// This FO ended with spaces. Return the BP
@@ -340,13 +343,13 @@
// Look for a legal line-break: breakable white-space and certain
// characters such as '-' which can serve as word breaks.
// Don't look for hyphenation points here though
- for (; iNextStart < chars.length; iNextStart++) {
- char c = chars[iNextStart];
+ for (; iNextStart < textArrayLength; iNextStart++) {
+ char c = textArray[iNextStart];
// Include any breakable white-space as break char
if ((c == NEWLINE) || (textInfo.bWrap
&& (CharUtilities.isBreakableSpace(c)
|| (BREAK_CHARS.indexOf(c) >= 0 && (iNextStart == 0
- || Character.isLetterOrDigit(chars[iNextStart-1])))))) {
+ || Character.isLetterOrDigit(textArray[iNextStart-1])))))) {
iFlags |= BreakPoss.CAN_BREAK_AFTER;
if (c != SPACE) {
iNextStart++;
@@ -360,11 +363,11 @@
// line-end, set a flag for parent LM.
int iLastChar;
for (iLastChar = iNextStart;
- iLastChar < chars.length
- && chars[iLastChar] == SPACE; iLastChar++) {
+ iLastChar < textArrayLength
+ && textArray[iLastChar] == SPACE; iLastChar++) {
//nop
}
- if (iLastChar == chars.length) {
+ if (iLastChar == textArrayLength) {
iFlags |= BreakPoss.REST_ARE_SUPPRESS_AT_LB;
}
return makeBreakPoss(iThisStart, spaceIPD, wordIPD,
@@ -413,7 +416,7 @@
*/
//bp.setDescender(textInfo.fs.getDescender());
//bp.setAscender(textInfo.fs.getAscender());
- if (iNextStart == chars.length) {
+ if (iNextStart == textArrayLength) {
flags |= BreakPoss.ISLAST;
setFinished(true);
}
@@ -486,10 +489,10 @@
int adjust = 0;
// ignore newline character
- if (chars[ai.iBreakIndex - 1] == NEWLINE) {
+ if (textArray[ai.iBreakIndex - 1] == NEWLINE) {
adjust = 1;
}
- String str = new String(chars, iStart, ai.iBreakIndex - iStart - adjust);
+ String str = new String(textArray, iStart, ai.iBreakIndex - iStart - adjust);
if (" ".equals(str)) {
word = new Space();
@@ -504,24 +507,24 @@
}
word = t;
}
- if ((chars[iStart] == SPACE || chars[iStart] == NBSPACE)
+ if ((textArray[iStart] == SPACE || textArray[iStart] == NBSPACE)
&& context.getLeadingSpace().hasSpaces()) {
context.getLeadingSpace().addSpace(halfWS);
}
// Set LAST flag if done making characters
int iLastChar;
for (iLastChar = ai.iBreakIndex;
- iLastChar < chars.length && chars[iLastChar] == SPACE;
+ iLastChar < textArrayLength && textArray[iLastChar] == SPACE;
iLastChar++) {
//nop
}
context.setFlags(LayoutContext.LAST_AREA,
- iLastChar == chars.length);
+ iLastChar == textArrayLength);
// Can we have any trailing space? Yes, if last char was a space!
context.setTrailingSpace(new SpaceSpecifier(false));
- if (chars[ai.iBreakIndex - 1] == SPACE
- || chars[ai.iBreakIndex - 1] == NBSPACE) {
+ if (textArray[ai.iBreakIndex - 1] == SPACE
+ || textArray[ai.iBreakIndex - 1] == NBSPACE) {
context.getTrailingSpace().addSpace(halfWS);
}
if (word != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org