You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2006/07/31 11:20:18 UTC

svn commit: r427052 [2/3] - in /xmlgraphics/fop/branches/Temp_Floats: ./ src/java/org/apache/fop/area/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/flow/ src/java/org/apache/fop/layoutmgr/ src/java/org/apache/fop/layoutmgr/breaking/ src/java/...

Added: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/breaking/OutOfLineRecord.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/breaking/OutOfLineRecord.java?rev=427052&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/breaking/OutOfLineRecord.java (added)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/breaking/OutOfLineRecord.java Mon Jul 31 02:20:16 2006
@@ -0,0 +1,601 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr.breaking;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.PageBreakingAlgorithm;
+import org.apache.fop.layoutmgr.SpaceResolver;
+import org.apache.fop.layoutmgr.PageBreakingAlgorithm.KnuthPageNode;
+import org.apache.fop.traits.MinOptMax;
+
+/**
+ * Helper class for dealing with out-of-line objects (before-floats and footnotes) when
+ * breaking text into pages. It stores the necessary informations to place out-of-line
+ * objects, and provides methods to manipulate them.
+ * 
+ * @see PageBreakingAlgorithm
+ */
+public class OutOfLineRecord {
+    
+    /**
+     * Stores informations about how many out-of-line objects have already been handled.
+     */
+    public static class ProgressInfo {
+
+        /** Cumulated BPD length of all out-of-line objects inserted so far. */
+        private int alreadyInsertedLength = 0;
+
+        /** Index of the last inserted out-of-line object. */
+        private int lastInsertedIndex = -1;
+
+        /**
+         * Index of the last inserted Knuth element of the last inserted out-of-line
+         * object. Currently only used for footnotes, as before-floats may not be split on
+         * several pages. Might be useful when later dealing with floats that cannot even
+         * be put on a page alone, however.
+         */
+        private int lastElementOfLastInsertedIndex = -1;
+        
+        /**
+         * Initializes this record, as if no out-of-line object were handled yet.
+         */
+        private void initialize() {
+            alreadyInsertedLength = 0;
+            lastInsertedIndex = -1;
+            lastElementOfLastInsertedIndex = -1;
+        }
+
+        /**
+         * @return a copy of this record
+         */
+        public ProgressInfo copy() {
+            ProgressInfo info = new ProgressInfo();
+            info.alreadyInsertedLength = alreadyInsertedLength;
+            info.lastInsertedIndex = lastInsertedIndex;
+            info.lastElementOfLastInsertedIndex = lastElementOfLastInsertedIndex;
+            return info;
+        }
+
+        /**
+         * Returns the cumulated length of all already typeset out-of-line objects.
+         * @return the total length in the block-progression-direction
+         */
+        public int getAlreadyInsertedLength() {
+            return alreadyInsertedLength;
+        }
+
+        /**
+         * Returns the index of the last element of the last already typeset out-of-line
+         * object.
+         * @return the index of the last placed KnuthElement
+         */
+        public int getLastElementOfLastInsertedIndex() {
+            return lastElementOfLastInsertedIndex;
+        }
+
+        /**
+         * @return the index of the last already typeset out-of-line object.
+         */
+        public int getLastInsertedIndex() {
+            return lastInsertedIndex;
+        }
+
+        public String toString() {
+            return "length=" + alreadyInsertedLength
+                    + ", index=" + lastInsertedIndex
+                    + ", elt=" + lastElementOfLastInsertedIndex;
+        }
+    }
+
+    /**
+     * Sequences of KnuthElement corresponding to already encountered out-of-line objects.
+     * This is a List of List of KnuthElement.
+     */
+    private List knuthSequences = null;
+
+    /**
+     * Each element of this list corresponds to the cumulated length in the BPD of all the
+     * out-of-line objects up to the given index. This is a List of Integer.
+     * 
+     * @see OutOfLineRecord#knuthSequences 
+     */
+    private List cumulativeLengths = null;
+
+    /**
+     * True if new out-of-line objects are cited in the sequence of Knuth elements since
+     * the last encountered legal breakpoint.
+     * 
+     * @see OutOfLineRecord#newSinceLastBreakpoint()
+     */
+    private boolean newSinceLastBreakpoint = false;
+
+    /**
+     * Index of the first newly encountered out-of-line object since the last legal
+     * breakpoint.
+     * 
+     * @see OutOfLineRecord#knuthSequences
+     */
+    private int firstNewIndex = 0;
+
+    /**
+     * Dimension in the BPD of the separator between the out-of-line area and the main
+     * area.
+     */
+    private MinOptMax separatorLength = null;
+
+    /**
+     * Record of already handled out-of-line objects.
+     * 
+     * @see ProgressInfo
+     */
+    private ProgressInfo progressInfo;
+
+    public OutOfLineRecord(MinOptMax separatorLength) {
+        this.separatorLength = separatorLength;
+        this.progressInfo = new ProgressInfo();
+    }
+
+    /**
+     * Initializes this record, as if no out-of-line object were handled yet.
+     */
+    public void initialize() {
+        knuthSequences = null;
+        cumulativeLengths = null;
+        newSinceLastBreakpoint = false;
+        firstNewIndex = 0;
+        progressInfo.initialize();
+    }
+
+    /**
+     * @return the informations about already handled out-of-line objects
+     */
+    public ProgressInfo getProgress() {
+        return this.progressInfo;
+    }
+
+    /**
+     * @return the length in the BPD of the separator between the out-of-line area and the
+     * main area.
+     */
+    public MinOptMax getSeparatorLength() {
+        return separatorLength;
+    }
+
+    /**
+     * @return the total length of already encountered out-of-line objects
+     */
+    public int getTotalLength() {
+        if (cumulativeLengths == null || cumulativeLengths.size() == 0) {
+            return 0;
+        } else {
+            return ((Integer) cumulativeLengths.get(cumulativeLengths.size() - 1)).intValue(); 
+        }
+    }
+
+    /**
+     * @return true if out-of-line objects have already been encountered (but not
+     * necessarily typeset yet)
+     */
+    public boolean existing() {
+        return (knuthSequences != null && knuthSequences.size() > 0);
+    }
+
+    public void resetNewSinceLastBreakpoint() {
+        newSinceLastBreakpoint = false;
+    }
+
+    /**
+     * @return true if new out-of-line objects are cited in the sequence of Knuth
+     * elements since the last encountered legal breakpoint.
+     */
+    public boolean newSinceLastBreakpoint() {
+        return newSinceLastBreakpoint;
+    }
+
+    /**
+     * Records one or more newly encountered out-of-line objects.
+     * @param elementLists the list of corresponding Knuth sequences
+     */
+    public void add(List elementLists) {
+        // Initialize stuff if necessary
+        if (knuthSequences == null) {
+            knuthSequences = new ArrayList();
+            cumulativeLengths = new ArrayList();
+        }
+        if (!newSinceLastBreakpoint) {
+            newSinceLastBreakpoint = true;
+            firstNewIndex = knuthSequences.size();
+        }
+        // compute the total length of the footnotes
+        ListIterator elementListsIterator = elementLists.listIterator();
+        while (elementListsIterator.hasNext()) {
+            LinkedList noteList = (LinkedList) elementListsIterator.next();
+            
+            //Space resolution (Note: this does not respect possible stacking constraints 
+            //between footnotes!)
+            SpaceResolver.resolveElementList(noteList);
+            
+            int noteLength = 0;
+            knuthSequences.add(noteList);
+            ListIterator noteListIterator = noteList.listIterator();
+            while (noteListIterator.hasNext()) {
+                KnuthElement element = (KnuthElement) noteListIterator.next();
+                if (element.isBox() || element.isGlue()) {
+                    noteLength += element.getW();
+                }
+            }
+            cumulativeLengths.add(new Integer(getTotalLength() + noteLength));
+        }
+    }
+
+    /**
+     * Sets the progress informations to the given values. Called whenever a new active
+     * node is considered; the informations regarding already handled out-of-line objects
+     * must be set to the active node's values in order to know from where to start the
+     * placement of further objects.
+     *
+     * @param info progress informations of the currently considered active node
+     */
+    public void setProgress(ProgressInfo info) {
+        this.progressInfo.alreadyInsertedLength = info.alreadyInsertedLength;
+        this.progressInfo.lastElementOfLastInsertedIndex = info.lastElementOfLastInsertedIndex;
+        this.progressInfo.lastInsertedIndex = info.lastInsertedIndex;
+    }
+
+    /* Unless I'm wrong, newOnThisPagePlusPiecesFromPrevious always implies
+     * notAllInserted. And if A => B, then A && B <=> B
+     * So this code may be simplified, see deferred() below
+     */
+    /**
+//   * Returns true if their are (pieces of) footnotes to be typeset on the
+//   * current page.
+//   * @param listIndex index of the last inserted footnote for the
+//   * currently considered active node
+//   * @param elementIndex index of the last element of the last inserted footnote
+//   * @param length total length of all footnotes inserted so far
+//   */
+//  public boolean deferredFootnotes(ProgressInfo progressInfo) {
+//      boolean newOnThisPagePlusPiecesFromPrevious =
+//              newSinceLastBreakpoint()
+//              && firstNewIndex != 0
+//              && (progressInfo.lastInsertedIndex < firstNewIndex - 1
+//                  || progressInfo.lastElementOfLastInsertedIndex <
+//                      ((LinkedList) knuthSequences.get(progressInfo.lastInsertedIndex)).size() - 1);
+//      boolean notAllInserted = progressInfo.alreadyInsertedLength < getTotalLength();
+//      return notAllInserted;
+//  }
+
+    /**
+     * @return <code>true</code> if some out-of-line objects have not already been
+     * typeset.
+     */
+    public boolean deferred() {
+        return progressInfo.alreadyInsertedLength < getTotalLength();
+    }
+
+    /**
+     * @return the number of not yet typeset out-of-line objects.
+     */
+    public int getNbOfDeferred() {
+        return knuthSequences.size() - 1 - progressInfo.lastInsertedIndex;
+    }
+
+    /**
+     * @return <code>true</code> if the last typeset out-of-line object must be split on
+     * several pages.
+     */
+    public boolean isSplit() {
+        return (progressInfo.lastElementOfLastInsertedIndex 
+                < ((LinkedList) knuthSequences.get(progressInfo.lastInsertedIndex)).size() - 1);
+    }
+
+    /**
+     * Returns the out-of-line object corresponding to the given index.
+     * @param index index of the object
+     * @return a List of KnuthElement corresponding to the object, or <code>null</code> if
+     * it does not exist
+     */
+    public List getSequence(int index) {
+        /*TODO vh: bof */
+        if (knuthSequences == null) {
+            return null;
+        } else {
+            return (List) knuthSequences.get(index);
+        }
+    }
+
+    /**
+     * Tries to split the flow of footnotes to put one part on the current page.
+     * @param prevNodeProgress informations about footnotes already inserted on the
+     * previous page
+     * @param availableLength available space for footnotes on this page
+     * @param canDeferOldFootnotes
+     * @return the length of footnotes which could be inserted on this page
+     */
+    public int getFootnoteSplit(ProgressInfo prevNodeProgress,
+                                int availableLength, boolean canDeferOldFootnotes) {
+        if (availableLength <= 0) {
+            progressInfo.alreadyInsertedLength = prevNodeProgress.getAlreadyInsertedLength();
+            return 0;
+        } else {
+            // the split should contain a piece of the last footnote
+            // together with all previous, not yet inserted footnotes;
+            // but if this is not possible, try adding as much content as possible
+            int splitLength = 0;
+            ListIterator noteListIterator = null;
+            KnuthElement element = null;
+            boolean somethingAdded = false;
+
+            // prevNodeProgress.lastInsertedIndex and
+            // prevNodeProgress.lastElementOfLastInsertedIndex points to the last footnote element
+            // already placed in a page: advance to the next element
+            int listIndex = prevNodeProgress.lastInsertedIndex;
+            int elementIndex = prevNodeProgress.lastElementOfLastInsertedIndex;
+            if (listIndex == -1
+                    || elementIndex == ((LinkedList) knuthSequences.get(listIndex)).size() - 1) {
+                listIndex++;
+                elementIndex = 0;
+            } else {
+                elementIndex++;
+            }
+
+            // try adding whole notes
+            // if there are more than 1 footnote to insert
+            if (knuthSequences.size() - 1 > listIndex) {
+                // add the previous footnotes: these cannot be broken or deferred
+                if (!canDeferOldFootnotes
+                    && newSinceLastBreakpoint()
+                    && firstNewIndex > 0) {
+                    splitLength = ((Integer) cumulativeLengths.get(firstNewIndex - 1)).intValue()
+                                  - prevNodeProgress.alreadyInsertedLength;
+                    listIndex = firstNewIndex;
+                    elementIndex = 0;
+                }
+                // try adding the new footnotes
+                while (((Integer) cumulativeLengths.get(listIndex)).intValue()
+                        - prevNodeProgress.alreadyInsertedLength <= availableLength) {
+                    splitLength = ((Integer) cumulativeLengths.get(listIndex)).intValue()
+                                  - prevNodeProgress.alreadyInsertedLength;
+                    somethingAdded = true;
+                    listIndex++;
+                    elementIndex = 0;
+                }
+                // as this method is called only if it is not possible to insert
+                // all footnotes, at this point listIndex and elementIndex points to
+                // an existing element, the next one we will try to insert 
+            }
+
+            // try adding a split of the next note
+            noteListIterator = ((List) knuthSequences.get(listIndex)).listIterator(elementIndex);
+
+            int prevSplitLength = 0;
+            int prevIndex = -1;
+            int index = -1;
+
+            while (!somethingAdded || splitLength <= availableLength) {
+                if (!somethingAdded) {
+                    somethingAdded = true;
+                } else {
+                    prevSplitLength = splitLength;
+                    prevIndex = index;
+                }
+                // get a sub-sequence from the note element list
+                boolean bPrevIsBox = false;
+                while (noteListIterator.hasNext()) {
+                    // as this method is called only if it is not possible to insert
+                    // all footnotes, and we have already tried (and failed) to insert
+                    // this whole footnote, the while loop will never reach the end
+                    // of the note sequence
+                    element = (KnuthElement) noteListIterator.next();
+                    if (element.isBox()) {
+                        // element is a box
+                        splitLength += element.getW();
+                        bPrevIsBox = true;
+                    } else if (element.isGlue()) {
+                        // element is a glue
+                        if (bPrevIsBox) {
+                            // end of the sub-sequence
+                            index = noteListIterator.previousIndex();
+                            break;
+                        }
+                        bPrevIsBox = false;
+                        splitLength += element.getW();
+                    } else {
+                        // element is a penalty
+                        if (element.getP() < KnuthElement.INFINITE) {
+                            // end of the sub-sequence
+                            index = noteListIterator.previousIndex();
+                            break;
+                        }
+                    }
+                }
+            }
+            // if prevSplitLength is 0, this means that the available length isn't enough
+            // to insert even the smallest split of the last footnote, so we cannot end a
+            // page here
+            // if prevSplitLength is > 0 we can insert some footnote content in this page
+            // and insert the remaining in the following one
+            if (!somethingAdded) {
+                // there was not enough space to add a piece of the first new footnote
+                // this is not a good break
+                prevSplitLength = 0;
+            } else if (prevSplitLength > 0) {
+                // prevIndex is -1 if we have added only some whole footnotes
+                progressInfo.lastInsertedIndex = (prevIndex != -1) ? listIndex : listIndex - 1;
+                progressInfo.lastElementOfLastInsertedIndex = (prevIndex != -1)
+                    ? prevIndex 
+                    : ((LinkedList) knuthSequences.get(progressInfo.lastInsertedIndex)).size() - 1;
+            }
+            progressInfo.alreadyInsertedLength
+                    = prevNodeProgress.getAlreadyInsertedLength() + prevSplitLength;
+            return prevSplitLength;
+        }
+    }
+
+    /**
+     * Tries to split the flow of floats to put some floats on the current page.
+     * @param prevProgress floats already inserted on the previous page
+     * @param availableLength available space for floats
+     * @return the length of floats which could be placed on the current page
+     */
+    public int getFloatSplit(ProgressInfo prevProgress, int availableLength) {
+        /*
+         * Normally this method is called only when there is some place for
+         * floats => availableLength > 0
+         */
+        int splitLength = 0;
+        int listIndex = prevProgress.lastInsertedIndex + 1;
+
+        while (listIndex < knuthSequences.size()
+                && ((Integer) cumulativeLengths.get(listIndex)).intValue()
+                    - prevProgress.alreadyInsertedLength <= availableLength) {
+            splitLength = ((Integer) cumulativeLengths.get(listIndex)).intValue()
+                    - prevProgress.alreadyInsertedLength;
+            listIndex++;
+        }
+        progressInfo.lastInsertedIndex = listIndex - 1;
+        progressInfo.alreadyInsertedLength = prevProgress.alreadyInsertedLength + splitLength;
+        return splitLength;
+    }
+
+    /**
+     * Places on the current page all of the out-of-line objects not yet inserted.
+     */
+    public void insertAll() {
+        progressInfo.alreadyInsertedLength = getTotalLength();
+        progressInfo.lastInsertedIndex = knuthSequences.size() - 1;
+        progressInfo.lastElementOfLastInsertedIndex
+                = ((List) knuthSequences.get(progressInfo.lastInsertedIndex)).size() - 1;        
+    }
+
+    /**
+     * When restarting the algorithm from a given point, reset the informations about
+     * out-of-line objects to the values at that point.
+     * @param elementLists out-of-line sequences which are met after the restarting point,
+     * and thus must be removed from the list of already encoutered objects.
+     */
+    public void reset(List elementLists) {
+        for (int i = 0; i < elementLists.size(); i++) {
+            knuthSequences.remove(knuthSequences.size() - 1);
+            cumulativeLengths.remove(cumulativeLengths.size() - 1);
+        }
+    }
+
+    /**
+     * When the whole normal flow has been typeset and there are still footnotes to be
+     * placed, creates as many pages as necessary to place them.
+     */
+    public void createFootnotePages(KnuthPageNode lastNode, PageBreakingAlgorithm algo, int lineWidth) {
+        progressInfo.alreadyInsertedLength = lastNode.footnotesProgress.getAlreadyInsertedLength();
+        progressInfo.lastInsertedIndex = lastNode.footnotesProgress.getLastInsertedIndex();
+        progressInfo.lastElementOfLastInsertedIndex = lastNode.footnotesProgress.getLastElementOfLastInsertedIndex();
+        int availableBPD = lineWidth;
+        int split = 0;
+        KnuthPageNode prevNode = lastNode;
+
+        // create pages containing the remaining footnote bodies
+        while (progressInfo.alreadyInsertedLength < getTotalLength()) {
+            // try adding some more content
+            if (((Integer) cumulativeLengths.get(progressInfo.lastInsertedIndex)).intValue() - progressInfo.alreadyInsertedLength
+                <= availableBPD) {
+                // add a whole footnote
+                availableBPD -= ((Integer) cumulativeLengths.get(progressInfo.lastInsertedIndex)).intValue()
+                                - progressInfo.alreadyInsertedLength;
+                progressInfo.alreadyInsertedLength = ((Integer)cumulativeLengths.get(progressInfo.lastInsertedIndex)).intValue();
+                progressInfo.lastElementOfLastInsertedIndex
+                    = ((LinkedList)knuthSequences.get(progressInfo.lastInsertedIndex)).size() - 1;
+            } else if ((split = getFootnoteSplit(progressInfo, availableBPD, true))
+                       > 0) {
+                // add a piece of a footnote
+                availableBPD -= split;
+                // footnoteListIndex has already been set in getFootnoteSplit()
+                // footnoteElementIndex has already been set in getFootnoteSplit()
+            } else {
+                // cannot add any content: create a new node and start again
+                KnuthPageNode node = (KnuthPageNode)
+                                     algo.createNode(lastNode.position, prevNode.line + 1, 1,
+                                                progressInfo.alreadyInsertedLength - prevNode.footnotesProgress.getAlreadyInsertedLength(), 
+                                                0, 0,
+                                                0, 0, 0,
+                                                0, 0, prevNode);
+                algo.addNode(node.line, node);
+                algo.removeNode(prevNode.line, prevNode);
+
+                prevNode = node;
+                availableBPD = lineWidth;
+            }
+        }
+        // create the last node
+        KnuthPageNode node = (KnuthPageNode)
+                             algo.createNode(lastNode.position, prevNode.line + 1, 1,
+                                        getTotalLength() - prevNode.footnotesProgress.getAlreadyInsertedLength(), 0, 0,
+                                        0, 0, 0,
+                                        0, 0, prevNode);
+        algo.addNode(node.line, node);
+        algo.removeNode(prevNode.line, prevNode);
+    }
+
+    /* TODO vh: won't work when there are also footnotes. To be merged with createFootnotePages */
+    public void createFloatPages(KnuthPageNode lastNode, PageBreakingAlgorithm algo, int lineWidth) {
+        progressInfo.alreadyInsertedLength = lastNode.floatsProgress.getAlreadyInsertedLength();
+        progressInfo.lastInsertedIndex = lastNode.floatsProgress.getLastInsertedIndex();
+        int availableBPD = lineWidth;
+        KnuthPageNode prevNode = lastNode;
+
+        // create pages containing the remaining float bodies
+        while (progressInfo.alreadyInsertedLength < getTotalLength()) {
+            // try adding some more content
+            if (((Integer) cumulativeLengths.get(progressInfo.lastInsertedIndex + 1)).intValue() - progressInfo.alreadyInsertedLength
+                <= availableBPD) {
+                // add a whole float
+                progressInfo.lastInsertedIndex++;
+                availableBPD -= ((Integer) cumulativeLengths.get(progressInfo.lastInsertedIndex)).intValue()
+                                - progressInfo.alreadyInsertedLength;
+                progressInfo.alreadyInsertedLength = ((Integer)cumulativeLengths.get(progressInfo.lastInsertedIndex)).intValue();
+            } else {
+                // cannot add any content: create a new node and start again
+                KnuthPageNode node = (KnuthPageNode)
+                                     algo.createNode(lastNode.position, prevNode.line + 1, 1,
+                                                progressInfo.alreadyInsertedLength - prevNode.floatsProgress.getAlreadyInsertedLength(), 
+                                                0, 0,
+                                                0, 0, 0,
+                                                0, prevNode.totalDemerits + (progressInfo.lastInsertedIndex - prevNode.floatsProgress.lastInsertedIndex) * 10000, prevNode);
+                algo.addNode(node.line, node);
+                algo.removeNode(prevNode.line, prevNode);
+
+                prevNode = node;
+                availableBPD = lineWidth;
+            }
+        }
+        // create the last node
+        KnuthPageNode node = (KnuthPageNode)
+                             algo.createNode(lastNode.position, prevNode.line + 1, 1,
+                                        getTotalLength() - prevNode.floatsProgress.getAlreadyInsertedLength(), 0, 0,
+                                        0, 0, 0,
+                                        0, prevNode.totalDemerits + (progressInfo.lastInsertedIndex - prevNode.floatsProgress.lastInsertedIndex) * 10000, prevNode);
+        algo.addNode(node.line, node);
+        algo.removeNode(prevNode.line, prevNode);
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/breaking/OutOfLineRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/FloatLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/FloatLayoutManager.java?rev=427052&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/FloatLayoutManager.java (added)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/FloatLayoutManager.java Mon Jul 31 02:20:16 2006
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr.inline;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.fop.fo.flow.Float;
+import org.apache.fop.layoutmgr.AbstractLayoutManager;
+import org.apache.fop.layoutmgr.FloatBodyLayoutManager;
+import org.apache.fop.layoutmgr.InlineKnuthSequence;
+import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthSequence;
+import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.Position;
+
+/**
+ * Layout manager for fo:float.
+ */
+public class FloatLayoutManager extends AbstractLayoutManager 
+                                   implements InlineLevelLayoutManager {
+
+    private Float floatNode;
+    private FloatBodyLayoutManager bodyLM;
+    /** Represents the float citation **/
+    private KnuthElement forcedAnchor;
+
+    /**
+     * Create a new float layout manager.
+     * @param node float to create the layout manager for
+     */
+    public FloatLayoutManager(Float node) {
+        super(node);
+        floatNode = node;
+    }
+    
+    /** @see org.apache.fop.layoutmgr.LayoutManager#initialize() */
+    public void initialize() {
+        // create a FloatBodyLM handling the fo:float-body child of fo:float
+        bodyLM = new FloatBodyLayoutManager(floatNode);
+    }
+
+    /** @see org.apache.fop.layoutmgr.LayoutManager */
+    public LinkedList getNextKnuthElements(LayoutContext context,
+                                           int alignment) {
+        // this is the only method that must be implemented:
+        // all other methods will never be called, as the returned elements
+        // contain Positions created by the citationLM, so its methods will
+        // be called instead
+
+        bodyLM.setParent(this);
+        bodyLM.initialize();
+
+        // get Knuth elements representing the float citation
+        LinkedList returnedList = new LinkedList();
+        //Inline part of the float is empty. Need to send back an auxiliary
+        //zero-width, zero-height inline box so the float gets painted.
+        KnuthSequence seq = new InlineKnuthSequence();
+        //Need to use an aux. box, otherwise, the line height can't be forced to zero height.
+        forcedAnchor = new KnuthInlineBox(0, null, null, true);
+        ((KnuthInlineBox) forcedAnchor).setFloatBodyLM(bodyLM);
+        seq.add(forcedAnchor);
+        returnedList.add(seq);
+        setFinished(true);
+
+        return returnedList;
+    }
+
+    /** @see org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager */
+    public List addALetterSpaceTo(List oldList) {
+        log.warn("null implementation of addALetterSpaceTo() called!");
+        return oldList;
+    }
+
+    /**
+     * Remove the word space represented by the given elements
+     *
+     * @param oldList the elements representing the word space
+     */
+    public void removeWordSpace(List oldList) {
+        // do nothing
+        log.warn(this.getClass().getName() + " should not receive a call to removeWordSpace(list)");
+    }
+
+    /** @see org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager */
+    public void getWordChars(StringBuffer sbChars, Position pos) {
+        log.warn("null implementation of getWordChars() called!");
+    }
+
+    /** @see org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager */
+    public void hyphenate(Position pos, HyphContext hc) {
+        log.warn("null implementation of hyphenate called!");
+    }
+
+    /** @see org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager */
+    public boolean applyChanges(List oldList) {
+        log.warn("null implementation of applyChanges() called!");
+        return false;
+    }
+
+    /**
+     * @see org.apache.fop.layoutmgr.LayoutManager#getChangedKnuthElements(java.util.List, int)
+     */
+    public LinkedList getChangedKnuthElements(List oldList,
+                                              int alignment) {
+        log.warn("null implementation of getChangeKnuthElement() called!");
+        return null;
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/FloatLayoutManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java?rev=427052&r1=427051&r2=427052&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java Mon Jul 31 02:20:16 2006
@@ -20,6 +20,7 @@
 package org.apache.fop.layoutmgr.inline;
 
 import org.apache.fop.layoutmgr.inline.AlignmentContext;
+import org.apache.fop.layoutmgr.FloatBodyLayoutManager;
 import org.apache.fop.layoutmgr.FootnoteBodyLayoutManager;
 import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.Position;
@@ -27,6 +28,7 @@
 public class KnuthInlineBox extends KnuthBox {
     
     private FootnoteBodyLayoutManager footnoteBodyLM = null;
+    private FloatBodyLayoutManager floatBodyLM = null;
     private AlignmentContext alignmentContext = null;
 
     /**
@@ -64,16 +66,43 @@
     }
 
     /**
-     * @return true if this box holds a reference to a FootnoteBodyLM
+     * @param fblm the FloatBodyLM this box must hold a reference to
+     */
+    public void setFloatBodyLM(FloatBodyLayoutManager fblm) {
+        floatBodyLM = fblm;
+    }
+
+    /**
+     * @return the FloatBodyLM this box holds a reference to
+     */
+    public FloatBodyLayoutManager getFloatBodyLM() {
+        return floatBodyLM;
+    }
+
+    /**
+     * @return true if this box holds a reference to an out-of-line object
      */
     public boolean isAnchor() {
+        return (footnoteBodyLM != null || floatBodyLM != null);
+    }
+
+    /**
+     * @return <code>true</code> if this box holds a reference to a footnote
+     */
+    public boolean isFootnoteAnchor() {
         return (footnoteBodyLM != null);
     }
-    
-    
+
+    /**
+     * @return <code>true</code> if this box holds a reference to a before-float
+     */
+    public boolean isFloatAnchor() {
+        return (floatBodyLM != null);
+    }
+
     /** @see java.lang.Object#toString() */
     public String toString() {
         StringBuffer sb = new StringBuffer(super.toString());
         return sb.toString();
     }
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=427052&r1=427051&r2=427052&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Mon Jul 31 02:20:16 2006
@@ -1094,14 +1094,20 @@
                     // create a list of the FootnoteBodyLM handling footnotes 
                     // whose citations are in this line
                     LinkedList footnoteList = new LinkedList();
+                    LinkedList floatList = new LinkedList();
                     ListIterator elementIterator = seq.listIterator(startIndex);
                     while (elementIterator.nextIndex() <= endIndex) {
                         KnuthElement element = (KnuthElement) elementIterator.next();
                         if (element instanceof KnuthInlineBox
                             && ((KnuthInlineBox) element).isAnchor()) {
-                            footnoteList.add(((KnuthInlineBox) element).getFootnoteBodyLM());
+                            if (((KnuthInlineBox) element).isFootnoteAnchor()) {
+                                footnoteList.add(((KnuthInlineBox) element).getFootnoteBodyLM());
+                            } else {
+                                floatList.add(((KnuthInlineBox) element).getFloatBodyLM());
+                            }
                         } else if (element instanceof KnuthBlockBox) {
                             footnoteList.addAll(((KnuthBlockBox) element).getFootnoteBodyLMs());
+                            floatList.addAll(((KnuthBlockBox) element).getFloatBodyLMs());
                         }
                     }
                     startIndex = endIndex + 1;
@@ -1109,7 +1115,7 @@
                       = (LineBreakPosition) llPoss.getChosenPosition(i);
                     returnList.add(new KnuthBlockBox
                                    (lbp.lineHeight + lbp.spaceBefore + lbp.spaceAfter,
-                                    footnoteList, lbp, false));
+                                    footnoteList, floatList, lbp, false));
                     /* // add stretch and shrink to the returnlist
                     if (!seq.isInlineSequence()
                             && lbp.availableStretch != 0 || lbp.availableShrink != 0) {

Modified: xmlgraphics/fop/branches/Temp_Floats/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/status.xml?rev=427052&r1=427051&r2=427052&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/status.xml (original)
+++ xmlgraphics/fop/branches/Temp_Floats/status.xml Mon Jul 31 02:20:16 2006
@@ -28,6 +28,9 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="add" fixes-bug="39777" due-to="Vincent Hennebert">
+        Initial support for fo:float with float="before" and float="none".
+      </action>
       <action context="Code" dev="JM" type="fix" fixes-bug="40106" due-to="Jeroen Meijer">
         Compatibility fix for GCJ (GNU Classpath): Using "UTF-16BE" instead of "UnicodeBigUnmarked"
         encoding.

Modified: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/disabled-testcases.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/disabled-testcases.xml?rev=427052&r1=427051&r2=427052&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/disabled-testcases.xml (original)
+++ xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/disabled-testcases.xml Mon Jul 31 02:20:16 2006
@@ -356,4 +356,24 @@
     <description>Long text cause an IndexOutOfBounds exception</description>
     <reference>http://issues.apache.org/bugzilla/show_bug.cgi?id=39414</reference>
   </testcase>
-</disabled-testcases>
\ No newline at end of file
+  <testcase>
+    <name>fo:float float="none" should be split</name>
+    <file>float_float_none_2.xml</file>
+    <description>When float="none", it should be possible to split an fo:float
+      element on several pages.</description>
+  </testcase>
+  <testcase>
+    <name>Before-floats when no stretch available</name>
+    <file>before-float_not-deferred_no-stretch_2.xml</file>
+    <description>Whereas there is room for placing the before-float on the same
+      page as its citation, the algorithm prefers to defer it to the following
+      page.</description>
+  </testcase>
+  <testcase>
+    <name>Before-floats deferred when no stretch available</name>
+    <file>before-float_deferred_no-stretch.xml</file>
+    <description>Instead of deferring a before-float on the following page, an
+    underfull page is created so that the citation be on the same page as the
+    float.</description>
+  </testcase>
+</disabled-testcases>

Added: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_basic.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_basic.xml?rev=427052&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_basic.xml (added)
+++ xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_basic.xml Mon Jul 31 02:20:16 2006
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks that a before-float on a simple one-page document is
+      rightly placed on the top of the page.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="3in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+	  <fo:block>
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	  </fo:block>
+	  <fo:block>
+	    This is a block with a float. This is a block with a float.
+	    The float anchor is just behind this <fo:inline
+	      color="blue">word</fo:inline><fo:float float="before"
+	      color="red">
+	      <fo:block>
+		This is the float content. This is the float content. This is
+		the float content. This is the float content. This is the float
+		content. This is the float content. This is the float content.
+		This is the float content.
+	      </fo:block>
+	    </fo:float>.
+	    This is a block with a float. This is a block with a float.
+	    This is a block with a float. This is a block with a float.
+	  </fo:block>
+	  <fo:block>
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	  </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="1" xpath="count(//pageViewport)"/>
+    <!-- before-float block -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <eval expected="This is the float content. This is the float content. This is the float"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block/lineArea/text[1]"/>
+    <eval expected="43200"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block/@bpd"/>
+    <!-- main area -->
+    <eval expected="3"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block)"/>
+  </checks>
+</testcase>

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_basic.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_basic.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_complex.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_complex.xml?rev=427052&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_complex.xml (added)
+++ xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_complex.xml Mon Jul 31 02:20:16 2006
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      Test for before-floats. This a complex documents with several floats; some
+      may be put on the same page as their citation, others not.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="3in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+	  <fo:block space-after.minimum="2pt"
+		    space-after.optimum="6pt"
+		    space-after.maximum="12pt"
+		    orphans="1"
+		    widows="1">
+	    <fo:block space-after="inherit">
+	      This is a block with a float. This is a block with a float.
+	      This float has the number <fo:inline
+		color="blue">1</fo:inline><fo:float float="before" color="red">
+		<fo:block>
+		  This is the float content. This is the float content. This is
+		  the float content. This is the float content. This is the
+		  float content. This was the float number 1.
+		</fo:block>
+	      </fo:float>.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block with a float. This is a block with a float.
+	      This float has the number <fo:inline
+		color="blue">2</fo:inline><fo:float float="before" color="red">
+		<fo:block>
+		  This is the float content. This is the float content. This is
+		  the float content. This is the float content. This is the
+		  float content. This was the float number 2.
+		</fo:block>
+	      </fo:float>.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block with a float. This is a block with a float.
+	      This float has the number <fo:inline
+		color="blue">3</fo:inline><fo:float float="before" color="red">
+		<fo:block>
+		  This is the float content. This is the float content. This is
+		  the float content. This is the float content. This is the
+		  float content. This was the float number 3.
+		</fo:block>
+	      </fo:float>.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block with a float. This is a block with a float.
+	      This float has the number <fo:inline
+		color="blue">4</fo:inline><fo:float float="before" color="red">
+		<fo:block>
+		  This is the float content. This is the float content. This is
+		  the float content. This is the float content. This is the
+		  float content. This was the float number 4.
+		</fo:block>
+	      </fo:float>.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block with a float. This is a block with a float.
+	      This float has the number <fo:inline
+		color="blue">5</fo:inline><fo:float float="before" color="red">
+		<fo:block>
+		  This is the float content. This is
+		  the float content. This is the float content. This is the
+		  float content. This is the float content. This is the float
+		  content. This is the float content. This is the float content.
+		  This is the float content. This is the float content. This is
+		  the float content. This is the float content. This is the
+		  float content. This is the float content. This is the float
+		  content. This is the float content. This is the float content.
+		  This was the float number 5.
+		</fo:block>
+	      </fo:float>.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	  </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="5" xpath="count(//pageViewport)"/>
+    <!-- page 1 -->
+    <eval expected="2"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <!-- float number 1 -->
+    <eval expected="the float number 1."
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block[1]/lineArea[3]/text"/>
+    <eval expected="43200"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block[1]/@bpd"/>
+    <!-- float number 2 -->
+    <eval expected="the float number 2."
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block[2]/lineArea[3]/text"/>
+    <eval expected="43200"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block[2]/@bpd"/>
+    <!-- page 2 -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <!-- float number 3 -->
+    <eval expected="the float number 3."
+          xpath="//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block/lineArea[3]/text"/>
+    <eval expected="43200"
+          xpath="//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block/@bpd"/>
+    <!-- page 3 -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[3]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <!-- float number 4 -->
+    <eval expected="the float number 4."
+          xpath="//pageViewport[3]/page/regionViewport/regionBody/beforeFloat/block/lineArea[3]/text"/>
+    <eval expected="43200"
+          xpath="//pageViewport[3]/page/regionViewport/regionBody/beforeFloat/block/@bpd"/>
+    <!-- page 4 -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[4]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <!-- float number 5 -->
+    <eval expected="This is the float content. This was the float number 5."
+          xpath="//pageViewport[4]/page/regionViewport/regionBody/beforeFloat/block/lineArea[7]/text"/>
+    <eval expected="100800"
+          xpath="//pageViewport[4]/page/regionViewport/regionBody/beforeFloat/block/@bpd"/>
+    <!-- page 5 -->
+    <eval expected="0"
+	  xpath="count(//pageViewport[5]/page/regionViewport/regionBody/beforeFloat/block)"/>
+  </checks>
+</testcase>

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_complex.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_complex.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_no-stretch.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_no-stretch.xml?rev=427052&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_no-stretch.xml (added)
+++ xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_no-stretch.xml Mon Jul 31 02:20:16 2006
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      Test for before-floats. On a two-page document, when no stretching is
+      allowed between blocks, when the float citation is on the first page and
+      there is not enough room for the float, it should be placed on the top of
+      the second page.
+    </p>
+    <p>
+      When no stretching is available, only "too short" nodes are created. When
+      there is not enough room to place the float, a too short node is created
+      with added demerits for the deferred float. This results in higher
+      demerits than for previous too short nodes, which then are preferred
+      whereas they create underfull pages.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="3.1in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+	  <fo:block orphans="1" widows="1">
+	    <fo:block>
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block>
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block>
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block>
+	      This is a block with a float. This is a block with a float.
+	      The float anchor is just behind this <fo:inline
+		color="blue">word</fo:inline><fo:float float="before"
+		color="red">
+		<fo:block>
+		  This is the float content. This is the float content. This is
+		  the float content. This is the float content. This is the
+		  float content. This is the float content. This is the float
+		  content. This is the float content.
+		</fo:block>
+	      </fo:float>.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float. This is a block with a float.
+	    </fo:block>
+	    <fo:block>
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	  </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="2" xpath="count(//pageViewport)"/>
+    <!-- first page -->
+    <eval expected="0"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <!-- main area -->
+    <eval expected="4"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block/block)"/>
+    <!-- four lines in the last block -->
+    <eval expected="4"
+          xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block/block[4]/lineArea)"/>
+    <!-- second page -->
+    <!-- before-float block -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <eval expected="This is the float content. This is the float content. This is the float"
+          xpath="//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block/lineArea/text[1]"/>
+    <eval expected="43200"
+          xpath="//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block/@bpd"/>
+    <!-- one block in the normal content -->
+    <eval expected="2"
+	  xpath="count(//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block)"/>
+    <!-- one remaining line in the first block -->
+    <eval expected="1"
+          xpath="count(//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block[1]/lineArea)"/>
+  </checks>
+</testcase>

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_no-stretch.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_no-stretch.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_stretch.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_stretch.xml?rev=427052&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_stretch.xml (added)
+++ xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_stretch.xml Mon Jul 31 02:20:16 2006
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      Test for before-floats. On a two-page document, when some stretching is
+      allowed between blocks, when the float citation is on the first page and
+      there is not enough room for the float, it should be placed on the top of
+      the second page.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="3in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+	  <fo:block space-after.minimum="2pt"
+		    space-after.optimum="6pt"
+		    space-after.maximum="16pt"
+		    orphans="1"
+		    widows="1">
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block with a float. This is a block with a float.
+	      The float anchor is just behind this <fo:inline
+		color="blue">word</fo:inline><fo:float float="before"
+		color="red">
+		<fo:block>
+		  This is the float content. This is the float content. This is
+		  the float content. This is the float content. This is the
+		  float content. This is the float content. This is the float
+		  content. This is the float content.
+		</fo:block>
+	      </fo:float>.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	  </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="2" xpath="count(//pageViewport)"/>
+    <!-- first page -->
+    <eval expected="0"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <!-- main area -->
+    <eval expected="4"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block/block)"/>
+    <!-- only one line in the last block -->
+    <eval expected="1"
+          xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block/block[4]/lineArea)"/>
+    <!-- second page -->
+    <!-- before-float block -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <eval expected="This is the float content. This is the float content. This is the float"
+          xpath="//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block/lineArea/text[1]"/>
+    <eval expected="43200"
+          xpath="//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block/@bpd"/>
+    <!-- one block in the normal content -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block)"/>
+    <!-- three remaining lines in the normal content -->
+    <eval expected="3"
+          xpath="count(//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block[1]/lineArea)"/>
+  </checks>
+</testcase>

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_stretch.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_deferred_stretch.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_1.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_1.xml?rev=427052&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_1.xml (added)
+++ xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_1.xml Mon Jul 31 02:20:16 2006
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      Test for before-floats. On a two-page document, when no stretching is
+      allowed between blocks, when the float citation is on the first page and
+      there is enough room for the float, it should be placed on the top of the
+      first page.
+    </p>
+    <p>
+      When no stretching is available, only "too short" nodes are created. There
+      is no feasible break. The result regarding floats should be the same,
+      however.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="3.1in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+	  <fo:block>
+	    This is a block with a float. This is a block with a float.
+	    The float anchor is just behind this <fo:inline
+	      color="blue">word</fo:inline><fo:float float="before"
+	      color="red">
+	      <fo:block>
+		This is the float content. This is the float content. This is
+		the float content. This is the float content. This is the float
+		content. This is the float content. This is the float content.
+		This is the float content.
+	      </fo:block>
+	    </fo:float>.
+	    This is a block with a float. This is a block with a float.
+	    This is a block with a float. This is a block with a float.
+	  </fo:block>
+	  <fo:block>
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	  </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="2" xpath="count(//pageViewport)"/>
+    <!-- first page -->
+    <!-- before-float block -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <eval expected="This is the float content. This is the float content. This is the float"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block/lineArea/text[1]"/>
+    <eval expected="43200"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block/@bpd"/>
+    <!-- main area -->
+    <eval expected="2"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block)"/>
+    <!-- only eight lines in the last block -->
+    <eval expected="8"
+          xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea)"/>
+    <!-- second page -->
+    <eval expected="0"
+	  xpath="count(//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <!-- four remaining lines from the previous last block -->
+    <eval expected="4"
+          xpath="count(//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/lineArea)"/>
+  </checks>
+</testcase>

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_1.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_2.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_2.xml?rev=427052&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_2.xml (added)
+++ xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_2.xml Mon Jul 31 02:20:16 2006
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test does not work. There is a before-float and a block of normal
+      text with no stretching. Normally the float should be on the first page.
+    </p>
+    <p>
+      Without the before-float, the normal content would fit on one page. With
+      the float, two pages are necessary. As there is no available stretching
+      the algorithm can only create "too short" nodes. In such a case it prefers
+      to defer the float on the last page, instead of putting it on the first
+      page and splitting the normal content on two pages. This should be
+      corrected eventually.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="3.1in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+	  <fo:block>
+	    This is a block with a float. This is a block with a float.
+	    The float anchor is just behind this <fo:inline
+	      color="blue">word</fo:inline><fo:float float="before"
+	      color="red">
+	      <fo:block>
+		This is the float content. This is the float content. This is
+		the float content. This is the float content. This is the float
+		content. This is the float content. This is the float content.
+		This is the float content.
+	      </fo:block>
+	    </fo:float>.
+	    This is a block with a float. This is a block with a float.
+	    This is a block with a float. This is a block with a float.
+	  </fo:block>
+	  <fo:block>
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	    This is a block without a float. This is a block without a float.
+	  </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="2" xpath="count(//pageViewport)"/>
+    <!-- first page -->
+    <!-- before-float block -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <eval expected="This is the float content. This is the float content. This is the float"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block/lineArea/text[1]"/>
+    <eval expected="43200"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block/@bpd"/>
+    <!-- main area -->
+    <eval expected="2"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block)"/>
+    <!-- second page -->
+    <eval expected="0"
+	  xpath="count(//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <!-- three remaining lines on the second page -->
+    <eval expected="3"
+	  xpath="count(//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/lineArea)"/>
+  </checks>
+</testcase>

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_no-stretch_2.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_stretch.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_stretch.xml?rev=427052&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_stretch.xml (added)
+++ xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_stretch.xml Mon Jul 31 02:20:16 2006
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      Test for before-floats. On a two-page document, when some stretching is
+      allowed between blocks, when the float citation is on the first page and
+      there is enough room for the float, it should be placed on the top of the
+      first page.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="3in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+	  <fo:block space-after.minimum="6pt"
+		    space-after.optimum="10pt"
+		    space-after.maximum="16pt"
+		    orphans="1"
+		    widows="1">
+	    <fo:block space-after="inherit">
+	      This is a block with a float. This is a block with a float.
+	      The float anchor is just behind this <fo:inline
+		color="blue">word</fo:inline><fo:float float="before"
+		color="red">
+		<fo:block>
+		  This is the float content. This is the float content. This is
+		  the float content. This is the float content. This is the
+		  float content. This is the float content. This is the float
+		  content. This is the float content.
+		</fo:block>
+	      </fo:float>.
+	      This is a block with a float. This is a block with a float.
+	      This is a block with a float. This is a block with a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	    <fo:block space-after="inherit">
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	      This is a block without a float. This is a block without a float.
+	    </fo:block>
+	  </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="2" xpath="count(//pageViewport)"/>
+    <!-- first page -->
+    <!-- before-float block -->
+    <eval expected="1"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block)"/>
+    <eval expected="This is the float content. This is the float content. This is the float"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block/lineArea/text[1]"/>
+    <eval expected="43200"
+          xpath="//pageViewport[1]/page/regionViewport/regionBody/beforeFloat/block/@bpd"/>
+    <!-- main area -->
+    <eval expected="3"
+	  xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block/block)"/>
+    <!-- only two lines in the last block -->
+    <eval expected="2"
+          xpath="count(//pageViewport[1]/page/regionViewport/regionBody/mainReference/span/flow/block/block[3]/lineArea)"/>
+    <!-- second page -->
+    <eval expected="0"
+	  xpath="count(//pageViewport[2]/page/regionViewport/regionBody/beforeFloat/block)"/>
+  </checks>
+</testcase>

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_stretch.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Floats/test/layoutengine/standard-testcases/before-float_not-deferred_stretch.xml
------------------------------------------------------------------------------
    svn:keywords = Id



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