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 sp...@apache.org on 2008/01/10 20:58:31 UTC

svn commit: r610906 [3/4] - in /xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking: ./ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/area/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/e...

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ElementListUtils.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ElementListUtils.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ElementListUtils.java Thu Jan 10 11:58:23 2008
@@ -32,31 +32,6 @@
 public class ElementListUtils {
 
     /**
-     * Removes all legal breaks in an element list.
-     * @param elements the element list
-     */
-    public static void removeLegalBreaks(List elements) {
-        ListIterator i = elements.listIterator();
-        while (i.hasNext()) {
-            ListElement el = (ListElement)i.next();
-            if (el.isPenalty()) {
-                BreakElement breakPoss = (BreakElement)el;
-                //Convert all penalties no break inhibitors
-                if (breakPoss.getPenaltyValue() < KnuthPenalty.INFINITE) {
-                    breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
-                }
-            } else if (el.isGlue()) {
-                i.previous();
-                if (el.isBox()) {
-                    i.next();
-                    i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, 
-                            null, false));
-                }
-            }
-        }
-    }
-    
-    /**
      * Removes legal breaks in an element list. A constraint can be specified to limit the
      * range in which the breaks are removed. Legal breaks occuring before at least 
      * constraint.opt space is filled will be removed.
@@ -67,7 +42,7 @@
     public static boolean removeLegalBreaks(List elements, MinOptMax constraint) {
         return removeLegalBreaks(elements, constraint.opt);
     }
-    
+
     /**
      * Removes legal breaks in an element list. A constraint can be specified to limit the
      * range in which the breaks are removed. Legal breaks occuring before at least 
@@ -85,7 +60,7 @@
                 KnuthPenalty penalty = (KnuthPenalty)el;
                 //Convert all penalties to break inhibitors
                 if (penalty.getP() < KnuthPenalty.INFINITE) {
-                    iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE, 
+                    iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
                             penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary()));
                 }
             } else if (el.isGlue()) {
@@ -95,7 +70,7 @@
                 el = (ListElement)iter.previous();
                 iter.next();
                 if (el.isBox()) {
-                    iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, 
+                    iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
                             null, false));
                 }
                 iter.next();
@@ -132,7 +107,7 @@
                 KnuthPenalty penalty = (KnuthPenalty)el;
                 //Convert all penalties to break inhibitors
                 if (penalty.getP() < KnuthPenalty.INFINITE) {
-                    i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE, 
+                    i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
                             penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary()));
                 }
             } else if (el.isGlue()) {
@@ -141,7 +116,7 @@
                 el = (ListElement)i.previous();
                 i.next();
                 if (el.isBox()) {
-                    i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, 
+                    i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
                             null, false));
                 }
             } else if (el.isUnresolvedElement()) {
@@ -164,7 +139,7 @@
         }
         return true;
     }
-    
+
     /**
      * Calculates the content length of the given element list. Warning: It doesn't take any
      * stretch and shrink possibilities into account.
@@ -194,7 +169,7 @@
         }
         return len;
     }
-    
+
     /**
      * Calculates the content length of the given element list. Warning: It doesn't take any
      * stretch and shrink possibilities into account.
@@ -204,7 +179,7 @@
     public static int calcContentLength(List elems) {
         return calcContentLength(elems, 0, elems.size() - 1);
     }
-    
+
     /**
      * Indicates whether the given element list ends with a forced break.
      * @param elems the element list
@@ -214,7 +189,7 @@
         ListElement last = (ListElement)elems.getLast();
         return last.isForcedBreak();
     }
-    
+
     /**
      * Determines the position of the previous break before the start index on an
      * element list.
@@ -233,7 +208,7 @@
         }
         return prevBreak;
     }
-    
+
     public static KnuthBox firstKnuthBox(List list) {
         Iterator iter = list.iterator();
         KnuthBox box = null;

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -332,14 +332,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            reset(null);
-        }
-    }
-    /**
      * Returns the IPD of the content area
      * @return the IPD of the content area
      */

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManager.java Thu Jan 10 11:58:23 2008
@@ -62,13 +62,6 @@
     PageSequenceLayoutManager getPSLM();
 
     /**
-     * Reset to the position.
-     *
-     * @param position the Position to reset to
-     */
-    void resetPosition(Position position);
-
-    /**
      * Return a value indicating whether this LayoutManager has laid out
      * all its content (or generated BreakPossibilities for all content.)
      *

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java Thu Jan 10 11:58:23 2008
@@ -20,6 +20,7 @@
 
 import java.util.List;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.extensions.ExternalDocument;
 import org.apache.fop.fo.pagination.Flow;
 import org.apache.fop.fo.pagination.PageSequence;
 import org.apache.fop.fo.pagination.SideRegion;
@@ -60,6 +61,15 @@
      */
     public PageSequenceLayoutManager makePageSequenceLayoutManager(
         AreaTreeHandler ath, PageSequence ps);
