aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/layoutmgr
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2007-09-20 20:00:45 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2007-09-20 20:00:45 +0000
commite958bfd23d914962790ee0269cbcd3684f71aa7d (patch)
tree4a92714bc3abcb60a8885fab88d1a2f88f291c1d /src/java/org/apache/fop/layoutmgr
parent453d4ed9e3a5dfb37f66409914a380911d87f95e (diff)
downloadxmlgraphics-fop-e958bfd23d914962790ee0269cbcd3684f71aa7d.tar.gz
xmlgraphics-fop-e958bfd23d914962790ee0269cbcd3684f71aa7d.zip
Bugfix: non-collapsed white-space caused ArrayIndexOutOfBoundsException
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@577899 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr')
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
index 93196d8ab..923c6261e 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
@@ -804,30 +804,34 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
ListIterator oldListIterator = oldList.listIterator();
KnuthElement el = (KnuthElement)oldListIterator.next();
LeafPosition pos = (LeafPosition) ((KnuthBox) el).getPosition();
- AreaInfo ai = (AreaInfo) vecAreaInfo.get(pos.getLeafPos());
- ai.iLScount++;
- ai.ipdArea.add(letterSpaceIPD);
- if (BREAK_CHARS.indexOf(textArray[iTempStart - 1]) >= 0) {
- // the last character could be used as a line break
- // append new elements to oldList
- oldListIterator = oldList.listIterator(oldList.size());
- oldListIterator.add(new KnuthPenalty(0, KnuthPenalty.FLAGGED_PENALTY, true,
- new LeafPosition(this, -1), false));
- oldListIterator.add(new KnuthGlue(letterSpaceIPD.opt,
- letterSpaceIPD.max - letterSpaceIPD.opt,
- letterSpaceIPD.opt - letterSpaceIPD.min,
- new LeafPosition(this, -1), false));
- } else if (letterSpaceIPD.min == letterSpaceIPD.max) {
- // constant letter space: replace the box
- oldListIterator.set(new KnuthInlineBox(ai.ipdArea.opt, alignmentContext, pos, false));
- } else {
- // adjustable letter space: replace the glue
- oldListIterator.next(); // this would return the penalty element
- oldListIterator.next(); // this would return the glue element
- oldListIterator.set(new KnuthGlue(ai.iLScount * letterSpaceIPD.opt,
- ai.iLScount * (letterSpaceIPD.max - letterSpaceIPD.opt),
- ai.iLScount * (letterSpaceIPD.opt - letterSpaceIPD.min),
- new LeafPosition(this, -1), true));
+ int idx = pos.getLeafPos();
+ //element could refer to '-1' position, for non-collapsed spaces (?)
+ if (idx >= -1) {
+ AreaInfo ai = (AreaInfo) vecAreaInfo.get(idx);
+ ai.iLScount++;
+ ai.ipdArea.add(letterSpaceIPD);
+ if (BREAK_CHARS.indexOf(textArray[iTempStart - 1]) >= 0) {
+ // the last character could be used as a line break
+ // append new elements to oldList
+ oldListIterator = oldList.listIterator(oldList.size());
+ oldListIterator.add(new KnuthPenalty(0, KnuthPenalty.FLAGGED_PENALTY, true,
+ new LeafPosition(this, -1), false));
+ oldListIterator.add(new KnuthGlue(letterSpaceIPD.opt,
+ letterSpaceIPD.max - letterSpaceIPD.opt,
+ letterSpaceIPD.opt - letterSpaceIPD.min,
+ new LeafPosition(this, -1), false));
+ } else if (letterSpaceIPD.min == letterSpaceIPD.max) {
+ // constant letter space: replace the box
+ oldListIterator.set(new KnuthInlineBox(ai.ipdArea.opt, alignmentContext, pos, false));
+ } else {
+ // adjustable letter space: replace the glue
+ oldListIterator.next(); // this would return the penalty element
+ oldListIterator.next(); // this would return the glue element
+ oldListIterator.set(new KnuthGlue(ai.iLScount * letterSpaceIPD.opt,
+ ai.iLScount * (letterSpaceIPD.max - letterSpaceIPD.opt),
+ ai.iLScount * (letterSpaceIPD.opt - letterSpaceIPD.min),
+ new LeafPosition(this, -1), true));
+ }
}
return oldList;
}