xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r230779 - in /xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline: FootnoteLayoutManager.java LineLayoutManager.java
Date Mon, 08 Aug 2005 09:38:38 GMT
Author: jeremias
Date: Mon Aug  8 02:38:32 2005
New Revision: 230779

URL: http://svn.apache.org/viewcvs?rev=230779&view=rev
Log:
Deal with a mix of KnuthSequences of KnuthSequences and KnuthSequences of KnuthElements to
allow for fewer container classes.
InlineLM instead of InlineStackingLM for inline part of footnote.
Supposedly fixed a bug in addALetterSpace.

Modified:
    xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
    xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java

Modified: xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java?rev=230779&r1=230778&r2=230779&view=diff
==============================================================================
--- xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
(original)
+++ xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
Mon Aug  8 02:38:32 2005
@@ -26,6 +26,7 @@
 import org.apache.fop.layoutmgr.AbstractLayoutManager;
 import org.apache.fop.layoutmgr.FootnoteBodyLayoutManager;
 import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthSequence;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.Position;
 
@@ -45,7 +46,7 @@
         footnote = node;
 
         // create an InlineStackingLM handling the fo:inline child of fo:footnote
-        citationLM = new InlineStackingLayoutManager(footnote.getFootnoteCitation());
+        citationLM = new InlineLayoutManager(footnote.getFootnoteCitation());
 
         // create a FootnoteBodyLM handling the fo:footnote-body child of fo:footnote
         bodyLM = new FootnoteBodyLayoutManager(footnote.getFootnoteBody());
@@ -85,12 +86,24 @@
     private void addAnchor(LinkedList citationList) {
         // find the last box in the sequence, and add a reference
         // to the FootnoteBodyLM
-        ListIterator citationIterator = citationList.listIterator(citationList.size());
         KnuthInlineBox lastBox = null;
+        ListIterator citationIterator = citationList.listIterator(citationList.size());
         while (citationIterator.hasPrevious() && lastBox == null) {
-            KnuthElement element = (KnuthElement) citationIterator.previous();
-            if (element instanceof KnuthInlineBox) {
-                lastBox = (KnuthInlineBox) element;
+            Object obj = citationIterator.previous();
+            if (obj instanceof KnuthElement) {
+                KnuthElement element = (KnuthElement)obj;
+                if (element instanceof KnuthInlineBox) {
+                    lastBox = (KnuthInlineBox) element;
+                }
+            } else {
+                KnuthSequence seq = (KnuthSequence)obj;
+                ListIterator nestedIterator = seq.listIterator(seq.size());
+                while (nestedIterator.hasPrevious() && lastBox == null) {
+                    KnuthElement element = (KnuthElement)nestedIterator.previous();
+                    if (element instanceof KnuthInlineBox) {
+                        lastBox = (KnuthInlineBox) element;
+                    }
+                }
             }
         }
         if (lastBox != null) {

Modified: xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=230779&r1=230778&r2=230779&view=diff
==============================================================================
--- xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
(original)
+++ xmlgraphics/fop/branches/inlineblock/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
Mon Aug  8 02:38:32 2005
@@ -288,7 +288,7 @@
                 // while the other elements are not changed
                 oldList.add(prevBox);
                 // TODO check if this is the correct place; merge was not correct
-                oldList.addFirst((KnuthBox) removeLast());
+                // already done by above call???? oldList.addFirst((KnuthBox) removeLast());
                 oldList.addFirst((KnuthGlue) removeLast());
                 oldList.addFirst((KnuthPenalty) removeLast());
             }
@@ -644,25 +644,45 @@
                 }
                 // does the first element of the first paragraph add to an existing word?
                 if (lastPar != null) {
-                    KnuthSequence firstSeq = (KnuthSequence) returnedList.getFirst();
-                    if (!firstSeq.isInlineSequence()) {
-                        log.error("Expect inline sequence as first sequence when last paragraph
is not null");
+                    Object obj = returnedList.getFirst();
+                    KnuthElement thisElement;
+                    if (obj instanceof KnuthElement) {
+                        thisElement = (KnuthElement)obj;
+                    } else {
+                        KnuthSequence firstSeq = (KnuthSequence) obj;
+                        if (!firstSeq.isInlineSequence()) {
+                            log.error("Expect inline sequence as first sequence when last
paragraph is not null");
+                        }
+                        thisElement = (KnuthElement) firstSeq.get(0);
                     }
-                    KnuthElement thisElement = (KnuthElement) firstSeq.get(0);
                     if (thisElement.isBox() && !thisElement.isAuxiliary()
                             && bPrevWasKnuthBox) {
                         lastPar.addALetterSpace();
                     }
                 }
 
-                // loop over the KnuthSequences in returnedList
+                // loop over the KnuthSequences (and single KnuthElements) in returnedList
+                // (LeafNodeLM descendants may also skip wrapping elements in KnuthSequences
+                // to cause fewer container structures)
                 ListIterator iter = returnedList.listIterator();
                 while (iter.hasNext()) {
-                    KnuthSequence sequence = (KnuthSequence) iter.next();
+                    Object obj = iter.next();
+                    KnuthElement singleElement = null;
+                    KnuthSequence sequence = null;
+                    if (obj instanceof KnuthElement) {
+                        singleElement = (KnuthElement)obj;
+                    } else {
+                        sequence = (KnuthSequence)obj;
+                    }
                     // the sequence contains inline Knuth elements
-                    if (sequence.isInlineSequence()) {
+                    if (singleElement != null || sequence.isInlineSequence()) {
                         // look at the last element 
-                        KnuthElement lastElement = (KnuthElement) sequence.getLast();
+                        KnuthElement lastElement;
+                        if (singleElement != null) {
+                            lastElement = singleElement;
+                        } else {
+                            lastElement = (KnuthElement) sequence.getLast();
+                        }
                         bPrevWasKnuthBox = lastElement.isBox();
 
                         // if last paragraph is open, add the new elements to the paragraph
@@ -680,7 +700,11 @@
                                 trace.append(" +");
                             }
                         }
-                        lastPar.addAll(sequence);
+                        if (singleElement != null) {
+                            lastPar.add(singleElement);
+                        } else {
+                            lastPar.addAll(sequence);
+                        }
                         if (log.isTraceEnabled()) {
                             trace.append(" I");
                         }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message