Index: src/java/org/apache/fop/apps/Document.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Document.java,v
retrieving revision 1.13
diff -u -r1.13 Document.java
--- src/java/org/apache/fop/apps/Document.java	22 Apr 2004 21:38:39 -0000	1.13
+++ src/java/org/apache/fop/apps/Document.java	16 May 2004 16:12:09 -0000
@@ -24,22 +24,25 @@
 import java.util.Set;
 import java.util.HashSet;
 
-
 // FOP
-import org.apache.fop.apps.FOUserAgent;
-
 import org.apache.fop.area.AreaTree;
 import org.apache.fop.area.AreaTreeControl;
 import org.apache.fop.area.AreaTreeModel;
+import org.apache.fop.area.Title;
 
-import org.apache.fop.fo.extensions.Bookmarks;
 import org.apache.fop.fo.FOInputHandler;
 import org.apache.fop.fo.FOTreeControl;
 import org.apache.fop.fo.FOTreeEvent;
 import org.apache.fop.fo.FOTreeListener;
+import org.apache.fop.fo.extensions.Bookmarks;
 import org.apache.fop.fo.pagination.PageSequence;
 import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.layout.LayoutStrategy;
+import org.apache.fop.layoutmgr.AddLMVisitor;
+import org.apache.fop.layoutmgr.ContentLayoutManager;
+import org.apache.fop.layoutmgr.InlineStackingLayoutManager;
+import org.apache.fop.layoutmgr.LMiter;
+import org.apache.fop.layoutmgr.PageLayoutManager;
+
 
 import org.apache.commons.logging.Log;
 
@@ -59,13 +62,6 @@
     /** The Font information relevant for this document */
     private FontInfo fontInfo;
     
-    /**
-     * the LayoutStrategy to be used to process this document
-     * TODO: this actually belongs in the RenderContext class, when it is
-     * created
-     */
-    private LayoutStrategy layoutStrategy = null;
-
     /** The current AreaTree for the PageSequence being rendered. */
     public AreaTree areaTree;
 
@@ -74,6 +70,8 @@
 
     private Bookmarks bookmarks = null;
 
+    private AddLMVisitor addLMVisitor = null;
+
     /**
      * The current set of id's in the FO tree.
      * This is used so we know if the FO tree contains duplicates.
@@ -104,21 +102,6 @@
     }
 
     /**
-     * Set the LayoutStrategy to be used to process this Document
-     * @param ls the LayoutStrategy object to be used to process this Document
-     */
-    public void setLayoutStrategy(LayoutStrategy ls) {
-        this.layoutStrategy = ls;
-    }
-
-    /**
-     * @return this Document's LayoutStrategy object
-     */
-    public LayoutStrategy getLayoutStrategy () {
-        return layoutStrategy;
-    }
-
-    /**
      * Public accessor for the parent Driver of this Document
      * @return the parent Driver for this Document
      */
