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 2004/12/24 13:06:26 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LayoutManagerMaker.java LayoutManagerMapping.java AbstractLayoutManager.java ContentLayoutManager.java LayoutManager.java PageSequenceLayoutManager.java

spepping    2004/12/24 04:06:26

  Modified:    src/java/org/apache/fop/apps FOUserAgent.java
               src/java/org/apache/fop/area AreaTreeHandler.java
               src/java/org/apache/fop/fo FONode.java FOText.java
                        FObjMixed.java
               src/java/org/apache/fop/fo/flow BasicLink.java
                        BidiOverride.java Block.java BlockContainer.java
                        Character.java ExternalGraphic.java Footnote.java
                        Inline.java InlineContainer.java InlineLevel.java
                        InstreamForeignObject.java Leader.java
                        ListBlock.java ListItem.java Marker.java
                        PageNumber.java PageNumberCitation.java
                        RetrieveMarker.java Table.java TableBody.java
                        TableCell.java TableRow.java Wrapper.java
               src/java/org/apache/fop/fo/pagination Flow.java
               src/java/org/apache/fop/layoutmgr AbstractLayoutManager.java
                        ContentLayoutManager.java LayoutManager.java
                        PageSequenceLayoutManager.java
  Added:       src/java/org/apache/fop/layoutmgr LayoutManagerMaker.java
                        LayoutManagerMapping.java
  Log:
  This patch implements a pluggable LayoutManagers system, according
  to the ideas of Finn Bock and his patch in bug 30500.
  
  Created a LayoutManagerMaker interface, with method
  makeLayoutManagers(FONode, List), and two convenience methods on top
  of it.
  
  Created an implementation: LayoutManagerMapping. This is along the
  pattern of FOElementMapping. It creates a Map from FObj class to Maker
  objects. There are many static inner classes which are subclasses of
  Maker. Each subclass implements its own version of the make method.
  
  FOUserAgent has a setter and getter for
  LayoutManagerMakerOverride. AreaTreeHandler creates a
  LayoutManagerMaker, taking the user's override into account, using
  LayoutManagerMapping as the default. It has a get method for it.
  
  The LayoutManager interface has a get method for the AreaTreeHandler
  object, a reference to which is held in PageSequenceLM, the top of the
  LM tree.
  
  Revision  Changes    Path
  1.20      +20 -1     xml-fop/src/java/org/apache/fop/apps/FOUserAgent.java
  
  Index: FOUserAgent.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/FOUserAgent.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- FOUserAgent.java	24 Oct 2004 00:03:49 -0000	1.19
  +++ FOUserAgent.java	24 Dec 2004 12:06:25 -0000	1.20
  @@ -37,6 +37,7 @@
   // FOP
   import org.apache.fop.fo.ElementMapping;
   import org.apache.fop.fo.FOEventHandler;
  +import org.apache.fop.layoutmgr.LayoutManagerMaker;
   import org.apache.fop.pdf.PDFEncryptionParams;
   import org.apache.fop.render.Renderer;
   
  @@ -74,6 +75,7 @@
       private InputHandler inputHandler = null;
       private Renderer rendererOverride = null;
       private FOEventHandler foEventHandlerOverride = null;
  +    private LayoutManagerMaker lmMakerOverride = null;
       /* user configuration */
       private Configuration userConfig = null;
       private Log log = LogFactory.getLog("FOP");
  @@ -164,6 +166,23 @@
        */
       public FOEventHandler getFOEventHandlerOverride() {
           return this.foEventHandlerOverride;
  +    }
  +
  +    /**
  +     * Sets an explicit LayoutManagerMaker instance which overrides the one
  +     * defined by the AreaTreeHandler.
  +     * @param lmMaker the LayoutManagerMaker instance
  +     */
  +    public void setLayoutManagerMakerOverride(LayoutManagerMaker lmMaker) {
  +        this.lmMakerOverride = lmMaker;
  +    }
  +
  +    /**
  +     * Returns the overriding LayoutManagerMaker instance, if any.
  +     * @return the overriding LayoutManagerMaker or null
  +     */
  +    public LayoutManagerMaker getLayoutManagerMakerOverride() {
  +        return this.lmMakerOverride;
       }
   
       /**
  
  
  
  1.28      +24 -3     xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java
  
  Index: AreaTreeHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- AreaTreeHandler.java	17 Dec 2004 00:19:10 -0000	1.27
  +++ AreaTreeHandler.java	24 Dec 2004 12:06:25 -0000	1.28
  @@ -40,6 +40,8 @@
   import org.apache.fop.fo.pagination.PageSequence;
   import org.apache.fop.fo.pagination.Root;
   import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
  +import org.apache.fop.layoutmgr.LayoutManagerMaker;
  +import org.apache.fop.layoutmgr.LayoutManagerMapping;
   
   /**
    * Area tree handler for formatting objects.
  @@ -72,6 +74,9 @@
       // time used in rendering (for statistics)
       private long startTime;
   
  +    // the LayoutManager maker
  +    private LayoutManagerMaker lmMaker;
  +
       // count of number of pages rendered
       private int pageCount;
   
  @@ -106,6 +111,11 @@
           model = new RenderPagesModel(userAgent, renderType, fontInfo,
               stream);
               
  +        lmMaker = userAgent.getLayoutManagerMakerOverride();
  +        if (lmMaker == null) {
  +            lmMaker = new LayoutManagerMapping();
  +        }
  +
           outputStatistics = log.isDebugEnabled();
   
           if (outputStatistics) {
  @@ -123,6 +133,15 @@
       }
   
       /**
  +     * Get the LayoutManager maker for this area tree.
  +     *
  +     * @return LayoutManagerMaker the LayoutManager maker being used for this area tree
  +     */
  +    public LayoutManagerMaker getLayoutManagerMaker() {
  +        return lmMaker;
  +    }
  +
  +    /**
        * Tie a PageViewport with an ID found on a child area of the PV.
        * Note that an area with a given ID may be on more than one PV, hence
        * an ID may have more than one PV associated with it.
  @@ -210,8 +229,10 @@
   
           // If no main flow, nothing to layout!
           if (pageSequence.getMainFlow() != null) {
  -            PageSequenceLayoutManager pageSLM 
  -                = new PageSequenceLayoutManager(this, pageSequence);
  +            PageSequenceLayoutManager pageSLM =
  +                (PageSequenceLayoutManager)
  +                getLayoutManagerMaker().makeLayoutManager(pageSequence);
  +            pageSLM.setAreaTreeHandler(this);
               pageSLM.activateLayout();
           }
       }
  
  
  
  1.51      +0 -8      xml-fop/src/java/org/apache/fop/fo/FONode.java
  
  Index: FONode.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- FONode.java	21 Dec 2004 11:28:05 -0000	1.50
  +++ FONode.java	24 Dec 2004 12:06:25 -0000	1.51
  @@ -371,14 +371,6 @@
       }
   
       /**
  -     * Return a LayoutManager responsible for laying out this FObj's content.
  -     * Must override in subclasses if their content can be laid out.
  -     * @param list the list to which the layout manager(s) should be added
  -     */
  -    public void addLayoutManager(List list) {
  -    }
  -
  -    /**
        * Returns the name of the node
        * @return the name of this node
        */
  
  
  
  1.36      +0 -9      xml-fop/src/java/org/apache/fop/fo/FOText.java
  
  Index: FOText.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOText.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- FOText.java	22 Dec 2004 18:22:35 -0000	1.35
  +++ FOText.java	24 Dec 2004 12:06:25 -0000	1.36
  @@ -567,13 +567,4 @@
       public int getWrapOption() {
           return wrapOption; 
       }
  -
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        if (endIndex - startIndex > 0) {
  -            list.add(new TextLayoutManager(this));
  -        }
  -    }
   }
  
  
  
  1.45      +0 -7      xml-fop/src/java/org/apache/fop/fo/FObjMixed.java
  
  Index: FObjMixed.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObjMixed.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- FObjMixed.java	22 Dec 2004 08:54:10 -0000	1.44
  +++ FObjMixed.java	24 Dec 2004 12:06:25 -0000	1.45
  @@ -61,13 +61,6 @@
       public CharIterator charIterator() {
           return new RecursiveCharIterator(this);
       }
  -
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {    
  -        // no layout manager
  -    }
       
   }
   
  
  
  
  1.35      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/BasicLink.java
  
  Index: BasicLink.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/BasicLink.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- BasicLink.java	29 Oct 2004 10:20:55 -0000	1.34
  +++ BasicLink.java	24 Dec 2004 12:06:25 -0000	1.35
  @@ -118,14 +118,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {    
  -        BasicLinkLayoutManager lm = new BasicLinkLayoutManager(this);
  -        list.add(lm);
  -    }
  -
  -    /**
        * Return the "internal-destination" property.
        */
       public String getInternalDestination() {
  
  
  
  1.25      +0 -24     xml-fop/src/java/org/apache/fop/fo/flow/BidiOverride.java
  
  Index: BidiOverride.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/BidiOverride.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- BidiOverride.java	22 Dec 2004 08:54:10 -0000	1.24
  +++ BidiOverride.java	24 Dec 2004 12:06:25 -0000	1.25
  @@ -132,30 +132,6 @@
               blockOrInlineItemFound = true;
           }
       }
  -    
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     * @todo see if can/should move the child iteration logic 
  -     *      to BidiLayoutManager
  -     */
  -    public void addLayoutManager(List list) {    
  -        if (false) {
  -            super.addLayoutManager(list);
  -        } else {
  -            ArrayList childList = new ArrayList();
  -            super.addLayoutManager(list);
  -            for (int count = childList.size() - 1; count >= 0; count--) {
  -                LayoutManager lm = (LayoutManager) childList.get(count);
  -                if (lm.generatesInlineAreas()) {
  -                    LayoutManager blm = new BidiLayoutManager(this,
  -                        (InlineLayoutManager) lm);
  -                    list.add(blm);
  -                } else {
  -                    list.add(lm);
  -                }
  -            }
  -        }
  -    }
   
       /**
        * @see org.apache.fop.fo.FObj#getName()
  
  
  
  1.51      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/Block.java
  
  Index: Block.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Block.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- Block.java	24 Nov 2004 21:07:29 -0000	1.50
  +++ Block.java	24 Dec 2004 12:06:25 -0000	1.51
  @@ -473,14 +473,6 @@
               bNextIsLF = false;
           }
       }
  -
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {    
  -        BlockLayoutManager blm = new BlockLayoutManager(this);
  -        list.add(blm);
  -    }
        
       /**
        * @see org.apache.fop.fo.FONode#getName()
  
  
  
  1.33      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/BlockContainer.java
  
  Index: BlockContainer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/BlockContainer.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- BlockContainer.java	29 Oct 2004 11:19:36 -0000	1.32
  +++ BlockContainer.java	24 Dec 2004 12:06:26 -0000	1.33
  @@ -190,14 +190,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {    
  -        BlockContainerLayoutManager blm = new BlockContainerLayoutManager(this);
  -        list.add(blm);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.31      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/Character.java
  
  Index: Character.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Character.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- Character.java	13 Nov 2004 20:37:17 -0000	1.30
  +++ Character.java	24 Dec 2004 12:06:26 -0000	1.31
  @@ -234,14 +234,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        CharacterLayoutManager lm = new CharacterLayoutManager(this);
  -        list.add(lm);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.49      +0 -10     xml-fop/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
  
  Index: ExternalGraphic.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ExternalGraphic.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- ExternalGraphic.java	29 Oct 2004 11:19:36 -0000	1.48
  +++ ExternalGraphic.java	24 Dec 2004 12:06:26 -0000	1.49
  @@ -241,16 +241,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        if (!src.equals("")) {
  -            ExternalGraphicLayoutManager lm = new ExternalGraphicLayoutManager(this);
  -            list.add(lm);
  -        }
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.31      +0 -11     xml-fop/src/java/org/apache/fop/fo/flow/Footnote.java
  
  Index: Footnote.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Footnote.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- Footnote.java	28 Oct 2004 10:00:21 -0000	1.30
  +++ Footnote.java	24 Dec 2004 12:06:26 -0000	1.31
  @@ -121,17 +121,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        if (getInlineFO() == null) {
  -            getLogger().error("inline required in footnote");
  -            return;
  -        }
  -        getInlineFO().addLayoutManager(list);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.37      +0 -10     xml-fop/src/java/org/apache/fop/fo/flow/Inline.java
  
  Index: Inline.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Inline.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Inline.java	22 Dec 2004 08:54:10 -0000	1.36
  +++ Inline.java	24 Dec 2004 12:06:26 -0000	1.37
  @@ -182,16 +182,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {    
  -        if (getChildNodes() != null) {
  -            InlineLayoutManager lm = new InlineLayoutManager(this);
  -            list.add(lm);
  -        }
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.25      +0 -10     xml-fop/src/java/org/apache/fop/fo/flow/InlineContainer.java
  
  Index: InlineContainer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/InlineContainer.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- InlineContainer.java	29 Oct 2004 10:20:55 -0000	1.24
  +++ InlineContainer.java	24 Dec 2004 12:06:26 -0000	1.25
  @@ -114,16 +114,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        ArrayList childList = new ArrayList();
  -        super.addLayoutManager(childList);
  -        LayoutManager lm = new ICLayoutManager(this, childList);
  -        list.add(lm);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FONode#getName()
        */
       public String getName() {
  
  
  
  1.2       +1 -13     xml-fop/src/java/org/apache/fop/fo/flow/InlineLevel.java
  
  Index: InlineLevel.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/InlineLevel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InlineLevel.java	22 Dec 2004 08:54:10 -0000	1.1
  +++ InlineLevel.java	24 Dec 2004 12:06:26 -0000	1.2
  @@ -96,17 +96,5 @@
       public ColorType getColor() {
           return color;
       }
  -
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {    
  -        if (getChildNodes() != null) {
  -            InlineLayoutManager lm;
  -            lm = new InlineLayoutManager(this);
  -            list.add(lm);
  -        }
  -    }
  -
   }
   
  
  
  
  1.36      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
  
  Index: InstreamForeignObject.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- InstreamForeignObject.java	24 Nov 2004 21:07:29 -0000	1.35
  +++ InstreamForeignObject.java	24 Dec 2004 12:06:26 -0000	1.36
  @@ -261,14 +261,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        InstreamForeignObjectLM lm = new InstreamForeignObjectLM(this);
  -        list.add(lm);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.51      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/Leader.java
  
  Index: Leader.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Leader.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- Leader.java	22 Dec 2004 08:54:10 -0000	1.50
  +++ Leader.java	24 Dec 2004 12:06:26 -0000	1.51
  @@ -176,14 +176,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        LeaderLayoutManager lm = new LeaderLayoutManager(this);
  -        list.add(lm);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.36      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/ListBlock.java
  
  Index: ListBlock.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ListBlock.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- ListBlock.java	29 Oct 2004 10:20:55 -0000	1.35
  +++ ListBlock.java	24 Dec 2004 12:06:26 -0000	1.36
  @@ -147,14 +147,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        ListBlockLayoutManager lm = new ListBlockLayoutManager(this);
  -        list.add(lm);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.35      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/ListItem.java
  
  Index: ListItem.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ListItem.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- ListItem.java	29 Oct 2004 10:20:55 -0000	1.34
  +++ ListItem.java	24 Dec 2004 12:06:26 -0000	1.35
  @@ -155,14 +155,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        ListItemLayoutManager blm = new ListItemLayoutManager(this);
  -        list.add(blm);
  -    }
  -
  -    /**
        * @return the label of the list item
        */
       public ListItemLabel getLabel() {
  
  
  
  1.23      +0 -7      xml-fop/src/java/org/apache/fop/fo/flow/Marker.java
  
  Index: Marker.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Marker.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Marker.java	21 Dec 2004 11:28:05 -0000	1.22
  +++ Marker.java	24 Dec 2004 12:06:26 -0000	1.23
  @@ -123,13 +123,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        // no layout manager
  -    }
  -
  -    /**
        * Return the "marker-class-name" property.
        */
       public String getMarkerClassName() {
  
  
  
  1.47      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/PageNumber.java
  
  Index: PageNumber.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/PageNumber.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- PageNumber.java	29 Oct 2004 11:19:36 -0000	1.46
  +++ PageNumber.java	24 Dec 2004 12:06:26 -0000	1.47
  @@ -160,14 +160,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        PageNumberLayoutManager lm = new PageNumberLayoutManager(this);
  -        list.add(lm);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FONode#getName()
        */
       public String getName() {
  
  
  
  1.44      +0 -9      xml-fop/src/java/org/apache/fop/fo/flow/PageNumberCitation.java
  
  Index: PageNumberCitation.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/PageNumberCitation.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- PageNumberCitation.java	29 Oct 2004 11:19:36 -0000	1.43
  +++ PageNumberCitation.java	24 Dec 2004 12:06:26 -0000	1.44
  @@ -151,15 +151,6 @@
       public String getRefId() {
           return refId;
       }
  -
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        PageNumberCitationLayoutManager lm = 
  -            new PageNumberCitationLayoutManager(this);
  -        list.add(lm);
  -    }
        
       /**
        * @see org.apache.fop.fo.FObj#getName()
  
  
  
  1.27      +0 -15     xml-fop/src/java/org/apache/fop/fo/flow/RetrieveMarker.java
  
  Index: RetrieveMarker.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/RetrieveMarker.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- RetrieveMarker.java	21 Dec 2004 11:28:05 -0000	1.26
  +++ RetrieveMarker.java	24 Dec 2004 12:06:26 -0000	1.27
  @@ -80,21 +80,6 @@
               invalidChildError(loc, nsURI, localName);
       }
   
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     * @todo remove null check when vCN() & endOfNode() implemented
  -     */
  -    public void addLayoutManager(List list) {
  -        Iterator baseIter = getChildNodes();
  -        if (baseIter == null) {
  -            return;
  -        }
  -        while (baseIter.hasNext()) {
  -            FONode child = (FONode) baseIter.next();
  -            child.addLayoutManager(list);
  -        }
  -    }
  -
       protected PropertyList createPropertyList(PropertyList parent, 
               FOEventHandler foEventHandler) throws FOPException {
           // TODO: A special RetrieveMarkerPropertyList would be more memory
  
  
  
  1.42      +3 -38     xml-fop/src/java/org/apache/fop/fo/flow/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Table.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- Table.java	29 Oct 2004 10:20:55 -0000	1.41
  +++ Table.java	24 Dec 2004 12:06:26 -0000	1.42
  @@ -153,15 +153,15 @@
           }
       }
   
  -    private ArrayList getColumns() {
  +    public ArrayList getColumns() {
           return columns;
       }
   
  -    private TableBody getTableHeader() {
  +    public TableBody getTableHeader() {
           return tableHeader;
       }
   
  -    private TableBody getTableFooter() {
  +    public TableBody getTableFooter() {
           return tableFooter;
       }
   
  @@ -184,41 +184,6 @@
        */
       public String getId() {
           return id;
  -    }
  -
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     * @todo see if can/should move much of this logic into TableLayoutManager
  -     *      and/or TableBody and TableColumn FO subclasses.
  -     */
  -    public void addLayoutManager(List list) {
  -        TableLayoutManager tlm = new TableLayoutManager(this);
  -        ArrayList columns = getColumns();
  -        if (columns != null) {
  -            ArrayList columnLMs = new ArrayList();
  -            ListIterator iter = columns.listIterator();
  -            while (iter.hasNext()) {
  -                columnLMs.add(getTableColumnLayoutManager((TableColumn)iter.next()));
  -            }
  -            tlm.setColumns(columnLMs);
  -        }
  -        if (getTableHeader() != null) {
  -            tlm.setTableHeader(getTableBodyLayoutManager(getTableHeader()));
  -        }
  -        if (getTableFooter() != null) {
  -            tlm.setTableFooter(getTableBodyLayoutManager(getTableFooter()));
  -        }
  -        list.add(tlm);
  -    }
  -
  -    public Column getTableColumnLayoutManager(TableColumn node) {
  -         Column clm = new Column(node);
  -         return clm;
  -    }
  -    
  -    public Body getTableBodyLayoutManager(TableBody node) {
  -         Body blm = new Body(node);
  -         return blm;
       }
   
       /**
  
  
  
  1.35      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/TableBody.java
  
  Index: TableBody.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableBody.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- TableBody.java	29 Oct 2004 11:19:36 -0000	1.34
  +++ TableBody.java	24 Dec 2004 12:06:26 -0000	1.35
  @@ -92,14 +92,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        Body blm = new Body(this);
  -        list.add(blm);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.42      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/TableCell.java
  
  Index: TableCell.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableCell.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- TableCell.java	24 Nov 2004 21:07:29 -0000	1.41
  +++ TableCell.java	24 Dec 2004 12:06:26 -0000	1.42
  @@ -315,14 +315,6 @@
       public int getNumberRowsSpanned() {
           return Math.max(numberRowsSpanned.getValue(), 1);
       }
  -
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        Cell clm = new Cell(this);
  -        list.add(clm);
  -    }
       
       /**
        * @see org.apache.fop.fo.FObj#getName()
  
  
  
  1.43      +0 -8      xml-fop/src/java/org/apache/fop/fo/flow/TableRow.java
  
  Index: TableRow.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableRow.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- TableRow.java	29 Oct 2004 11:19:36 -0000	1.42
  +++ TableRow.java	24 Dec 2004 12:06:26 -0000	1.43
  @@ -163,14 +163,6 @@
       public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
           return commonBorderPaddingBackground;
       }
  -
  -    /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        Row rlm = new Row(this);
  -        list.add(rlm);
  -    }
       
       /**
        * @see org.apache.fop.fo.FObj#getName()
  
  
  
  1.19      +0 -15     xml-fop/src/java/org/apache/fop/fo/flow/Wrapper.java
  
  Index: Wrapper.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Wrapper.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Wrapper.java	28 Oct 2004 10:00:21 -0000	1.18
  +++ Wrapper.java	24 Dec 2004 12:06:26 -0000	1.19
  @@ -70,21 +70,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     * @todo remove null check when vCN() & endOfNode() implemented
  -     */
  -    public void addLayoutManager(List list) {
  -        ListIterator baseIter = getChildNodes();
  -        if (baseIter == null) {
  -            return;
  -        }
  -        while (baseIter.hasNext()) {
  -            FONode child = (FONode) baseIter.next();
  -            child.addLayoutManager(list);
  -        }
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.38      +1 -9      xml-fop/src/java/org/apache/fop/fo/pagination/Flow.java
  
  Index: Flow.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Flow.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- Flow.java	28 Oct 2004 10:00:23 -0000	1.37
  +++ Flow.java	24 Dec 2004 12:06:26 -0000	1.38
  @@ -139,14 +139,6 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
  -     */
  -    public void addLayoutManager(List list) {
  -        FlowLayoutManager lm = new FlowLayoutManager(this);
  -        list.add(lm);
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.35      +13 -1     xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
  
  Index: AbstractLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- AbstractLayoutManager.java	21 Dec 2004 11:28:05 -0000	1.34
  +++ AbstractLayoutManager.java	24 Dec 2004 12:06:26 -0000	1.35
  @@ -23,6 +23,7 @@
   import org.apache.fop.area.Area;
   import org.apache.fop.area.Resolvable;
   import org.apache.fop.area.PageViewport;
  +import org.apache.fop.area.AreaTreeHandler;
   import org.apache.fop.fo.Constants;
   import org.apache.fop.fo.flow.RetrieveMarker;
   import org.apache.fop.fo.flow.Marker;
  @@ -360,6 +361,16 @@
       }
   
       /**
  +     * Delegate getAreaTreeHandler to the parent layout manager.
  +     *
  +     * @see org.apache.fop.layoutmgr.LayoutManager
  +     * @return the AreaTreeHandler object.
  +     */
  +    public AreaTreeHandler getAreaTreeHandler() {
  +        return parentLM.getAreaTreeHandler();
  +    }
  +
  +    /**
        * Convenience method: preload a number of child LMs
        * @param size the requested number of child LMs
        * @return the list with the preloaded child LMs
  @@ -384,7 +395,8 @@
                       rm.bindMarker(marker);
                       foNode = rm;
                   }
  -                foNode.addLayoutManager(newLMs);
  +                getAreaTreeHandler().getLayoutManagerMaker().
  +                    makeLayoutManagers(foNode, newLMs);
               }
           }
           return newLMs;
  
  
  
  1.18      +27 -0     xml-fop/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java
  
  Index: ContentLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ContentLayoutManager.java	22 Dec 2004 18:22:35 -0000	1.17
  +++ ContentLayoutManager.java	24 Dec 2004 12:06:26 -0000	1.18
  @@ -23,6 +23,7 @@
   import org.apache.fop.fo.Constants;
   import org.apache.fop.fo.flow.Marker;
   import org.apache.fop.area.Area;
  +import org.apache.fop.area.AreaTreeHandler;
   import org.apache.fop.area.inline.InlineArea;
   import org.apache.fop.area.Resolvable;
   import org.apache.fop.area.PageViewport;
  @@ -44,6 +45,7 @@
    */
   public class ContentLayoutManager implements InlineLevelLayoutManager {
       private FOUserAgent userAgent;
  +    private AreaTreeHandler areaTreeHandler;
       private Area holder;
       private int stackSize;
       private LayoutManager parentLM;
  @@ -254,6 +256,31 @@
       /** @see org.apache.fop.layoutmgr.LayoutManager */
       public Marker retrieveMarker(String name, int pos, int boundary) {
           return parentLM.retrieveMarker(name, pos, boundary);
  +    }
  +
  +    /**
  +     * Set the AreaTreeHandler.
  +     * This is used by the PageSequenceLM for the Title,
  +     * because it does not set itself as the parentLM.
  +     * @param areaTreeHandler the area tree handler to add pages to
  +     */
  +    public void setAreaTreeHandler(AreaTreeHandler areaTreeHandler) {
  +        this.areaTreeHandler = areaTreeHandler;
  +    }
  +
  +    /**
  +     * Either areaTreeHandler or parentLM should not be null.
  +     * If areaTreeHandler is null,
  +     * delegate getAreaTreeHandler to the parent layout manager.
  +     *
  +     * @see org.apache.fop.layoutmgr.LayoutManager
  +     * @return the AreaTreeHandler object.
  +     */
  +    public AreaTreeHandler getAreaTreeHandler() {
  +        if (areaTreeHandler == null) {
  +            areaTreeHandler = parentLM.getAreaTreeHandler();
  +        }
  +        return areaTreeHandler;
       }
   
       /**
  
  
  
  1.17      +6 -0      xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManager.java
  
  Index: LayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManager.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- LayoutManager.java	10 Dec 2004 10:12:21 -0000	1.16
  +++ LayoutManager.java	24 Dec 2004 12:06:26 -0000	1.17
  @@ -26,6 +26,7 @@
   import org.apache.fop.area.Area;
   import org.apache.fop.area.Resolvable;
   import org.apache.fop.area.PageViewport;
  +import org.apache.fop.area.AreaTreeHandler;
   import org.apache.fop.fo.FObj;
   
   /**
  @@ -210,6 +211,11 @@
        * @return the layout manaager of the retrieved marker if any
        */
       Marker retrieveMarker(String name, int pos, int boundary);
  +
  +    /**
  +     * @return the AreaTreeHandler object.
  +     */
  +    AreaTreeHandler getAreaTreeHandler();
   
       /**
        * Load next child LMs, up to child LM index pos
  
  
  
  1.20      +28 -10    xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
  
  Index: PageSequenceLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- PageSequenceLayoutManager.java	22 Dec 2004 08:54:10 -0000	1.19
  +++ PageSequenceLayoutManager.java	24 Dec 2004 12:06:26 -0000	1.20
  @@ -128,20 +128,35 @@
        * This is the top level layout manager.
        * It is created by the PageSequence FO.
        *
  -     * @param areaTree the area tree to add pages to
        * @param pageseq the page sequence fo
        */
  -    public PageSequenceLayoutManager(AreaTreeHandler areaTreeHandler, PageSequence pageseq) {
  +    public PageSequenceLayoutManager(PageSequence pageseq) {
           super(pageseq);
           fobj = pageseq;
  -        this.areaTreeHandler = areaTreeHandler;
  -        areaTreeModel = areaTreeHandler.getAreaTreeModel();
           if (fobj.getPageSequenceMaster() != null) {
               fobj.getPageSequenceMaster().reset();
           }
       }
   
       /**
  +     * Set the AreaTreeHandler
  +     * @param areaTreeHandler the area tree handler to add pages to
  +     */
  +    public void setAreaTreeHandler(AreaTreeHandler areaTreeHandler) {
  +        this.areaTreeHandler = areaTreeHandler;
  +        areaTreeModel = areaTreeHandler.getAreaTreeModel();
  +    }
  +
  +    /**
  +     * @see org.apache.fop.layoutmgr.LayoutManager
  +     * @return the AreaTreeHandler object
  +     */
  +    public AreaTreeHandler getAreaTreeHandler() {
  +        return areaTreeHandler;
  +    }
  +
  +
  +    /**
        * Set the page counting for this page sequence.
        * This sets the initial page number and the page number formatter.
        *
  @@ -174,6 +189,7 @@
   
           ContentLayoutManager clm = new ContentLayoutManager(title);
           clm.setUserAgent(foTitle.getUserAgent());
  +        clm.setAreaTreeHandler(areaTreeHandler);
   
           // use special layout manager to add the inline areas
           // to the Title.
  @@ -891,12 +907,14 @@
        */
       private StaticContentLayoutManager getStaticContentLayoutManager(StaticContent sc) {
           StaticContentLayoutManager lm =
  -                (StaticContentLayoutManager)staticContentLMs.get(sc.getFlowName());
  -        if (lm != null) {
  -            return lm;
  +            (StaticContentLayoutManager)
  +            staticContentLMs.get(sc.getFlowName());
  +        if (lm == null) {
  +            lm = (StaticContentLayoutManager)
  +                getAreaTreeHandler().getLayoutManagerMaker().
  +                makeLayoutManager(sc);
  +            staticContentLMs.put(sc.getFlowName(), lm);
           }
  -        lm = new StaticContentLayoutManager(sc);
  -        staticContentLMs.put(sc.getFlowName(), lm);
           return lm;
       }
   }
  
  
  
  1.1                  xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
  
  Index: LayoutManagerMaker.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /* $Id: LayoutManagerMaker.java,v 1.1 2004/12/24 12:06:26 spepping Exp $ */
  package org.apache.fop.layoutmgr;
  
  import java.util.List;
  import org.apache.fop.fo.FONode;
  
  public interface LayoutManagerMaker {
      
      public void makeLayoutManagers(FONode node, List lms);
  
      public LayoutManager makeLayoutManager(FONode node);
  
      public LayoutManager makeLayoutManager(FONode node, boolean checkLength);
  
  }
  
  
  
  
  1.1                  xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
  
  Index: LayoutManagerMapping.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /* $Id: LayoutManagerMapping.java,v 1.1 2004/12/24 12:06:26 spepping Exp $ */
  package org.apache.fop.layoutmgr;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import java.util.ArrayList;
  import java.util.Map;
  import java.util.HashMap;
  import java.util.List;
  import java.util.ListIterator;
  import java.util.Iterator;
  
  import org.apache.fop.fo.FONode;
  import org.apache.fop.fo.FOText;
  import org.apache.fop.fo.FObj;
  import org.apache.fop.fo.FObjMixed;
  import org.apache.fop.fo.XMLObj;
  import org.apache.fop.fo.flow.BasicLink;
  import org.apache.fop.fo.flow.BidiOverride;
  import org.apache.fop.fo.flow.Block;
  import org.apache.fop.fo.flow.BlockContainer;
  import org.apache.fop.fo.flow.Character;
  import org.apache.fop.fo.flow.ExternalGraphic;
  import org.apache.fop.fo.flow.Footnote;
  import org.apache.fop.fo.flow.Inline;
  import org.apache.fop.fo.flow.InlineLevel;
  import org.apache.fop.fo.flow.InlineContainer;
  import org.apache.fop.fo.flow.InstreamForeignObject;
  import org.apache.fop.fo.flow.Leader;
  import org.apache.fop.fo.flow.ListBlock;
  import org.apache.fop.fo.flow.ListItem;
  import org.apache.fop.fo.flow.ListItemBody;
  import org.apache.fop.fo.flow.ListItemLabel;
  import org.apache.fop.fo.flow.PageNumber;
  import org.apache.fop.fo.flow.PageNumberCitation;
  import org.apache.fop.fo.flow.RetrieveMarker;
  import org.apache.fop.fo.flow.Table;
  import org.apache.fop.fo.flow.TableBody;
  import org.apache.fop.fo.flow.TableCell;
  import org.apache.fop.fo.flow.TableColumn;
  import org.apache.fop.fo.flow.TableFooter;
  import org.apache.fop.fo.flow.TableHeader;
  import org.apache.fop.fo.flow.TableRow;
  import org.apache.fop.fo.flow.Wrapper;
  import org.apache.fop.fo.pagination.Flow;
  import org.apache.fop.fo.pagination.PageSequence;
  import org.apache.fop.fo.pagination.StaticContent;
  import org.apache.fop.fo.pagination.Title;
  
  import org.apache.fop.layoutmgr.list.Item;
  import org.apache.fop.layoutmgr.list.ListBlockLayoutManager;
  import org.apache.fop.layoutmgr.list.ListItemLayoutManager;
  import org.apache.fop.layoutmgr.table.Body;
  import org.apache.fop.layoutmgr.table.Cell;
  import org.apache.fop.layoutmgr.table.Column;
  import org.apache.fop.layoutmgr.table.Row;
  import org.apache.fop.layoutmgr.table.TableLayoutManager;
  
  /**
   * The default class for creating layout managers. 
   */
  public class LayoutManagerMapping implements LayoutManagerMaker {
  
      /** logging instance */
      protected static Log log = LogFactory.getLog(LayoutManagerMapping.class);
  
      /** The map of LayoutManagerMakers */
      private Map makers = new HashMap();
  
      public LayoutManagerMapping() {
          initialize();
      }
  
      /**
       * Initializes the set of maker objects associated with this LayoutManagerMapping
       */
      private void initialize() {
      	makers.put(FOText.class, new FOTextLayoutManagerMaker());
      	makers.put(FObjMixed.class, new Maker());
      	makers.put(BidiOverride.class, new BidiOverrideLayoutManagerMaker());
      	makers.put(Inline.class, new InlineLayoutManagerMaker());
      	makers.put(Footnote.class, new FootnodeLayoutManagerMaker());
      	makers.put(InlineContainer.class,
                     new InlineContainerLayoutManagerMaker());
      	makers.put(BasicLink.class, new BasicLinkLayoutManagerMaker());
      	makers.put(Block.class, new BlockLayoutManagerMaker());
      	makers.put(Leader.class, new LeaderLayoutManagerMaker());
      	makers.put(RetrieveMarker.class, new WrapperLayoutManagerMaker());
      	makers.put(Character.class, new CharacterLayoutManagerMaker());
      	makers.put(ExternalGraphic.class,
                     new ExternalGraphicLayoutManagerMaker());
      	makers.put(BlockContainer.class,
                     new BlockContainerLayoutManagerMaker());
      	makers.put(ListItem.class, new ListItemLayoutManagerMaker());
      	makers.put(ListBlock.class, new ListBlockLayoutManagerMaker());
      	makers.put(InstreamForeignObject.class,
                     new InstreamForeignObjectLayoutManagerMaker());
      	makers.put(PageNumber.class, new PageNumberLayoutManagerMaker());
      	makers.put(PageNumberCitation.class,
                     new PageNumberCitationLayoutManagerMaker());
      	makers.put(PageSequence.class, new PageSequenceLayoutManagerMaker());
      	makers.put(Table.class, new TableLayoutManagerMaker());
      	makers.put(TableBody.class, new TableBodyLayoutManagerMaker());
      	makers.put(TableColumn.class, new TableColumnLayoutManagerMaker());
      	makers.put(TableRow.class, new TableRowLayoutManagerMaker());
      	makers.put(TableCell.class, new TableCellLayoutManagerMaker());
      	makers.put(TableFooter.class, new TableBodyLayoutManagerMaker());
      	makers.put(TableHeader.class, new TableBodyLayoutManagerMaker());
      	makers.put(Flow.class, new FlowLayoutManagerMaker());
      	makers.put(StaticContent.class, new StaticContentLayoutManagerMaker());
      	makers.put(Wrapper.class, new WrapperLayoutManagerMaker());
      	makers.put(Title.class, new InlineLayoutManagerMaker());
      }
      
      public void makeLayoutManagers(FONode node, List lms) {
      	Maker maker = (Maker) makers.get(node.getClass());
      	if (maker == null) {
              log.error("No LayoutManager maker for class " + node.getClass());
          } else {
      		maker.make(node, lms);
      	}
      }
  
      public LayoutManager makeLayoutManager(FONode node) {
          return makeLayoutManager(node, false);
      }
  
      public LayoutManager makeLayoutManager(FONode node, boolean checkLength) {
          List lms = new ArrayList();
          makeLayoutManagers(node, lms);
          LayoutManager lm = null;
          if (checkLength && lms.size() != 1) {
              log.error("More than 1 LayoutManager for class "
                        + node.getClass()
                        + "; 1 was requested"); 
          } else if (lms.size() != 0) {
              lm = (LayoutManager) lms.get(0);
          }
          return lm;
      }
  
  	public static class Maker {
  		public void make(FONode node, List lms) {
              // no layout manager
  			return;
  		}
  	}
  	
  	public static class FOTextLayoutManagerMaker extends Maker {
  		public void make(FONode node, List lms) {
  			FOText foText = (FOText) node;
  	        if (foText.endIndex - foText.startIndex > 0) {
  	        	lms.add(new TextLayoutManager(foText));
  		    }
  		}
  	}
  	
      /*
  	public static class FObjMixedLayoutManagerMaker extends Maker {
  	    public void make(FONode node, List lms) {
  	        if (node.getChildNodes() != null) {
  	            InlineStackingLayoutManager lm;
  	            lm = new InlineStackingLayoutManager((FObjMixed) node);
  	            lms.add(lm);
  	        }
  	    }		
  	}
      */
  
  	public static class BidiOverrideLayoutManagerMaker extends Maker {
          // public static class BidiOverrideLayoutManagerMaker extends FObjMixedLayoutManagerMaker {
  	    public void make(BidiOverride node, List lms) {
  	        if (false) {
                  // this is broken; it does nothing
                  // it should make something like an InlineStackingLM
  	            super.make(node, lms);
  	        } else {
  	            ArrayList childList = new ArrayList();
                  // this is broken; it does nothing
                  // it should make something like an InlineStackingLM
  	            super.make(node, childList);
  	            for (int count = childList.size() - 1; count >= 0; count--) {
  	                LayoutManager lm = (LayoutManager) childList.get(count);
  	                if (lm.generatesInlineAreas()) {
  	                    LayoutManager blm = new BidiLayoutManager
                              (node, (InlineLayoutManager) lm);
  	                    lms.add(blm);
  	                } else {
  	                    lms.add(lm);
  	                }
  	            }
  	        }
  	    }
  	}
  	
  	public static class InlineLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
               if (node.getChildNodes() != null) {
                   lms.add(new InlineLayoutManager((InlineLevel) node));
               }
  	     }
  	}
  	
  	public static class FootnodeLayoutManagerMaker extends Maker {
  	    public void make(FONode node, List lms) {
              Inline citation = ((Footnote) node).getInlineFO();
  	        if (citation != null) {
                  lms.add(new InlineLayoutManager(citation));
              }
  	    }		
  	}
  	
  	public static class InlineContainerLayoutManagerMaker extends Maker {
  	    public void make(FONode node, List lms) {
  	        ArrayList childList = new ArrayList();
  	        super.make(node, childList);
  	        lms.add(new ICLayoutManager((InlineContainer) node, childList));
  	    }		
  	}
  	
  	public static class BasicLinkLayoutManagerMaker extends Maker {
          public void make(FONode node, List lms) {
              lms.add(new BasicLinkLayoutManager((BasicLink) node));
          }
      }
  	
  	public static class BlockLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
  	         lms.add(new BlockLayoutManager((Block) node));
  	     }
  	}
  	
  	public static class LeaderLayoutManagerMaker extends Maker {
          public void make(FONode node, List lms) {
              lms.add(new LeaderLayoutManager((Leader) node));
          }
      }
  
  	public static class CharacterLayoutManagerMaker extends Maker {
          public void make(FONode node, List lms) {
              lms.add(new CharacterLayoutManager((Character) node));
          }
      }
  
  	public static class ExternalGraphicLayoutManagerMaker extends Maker {
  	    public void make(FONode node, List lms) {
              ExternalGraphic eg = (ExternalGraphic) node;
              if (!eg.getSrc().equals("")) {
                  lms.add(new ExternalGraphicLayoutManager(eg));
              }
          }
      }
  
  	public static class BlockContainerLayoutManagerMaker extends Maker {
  		public void make(FONode node, List lms) {
  	        lms.add(new BlockContainerLayoutManager((BlockContainer) node));
  	     }
  	}
  
  	public static class ListItemLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
               lms.add(new ListItemLayoutManager((ListItem) node));
  	     }		
  	}
  
  	public static class ListBlockLayoutManagerMaker extends Maker {
  		public void make(FONode node, List lms) {
  			lms.add(new ListBlockLayoutManager((ListBlock) node));
  		}
  	}
  
  	public static class InstreamForeignObjectLayoutManagerMaker extends Maker {
  		public void make(FONode node, List lms) {
              lms.add(new InstreamForeignObjectLM((InstreamForeignObject) node));
          }
      }
  
  	public static class PageNumberLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
               lms.add(new PageNumberLayoutManager((PageNumber) node));
  	     }		
  	}
  
  	public static class PageNumberCitationLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
  	     	lms.add(new PageNumberCitationLayoutManager((PageNumberCitation) node));
  	     }
      }
  
      public static class PageSequenceLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
               lms.add(new PageSequenceLayoutManager((PageSequence) node));
           }
      }
  
  	public static class TableLayoutManagerMaker extends Maker {
  		public void make(FONode node, List lms) {
  			Table table = (Table) node;
  			TableLayoutManager tlm = new TableLayoutManager(table);
  			ArrayList columns = table.getColumns();
  			if (columns != null) {
  				ArrayList columnLMs = new ArrayList();
  				ListIterator iter = columns.listIterator();
  				while (iter.hasNext()) {
                      columnLMs.add(new Column((TableColumn) node));
  				}
  				tlm.setColumns(columnLMs);
  			}
  			if (table.getTableHeader() != null) {
  				tlm.setTableHeader(new Body(table.getTableHeader()));
  			}
  			if (table.getTableFooter() != null) {
  				tlm.setTableFooter(new Body(table.getTableFooter()));
  			}
  			lms.add(tlm);
  		}
      }
  		
  	public static class TableBodyLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
  	         lms.add(new Body((TableBody) node));
  	     }
  
  	}
  	
      public static class TableColumnLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
               lms.add(new Column((TableColumn) node));
  		}		
  	}
  
  	public static class TableRowLayoutManagerMaker extends Maker {
  	    public void make(FONode node, List lms) {
  	        lms.add(new Row((TableRow) node));
  	    }
  	}
  
  	public static class TableCellLayoutManagerMaker extends Maker {
  	    public void make(FONode node, List lms) {
  	        lms.add(new Cell((TableCell) node));
  	    }
  	}
  
  	public static class FlowLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
  	         lms.add(new FlowLayoutManager((Flow) node));
  	     }
  	}
  
  	public static class StaticContentLayoutManagerMaker extends Maker {
  	     public void make(FONode node, List lms) {
  	         lms.add(new StaticContentLayoutManager((StaticContent) node));
  	     }
  	}
  
  	public class WrapperLayoutManagerMaker extends Maker {
  	    public void make(FONode node, List lms) {
  	        Iterator baseIter;
  	        baseIter = node.getChildNodes();
  	        if (baseIter == null) {
                  return;
              }
  	        while (baseIter.hasNext()) {
  	            FONode child = (FONode) baseIter.next();
  	            makeLayoutManagers(child, lms);
  	        }
  	    }		
  	}
  
  }
  
  
  

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


Re: cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LayoutManagerMaker.java LayoutManagerMapping.java AbstractLayoutManager.java ContentLayoutManager.java LayoutManager.java PageSequenceLayoutManager.java

Posted by Glen Mazza <gr...@yahoo.com>.
Simon, 

Will you please comment this method--the purpose of
checkLength is not obvious in meaning at least to me.

Thanks,
Glen

--- spepping@apache.org wrote:

>       public LayoutManager makeLayoutManager(FONode
> node, boolean checkLength) {
>           List lms = new ArrayList();
>           makeLayoutManagers(node, lms);
>           LayoutManager lm = null;
>           if (checkLength && lms.size() != 1) {
>               log.error("More than 1 LayoutManager
> for class "
>                         + node.getClass()
>                         + "; 1 was requested"); 
>           } else if (lms.size() != 0) {
>               lm = (LayoutManager) lms.get(0);
>           }
>           return lm;
>       }
>