+
+    /**
+     * Make a ExternalDocumentLayoutManager object for the fox:external-document extension.
+     * @param ath the AreaTreeHandler object the external-document interacts with
+     * @param ed the fox:external-document object to be processed
+     * @return The created ExternalDocumentLayoutManager object
+     */
+    public ExternalDocumentLayoutManager makeExternalDocumentLayoutManager(
+        AreaTreeHandler ath, ExternalDocument ed);
 
     /**
      * Make a FlowLayoutManager object.

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java Thu Jan 10 11:58:23 2008
@@ -32,6 +32,7 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FOText;
 import org.apache.fop.fo.FObjMixed;
+import org.apache.fop.fo.extensions.ExternalDocument;
 import org.apache.fop.fo.flow.BasicLink;
 import org.apache.fop.fo.flow.BidiOverride;
 import org.apache.fop.fo.flow.Block;
@@ -403,6 +404,11 @@
                 makeLayoutManagers(child, lms);
             }
         }       
+    }
+
+    public ExternalDocumentLayoutManager makeExternalDocumentLayoutManager(
+        AreaTreeHandler ath, ExternalDocument ed) {
+        return new ExternalDocumentLayoutManager(ath, ed);
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/Page.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/Page.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/Page.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/Page.java Thu Jan 10 11:58:23 2008
@@ -19,6 +19,8 @@
 
 package org.apache.fop.layoutmgr;
 
+import java.awt.geom.Rectangle2D;
+
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.fo.pagination.SimplePageMaster;
 
@@ -43,6 +45,18 @@
     public Page(SimplePageMaster spm, int pageNumber, String pageNumberStr, boolean blank) {
         this.spm = spm;
         this.pageViewport = new PageViewport(spm, pageNumber, pageNumberStr, blank);
+    }
+    
+    /**
+     * Auxiliary constructor used when there's no SimplePageMaster.
+     * @param viewArea the view area of the page
+     * @param pageNumber the page number (as an int)
+     * @param pageNumberStr the page number (as a String) 
+     * @param blank true if this is a blank page
+     */
+    public Page(Rectangle2D viewArea, int pageNumber, String pageNumberStr, boolean blank) {
+        this.spm = null;
+        this.pageViewport = new PageViewport(viewArea, pageNumber, pageNumberStr, null, blank);
     }
     
     /** @return the simple-page-master that created this page */

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageProvider.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageProvider.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageProvider.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageProvider.java Thu Jan 10 11:58:23 2008
@@ -252,7 +252,7 @@
         try {
             String pageNumberString = pageSeq.makeFormattedPageNumber(index);
             SimplePageMaster spm = pageSeq.getNextSimplePageMaster(
-                    index, (startPageOfPageSequence == index), isLastPage, isBlank);
+                    index, (startPageOfPageSequence == index), isLastPage, false, isBlank);
                 
             Region body = spm.getRegion(FO_REGION_BODY);
             if (!pageSeq.getMainFlow().getFlowName().equals(body.getRegionName())) {

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -21,61 +21,26 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fop.datatypes.Numeric;
 
 import org.apache.fop.area.AreaTreeHandler;
-import org.apache.fop.area.AreaTreeModel;
-import org.apache.fop.area.IDTracker;
-import org.apache.fop.area.PageViewport;
 import org.apache.fop.area.LineArea;
-import org.apache.fop.area.Resolvable;
-
-import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.flow.Marker;
-import org.apache.fop.fo.flow.RetrieveMarker;
-
 import org.apache.fop.fo.pagination.PageSequence;
 import org.apache.fop.fo.pagination.PageSequenceMaster;
 import org.apache.fop.fo.pagination.SideRegion;
 import org.apache.fop.fo.pagination.StaticContent;
 import org.apache.fop.layoutmgr.inline.ContentLayoutManager;
 
-import java.util.List;
-
 /**
  * LayoutManager for a PageSequence.  This class is instantiated by
  * area.AreaTreeHandler for each fo:page-sequence found in the
  * input document.
  */
-public class PageSequenceLayoutManager extends AbstractLayoutManager {
+public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager {
 
     private static Log log = LogFactory.getLog(PageSequenceLayoutManager.class);
 
-    /** 
-     * AreaTreeHandler which activates the PSLM and controls
-     * the rendering of its pages.
-     */
-    private AreaTreeHandler areaTreeHandler;
-
-    /** 
-     * fo:page-sequence formatting object being
-     * processed by this class
-     */
-    private PageSequence pageSeq;
-
     private PageProvider pageProvider;
 
-    private IDTracker idTracker;
-
-    /** 
-     * Current page with page-viewport-area being filled by
-     * the PSLM.
-     */
-    private Page curPage;
-
-    private int startPageNum = 0;
-    private int currentPageNum = 0;
-    
     /**
      * Constructor
      *
@@ -83,20 +48,10 @@
      * @param pseq fo:page-sequence to process
      */
     public PageSequenceLayoutManager(AreaTreeHandler ath, PageSequence pseq) {
-        super(pseq);
-        this.areaTreeHandler = ath;
-        this.idTracker = ath.getIDTracker();
-        this.pageSeq = pseq;
+        super(ath, pseq);
         this.pageProvider = new PageProvider(ath, pseq);
     }
 
-    /**
-     * @return the LayoutManagerMaker object associated to the areaTreeHandler
-     */
-    public LayoutManagerMaker getLayoutManagerMaker() {
-        return areaTreeHandler.getLayoutManagerMaker();
-    }
-
     /** @return the PageProvider applicable to this page-sequence. */
     public PageProvider getPageProvider() {
         return this.pageProvider;
@@ -106,25 +61,27 @@
      * @return the PageSequence being managed by this layout manager 
      */
     protected PageSequence getPageSequence() {
-        return pageSeq;
+        return (PageSequence)pageSeq;
     }
 
     /**
-     * Activate the layout of this page sequence.
-     * PageViewports corresponding to each page generated by this 
-     * page sequence will be created and sent to the AreaTreeModel
-     * for rendering.
+     * Provides access to this object
+     * @return this PageSequenceLayoutManager instance
      */
+    public PageSequenceLayoutManager getPSLM() {
+        return this;
+    }
+    
+    /** {@inheritDoc} */
     public void activateLayout() {
-        startPageNum = pageSeq.getStartingPageNumber();
-        currentPageNum = startPageNum - 1;
+        initialize();
 
         LineArea title = null;
 
-        if (pageSeq.getTitleFO() != null) {
+        if (getPageSequence().getTitleFO() != null) {
             try {
                 ContentLayoutManager clm = getLayoutManagerMaker().
-                    makeContentLayoutManager(this, pageSeq.getTitleFO());
+                    makeContentLayoutManager(this, getPageSequence().getTitleFO());
                 title = (LineArea) clm.getParentArea(null);
             } catch (IllegalStateException e) {
                 // empty title; do nothing
@@ -145,9 +102,7 @@
         finishPage();
     }
         
-    /**
-     * Finished the page-sequence and notifies everyone about it.
-     */
+    /** {@inheritDoc} */
     public void finishPageSequence() {
         if (pageSeq.hasId()) {
             idTracker.signalIDProcessed(pageSeq.getId());
@@ -157,11 +112,11 @@
                 (currentPageNum - startPageNum) + 1);
         areaTreeHandler.notifyPageSequenceFinished(pageSeq,
                 (currentPageNum - startPageNum) + 1);
-        pageSeq.releasePageSequence();
+        getPageSequence().releasePageSequence();
         
         // If this sequence has a page sequence master so we must reset
         // it in preparation for the next sequence
-        String masterReference = pageSeq.getMasterReference();
+        String masterReference = getPageSequence().getMasterReference();
         PageSequenceMaster pageSeqMaster
             = pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(masterReference);
         if (pageSeqMaster != null) {
@@ -173,229 +128,18 @@
         }
     }
     
-    /**
-     * Provides access to the current page.
-     * @return the current Page
-     */
-    public Page getCurrentPage() {
-        return curPage;
-    }
-
-    /**
-     * Provides access for setting the current page.
-     * @param currentPage the new current Page
-     */
-    protected void setCurrentPage(Page currentPage) {
-        this.curPage = currentPage;
-    }
-
-    /**
-     * Provides access to the current page number
-     * @return the current page number
-     */
-    protected int getCurrentPageNum() {
-        return currentPageNum;
-    }
-
-    /**
-     * Provides access to the current page viewport.
-     * @return the current PageViewport
-     *//*
-    public PageViewport getCurrentPageViewport() {
-        return curPage.getPageViewport();
-    }*/
-
-    /**
-     * Provides access to this object
-     * @return this PageSequenceLayoutManager instance
-     */
-    public PageSequenceLayoutManager getPSLM() {
-        return this;
+    /** {@inheritDoc} */
+    protected Page createPage(int pageNumber, boolean isBlank) {
+        return pageProvider.getPage(isBlank,
+                pageNumber, PageProvider.RELTO_PAGE_SEQUENCE);
     }
     
-    /**
-     * This returns the first PageViewport that contains an id trait
-     * matching the idref argument, or null if no such PV exists.
-     *
-     * @param idref the idref trait needing to be resolved 
-     * @return the first PageViewport that contains the ID trait
-     */
-    public PageViewport getFirstPVWithID(String idref) {
-        List list = idTracker.getPageViewportsContainingID(idref);
-        if (list != null && list.size() > 0) {
-            return (PageViewport) list.get(0);
-        }
-        return null;
-    }
-
-    /**
-     * This returns the last PageViewport that contains an id trait
-     * matching the idref argument, or null if no such PV exists.
-     *
-     * @param idref the idref trait needing to be resolved 
-     * @return the last PageViewport that contains the ID trait
-     */
-    public PageViewport getLastPVWithID(String idref) {
-        List list = idTracker.getPageViewportsContainingID(idref);
-        if (list != null && list.size() > 0) {
-            return (PageViewport) list.get(list.size() - 1);
-        }
-        return null;
-    }
-    
-    /**
-     * Add an ID reference to the current page.
-     * When adding areas the area adds its ID reference.
-     * For the page layout manager it adds the id reference
-     * with the current page to the area tree.
-     *
-     * @param id the ID reference to add
-     */
-    public void addIDToPage(String id) {
-        if (id != null && id.length() > 0) {
-            idTracker.associateIDWithPageViewport(id, curPage.getPageViewport());
-        }
-    }
-    
-    /**
-     * Add an id reference of the layout manager in the AreaTreeHandler,
-     * if the id hasn't been resolved yet
-     * @param id the id to track
-     * @return a boolean indicating if the id has already been resolved
-     * TODO Maybe give this a better name
-     */
-    public boolean associateLayoutManagerID(String id) {
-        if (log.isDebugEnabled()) {
-            log.debug("associateLayoutManagerID(" + id + ")");
-        }
-        if (!idTracker.alreadyResolvedID(id)) {
-            idTracker.signalPendingID(id);
-            return false;
-        } else {
-            return true;
-        }
-    }
-    
-    /**
-     * Notify the areaTreeHandler that the LayoutManagers containing
-     * idrefs have finished creating areas
-     * @param id the id for which layout has finished
-     */
-    public void notifyEndOfLayout(String id) {
-        idTracker.signalIDProcessed(id);
-    }
-    
-    /**
-     * Identify an unresolved area (one needing an idref to be 
-     * resolved, e.g. the internal-destination of an fo:basic-link)
-     * for both the AreaTreeHandler and PageViewport object.
-     * 
-     * The IDTracker keeps a document-wide list of idref's
-     * and the PV's needing them to be resolved.  It uses this to  
-     * send notifications to the PV's when an id has been resolved.
-     * 
-     * The PageViewport keeps lists of id's needing resolving, along
-     * with the child areas (page-number-citation, basic-link, etc.)
-     * of the PV needing their resolution.
-     *
-     * @param id the ID reference to add
-     * @param res the resolvable object that needs resolving
-     */
-    public void addUnresolvedArea(String id, Resolvable res) {
-        curPage.getPageViewport().addUnresolvedIDRef(id, res);
-        idTracker.addUnresolvedIDRef(id, curPage.getPageViewport());
-    }
-
-    /**
-     * Bind the RetrieveMarker to the corresponding Marker subtree.
-     * If the boundary is page then it will only check the
-     * current page. For page-sequence and document it will
-     * lookup preceding pages from the area tree and try to find
-     * a marker.
-     * If we retrieve a marker from a preceding page,
-     * then the containing page does not have a qualifying area,
-     * and all qualifying areas have ended.
-     * Therefore we use last-ending-within-page (Constants.EN_LEWP)
-     * as the position. 
-     *
-     * @param rm the RetrieveMarker instance whose properties are to
-     * used to find the matching Marker.
-     * @return a bound RetrieveMarker instance, or null if no Marker
-     * could be found.
-     */
-    public RetrieveMarker resolveRetrieveMarker(RetrieveMarker rm) {
-        AreaTreeModel areaTreeModel = areaTreeHandler.getAreaTreeModel();
-        String name = rm.getRetrieveClassName();
-        int pos = rm.getRetrievePosition();
-        int boundary = rm.getRetrieveBoundary();               
-        
-        // get marker from the current markers on area tree
-        Marker mark = (Marker)getCurrentPV().getMarker(name, pos);
-        if (mark == null && boundary != EN_PAGE) {
-            // go back over pages until mark found
-            // if document boundary then keep going
-            boolean doc = boundary == EN_DOCUMENT;
-            int seq = areaTreeModel.getPageSequenceCount();
-            int page = areaTreeModel.getPageCount(seq) - 1;
-            while (page < 0 && doc && seq > 1) {
-                seq--;
-                page = areaTreeModel.getPageCount(seq) - 1;
-            }
-            while (page >= 0) {
-                PageViewport pv = areaTreeModel.getPage(seq, page);
-                mark = (Marker)pv.getMarker(name, Constants.EN_LEWP);
-                if (mark != null) {
-                    break;
-                }
-                page--;
-                if (page < 0 && doc && seq > 1) {
-                    seq--;
-                    page = areaTreeModel.getPageCount(seq) - 1;
-                }
-            }
-        }
-
-        if (mark == null) {
-            log.debug("found no marker with name: " + name);
-            return null;
-        } else {
-            rm.bindMarker(mark);
-            return rm;
-        }
-    }
-
-    /**
-     * Makes a new page
-     * 
-     * @param bIsBlank whether this page is blank or not
-     * @param bIsLast whether this page is the last page or not
-     * @return a new page
-     */
-    protected Page makeNewPage(boolean bIsBlank, boolean bIsLast) {
-        if (curPage != null) {
-            finishPage();
-        }
-
-        currentPageNum++;
-
-        curPage = pageProvider.getPage(bIsBlank,
-                currentPageNum, PageProvider.RELTO_PAGE_SEQUENCE);
-
-        if (log.isDebugEnabled()) {
-            log.debug("[" + curPage.getPageViewport().getPageNumberString() 
-                    + (bIsBlank ? "*" : "") + "]");
-        }
-        
-        addIDToPage(pageSeq.getId());
-        return curPage;
-    }
-
     private void layoutSideRegion(int regionID) {
         SideRegion reg = (SideRegion)curPage.getSimplePageMaster().getRegion(regionID);
         if (reg == null) {
             return;
         }
-        StaticContent sc = pageSeq.getStaticContent(reg.getRegionName());
+        StaticContent sc = getPageSequence().getStaticContent(reg.getRegionName());
         if (sc == null) {
             return;
         }
@@ -406,94 +150,15 @@
         lm.doLayout();
     }
 
-    private void finishPage() {
-        if (log.isTraceEnabled()) {
-            curPage.getPageViewport().dumpMarkers();
-        }
+    /** {@inheritDoc} */
+    protected void finishPage() {
         // Layout side regions
         layoutSideRegion(FO_REGION_BEFORE); 
         layoutSideRegion(FO_REGION_AFTER);
         layoutSideRegion(FO_REGION_START);
         layoutSideRegion(FO_REGION_END);
         
-        // Try to resolve any unresolved IDs for the current page.
-        // 
-        idTracker.tryIDResolution(curPage.getPageViewport());
-        // Queue for ID resolution and rendering
-        areaTreeHandler.getAreaTreeModel().addPage(curPage.getPageViewport());
-        if (log.isDebugEnabled()) {
-            log.debug("page finished: " + curPage.getPageViewport().getPageNumberString() 
-                    + ", current num: " + currentPageNum);
-        }
-        curPage = null;
+        super.finishPage();
     }
         
-    /**
-     * Act upon the force-page-count trait,
-     * in relation to the initial-page-number trait of the following page-sequence.
-     * @param nextPageSeqInitialPageNumber initial-page-number trait of next page-sequence
-     */
-    public void doForcePageCount(Numeric nextPageSeqInitialPageNumber) {
-
-        int forcePageCount = pageSeq.getForcePageCount();
-
-        // xsl-spec version 1.0   (15.oct 2001)
-        // auto | even | odd | end-on-even | end-on-odd | no-force | inherit
-        // auto:
-        // Force the last page in this page-sequence to be an odd-page 
-        // if the initial-page-number of the next page-sequence is even. 
-        // Force it to be an even-page 
-        // if the initial-page-number of the next page-sequence is odd. 
-        // If there is no next page-sequence 
-        // or if the value of its initial-page-number is "auto" do not force any page.
-            
-        // if force-page-count is auto then set the value of forcePageCount 
-        // depending on the initial-page-number of the next page-sequence
-        if (nextPageSeqInitialPageNumber != null && forcePageCount == Constants.EN_AUTO) {
-            if (nextPageSeqInitialPageNumber.getEnum() != 0) {
-                // auto | auto-odd | auto-even
-                int nextPageSeqPageNumberType = nextPageSeqInitialPageNumber.getEnum();
-                if (nextPageSeqPageNumberType == Constants.EN_AUTO_ODD) {
-                    forcePageCount = Constants.EN_END_ON_EVEN;
-                } else if (nextPageSeqPageNumberType == Constants.EN_AUTO_EVEN) {
-                    forcePageCount = Constants.EN_END_ON_ODD;
-                } else {   // auto
-                    forcePageCount = Constants.EN_NO_FORCE;
-                }
-            } else { // <integer> for explicit page number
-                int nextPageSeqPageStart = nextPageSeqInitialPageNumber.getValue();
-                // spec rule
-                nextPageSeqPageStart = (nextPageSeqPageStart > 0) ? nextPageSeqPageStart : 1;
-                if (nextPageSeqPageStart % 2 == 0) {   // explicit even startnumber
-                    forcePageCount = Constants.EN_END_ON_ODD;
-                } else {    // explicit odd startnumber
-                    forcePageCount = Constants.EN_END_ON_EVEN;
-                }
-            }
-        }
-
-        if (forcePageCount == Constants.EN_EVEN) {
-            if ((currentPageNum - startPageNum + 1) % 2 != 0) { // we have an odd number of pages
-                curPage = makeNewPage(true, false);
-            }
-        } else if (forcePageCount == Constants.EN_ODD) {
-            if ((currentPageNum - startPageNum + 1) % 2 == 0) { // we have an even number of pages
-                curPage = makeNewPage(true, false);
-            }
-        } else if (forcePageCount == Constants.EN_END_ON_EVEN) {
-            if (currentPageNum % 2 != 0) { // we are now on an odd page
-                curPage = makeNewPage(true, false);
-            }
-        } else if (forcePageCount == Constants.EN_END_ON_ODD) {
-            if (currentPageNum % 2 == 0) { // we are now on an even page
-                curPage = makeNewPage(true, false);
-            }
-        } else if (forcePageCount == Constants.EN_NO_FORCE) {
-            // i hope: nothing special at all
-        }
-
-        if (curPage != null) {
-            finishPage();
-        }
-    }
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -19,12 +19,12 @@
 
 package org.apache.fop.layoutmgr.inline;
 
-import java.awt.geom.Rectangle2D;
+import java.awt.Dimension;
+import java.awt.Rectangle;
 import java.util.LinkedList;
 
 import org.apache.fop.area.Area;
 import org.apache.fop.area.inline.Viewport;
-import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.flow.AbstractGraphics;
@@ -57,156 +57,29 @@
      * @return the viewport inline area
      */
     private Viewport getInlineArea() {
+        Dimension intrinsicSize = new Dimension(
+                fobj.getIntrinsicWidth(),
+                fobj.getIntrinsicHeight());
 
-        // viewport size is determined by block-progression-dimension
-        // and inline-progression-dimension
+        //TODO Investigate if the line-height property has to be taken into the calculation
+        //somehow. There was some code here that hints in this direction but it was disabled.
 
-        // if replaced then use height then ignore block-progression-dimension
-        //int h = this.propertyList.get("height").getLength().mvalue();
-
-        // use specified line-height then ignore dimension in height direction
-        boolean hasLH = false; //propertyList.get("line-height").getSpecifiedValue() != null;
-
-        Length len;
-
-        int bpd = -1;
-        int ipd = -1;
-        if (hasLH) {
-            bpd = fobj.getLineHeight().getOptimum(this).getLength().getValue(this);
-        } else {
-            // this property does not apply when the line-height applies
-            // isn't the block-progression-dimension always in the same
-            // direction as the line height?
-            len = fobj.getBlockProgressionDimension().getOptimum(this).getLength();
-            if (len.getEnum() != EN_AUTO) {
-                bpd = len.getValue(this);
-            } else {
-                len = fobj.getHeight();
-                if (len.getEnum() != EN_AUTO) {
-                    bpd = len.getValue(this);
-                }
-            }
-        }
-
-        len = fobj.getInlineProgressionDimension().getOptimum(this).getLength();
-        if (len.getEnum() != EN_AUTO) {
-            ipd = len.getValue(this);
-        } else {
-            len = fobj.getWidth();
-            if (len.getEnum() != EN_AUTO) {
-                ipd = len.getValue(this);
-            }
-        }
-
-        // if auto then use the intrinsic size of the content scaled
-        // to the content-height and content-width
-        int cwidth = -1;
-        int cheight = -1;
-        len = fobj.getContentWidth();
-        if (len.getEnum() != EN_AUTO) {
-            if (len.getEnum() == EN_SCALE_TO_FIT) {
-                if (ipd != -1) {
-                    cwidth = ipd;
-                }
-            } else {
-                cwidth = len.getValue(this);
-            }
-        }
-        len = fobj.getContentHeight();
-        if (len.getEnum() != EN_AUTO) {
-            if (len.getEnum() == EN_SCALE_TO_FIT) {
-                if (bpd != -1) {
-                    cheight = bpd;
-                }
-            } else {
-                cheight = len.getValue(this);
-            }
-        }
-
-        int scaling = fobj.getScaling();
-        if ((scaling == EN_UNIFORM) || (cwidth == -1) || cheight == -1) {
-            if (cwidth == -1 && cheight == -1) {
-                cwidth = fobj.getIntrinsicWidth();
-                cheight = fobj.getIntrinsicHeight();
-            } else if (cwidth == -1) {
-                if (fobj.getIntrinsicHeight() == 0) {
-                    cwidth = 0;
-                } else {
-                    cwidth = (int)(fobj.getIntrinsicWidth() * (double)cheight 
-                            / fobj.getIntrinsicHeight());
-                }
-            } else if (cheight == -1) {
-                if (fobj.getIntrinsicWidth() == 0) {
-                    cheight = 0;
-                } else {
-                    cheight = (int)(fobj.getIntrinsicHeight() * (double)cwidth 
-                            / fobj.getIntrinsicWidth());
-                }
-            } else {
-                // adjust the larger
-                if (fobj.getIntrinsicWidth() == 0 || fobj.getIntrinsicHeight() == 0) {
-                    cwidth = 0;
-                    cheight = 0;
-                } else {
-                    double rat1 = (double) cwidth / fobj.getIntrinsicWidth();
-                    double rat2 = (double) cheight / fobj.getIntrinsicHeight();
-                    if (rat1 < rat2) {
-                        // reduce cheight
-                        cheight = (int)(rat1 * fobj.getIntrinsicHeight());
-                    } else if (rat1 > rat2) {
-                        cwidth = (int)(rat2 * fobj.getIntrinsicWidth());
-                    }
-                }
-            }
-        }
-
-        if (ipd == -1) {
-            ipd = cwidth;
-        }
-        if (bpd == -1) {
-            bpd = cheight;
-        }
-
-        boolean clip = false;
-        if (cwidth > ipd || cheight > bpd) {
-            int overflow = fobj.getOverflow();
-            if (overflow == EN_HIDDEN) {
-                clip = true;
-            } else if (overflow == EN_ERROR_IF_OVERFLOW) {
-                log.error("Object overflows the viewport: clipping");
-                clip = true;
-            }
-        }
-
-        int xoffset = fobj.computeXOffset(ipd, cwidth);
-        int yoffset = fobj.computeYOffset(bpd, cheight);
+        ImageLayout imageLayout = new ImageLayout(fobj, this, intrinsicSize);
+        Rectangle placement = imageLayout.getPlacement();
 
         CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
         
-        //Determine extra BPD from borders etc.
+        //Determine extra BPD from borders and padding
         int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
-        beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
-                                             false);
-        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
-        afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
+        beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE, false);
         
-        yoffset += beforeBPD;
-        //bpd += beforeBPD;
-        //bpd += afterBPD;
+        placement.y += beforeBPD;
         
-        //Determine extra IPD from borders etc.
-        int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
-                false, this);
-        startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
-                 false);
-        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false, this);
-        endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false);
+        //Determine extra IPD from borders and padding
+        int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START, false, this);
+        startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, false);
         
-        xoffset += startIPD;
-        //ipd += startIPD;
-        //ipd += endIPD;
-
-        Rectangle2D placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
+        placement.x += startIPD;
 
         Area viewportArea = getChildArea();
         TraitSetter.setProducerID(viewportArea, fobj.getId());
@@ -214,10 +87,10 @@
 
         Viewport vp = new Viewport(viewportArea);
         TraitSetter.setProducerID(vp, fobj.getId());
-        vp.setIPD(ipd);
-        vp.setBPD(bpd);
+        vp.setIPD(imageLayout.getViewportSize().width);
+        vp.setBPD(imageLayout.getViewportSize().height);
         vp.setContentPosition(placement);
-        vp.setClip(clip);
+        vp.setClip(imageLayout.isClipped());
         vp.setOffset(0);
 
         // Common Border, Padding, and Background Properties
@@ -230,9 +103,7 @@
         return vp;
     }
     
-    /**
-     * {@inheritDoc} 
-     */
+    /** {@inheritDoc} */
     public LinkedList getNextKnuthElements(LayoutContext context,
                                            int alignment) {
         Viewport areaCurrent = getInlineArea();
@@ -240,9 +111,7 @@
         return super.getNextKnuthElements(context, alignment);
     }
     
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected AlignmentContext makeAlignmentContext(LayoutContext context) {
         return new AlignmentContext(
                 get(context).getAllocBPD()

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -214,13 +214,6 @@
     /**
      * {@inheritDoc}
      */
-    public void resetPosition(Position position) {
-        //to be done
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public boolean createNextChildLMs(int pos) {
         return false;
     }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -19,7 +19,6 @@
 
 package org.apache.fop.layoutmgr.inline;
 
-import java.awt.geom.Rectangle2D;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.inline.Image;
 import org.apache.fop.fo.flow.ExternalGraphic;
@@ -34,7 +33,6 @@
 
     /**
      * Constructor
-     *
      * @param node the fo:external-graphic formatting object that creates the area
      */
     public ExternalGraphicLayoutManager(ExternalGraphic node) {
@@ -42,165 +40,7 @@
         fobj = node;
     }
 
-    /**
-     * Setup this image.
-     * This gets the sizes for the image and the dimensions and clipping.
-     * @todo see if can simplify property handling logic
-     */
-    /*
-    private void setup() {
-        // assume lr-tb for now and just use the .optimum value of the range
-        Length ipd = fobj.getInlineProgressionDimension().getOptimum(this).getLength();
-        if (ipd.getEnum() != EN_AUTO) {
-            viewWidth = ipd.getValue(this);
-        } else {
-            ipd = fobj.getWidth();
-            if (ipd.getEnum() != EN_AUTO) {
-                viewWidth = ipd.getValue(this);
-            }
-        }
-        Length bpd = fobj.getBlockProgressionDimension().getOptimum(this).getLength();
-        if (bpd.getEnum() != EN_AUTO) {
-            viewHeight = bpd.getValue(this);
-        } else {
-            bpd = fobj.getHeight();
-            if (bpd.getEnum() != EN_AUTO) {
-                viewHeight = bpd.getValue(this);
-            }
-        }
-
-        int cwidth = -1;
-        int cheight = -1;
-        Length ch = fobj.getContentHeight();
-        if (ch.getEnum() != EN_AUTO) {
-            if (ch.getEnum() == EN_SCALE_TO_FIT) {
-                if (viewHeight != -1) {
-                    cheight = viewHeight;
-                }
-            } else {
-                cheight = ch.getValue(this);
-            }
-        }
-        Length cw = fobj.getContentWidth();
-        if (cw.getEnum() != EN_AUTO) {
-            if (cw.getEnum() == EN_SCALE_TO_FIT) {
-                if (viewWidth != -1) {
-                    cwidth = viewWidth;
-                }
-            } else {
-                cwidth = cw.getValue(this);
-            }
-        }
-
-        int scaling = fobj.getScaling();
-        if ((scaling == EN_UNIFORM) || (cwidth == -1) || cheight == -1) {
-            if (cwidth == -1 && cheight == -1) {
-                cwidth = fobj.getIntrinsicWidth();
-                cheight = fobj.getIntrinsicHeight();
-            } else if (cwidth == -1) {
-                cwidth = (int)(fobj.getIntrinsicWidth() * (double)cheight 
-                    / fobj.getIntrinsicHeight());
-            } else if (cheight == -1) {
-                cheight = (int)(fobj.getIntrinsicHeight() * (double)cwidth 
-                    / fobj.getIntrinsicWidth());
-            } else {
-                // adjust the larger
-                double rat1 = (double)cwidth / fobj.getIntrinsicWidth();
-                double rat2 = (double)cheight / fobj.getIntrinsicHeight();
-                if (rat1 < rat2) {
-                    // reduce cheight
-                    cheight = (int)(rat1 * fobj.getIntrinsicHeight());
-                } else if (rat1 > rat2) {
-                    cwidth = (int)(rat2 * fobj.getIntrinsicWidth());
-                }
-            }
-        }
-
-        if (viewWidth == -1) {
-            viewWidth = cwidth;
-        }
-        if (viewHeight == -1) {
-            viewHeight = cheight;
-        }
-
-        if (cwidth > viewWidth || cheight > viewHeight) {
-            int overflow = fobj.getOverflow();
-            if (overflow == EN_HIDDEN) {
-                clip = true;
-            } else if (overflow == EN_ERROR_IF_OVERFLOW) {
-                fobj.getLogger().error("Image: " + fobj.getURL()
-                                  + " overflows the viewport, clipping to viewport");
-                clip = true;
-            }
-        }
-
-        int xoffset = 0;
-        int yoffset = 0;
-        switch(fobj.getDisplayAlign()) {
-            case EN_BEFORE:
-            break;
-            case EN_AFTER:
-                yoffset = viewHeight - cheight;
-            break;
-            case EN_CENTER:
-                yoffset = (viewHeight - cheight) / 2;
-            break;
-            case EN_AUTO:
-            default:
-            break;
-        }
-
-        switch(fobj.getTextAlign()) {
-            case EN_CENTER:
-                xoffset = (viewWidth - cwidth) / 2;
-            break;
-            case EN_END:
-                xoffset = viewWidth - cwidth;
-            break;
-            case EN_START:
-            break;
-            case EN_JUSTIFY:
-            default:
-            break;
-        }
-        
-        
-        CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
-        
-        //Determine extra BPD from borders etc.
-        int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
-        beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
-                                             false);
-        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
-        afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
-        
-        yoffset += beforeBPD;
-        viewBPD = viewHeight;
-        viewHeight += beforeBPD;
-        viewHeight += afterBPD;
-        
-        //Determine extra IPD from borders etc.
-        int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
-                false, this);
-        startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
-                 false);
-        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false, this);
-        endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false);
-        
-        xoffset += startIPD;
-        viewIPD = viewWidth;
-        viewWidth += startIPD;
-        viewWidth += endIPD;
-        
-        placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
-    }
-    */
-    
-    /**
-     * Get the inline area created by this element.
-     *
-     * @return the inline area
-     */
+    /** {@inheritDoc} */
     protected Area getChildArea() {
         return new Image(fobj.getSrc());
     }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -155,41 +155,6 @@
     }
 
     /**
-     * Reset position for returning next BreakPossibility.
-     * @param prevPos a Position returned by this layout manager
-     * representing a potential break decision.
-     */
-    public void resetPosition(Position prevPos) {
-        if (prevPos != null) {
-            // ASSERT (prevPos.getLM() == this)
-            if (prevPos.getLM() != this) {
-                //getLogger().error(
-                //  "InlineStackingLayoutManager.resetPosition: " +
-                //  "LM mismatch!!!");
-            }
-            // Back up the child LM Position
-            Position childPos = prevPos.getPosition();
-            reset(childPos);
-            /*
-            if (prevBP != null
-                    && prevBP.getLayoutManager() != childPos.getLM()) {
-                childLC = null;
-            }
-            prevBP = new BreakPoss(childPos);
-            */
-        } else {
-            // Backup to start of first child layout manager
-            //prevBP = null;
-            // super.resetPosition(prevPos);
-            reset(prevPos);
-            // If any areas created, we are restarting!
-            bAreaCreated = false;
-        }
-        // Do we need to reset some context like pending or prevContent?
-        // What about prevBP?
-    }
-
-    /**
      * TODO: Explain this method
      * @param lm ???
      * @return ???

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java Thu Jan 10 11:58:23 2008
@@ -40,11 +40,7 @@
         fobj = node;
     }
 
-    /**
-     * Get the inline area created by this element.
-     *
-     * @return the inline area
-     */
+    /** {@inheritDoc} */
     protected Area getChildArea() {
         XMLObj child = (XMLObj) fobj.getChildXMLObj();
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -1034,35 +1034,6 @@
     }
 
     /**
-     * Reset the positions to the given position.
-     *
-     * @param resetPos the position to reset to
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            setFinished(false);
-            iReturnedLBP = 0;
-        } else {
-            if (isFinished()) {
-                // if isFinished is true, iReturned LBP == breakpoints.size()
-                // and breakpoints.get(iReturnedLBP) would generate
-                // an IndexOutOfBoundException
-                setFinished(false);
-                iReturnedLBP--;
-            }
-            // It is not clear that the member lineLayouts has the correct value;
-            // because the method is not called, this cannot be checked.
-            // Added comment: The member lineLayouts cannot have the correct value,
-            // because it is never set.
-            while ((LineBreakPosition) lineLayouts.getChosenPosition(iReturnedLBP)
-                   != (LineBreakPosition) resetPos) {
-                iReturnedLBP--;
-            }
-            iReturnedLBP++;
-        }
-    }
-
-    /**
      * Add the areas with the break points.
      *
      * @param parentIter the iterator of break positions

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -224,36 +224,6 @@
 
     }
 
-    /**
-     * Reset position for returning next BreakPossibility.
-     *
-     * @param prevPos the position to reset to
-     */
-    public void resetPosition(Position prevPos) {
-        if (prevPos != null) {
-            // ASSERT (prevPos.getLM() == this)
-            if (prevPos.getLM() != this) {
-                log.error("TextLayoutManager.resetPosition: "
-                          + "LM mismatch!!!");
-            }
-            LeafPosition tbp = (LeafPosition) prevPos;
-            AreaInfo ai = (AreaInfo) vecAreaInfo.get(tbp.getLeafPos());
-            if (ai.iBreakIndex != iNextStart) {
-                iNextStart = ai.iBreakIndex;
-                vecAreaInfo.ensureCapacity(tbp.getLeafPos() + 1);
-                // TODO: reset or recalculate total IPD = sum of all word IPD
-                // up to the break position
-                ipdTotal = ai.ipdArea;
-                setFinished(false);
-            }
-        } else {
-            // Reset to beginning!
-            vecAreaInfo.clear();
-            iNextStart = 0;
-            setFinished(false);
-        }
-    }
-
     // TODO: see if we can use normal getNextBreakPoss for this with
     // extra hyphenation information in LayoutContext
     private boolean getHyphenIPD(HyphContext hc, MinOptMax hyphIPD) {

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -284,19 +284,6 @@
         }
     }
 
-    /**
-     * Reset the position of this layout manager.
-     *
-     * @param resetPos the position to reset to
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            reset(null);
-        } else {
-            //TODO Something to put here?
-        }
-    }
-    
     /** {@inheritDoc} */
     public boolean mustKeepTogether() {
         //TODO Keeps will have to be more sophisticated sooner or later

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -220,20 +220,6 @@
         }
     }
 
-    /**
-     * Reset the position of the layout.
-     *
-     * @param resetPos the position to reset to
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            reset(null);
-        } else {
-            setFinished(false);
-            //reset(resetPos);
-        }
-    }
-    
     /** {@inheritDoc} */
     public boolean mustKeepTogether() {
         //TODO Keeps will have to be more sophisticated sooner or later

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -706,17 +706,6 @@
         }
     }
 