@@ -135,7 +118,7 @@
     public void foPageSequenceComplete (FOTreeEvent event) throws FOPException {
         PageSequence pageSeq = event.getPageSequence();
         areaTree.addBookmarksToAreaTree();
-        layoutStrategy.format(pageSeq, areaTree);
+        format(pageSeq, areaTree);
     }
 
     /**
@@ -195,4 +178,103 @@
         return foInputHandler;
     }
 
+    /**
+     * Runs the formatting of this page sequence into the given area tree
+     *
+     * @param pageSeq the PageSequence to be formatted
+     * @param areaTree the area tree to format this page sequence into
+     * @throws FOPException if there is an error formatting the contents
+     */
+    public void format(PageSequence pageSeq, AreaTree areaTree) throws FOPException {
+        Title title = null;
+        if (pageSeq.getTitleFO() != null) {
+            title = getTitleArea(pageSeq.getTitleFO());
+        }
+        areaTree.startPageSequence(title);
+        // Make a new PageLayoutManager and a FlowLayoutManager
+        // Run the PLM in a thread
+        // Wait for them to finish.
+
+        // If no main flow, nothing to layout!
+        if (pageSeq.getMainFlow() == null) {
+            return;
+        }
+
+        // Initialize if already used?
+        //    this.layoutMasterSet.resetPageMasters();
+        if (pageSeq.getPageSequenceMaster() != null) {
+            pageSeq.getPageSequenceMaster().reset();
+        }
+
+        pageSeq.initPageNumber();
+
+        // This will layout pages and add them to the area tree
+        PageLayoutManager pageLM = new PageLayoutManager(areaTree, pageSeq, this);
+        pageLM.setPageCounting(pageSeq.getCurrentPageNumber(),
+                               pageSeq.getPageNumberGenerator());
+
+        // For now, skip the threading and just call run directly.
+        pageLM.run();
+
+        // Thread layoutThread = new Thread(pageLM);
+//  layoutThread.start();
+// log.debug("Layout thread started");
+
+// // wait on both managers
+// try {
+//     layoutThread.join();
+//     log.debug("Layout thread done");
+// } catch (InterruptedException ie) {
+//     log.error("PageSequence.format() interrupted waiting on layout");
+// }
+        pageSeq.setCurrentPageNumber(pageLM.getPageCount());
+        // Tell the root the last page number we created.
+        pageSeq.getRoot().setRunningPageNumberCounter(pageSeq.getCurrentPageNumber());
+    }
+
+    /**
+     * @return the Title area
+     */
+    public org.apache.fop.area.Title getTitleArea(org.apache.fop.fo.pagination.Title foTitle) {
+        // use special layout manager to add the inline areas
+        // to the Title.
+        InlineStackingLayoutManager lm;
+        lm = new InlineStackingLayoutManager(foTitle);
+        lm.setLMiter(new LMiter(lm, foTitle.children.listIterator()));
+        lm.initialize();
+
+        // get breaks then add areas to title
+        org.apache.fop.area.Title title =
+                 new org.apache.fop.area.Title();
+
+        ContentLayoutManager clm = new ContentLayoutManager(title);
+        clm.setUserAgent(foTitle.getUserAgent());
+        lm.setParent(clm);
+
+        clm.fillArea(lm);
+
+        return title;
+    }
+
+    /**
+     * Public accessor to set the AddLMVisitor object that should be used.
+     * This allows subclasses of AddLMVisitor to be used, which can be useful
+     * for extensions to the FO Tree.
+     * @param addLMVisitor the AddLMVisitor object that should be used.
+     */
+    public void setAddLMVisitor(AddLMVisitor addLMVisitor) {
+        this.addLMVisitor = addLMVisitor;
+    }
+
+    /**
+     * Public accessor to get the AddLMVisitor object that should be used.
+     * @return the AddLMVisitor object that should be used.
+     */
+    public AddLMVisitor getAddLMVisitor() {
+        if (this.addLMVisitor == null) {
+            this.addLMVisitor = new AddLMVisitor();
+        }
+        return this.addLMVisitor;
+    }
+    
 }
Index: src/java/org/apache/fop/apps/Driver.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Driver.java,v
retrieving revision 1.58
diff -u -r1.58 Driver.java
--- src/java/org/apache/fop/apps/Driver.java	12 May 2004 23:19:52 -0000	1.58
+++ src/java/org/apache/fop/apps/Driver.java	16 May 2004 16:12:16 -0000
@@ -34,7 +34,6 @@
 import org.apache.fop.tools.DocumentInputSource;
 import org.apache.fop.tools.DocumentReader;
 import org.apache.fop.tools.ProxyContentHandler;
-import org.apache.fop.layoutmgr.LayoutManagerLS;
 
 import org.apache.commons.logging.impl.SimpleLog;
 import org.apache.commons.logging.Log;
@@ -509,13 +508,6 @@
             }
         }
         currentDocument.foInputHandler = foInputHandler;
-        /** LayoutStrategy is hard-wired for now, but needs to be made
-        accessible through the API and/or configuration */
-        if (foInputHandler instanceof FOTreeHandler) {
-            if (currentDocument.getLayoutStrategy() == null) {
-                currentDocument.setLayoutStrategy(new LayoutManagerLS());
-            }
-        }
 
         foInputHandler.setLogger(getLogger());
 
@@ -561,6 +553,8 @@
      * This is the main render() method. The other render() methods are for
      * convenience, and normalize to this form, then run this.
      * Renders the FO document read by a SAX Parser from an InputSource.
+     * For versions not needing an FO Tree (e.g., Alt-Design), override this.
+     *
      * @param parser the SAX parser.
      * @param source the input source the parser reads from.
      * @throws FOPException if anything goes wrong.
