aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/FOText.java35
-rw-r--r--src/java/org/apache/fop/fo/FObjMixed.java53
-rw-r--r--src/java/org/apache/fop/fo/flow/Block.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/Inline.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/Marker.java5
5 files changed, 67 insertions, 29 deletions
diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java
index ec86ef867..01674f615 100644
--- a/src/java/org/apache/fop/fo/FOText.java
+++ b/src/java/org/apache/fop/fo/FOText.java
@@ -29,6 +29,7 @@ import org.apache.fop.fo.properties.CommonHyphenation;
import org.apache.fop.fo.properties.CommonTextDecoration;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.SpaceProperty;
+import org.xml.sax.Locator;
/**
* A text node (PCDATA) in the formatting object tree.
@@ -88,21 +89,32 @@ public class FOText extends FONode {
private static final int IS_WORD_CHAR_MAYBE = 2;
/**
- *
- * @param chars array of chars which contains the text in this object (may
- * 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
+ * Creates a now FO text node.
* @param parent FONode that is the parent of this object
*/
- public FOText(char[] chars, int start, int end, FONode parent) {
+ public FOText(FONode parent) {
super(parent);
- endIndex = end - start;
- this.ca = new char[endIndex];
- System.arraycopy(chars, start, ca, 0, endIndex);
-// System.out.println("->" + new String(ca) + "<-");
}
+ /** @see org.apache.fop.fo.FONode */
+ protected void addCharacters(char[] data, int start, int end,
+ PropertyList list, Locator locator) throws FOPException {
+
+ int length = end - start;
+ int calength = 0;
+ char[] nca = null;
+ if (ca != null) {
+ calength = ca.length;
+ nca = new char[calength + length];
+ System.arraycopy(ca, 0, nca, 0, calength);
+ } else {
+ nca = new char[length];
+ }
+ System.arraycopy(data, start, nca, calength, length);
+ endIndex = nca.length;
+ this.ca = nca;
+ }
+
/**
* @see org.apache.fop.fo.FObj#bind(PropertyList)
*/
@@ -120,7 +132,8 @@ public class FOText extends FONode {
textDecoration = pList.getTextDecorationProps();
}
- protected void startOfNode() {
+ /** @see org.apache.fop.fo.FONode#endOfNode() */
+ protected void endOfNode() throws FOPException {
textTransform();
}
diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java
index b20cedc14..853ff57b3 100644
--- a/src/java/org/apache/fop/fo/FObjMixed.java
+++ b/src/java/org/apache/fop/fo/FObjMixed.java
@@ -28,6 +28,10 @@ import org.apache.fop.apps.FOPException;
* It should not be instantiated directly.
*/
public abstract class FObjMixed extends FObj {
+
+ /** Represents accumulated, pending FO text. See flushText(). */
+ protected FOText ft = null;
+
/**
* @param parent FONode that is the parent of this object
*/
@@ -35,26 +39,41 @@ public abstract class FObjMixed extends FObj {
super(parent);
}
- /**
- * Adds characters
- * @param data array of characters containing text to be added
- * @param start starting array element to add
- * @param end ending array element to add
- * @param pList currently applicable PropertyList
- * @param locator location in fo source file.
- * @throws FOPException if there's a problem during processing
- * @see org.apache.fop.fo.FONode#addCharacters(char[], int, int, org.apache.fop.fo.PropertyList, org.xml.sax.Locator)
- */
+ /** @see org.apache.fop.fo.FONode */
protected void addCharacters(char[] data, int start, int end,
PropertyList pList,
Locator locator) throws FOPException {
- FOText ft = new FOText(data, start, end, this);
- ft.setLocator(locator);
- ft.bind(pList);
- ft.startOfNode();
-
- getFOEventHandler().characters(ft.ca, ft.startIndex, ft.endIndex);
- addChildNode(ft);
+ if (ft == null) {
+ ft = new FOText(this);
+ ft.setLocator(locator);
+ ft.bind(pList);
+ }
+ ft.addCharacters(data, start, end, null, null);
+ }
+
+ /** @see org.apache.fop.fo.FONode#endOfNode() */
+ protected void endOfNode() throws FOPException {
+ flushText();
+ super.endOfNode();
+ }
+
+ /**
+ * Adds accumulated text as one FOText instance.
+ * @throws FOPException if there is a problem during processing
+ */
+ protected void flushText() throws FOPException {
+ if (ft != null) {
+ FOText lft = ft;
+ ft = null;
+ lft.endOfNode();
+ getFOEventHandler().characters(lft.ca, lft.startIndex, lft.endIndex);
+ addChildNode(lft);
+ }
+ }
+
+ protected void addChildNode(FONode child) throws FOPException {
+ flushText();
+ super.addChildNode(child);
}
/**
diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java
index 73fd6bf9c..a1c03be5a 100644
--- a/src/java/org/apache/fop/fo/flow/Block.java
+++ b/src/java/org/apache/fop/fo/flow/Block.java
@@ -174,6 +174,7 @@ public class Block extends FObjMixed {
* @see org.apache.fop.fo.FONode#endOfNode
*/
protected void endOfNode() throws FOPException {
+ super.endOfNode();
handleWhiteSpace();
getFOEventHandler().endBlock(this);
}
@@ -330,6 +331,7 @@ public class Block extends FObjMixed {
* @see org.apache.fop.fo.FONode#addChildNode(FONode)
*/
public void addChildNode(FONode child) throws FOPException {
+ flushText();
// Handle whitespace based on values of properties
// Handle a sequence of inline-producing child nodes in
// one pass
diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java
index f396c7dc2..fb62c77b2 100644
--- a/src/java/org/apache/fop/fo/flow/Inline.java
+++ b/src/java/org/apache/fop/fo/flow/Inline.java
@@ -117,6 +117,7 @@ public class Inline extends InlineLevel {
* @see org.apache.fop.fo.FONode#endOfNode
*/
protected void endOfNode() throws FOPException {
+ super.endOfNode();
getFOEventHandler().endInline(this);
}
diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java
index 15fe81aed..eb03f2f73 100644
--- a/src/java/org/apache/fop/fo/flow/Marker.java
+++ b/src/java/org/apache/fop/fo/flow/Marker.java
@@ -83,6 +83,7 @@ public class Marker extends FObjMixed {
return new MarkerPropertyList(this, parent);
}
+ /** @see org.apache.fop.fo.FONode#startOfNode() */
protected void startOfNode() {
FOEventHandler foEventHandler = getFOEventHandler();
// Push a new property list maker which will make MarkerPropertyLists.
@@ -96,7 +97,9 @@ public class Marker extends FObjMixed {
});
}
- protected void endOfNode() {
+ /** @see org.apache.fop.fo.FONode#endOfNode() */
+ protected void endOfNode() throws FOPException {
+ super.endOfNode();
// Pop the MarkerPropertyList maker.
getFOEventHandler().setPropertyListMaker(savePropertyListMaker);
savePropertyListMaker = null;