]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixing a ClassCastException due to the incorrect "pattern" of elements representing...
authorLuca Furini <lfurini@apache.org>
Fri, 14 Oct 2005 12:20:25 +0000 (12:20 +0000)
committerLuca Furini <lfurini@apache.org>
Fri, 14 Oct 2005 12:20:25 +0000 (12:20 +0000)
Maybe not very elegant ... but at least it works; as Manuel suggested, the removal of trailing spaces should maybe happen somewhere else.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@321084 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java

index d95525380b2f3ef8bfc4f02d5184743a0c3022de..e2aec76bd17a4e0fb96b60faacb66c6dc4b3160c 100644 (file)
@@ -296,8 +296,14 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                 removedElements = new LinkedList();
                 inlineLM = (InlineLevelLayoutManager)
                     ((KnuthElement) this.get(this.size() - 1)).getLayoutManager();
-                if (effectiveAlignment == EN_CENTER) {
-                    // centered text: the pattern is
+                if (effectiveAlignment == EN_CENTER
+                    || this.size() > 6
+                       && ((KnuthElement) this.get(this.size() - 6)).isGlue()
+                       && ((KnuthElement) this.get(this.size() - 5)).isPenalty()
+                       && ((KnuthElement) this.get(this.size() - 4)).isGlue()
+                       && ((KnuthElement) this.get(this.size() - 3)).isBox()
+                       && ((KnuthElement) this.get(this.size() - 2)).isPenalty()) {
+                    // centered text (or text with inline borders and padding): the pattern is
                     //     <glue> <penaly> <glue> <box> <penaly> <glue>
                     removedElements.addFirst((KnuthGlue) this.remove(this.size() - 1));
                     removedElements.addFirst((KnuthPenalty) this.remove(this.size() - 1));