From: Simon Pepping Date: Fri, 19 May 2006 15:10:44 +0000 (+0000) Subject: An emergency patch to avoid that a non-breaking space at the end of an X-Git-Tag: fop-0_93~222 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=276670d6bbb7cf51f8f8365675335f4ac945209e;p=xmlgraphics-fop.git An emergency patch to avoid that a non-breaking space at the end of an fo:inline with padding, followed by another fo:inline, while text-align is justify, does not cause a NullPointerException due to InlineStackingLayoutManager.addALetterSpaceTo(). Patch submitted by Max Berger , applied with some modifications. This patch solves bug 39571. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@407819 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java index 0e48eb1ae..f66c0d119 100644 --- a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java +++ b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java @@ -140,7 +140,9 @@ public class InlineKnuthSequence extends KnuthSequence { addAll(((InlineLevelLayoutManager) prevBox.getLayoutManager()) .addALetterSpaceTo(oldList)); - if (((KnuthInlineBox) prevBox).isAnchor()) { + // prevBox may not be a KnuthInlineBox; + // this may happen if it is a padding box; see bug 39571. + if ( prevBox instanceof KnuthInlineBox && ((KnuthInlineBox) prevBox).isAnchor()) { // prevBox represents a footnote citation: copy footnote info // from prevBox to the new box KnuthInlineBox newBox = (KnuthInlineBox) getLast(); diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java index 515caf578..b31fb8b42 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java @@ -292,9 +292,13 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager element.setPosition(((NonLeafPosition)element.getPosition()).getPosition()); } - oldList = ((InlineLevelLayoutManager) - element.getLayoutManager()).addALetterSpaceTo(oldList); - + // The last element may not have a layout manager (its position == null); + // this may happen if it is a padding box; see bug 39571. + InlineLevelLayoutManager LM = + (InlineLevelLayoutManager) element.getLayoutManager(); + if (LM != null) { + oldList = LM.addALetterSpaceTo(oldList); + } // "wrap" again the Position stored in each element of oldList oldListIterator = oldList.listIterator(); while (oldListIterator.hasNext()) { diff --git a/test/layoutengine/standard-testcases/inline_letter-spacing_3.xml b/test/layoutengine/standard-testcases/inline_letter-spacing_3.xml new file mode 100644 index 000000000..daa17f026 --- /dev/null +++ b/test/layoutengine/standard-testcases/inline_letter-spacing_3.xml @@ -0,0 +1,60 @@ + + + + + +

+ This test checks that a non-breaking space at the end of an + fo:inline with padding, followed by another fo:inline, while + text-align is justify, does not cause a NullPointerException due + to InlineStackingLayoutManager.addALetterSpaceTo(). +

+

http://issues.apache.org/bugzilla/show_bug.cgi?id=39571

+
+ + + + + + + + + + + + non-breaking space + + + + + + + + + + +