gmazza      2004/08/06 08:41:12

  Modified:    src/java/org/apache/fop/fo FOText.java FObjMixed.java
               src/java/org/apache/fop/fo/flow BasicLink.java
                        BidiOverride.java Block.java BlockContainer.java
                        ExternalGraphic.java Footnote.java
                        InlineContainer.java ListBlock.java
                        PageNumberCitation.java TableCell.java
                        TableRow.java
               src/java/org/apache/fop/fo/pagination Flow.java
               src/java/org/apache/fop/layoutmgr AddLMVisitor.java
  Log:
  Moved three FO's from AddLMVisitor->FObj.AddLayoutManager(); will eventually need to 
create additional LM's for at least two of them to remove the Area-specific code these 
FO's now have.
  
  Revision  Changes    Path
  1.23      +1 -1      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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- FOText.java       6 Aug 2004 04:22:15 -0000       1.22
  +++ FOText.java       6 Aug 2004 15:41:10 -0000       1.23
  @@ -493,7 +493,7 @@
       }
   
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           if (endIndex - startIndex > 0) {
  
  
  
  1.31      +1 -1      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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- FObjMixed.java    6 Aug 2004 04:22:15 -0000       1.30
  +++ FObjMixed.java    6 Aug 2004 15:41:10 -0000       1.31
  @@ -76,7 +76,7 @@
       }
   
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           if (getChildNodes() != null) {
  
  
  
  1.22      +49 -27    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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- BasicLink.java    6 Aug 2004 04:22:15 -0000       1.21
  +++ BasicLink.java    6 Aug 2004 15:41:10 -0000       1.22
  @@ -18,29 +18,38 @@
   
   package org.apache.fop.fo.flow;
   
  +// Java
  +import java.util.List;
  +
   // XML
   import org.xml.sax.Attributes;
   import org.xml.sax.Locator;
   import org.xml.sax.SAXParseException;
   
   // FOP
  +import org.apache.fop.area.inline.InlineArea;
  +import org.apache.fop.area.inline.InlineParent;
  +import org.apache.fop.area.LinkResolver;
  +import org.apache.fop.area.PageViewport;
  +import org.apache.fop.area.Trait;
   import org.apache.fop.fo.FOElementMapping;
   import org.apache.fop.fo.FONode;
  -import org.apache.fop.layoutmgr.AddLMVisitor;
  +import org.apache.fop.layoutmgr.LayoutManager;
  +import org.apache.fop.layoutmgr.LMiter;
  +import org.apache.fop.layoutmgr.InlineStackingLayoutManager;
   import org.apache.fop.fo.properties.CommonAccessibility;
   import org.apache.fop.fo.properties.CommonAural;
   import org.apache.fop.fo.properties.CommonBorderAndPadding;
   import org.apache.fop.fo.properties.CommonBackground;
   import org.apache.fop.fo.properties.CommonMarginInline;
   import org.apache.fop.fo.properties.CommonRelativePosition;
  -import org.apache.fop.fo.LMVisited;
   
   /**
    * The basic link.
    * This sets the basic link trait on the inline parent areas
    * that are created by the fo element.
    */
  -public class BasicLink extends Inline implements LMVisited {
  +public class BasicLink extends Inline {
       private String link = null;
       private boolean external = false;
   
  @@ -105,24 +114,6 @@
       }
   
       /**
  -     * @return the String value of the link
  -     */
  -    public String getLink() {
  -        return link;
  -    }
  -
  -    /**
  -     * @return true if the link is external, false otherwise
  -     */
  -    public boolean getExternal() {
  -        return external;
  -    }
  -
  -    public String getName() {
  -        return "fo:basic-link";
  -    }
  -
  -    /**
        * @return true (BasicLink can contain Markers)
       */
       protected boolean containsMarkers() {
  @@ -130,11 +121,42 @@
       }
   
       /**
  -     * This is a hook for the AddLMVisitor class to be able to access
  -     * this object.
  -     * @param aLMV the AddLMVisitor object that can access this object.
  -     */
  -    public void acceptVisitor(AddLMVisitor aLMV) {
  -        aLMV.serveBasicLink(this);
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
  +     * @todo create a subclass for InlineStackingLayoutManager, moving the 
formatting
  +     *  logic to the layoutmgr package
  +    */
  +    public void addLayoutManager(List list) {         
  +        InlineStackingLayoutManager lm;
  +        lm = new InlineStackingLayoutManager(this) {
  +            protected InlineParent createArea() {
  +                InlineParent area = super.createArea();
  +                setupBasicLinkArea(parentLM, area);
  +                return area;
  +            }
  +        };
  +        lm.setLMiter(new LMiter(lm, getChildNodes()));
  +        list.add(lm);
  +    }
  +     
  +    protected void setupBasicLinkArea(LayoutManager parentLM,
  +                                      InlineParent area) {
  +         if (link == null) {
  +             return;
  +         }
  +         if (external) {
  +             area.addTrait(Trait.EXTERNAL_LINK, link);
  +         } else {
  +             PageViewport page = parentLM.resolveRefID(link);
  +             if (page != null) {
  +                 area.addTrait(Trait.INTERNAL_LINK, page.getKey());
  +             } else {
  +                 LinkResolver res = new LinkResolver(link, area);
  +                 parentLM.addUnresolvedArea(link, res);
  +             }
  +         }
  +     }
  +     
  +    public String getName() {
  +        return "fo:basic-link";
       }
   }
  
  
  
  1.13      +1 -3      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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- BidiOverride.java 6 Aug 2004 04:22:15 -0000       1.12
  +++ BidiOverride.java 6 Aug 2004 15:41:10 -0000       1.13
  @@ -119,9 +119,7 @@
       }
   
       /**
  -     * This is a hook for the AddLMVisitor class to be able to access
  -     * this object.
  -     * @param aLMV the AddLMVisitor object that can access this object.
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           if (false) {
  
  
  
  1.28      +1 -1      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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Block.java        6 Aug 2004 04:22:15 -0000       1.27
  +++ Block.java        6 Aug 2004 15:41:10 -0000       1.28
  @@ -340,7 +340,7 @@
       }
   
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           BlockLayoutManager blm = new BlockLayoutManager(this);
  
  
  
  1.15      +1 -1      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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- BlockContainer.java       6 Aug 2004 04:22:15 -0000       1.14
  +++ BlockContainer.java       6 Aug 2004 15:41:10 -0000       1.15
  @@ -134,7 +134,7 @@
       }
   
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           BlockContainerLayoutManager blm = new BlockContainerLayoutManager(this);
  
  
  
  1.33      +51 -11    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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- ExternalGraphic.java      6 Aug 2004 04:22:15 -0000       1.32
  +++ ExternalGraphic.java      6 Aug 2004 15:41:10 -0000       1.33
  @@ -19,6 +19,7 @@
   package org.apache.fop.fo.flow;
   
   // Java
  +import java.util.List;
   import java.awt.geom.Rectangle2D;
   
   // XML
  @@ -26,21 +27,25 @@
   import org.xml.sax.Locator;
   import org.xml.sax.SAXParseException;
   
  +import org.apache.fop.area.inline.Image;
  +import org.apache.fop.area.inline.InlineArea;
  +import org.apache.fop.area.inline.Viewport;
   import org.apache.fop.datatypes.Length;
  +import org.apache.fop.fo.properties.CommonBorderAndPadding;
  +import org.apache.fop.fo.properties.CommonBackground;
   import org.apache.fop.fo.FONode;
  -import org.apache.fop.layoutmgr.AddLMVisitor;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.image.FopImage;
   import org.apache.fop.image.ImageFactory;
  -import org.xml.sax.Attributes;
  -import org.apache.fop.fo.LMVisited;
  +import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
  +import org.apache.fop.layoutmgr.TraitSetter;
   
   /**
    * External graphic formatting object.
    * This FO node handles the external graphic. It creates an image
    * inline area that can be added to the area tree.
    */
  -public class ExternalGraphic extends FObj implements LMVisited {
  +public class ExternalGraphic extends FObj {
       private String url;
       private int breakAfter;
       private int breakBefore;
  @@ -85,6 +90,7 @@
        * This gets the sizes for the image and the dimensions and clipping.
        */
       private void setup() {
  +        setupID();
           url = this.propertyList.get(PR_SRC).getString();
           if (url == null) {
               return;
  @@ -251,12 +257,46 @@
       }
   
       /**
  -     * This is a hook for the AddLMVisitor class to be able to access
  -     * this object.
  -     * @param aLMV the AddLMVisitor object that can access this object.
  -     */
  -    public void acceptVisitor(AddLMVisitor aLMV) {
  -       setup();
  -       aLMV.serveExternalGraphic(this);
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
  +    */
  +    public void addLayoutManager(List list) {
  +        setup();
  +        InlineArea area = getExternalGraphicInlineArea();
  +        if (area != null) {
  +            LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this);
  +            lm.setCurrentArea(area);
  +            lm.setAlignment(getProperty(PR_VERTICAL_ALIGN).getEnum());
  +            lm.setLead(getViewHeight());
  +            list.add(lm);
  +        }
       }
  +
  +     /**
  +      * Get the inline area for this external grpahic.
  +      * This creates the image area and puts it inside a viewport.
  +      *
  +      * @return the viewport containing the image area
  +      * @todo see if can move to LM classes.
  +      */
  +     public InlineArea getExternalGraphicInlineArea() {
  +         if (getURL() == null) {
  +             return null;
  +         }
  +         Image imArea = new Image(getURL());
  +         Viewport vp = new Viewport(imArea);
  +         vp.setWidth(getViewWidth());
  +         vp.setHeight(getViewHeight());
  +         vp.setClip(getClip());
  +         vp.setContentPosition(getPlacement());
  +         vp.setOffset(0);
  +
  +         // Common Border, Padding, and Background Properties
  +         CommonBorderAndPadding bap = getPropertyManager().getBorderAndPadding();
  +         CommonBackground bProps = getPropertyManager().getBackgroundProps();
  +         TraitSetter.addBorders(vp, bap);
  +         TraitSetter.addBackground(vp, bProps);
  +
  +         return vp;
  +     }
  +    
   }
  
  
  
  1.19      +1 -1      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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Footnote.java     6 Aug 2004 04:22:15 -0000       1.18
  +++ Footnote.java     6 Aug 2004 15:41:10 -0000       1.19
  @@ -82,7 +82,7 @@
       }
       
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           if (getInlineFO() == null) {
  
  
  
  1.14      +1 -1      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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- InlineContainer.java      6 Aug 2004 04:22:16 -0000       1.13
  +++ InlineContainer.java      6 Aug 2004 15:41:10 -0000       1.14
  @@ -94,7 +94,7 @@
       }
   
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           ArrayList childList = new ArrayList();
  
  
  
  1.20      +1 -1      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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ListBlock.java    6 Aug 2004 04:22:16 -0000       1.19
  +++ ListBlock.java    6 Aug 2004 15:41:10 -0000       1.20
  @@ -102,7 +102,7 @@
       }
   
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           ListBlockLayoutManager lm = new ListBlockLayoutManager(this);
  
  
  
  1.29      +85 -23    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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- PageNumberCitation.java   6 Aug 2004 04:22:16 -0000       1.28
  +++ PageNumberCitation.java   6 Aug 2004 15:41:11 -0000       1.29
  @@ -18,6 +18,9 @@
   
   package org.apache.fop.fo.flow;
   
  +// Java
  +import java.util.List;
  +
   // XML
   import org.xml.sax.Attributes;
   import org.xml.sax.Locator;
  @@ -25,7 +28,6 @@
   
   import org.apache.fop.datatypes.ColorType;
   import org.apache.fop.fo.FONode;
  -import org.apache.fop.layoutmgr.AddLMVisitor;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.properties.CommonAccessibility;
   import org.apache.fop.fo.properties.CommonAural;
  @@ -34,8 +36,16 @@
   import org.apache.fop.fo.properties.CommonMarginInline;
   import org.apache.fop.fo.properties.CommonRelativePosition;
   import org.apache.fop.fonts.Font;
  -import org.apache.fop.fo.LMVisited;
  -
  +import org.apache.fop.layoutmgr.LayoutContext;        
  +import org.apache.fop.layoutmgr.LayoutManager;        
  +import org.apache.fop.layoutmgr.LeafNodeLayoutManager;        
  +import org.apache.fop.layoutmgr.PositionIterator;
  +import org.apache.fop.area.PageViewport;      
  +import org.apache.fop.area.Resolveable;       
  +import org.apache.fop.area.Trait;     
  +import org.apache.fop.area.inline.InlineArea;         
  +import org.apache.fop.area.inline.UnresolvedPageNumber;       
  +import org.apache.fop.area.inline.TextArea;
   
   /**
    * Class modelling the fo:page-number-citation object. See Sec. 6.6.11 of the
  @@ -44,7 +54,7 @@
    * The page number used is the page that contains the start of the
    * block referenced with the ref-id attribute.
    */
  -public class PageNumberCitation extends FObj implements LMVisited {
  +public class PageNumberCitation extends FObj {
       /** Fontstate for this object **/
       protected Font fontState;
   
  @@ -106,22 +116,7 @@
           CommonRelativePosition mRelProps =
             propMgr.getRelativePositionProps();
   
  -        // this.propertyList.get("alignment-adjust");
  -        // this.propertyList.get("alignment-baseline");
  -        // this.propertyList.get("baseline-shift");
  -        // this.propertyList.get("dominant-baseline");
           setupID();
  -        // this.propertyList.get("keep-with-next");
  -        // this.propertyList.get("keep-with-previous");
  -        // this.propertyList.get("letter-spacing");
  -        // this.propertyList.get("line-height");
  -        // this.propertyList.get("line-height-shift-adjustment");
  -        // this.propertyList.get("ref-id");
  -        // this.propertyList.get("score-spaces");
  -        // this.propertyList.get("text-decoration");
  -        // this.propertyList.get("text-shadow");
  -        // this.propertyList.get("text-transform");
  -        // this.propertyList.get("word-spacing");
   
           ColorType c = this.propertyList.get(PR_COLOR).getColorType();
           this.red = c.getRed();
  @@ -157,8 +152,75 @@
           return "fo:page-number-citation";
       }
   
  -    public void acceptVisitor(AddLMVisitor aLMV) {
  -       setup();
  -       aLMV.servePageNumberCitation(this);
  -    }
  +    /**
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
  +     * @todo create a subclass for LeafNodeLayoutManager, moving the formatting
  +     *  logic to the layoutmgr package
  +     */
  +    public void addLayoutManager(List list) {         
  +        setup();
  +        LayoutManager lm;
  +        lm = new LeafNodeLayoutManager(this) {
  +                 public InlineArea get(LayoutContext context) {
  +                     curArea = getPageNumberCitationInlineArea(parentLM);
  +                     return curArea;
  +                 }
  +    
  +                 public void addAreas(PositionIterator posIter,
  +                                      LayoutContext context) {
  +                     super.addAreas(posIter, context);
  +                     if (getUnresolved()) {
  +                         parentLM.addUnresolvedArea(getRefId(),
  +                                                    (Resolveable) curArea);
  +                     }
  +                 }
  +    
  +                 protected void offsetArea(LayoutContext context) {
  +                     curArea.setOffset(context.getBaseline());
  +                 }
  +             };
  +        list.add(lm);         
  +    }
  +
  +     // if id can be resolved then simply return a word, otherwise
  +     // return a resolveable area
  +     public InlineArea getPageNumberCitationInlineArea(LayoutManager parentLM) {
  +         if (getRefId().equals("")) {
  +             getLogger().error("page-number-citation must contain \"ref-id\"");
  +             return null;
  +         }
  +         PageViewport page = parentLM.resolveRefID(getRefId());
  +         InlineArea inline = null;
  +         if (page != null) {
  +             String str = page.getPageNumber();
  +             // get page string from parent, build area
  +             TextArea text = new TextArea();
  +             inline = text;
  +             int width = getStringWidth(str);
  +             text.setTextArea(str);
  +             inline.setIPD(width);
  +             inline.setHeight(getFontState().getAscender()
  +                              - getFontState().getDescender());
  +             inline.setOffset(getFontState().getAscender());
  +
  +             inline.addTrait(Trait.FONT_NAME, getFontState().getFontName());
  +             inline.addTrait(Trait.FONT_SIZE,
  +                             new Integer(getFontState().getFontSize()));
  +             setUnresolved(false);
  +         } else {
  +             setUnresolved(true);
  +             inline = new UnresolvedPageNumber(getRefId());
  +             String str = "MMM"; // reserve three spaces for page number
  +             int width = getStringWidth(str);
  +             inline.setIPD(width);
  +             inline.setHeight(getFontState().getAscender()
  +                              - getFontState().getDescender());
  +             inline.setOffset(getFontState().getAscender());
  +
  +             inline.addTrait(Trait.FONT_NAME, getFontState().getFontName());
  +             inline.addTrait(Trait.FONT_SIZE,
  +                             new Integer(getFontState().getFontSize()));
  +         }
  +         return inline;
  +     }
   }
  
  
  
  1.23      +1 -1      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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- TableCell.java    6 Aug 2004 04:22:16 -0000       1.22
  +++ TableCell.java    6 Aug 2004 15:41:11 -0000       1.23
  @@ -342,7 +342,7 @@
       }
   
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           Cell clm = new Cell(this);
  
  
  
  1.25      +1 -1      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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- TableRow.java     6 Aug 2004 04:22:16 -0000       1.24
  +++ TableRow.java     6 Aug 2004 15:41:11 -0000       1.25
  @@ -138,7 +138,7 @@
       }
   
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           Row rlm = new Row(this);
  
  
  
  1.24      +2 -2      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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Flow.java 6 Aug 2004 04:22:18 -0000       1.23
  +++ Flow.java 6 Aug 2004 15:41:12 -0000       1.24
  @@ -172,7 +172,7 @@
       }
   
       /**
  -     * @param list the list to which the layout manager(s) should be added
  +     * @see org.apache.fop.fo.FObj#addLayoutManager(List)
        */
       public void addLayoutManager(List list) {         
           FlowLayoutManager lm = new FlowLayoutManager(this);
  
  
  
  1.49      +13 -163   xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
  
  Index: AddLMVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- AddLMVisitor.java 6 Aug 2004 04:22:18 -0000       1.48
  +++ AddLMVisitor.java 6 Aug 2004 15:41:12 -0000       1.49
  @@ -25,9 +25,6 @@
   import java.util.List;
   import java.util.ListIterator;
   
  -import org.apache.fop.area.LinkResolver;
  -import org.apache.fop.area.PageViewport;
  -import org.apache.fop.area.Resolveable;
   import org.apache.fop.area.Trait;
   import org.apache.fop.area.inline.FilledArea;
   import org.apache.fop.area.inline.ForeignObject;
  @@ -43,10 +40,8 @@
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.XMLObj;
  -import org.apache.fop.fo.flow.BasicLink;
   import org.apache.fop.fo.flow.Block;
   import org.apache.fop.fo.flow.Character;
  -import org.apache.fop.fo.flow.ExternalGraphic;
   import org.apache.fop.fo.flow.Inline;
   import org.apache.fop.fo.flow.InstreamForeignObject;
   import org.apache.fop.fo.flow.Leader;
  @@ -54,7 +49,6 @@
   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.TableAndCaption;
  @@ -126,39 +120,22 @@
       }
   
       /**
  -     * Add start and end properties for the link
  +     * @param node Wrapper object to process
        */
  -    public void serveBasicLink(final BasicLink node) {
  -        InlineStackingLayoutManager lm;
  -        lm = new InlineStackingLayoutManager(node) {
  -            protected InlineParent createArea() {
  -                InlineParent area = super.createArea();
  -                setupBasicLinkArea(node, parentLM, area);
  -                return area;
  +    public void serveWrapper(Wrapper node) {
  +        ListIterator baseIter;
  +        baseIter = node.getChildNodes();
  +        if (baseIter == null) return;
  +        while (baseIter.hasNext()) {
  +            FObj child = (FObj) baseIter.next();
  +            if (child instanceof LMVisited) {
  +                ((LMVisited) child).acceptVisitor(this);
  +            } else {
  +                child.addLayoutManager(currentLMList);
               }
  -        };
  -        lm.setLMiter(new LMiter(lm, node.getChildNodes()));
  -        currentLMList.add(lm);
  +        }
       }
   
  -    protected void setupBasicLinkArea(BasicLink node, LayoutManager parentLM,
  -                                      InlineParent area) {
  -         if (node.getLink() == null) {
  -             return;
  -         }
  -         if (node.getExternal()) {
  -             area.addTrait(Trait.EXTERNAL_LINK, node.getLink());
  -         } else {
  -             PageViewport page = parentLM.resolveRefID(node.getLink());
  -             if (page != null) {
  -                 area.addTrait(Trait.INTERNAL_LINK, page.getKey());
  -             } else {
  -                 LinkResolver res = new LinkResolver(node.getLink(), area);
  -                 parentLM.addUnresolvedArea(node.getLink(), res);
  -             }
  -         }
  -     }
  -
        public void serveLeader(final Leader node) {
            LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node) {
                public InlineArea get(LayoutContext context) {
  @@ -285,49 +262,6 @@
            return null;
        }
   
  -     /**
  -      * This adds a leafnode layout manager that deals with the
  -      * created viewport/image area.
  -      */
  -     public void serveExternalGraphic(ExternalGraphic node) {
  -         InlineArea area = getExternalGraphicInlineArea(node);
  -         if (area != null) {
  -             node.setupID();
  -             LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node);
  -             lm.setCurrentArea(area);
  -             
lm.setAlignment(node.getProperty(Constants.PR_VERTICAL_ALIGN).getEnum());
  -             lm.setLead(node.getViewHeight());
  -             currentLMList.add(lm);
  -         }
  -     }
  -
  -     /**
  -      * Get the inline area for this external grpahic.
  -      * This creates the image area and puts it inside a viewport.
  -      *
  -      * @return the viewport containing the image area
  -      */
  -     public InlineArea getExternalGraphicInlineArea(ExternalGraphic node) {
  -         if (node.getURL() == null) {
  -             return null;
  -         }
  -         Image imArea = new Image(node.getURL());
  -         Viewport vp = new Viewport(imArea);
  -         vp.setWidth(node.getViewWidth());
  -         vp.setHeight(node.getViewHeight());
  -         vp.setClip(node.getClip());
  -         vp.setContentPosition(node.getPlacement());
  -         vp.setOffset(0);
  -
  -         // Common Border, Padding, and Background Properties
  -         CommonBorderAndPadding bap = 
node.getPropertyManager().getBorderAndPadding();
  -         CommonBackground bProps = node.getPropertyManager().getBackgroundProps();
  -         TraitSetter.addBorders(vp, bap);
  -         TraitSetter.addBackground(vp, bProps);
  -
  -         return vp;
  -     }
  -
        public void serveInstreamForeignObject(InstreamForeignObject node) {
            Viewport areaCurrent = getInstreamForeignObjectInlineArea(node);
            if (areaCurrent != null) {
  @@ -552,73 +486,6 @@
            currentLMList.add(lm);
        }
   
  -     public void servePageNumberCitation(final PageNumberCitation node) {
  -         LayoutManager lm;
  -         lm = new LeafNodeLayoutManager(node) {
  -                     public InlineArea get(LayoutContext context) {
  -                         curArea = getPageNumberCitationInlineArea(node, parentLM);
  -                         return curArea;
  -                     }
  -
  -                     public void addAreas(PositionIterator posIter,
  -                                          LayoutContext context) {
  -                         super.addAreas(posIter, context);
  -                         if (node.getUnresolved()) {
  -                             parentLM.addUnresolvedArea(node.getRefId(),
  -                                                        (Resolveable) curArea);
  -                         }
  -                     }
  -
  -                     protected void offsetArea(LayoutContext context) {
  -                         curArea.setOffset(context.getBaseline());
  -                     }
  -                 };
  -         currentLMList.add(lm);
  -     }
  -
  -     // if id can be resolved then simply return a word, otherwise
  -     // return a resolveable area
  -     public InlineArea getPageNumberCitationInlineArea(PageNumberCitation node,
  -             LayoutManager parentLM) {
  -         if (node.getRefId().equals("")) {
  -             node.getLogger().error("page-number-citation must contain \"ref-id\"");
  -             return null;
  -         }
  -         PageViewport page = parentLM.resolveRefID(node.getRefId());
  -         InlineArea inline = null;
  -         if (page != null) {
  -             String str = page.getPageNumber();
  -             // get page string from parent, build area
  -             TextArea text = new TextArea();
  -             inline = text;
  -             int width = node.getStringWidth(str);
  -             text.setTextArea(str);
  -             inline.setIPD(width);
  -             inline.setHeight(node.getFontState().getAscender()
  -                              - node.getFontState().getDescender());
  -             inline.setOffset(node.getFontState().getAscender());
  -
  -             inline.addTrait(Trait.FONT_NAME, node.getFontState().getFontName());
  -             inline.addTrait(Trait.FONT_SIZE,
  -                             new Integer(node.getFontState().getFontSize()));
  -             node.setUnresolved(false);
  -         } else {
  -             node.setUnresolved(true);
  -             inline = new UnresolvedPageNumber(node.getRefId());
  -             String str = "MMM"; // reserve three spaces for page number
  -             int width = node.getStringWidth(str);
  -             inline.setIPD(width);
  -             inline.setHeight(node.getFontState().getAscender()
  -                              - node.getFontState().getDescender());
  -             inline.setOffset(node.getFontState().getAscender());
  -
  -             inline.addTrait(Trait.FONT_NAME, node.getFontState().getFontName());
  -             inline.addTrait(Trait.FONT_SIZE,
  -                             new Integer(node.getFontState().getFontSize()));
  -         }
  -         return inline;
  -     }
  -
        public void serveTable(Table node) {
            TableLayoutManager tlm = new TableLayoutManager(node);
            ArrayList columns = node.getColumns();
  @@ -666,22 +533,5 @@
        */
       public void serveTableHeader(TableHeader node) {
           serveTableBody((TableBody)node);
  -    }
  -
  -    /**
  -     * @param node Wrapper object to process
  -     */
  -    public void serveWrapper(Wrapper node) {
  -        ListIterator baseIter;
  -        baseIter = node.getChildNodes();
  -        if (baseIter == null) return;
  -        while (baseIter.hasNext()) {
  -            FObj child = (FObj) baseIter.next();
  -            if (child instanceof LMVisited) {
  -                ((LMVisited) child).acceptVisitor(this);
  -            } else {
  -                child.addLayoutManager(currentLMList);
  -            }
  -        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to