From c815699e2399a1d47ef678c157bad84e62cfa830 Mon Sep 17 00:00:00 2001 From: Manuel Mall Date: Wed, 28 Dec 2005 03:08:49 +0000 Subject: [PATCH] LineArea had a finalize method which caused a NPE when called from the garbage collector. I assume it was never intended for this method to be an override of the Java Object finalize method. Renamed the method to finalise. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@359364 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/LineArea.java | 4 ++-- .../apache/fop/layoutmgr/InlineKnuthSequence.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index 4f13ad65f..15d22548f 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -190,7 +190,7 @@ public class LineArea extends Area { // if the LineArea has already been added to the area tree, // call finalize(); otherwise, wait for the LineLM to call it if (adjustingInfo.bAddedToAreaTree) { - finalize(); + finalise(); } break; default: @@ -203,7 +203,7 @@ public class LineArea extends Area { * and destroy the AdjustingInfo object if there are * no UnresolvedAreas left */ - public void finalize() { + public void finalise() { if (adjustingInfo.lineAlignment == Constants.EN_JUSTIFY) { // justified line: apply the variation factor boolean bUnresolvedAreasPresent = false; diff --git a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java index 788339790..efe3e28ce 100644 --- a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java @@ -105,7 +105,18 @@ public class InlineKnuthSequence extends KnuthSequence { } public void addALetterSpace() { - KnuthBox prevBox = (KnuthBox) removeLast(); + KnuthBox prevBox = (KnuthBox) getLast(); + if (prevBox.isAuxiliary() + && (size() < 4 + || !getElement(size()-2).isGlue() + || !getElement(size()-3).isPenalty() + || !getElement(size()-4).isBox() + ) + ) { + // Not the sequence we are expecting + return; + } + removeLast(); LinkedList oldList = new LinkedList(); // if there are two consecutive KnuthBoxes the // first one does not represent a whole word, -- 2.39.5