@@ -569,22 +563,6 @@
                 throws FOPException {
         parser.setContentHandler(getContentHandler());
 
-        /**
-         * The following statement handles the case of a LayoutStrategy that
-         * does not wish to build an FO Tree, but wishes to parse the incoming
-         * document some other way. This applies primarily to the alt-design
-         * system.
-         */
-        if (currentDocument.getLayoutStrategy() != null) {
-            if (!currentDocument.getLayoutStrategy().foTreeNeeded()) {
-                currentDocument.getLayoutStrategy().format(null, null);
-                return;
-            }
-        }
-
-        /**
-         * For all other cases, we wish to parse normally.
-         */
         try {
             /**
              The following statement triggers virtually all of the processing
Index: src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java,v
retrieving revision 1.12
diff -u -r1.12 AbstractLayoutManager.java
--- src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java	15 May 2004 21:51:59 -0000	1.12
+++ src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java	16 May 2004 16:12:32 -0000
@@ -20,6 +20,7 @@
 
 import org.apache.fop.fo.FObj;
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Document;
 import org.apache.fop.fo.flow.Marker;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Resolveable;
@@ -108,8 +109,8 @@
         return this.parentLM;
     }
 
-    public LayoutManagerLS getLayoutManagerLS() {
-        return getParent().getLayoutManagerLS();
+    public Document getDocument() {
+        return getParent().getDocument();
     }
 
     //     /**
Index: src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java,v
retrieving revision 1.8
diff -u -r1.8 ContentLayoutManager.java
--- src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java	21 Mar 2004 12:03:08 -0000	1.8
+++ src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java	16 May 2004 16:12:32 -0000
@@ -19,6 +19,7 @@
 package org.apache.fop.layoutmgr;
 
 import org.apache.fop.fo.FObj;
+import org.apache.fop.apps.Document;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.flow.Marker;
 import org.apache.fop.area.Area;
@@ -170,8 +171,8 @@
         return this.parentLM;
     }
 
-    public LayoutManagerLS getLayoutManagerLS() {
-        return getParent().getLayoutManagerLS();
+    public Document getDocument() {
+        return getParent().getDocument();
     }
 
     /** @see org.apache.fop.layoutmgr.LayoutManager */
Index: src/java/org/apache/fop/layoutmgr/LMiter.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LMiter.java,v
retrieving revision 1.5
diff -u -r1.5 LMiter.java
--- src/java/org/apache/fop/layoutmgr/LMiter.java	21 Mar 2004 12:03:08 -0000	1.5
+++ src/java/org/apache/fop/layoutmgr/LMiter.java	16 May 2004 16:12:32 -0000
@@ -46,7 +46,7 @@
     }
 
     protected boolean preLoadNext() {
-        AddLMVisitor addLMVisitor = lp.getLayoutManagerLS().getAddLMVisitor();
+        AddLMVisitor addLMVisitor = lp.getDocument().getAddLMVisitor();
         // skip over child FObj's that don't add lms
         while (baseIter != null && baseIter.hasNext()) {
             Object theobj = baseIter.next();
Index: src/java/org/apache/fop/layoutmgr/LayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManager.java,v
retrieving revision 1.5
diff -u -r1.5 LayoutManager.java
--- src/java/org/apache/fop/layoutmgr/LayoutManager.java	15 May 2004 21:52:00 -0000	1.5
+++ src/java/org/apache/fop/layoutmgr/LayoutManager.java	16 May 2004 16:12:39 -0000
@@ -71,10 +71,10 @@
     LayoutManager getParent();
 
     /**
-     * Get the LayoutManagerLS object that is at the top of the LM Tree
-     * @return the LayoutManagerLS object that is at the top of the LM Tree
+     * Get the Document object that is at the top of the LM Tree
+     * @return the Document object that is at the top of the LM Tree
      */
-    LayoutManagerLS getLayoutManagerLS();
+    org.apache.fop.apps.Document getDocument();
 
     /**
      * Initialize this layout manager.
Index: src/java/org/apache/fop/layoutmgr/PageLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java,v
retrieving revision 1.36
diff -u -r1.36 PageLayoutManager.java
--- src/java/org/apache/fop/layoutmgr/PageLayoutManager.java	15 May 2004 21:52:00 -0000	1.36
+++ src/java/org/apache/fop/layoutmgr/PageLayoutManager.java	16 May 2004 16:12:54 -0000
@@ -18,6 +18,7 @@
 
 package org.apache.fop.layoutmgr;
 
+import org.apache.fop.apps.Document;
 import org.apache.fop.apps.FOPException;
 
 import org.apache.fop.area.CTM;
@@ -106,6 +107,7 @@
      */
     private AreaTree areaTree;
     private PageSequence pageSequence;
+    private Document doc;
 
     /**
      * This is the SimplePageMaster that should be used to create the page. It
@@ -121,8 +123,6 @@
      */
     private HashMap staticContentLMs = new HashMap(4);
 
-    private LayoutManagerLS lmls;
-
     /**
      * This is the top level layout manager.
      * It is created by the PageSequence FO.
@@ -131,11 +131,11 @@
      * @param pageseq the page sequence fo
      */
     public PageLayoutManager(AreaTree areaTree, PageSequence pageseq,
-                             LayoutManagerLS lmls) {
+        Document doc) {
         super(pageseq);
         this.areaTree = areaTree;
         pageSequence = pageseq;
-        this.lmls = lmls;
+        this.doc = doc;
     }
 
     /**
@@ -895,9 +895,11 @@
         staticContentLMs.put(sc.getFlowName(), lm);
         return lm;
     }
-
-    public LayoutManagerLS getLayoutManagerLS() {
-        return lmls;
+    
+    /**
+     * @return the apps.Document object controlling this generation
+     */
+    public Document getDocument() {
+        return doc;
     }
-
 }