-    /**
-     * Reset the position of this layout manager.
-     *
-     * @param resetPos the position to reset to
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            reset(null);
-        }
-    }
-    
     /** {@inheritDoc} */
     public boolean mustKeepTogether() {
         //TODO Keeps will have to be more sophisticated sooner or later

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java Thu Jan 10 11:58:23 2008
@@ -266,12 +266,12 @@
     }
 
     /**
-     * Creates and returns a GridUnitPart instance for the content of this cell which
+     * Creates and returns a CellPart instance for the content of this cell which
      * is included in the next step.
      * 
-     * @return a GridUnitPart instance
+     * @return a CellPart instance
      */
-    GridUnitPart createGridUnitPart() {
+    CellPart createCellPart() {
         if (end + 1 == elementList.size()) {
             if (pgu.getFlag(GridUnit.KEEP_WITH_NEXT_PENDING)) {
                 keepWithNextSignal = true;
@@ -284,9 +284,9 @@
                 && elementList.size() == 1
                 && elementList.get(0) instanceof KnuthBoxCellWithBPD) {
             //Special case: Cell with fixed BPD
-            return new GridUnitPart(pgu, 0, pgu.getElements().size() - 1);
+            return new CellPart(pgu, 0, pgu.getElements().size() - 1);
         } else {
-            return new GridUnitPart(pgu, start, end);
+            return new CellPart(pgu, start, end);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java Thu Jan 10 11:58:23 2008
@@ -181,7 +181,22 @@
      * 
      * @param border1 a border specification
      * @param border2 another border specification
+     * @param discard true if the .conditionality component of the border width must be
+     * taken into account
      * @return the winning border, null if the two borders are equivalent
+     */
+    public abstract BorderSpecification determineWinner(BorderSpecification border1,
+            BorderSpecification border2, boolean discard);
+
+    /**
+     * Returns the border which wins the border conflict resolution. Same as
+     * {@link #determineWinner(BorderSpecification, BorderSpecification, boolean)
+     * determineWinner(border1, border2, false)}.
+     * 
+     * @param border1 a border specification
+     * @param border2 another border specification
+     * @return the winning border, null if the two borders are equivalent
+     * @see determineWinner
      */
     public abstract BorderSpecification determineWinner(BorderSpecification border1,
             BorderSpecification border2);

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java Thu Jan 10 11:58:23 2008
@@ -21,6 +21,7 @@
 
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.table.BorderSpecification;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 
 /**
@@ -29,6 +30,27 @@
  * TODO Column groups are not yet checked in this algorithm!
  */
 public class CollapsingBorderModelEyeCatching extends CollapsingBorderModel {
+
+    /** {@inheritDoc} */
+    public BorderSpecification determineWinner(BorderSpecification border1,
+            BorderSpecification border2, boolean discard) {
+        BorderInfo bi1 = border1.getBorderInfo();
+        BorderInfo bi2 = border2.getBorderInfo();
+        if (discard) {
+            if (bi1.getWidth().isDiscard()) {
+                if (bi2.getWidth().isDiscard()) {
+                    return new BorderSpecification(
+                            CommonBorderPaddingBackground.getDefaultBorderInfo(), 0/*TODO*/);
+                } else {
+                    return border2;
+                }
+            } else if (bi2.getWidth().isDiscard()) {
+                return border1;
+            }
+        }
+        // Otherwise, fall back to the default resolution algorithm
+        return determineWinner(border1, border2);
+    }
 
     /** {@inheritDoc} */
     public BorderSpecification determineWinner(BorderSpecification border1,

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -148,9 +148,9 @@
             TableRow tableRow = null;
             // The row's minimum content height; 0 if the row's height is auto, otherwise
             // the .minimum component of the explicitly specified value
-            int minContentHeight = 0;
-            int maxCellHeight = 0;
-            int effRowContentHeight = 0;
+            int minRowBPD = 0;
+            // The BPD of the biggest cell in the row
+            int maxCellBPD = 0;
             for (int j = 0; j < row.getGridUnits().size(); j++) {
                 assert maxColumnCount == 0 || maxColumnCount == row.getGridUnits().size();
                 maxColumnCount = Math.max(maxColumnCount, row.getGridUnits().size());
@@ -168,14 +168,12 @@
                             tableRow = primary.getRow();
                             
                             //Check for bpd on row, see CSS21, 17.5.3 Table height algorithms
-                            LengthRangeProperty bpd = tableRow.getBlockProgressionDimension();
-                            if (!bpd.getMinimum(tableLM).isAuto()) {
-                                minContentHeight = Math.max(
-                                        minContentHeight, 
-                                        bpd.getMinimum(
-                                                tableLM).getLength().getValue(tableLM));
+                            LengthRangeProperty rowBPD = tableRow.getBlockProgressionDimension();
+                            if (!rowBPD.getMinimum(tableLM).isAuto()) {
+                                minRowBPD = Math.max(minRowBPD,
+                                        rowBPD.getMinimum(tableLM).getLength().getValue(tableLM));
                             }
-                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM);
+                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], rowBPD, tableLM);
                             
                         }
 
@@ -218,31 +216,27 @@
                         }
                     }
 
-                    
-                    //Calculate height of cell contents
-                    primary.setContentLength(ElementListUtils.calcContentLength(
-                            primary.getElements()));
-                    maxCellHeight = Math.max(maxCellHeight, primary.getContentLength());
-
                     //Calculate height of row, see CSS21, 17.5.3 Table height algorithms
                     if (gu.isLastGridUnitRowSpan()) {
-                        int effCellContentHeight = minContentHeight;
-                        LengthRangeProperty bpd = primary.getCell().getBlockProgressionDimension();
-                        if (!bpd.getMinimum(tableLM).isAuto()) {
-                            effCellContentHeight = Math.max(
-                                effCellContentHeight,
-                                bpd.getMinimum(tableLM).getLength().getValue(tableLM));
-                        }
-                        if (!bpd.getOptimum(tableLM).isAuto()) {
-                            effCellContentHeight = Math.max(
-                                effCellContentHeight,
-                                bpd.getOptimum(tableLM).getLength().getValue(tableLM));
+                        // The effective cell's bpd, after taking into account bpd
+                        // (possibly explicitly) set on the row or on the cell, and the
+                        // cell's content length
+                        int effectiveCellBPD = minRowBPD;
+                        LengthRangeProperty cellBPD = primary.getCell()
+                                .getBlockProgressionDimension();
+                        if (!cellBPD.getMinimum(tableLM).isAuto()) {
+                            effectiveCellBPD = Math.max(effectiveCellBPD,
+                                    cellBPD.getMinimum(tableLM).getLength().getValue(tableLM));
+                        }
+                        if (!cellBPD.getOptimum(tableLM).isAuto()) {
+                            effectiveCellBPD = Math.max(effectiveCellBPD,
+                                    cellBPD.getOptimum(tableLM).getLength().getValue(tableLM));
                         }
                         if (gu.getRowSpanIndex() == 0) {
                             //TODO ATM only non-row-spanned cells are taken for this
-                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM);
+                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], cellBPD, tableLM);
                         }
-                        effCellContentHeight = Math.max(effCellContentHeight, 
+                        effectiveCellBPD = Math.max(effectiveCellBPD, 
                                 primary.getContentLength());
                         
                         int borderWidths;
@@ -253,13 +247,12 @@
                             borderWidths = primary.getHalfMaxBorderWidth();
                         }
                         int padding = 0;
-                        effRowContentHeight = Math.max(effRowContentHeight,
-                                effCellContentHeight);
+                        maxCellBPD = Math.max(maxCellBPD, effectiveCellBPD);
                         CommonBorderPaddingBackground cbpb 
                             = primary.getCell().getCommonBorderPaddingBackground(); 
                         padding += cbpb.getPaddingBefore(false, primary.getCellLM());
                         padding += cbpb.getPaddingAfter(false, primary.getCellLM());
-                        int effRowHeight = effCellContentHeight 
+                        int effRowHeight = effectiveCellBPD 
                                 + padding + borderWidths
                                 + 2 * tableLM.getHalfBorderSeparationBPD();
                         for (int previous = 0; previous < gu.getRowSpanIndex(); previous++) {
@@ -279,13 +272,13 @@
 
             row.setHeight(rowHeights[rgi]);
             row.setExplicitHeight(explicitRowHeights[rgi]);
-            if (effRowContentHeight > row.getExplicitHeight().max) {
+            if (maxCellBPD > row.getExplicitHeight().max) {
                 log.warn(FONode.decorateWithContextInfo(
                         "The contents of row " + (row.getIndex() + 1) 
                         + " are taller than they should be (there is a"
                         + " block-progression-dimension or height constraint on the indicated row)."
                         + " Due to its contents the row grows"
-                        + " to " + effRowContentHeight + " millipoints, but the row shouldn't get"
+                        + " to " + maxCellBPD + " millipoints, but the row shouldn't get"
                         + " any taller than " + row.getExplicitHeight() + " millipoints.", 
                         row.getTableRow()));
             }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowPainter.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowPainter.java Thu Jan 10 11:58:23 2008
@@ -19,9 +19,10 @@
 
 package org.apache.fop.layoutmgr.table;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
-import java.util.Map;
+import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -47,17 +48,15 @@
     private EffRow lastRow = null;
     private LayoutContext layoutContext;
     /**
-     * For each part of the table (header, footer, body), index of the first row of that
-     * part present on the current page.
+     * Index of the first row of the current part present on the current page.
      */
-    private int[] firstRow = new int[3];
+    private int firstRowIndex;
     /**
-     * Keeps track of the y-offsets of each row on a page (for body, header and footer separately).
+     * Keeps track of the y-offsets of each row on a page.
      * This is particularly needed for spanned cells where you need to know the y-offset
      * of the starting row when the area is generated at the time the cell is closed.
      */
-    private Map[] rowOffsets = new Map[] {new java.util.HashMap(),
-            new java.util.HashMap(), new java.util.HashMap()};
+    private List rowOffsets = new ArrayList();
 
     //These three variables are our buffer to recombine the individual steps into cells
     /** Primary grid units corresponding to the currently handled grid units, per row. */
@@ -79,7 +78,7 @@
     private int[] partBPD;
     private TableContentLayoutManager tclm;
 
-    public RowPainter(TableContentLayoutManager tclm, LayoutContext layoutContext) {
+    RowPainter(TableContentLayoutManager tclm, LayoutContext layoutContext) {
         this.tclm = tclm;
         this.layoutContext = layoutContext;
         this.colCount = tclm.getColumns().getColumnCount();
@@ -87,11 +86,11 @@
         this.start = new int[colCount];
         this.end = new int[colCount];
         this.partBPD = new int[colCount];
-        Arrays.fill(firstRow, -1);
+        this.firstRowIndex = -1;
         Arrays.fill(end, -1);
     }
 
-    public int getAccumulatedBPD() {
+    int getAccumulatedBPD() {
         return this.accumulatedBPD;
     }
 
@@ -101,7 +100,7 @@
      * 
      * @param tcpos a position representing the row fragment
      */
-    public void handleTableContentPosition(TableContentPosition tcpos) {
+    void handleTableContentPosition(TableContentPosition tcpos) {
         if (lastRow != tcpos.row && lastRow != null) {
             addAreasAndFlushRow(false);
         }
@@ -110,27 +109,30 @@
         }
         rowFO = tcpos.row.getTableRow();
         lastRow = tcpos.row;
-        Iterator partIter = tcpos.gridUnitParts.iterator();
+        if (firstRowIndex < 0) {
+            firstRowIndex = lastRow.getIndex();
+        }
+        Iterator partIter = tcpos.cellParts.iterator();
         //Iterate over all grid units in the current step
         while (partIter.hasNext()) {
-            GridUnitPart gup = (GridUnitPart)partIter.next();
+            CellPart cellPart = (CellPart)partIter.next();
             if (log.isDebugEnabled()) {
-                log.debug(">" + gup);
+                log.debug(">" + cellPart);
             }
-            int colIndex = gup.pgu.getStartCol();
-            if (primaryGridUnits[colIndex] != gup.pgu) {
+            int colIndex = cellPart.pgu.getStartCol();
+            if (primaryGridUnits[colIndex] != cellPart.pgu) {
                 if (primaryGridUnits[colIndex] != null) {
                     log.warn("Replacing GU in slot " + colIndex
                             + ". Some content may not be painted.");
                 }
-                primaryGridUnits[colIndex] = gup.pgu;
-                start[colIndex] = gup.start;
-                end[colIndex] = gup.end;
+                primaryGridUnits[colIndex] = cellPart.pgu;
+                start[colIndex] = cellPart.start;
+                end[colIndex] = cellPart.end;
             } else {
-                if (gup.end < end[colIndex]) {
+                if (cellPart.end < end[colIndex]) {
                     throw new IllegalStateException("Internal Error: stepper problem");
                 }
-                end[colIndex] = gup.end;
+                end[colIndex] = cellPart.end;
             }
         }
     }
@@ -146,20 +148,19 @@
      * part
      * @return the height of the (grid) row
      */
-    public int addAreasAndFlushRow(boolean forcedFlush) {
+    int addAreasAndFlushRow(boolean forcedFlush) {
         int actualRowHeight = 0;
 
-        int bt = lastRow.getBodyType();
         if (log.isDebugEnabled()) {
             log.debug("Remembering yoffset for row " + lastRow.getIndex() + ": " + yoffset);
         }
-        rowOffsets[bt].put(new Integer(lastRow.getIndex()), new Integer(yoffset));
+        recordRowOffset(lastRow.getIndex(), yoffset);
 
         for (int i = 0; i < primaryGridUnits.length; i++) {
             if ((primaryGridUnits[i] != null)
                     && (forcedFlush || (end[i] == primaryGridUnits[i].getElements().size() - 1))) {
                 actualRowHeight = Math.max(actualRowHeight, computeSpanHeight(
-                        primaryGridUnits[i], start[i], end[i], i, bt));
+                        primaryGridUnits[i], start[i], end[i], i));
             }
         }
         actualRowHeight += 2 * tclm.getTableLM().getHalfBorderSeparationBPD();
@@ -167,32 +168,12 @@
         //Add areas for row
         tclm.addRowBackgroundArea(rowFO, actualRowHeight, layoutContext.getRefIPD(), yoffset);
         for (int i = 0; i < primaryGridUnits.length; i++) {
-            GridUnit currentGU = lastRow.safelyGetGridUnit(i);
-            //currentGU can be null if there's no grid unit
-            //at this place in the current row (empty cell and no borders to process)
-            
-            if (primaryGridUnits[i] != null) {
-                if (forcedFlush || ((end[i] == primaryGridUnits[i].getElements().size() - 1)
-                        && (currentGU == null || currentGU.isLastGridUnitRowSpan()))) {
-                    //the last line in the "if" above is to avoid a premature end of a
-                    //row-spanned cell because no GridUnitParts are generated after a cell is
-                    //finished with its content.
-                    //See table-cell_number-rows-spanned_bug38397.xml
-                    addAreasForCell(primaryGridUnits[i], start[i], end[i], lastRow, partBPD[i],
-                            actualRowHeight);
-                    primaryGridUnits[i] = null;
-                    start[i] = 0;
-                    end[i] = -1;
-                    partBPD[i] = 0;
-                }
-            } else if (currentGU != null && !currentGU.isEmpty()
-                    && currentGU.getColSpanIndex() == 0
+            GridUnit currentGU = lastRow.getGridUnit(i);            
+            if (!currentGU.isEmpty() && currentGU.getColSpanIndex() == 0
                     && (forcedFlush || currentGU.isLastGridUnitRowSpan())) {
-                //A row-spanned cell has finished contributing content on the previous page
-                //and now still has to cause grid units to be painted.
-                //See table-cell_page-break_span.xml
                 addAreasForCell(currentGU.getPrimary(), start[i], end[i], lastRow, partBPD[i],
                         actualRowHeight);
+                primaryGridUnits[i] = null;
                 start[i] = 0;
                 end[i] = -1;
                 partBPD[i] = 0;
@@ -206,8 +187,10 @@
             // (header, footer, body) has been reached, and the next row will anyway be
             // different from the current one, and this is unnecessary to recall this
             // method in the first lines of handleTableContentPosition, so we may reset
-            // lastRow
+            // the following variables
             lastRow = null;
+            firstRowIndex = -1;
+            rowOffsets.clear();
         }
         return actualRowHeight;
     }
@@ -226,8 +209,7 @@
      * {@link TableRowIterator#BODY}
      * @return the cell's height
      */
-    private int computeSpanHeight(PrimaryGridUnit pgu, int start, int end, int columnIndex,
-            int bodyType) {
+    private int computeSpanHeight(PrimaryGridUnit pgu, int start, int end, int columnIndex) {
         if (log.isTraceEnabled()) {
             log.trace("getting len for " + columnIndex + " "
                     + start + "-" + end);
@@ -292,26 +274,15 @@
             len += pgu.getHalfMaxBeforeBorderWidth();
             len += pgu.getHalfMaxAfterBorderWidth();
         }
-        int startRow = Math.max(pgu.getStartRow(), firstRow[bodyType]);
-        Integer storedOffset = (Integer)rowOffsets[bodyType].get(new Integer(startRow));
-        int effYOffset;
-        if (storedOffset != null) {
-            effYOffset = storedOffset.intValue();
-        } else {
-            effYOffset = yoffset;
-        }
-        len -= yoffset - effYOffset;
+        int cellOffset = getRowOffset(Math.max(pgu.getStartRow(), firstRowIndex));
+        len -= yoffset - cellOffset;
         return len;
     }
 
     private void addAreasForCell(PrimaryGridUnit pgu, int startPos, int endPos,
             EffRow row, int contentHeight, int rowHeight) {
-        int bt = row.getBodyType();
-        if (firstRow[bt] < 0) {
-            firstRow[bt] = row.getIndex();
-        }
         //Determine the first row in this sequence
-        int startRowIndex = Math.max(pgu.getStartRow(), firstRow[bt]);
+        int startRowIndex = Math.max(pgu.getStartRow(), firstRowIndex);
         int lastRowIndex = lastRow.getIndex();
 
         // In collapsing-border model, if the cell spans over several columns/rows then
@@ -321,37 +292,28 @@
         int[] spannedGridRowHeights = null;
         if (!tclm.getTableLM().getTable().isSeparateBorderModel() && pgu.hasSpanning()) {
             spannedGridRowHeights = new int[lastRowIndex - startRowIndex + 1];
-            int prevOffset = ((Integer)rowOffsets[bt].get(new Integer(startRowIndex))).intValue();
+            int prevOffset = getRowOffset(startRowIndex);
             for (int i = 0; i < lastRowIndex - startRowIndex; i++) {
-                int newOffset = ((Integer) rowOffsets[bt].get(new Integer(startRowIndex + i + 1)))
-                        .intValue();
+                int newOffset = getRowOffset(startRowIndex + i + 1);
                 spannedGridRowHeights[i] = newOffset - prevOffset;
                 prevOffset = newOffset;
             }
             spannedGridRowHeights[lastRowIndex - startRowIndex] = rowHeight;
         }
 
-        //Determine y offset for the cell
-        Integer offset = (Integer)rowOffsets[bt].get(new Integer(startRowIndex));
-        while (offset == null) {
-            //TODO Figure out what this does and when it's triggered
-            //This block is probably never used, at least it's not triggered by any of our tests
-            startRowIndex--;
-            offset = (Integer)rowOffsets[bt].get(new Integer(startRowIndex));
-        }
-        int effYOffset = offset.intValue();
+        int cellOffset = getRowOffset(startRowIndex);
         int effCellHeight = rowHeight;
-        effCellHeight += yoffset - effYOffset;
+        effCellHeight += yoffset - cellOffset;
         if (log.isDebugEnabled()) {
             log.debug("Creating area for cell:");
             log.debug("  current row: " + row.getIndex());
-            log.debug("  start row: " + pgu.getStartRow() + " " + yoffset + " " + effYOffset);
+            log.debug("  start row: " + pgu.getStartRow() + " " + yoffset + " " + cellOffset);
             log.debug("  contentHeight: " + contentHeight + " rowHeight=" + rowHeight
                     + " effCellHeight=" + effCellHeight);
         }
         TableCellLayoutManager cellLM = pgu.getCellLM();
         cellLM.setXOffset(tclm.getXOffsetOfGridUnit(pgu));
-        cellLM.setYOffset(effYOffset);
+        cellLM.setYOffset(cellOffset);
         cellLM.setContentHeight(contentHeight);
         cellLM.setRowHeight(effCellHeight);
         //cellLM.setRowHeight(row.getHeight().opt);
@@ -363,5 +325,39 @@
         cellLM.addAreas(new KnuthPossPosIter(pgu.getElements(), startPos, endPos + 1),
                 layoutContext, spannedGridRowHeights, startRowIndex - pgu.getStartRow(),
                 lastRowIndex - pgu.getStartRow() + 1);
+    }
+
+    /**
+     * Records the y-offset of the row with the given index.
+     * 
+     * @param rowIndex index of the row
+     * @param offset y-offset of the row on the page
+     */
+    private void recordRowOffset(int rowIndex, int offset) {
+        /*
+         * In some very rare cases a row may be skipped. See for example Bugzilla #43633:
+         * in a two-column table, a row contains a row-spanning cell and a missing cell.
+         * In TableStepper#goToNextRowIfCurrentFinished this row will immediately be
+         * considered as finished, since it contains no cell ending on this row. Thus no
+         * TableContentPosition will be created for this row. Thus its index will never be
+         * recorded by the #handleTableContentPosition method.
+         * 
+         * The yoffset for such a row is the same as the next non-empty row. It's needed
+         * to correctly offset blocks for cells starting on this row. Hence the loop
+         * below.
+         */
+        for (int i = rowOffsets.size(); i <= rowIndex - firstRowIndex; i++) {
+            rowOffsets.add(new Integer(offset));
+        }
+    }
+
+    /**
+     * Returns the offset of the row with the given index.
+     * 
+     * @param rowIndex index of the row
+     * @return its y-offset on the page
+     */
+    private int getRowOffset(int rowIndex) {
+        return ((Integer) rowOffsets.get(rowIndex - firstRowIndex)).intValue();
     }
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -194,16 +194,5 @@
             curBlockArea.addBlock((Block) childArea);
         }
     }
-
-    /**
-     * Reset the position of this layout manager.
-     *
-     * @param resetPos the position to reset to
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            reset(null);
-        }
-    }
 }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -193,16 +193,5 @@
                 curBlockArea.addBlock((Block) childArea);
         }
     }
-
-    /**
-     * Reset the layout position.
-     *
-     * @param resetPos the position to reset to
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            reset(null);
-        }
-    }
 }
 



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