gmazza      2004/08/08 10:52:35

  Modified:    src/java/org/apache/fop/fo/flow PageNumber.java
               src/java/org/apache/fop/layoutmgr AddLMVisitor.java
  Added:       src/java/org/apache/fop/layoutmgr
                        PageNumberLayoutManager.java
  Log:
  Moved fo:page-number layout code from AddLMVisitor to new PageNumberLayoutManager 
class.
  
  Revision  Changes    Path
  1.32      +13 -53    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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- PageNumber.java   6 Aug 2004 04:22:16 -0000       1.31
  +++ PageNumber.java   8 Aug 2004 17:52:35 -0000       1.32
  @@ -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;
  @@ -26,23 +29,15 @@
   // FOP
   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;
  -import org.apache.fop.fo.properties.CommonBackground;
  -import org.apache.fop.fo.properties.CommonBorderAndPadding;
  -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.PageNumberLayoutManager;
   
   /**
    * Class modelling the fo:page-number object. See Sec. 6.6.10 of the XSL-FO
    * Standard.
    */
  -public class PageNumber extends FObj implements LMVisited {
  +public class PageNumber extends FObj {
       /** FontState for this object */
       protected Font fontState;
   
  @@ -77,42 +72,10 @@
       }
   
       private void setup() {
  -
  -        // Common Accessibility Properties
  -        CommonAccessibility mAccProps = propMgr.getAccessibilityProps();
  -
  -        // Common Aural Properties
  -        CommonAural mAurProps = propMgr.getAuralProps();
  -
  -        // Common Border, Padding, and Background Properties
  -        CommonBorderAndPadding bap = propMgr.getBorderAndPadding();
  -        CommonBackground bProps = propMgr.getBackgroundProps();
  -
           // Common Font Properties
           this.fontState = propMgr.getFontState(getFOInputHandler().getFontInfo());
   
  -        // Common Margin Properties-Inline
  -        CommonMarginInline mProps = propMgr.getMarginInlineProps();
  -
  -        // Common Relative Position Properties
  -        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("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();
  @@ -120,7 +83,6 @@
           this.blue = c.getBlue();
   
           this.wrapOption = this.propertyList.get(PR_WRAP_OPTION).getEnum();
  -
       }
   
       /**
  @@ -134,17 +96,15 @@
           getFOInputHandler().endPageNumber(this);
       }
       
  -    public String getName() {
  -        return "fo:page-number";
  -    }
  -    
       /**
  -     * 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 acceptVisitor(AddLMVisitor aLMV) {
  -       setup();
  -       aLMV.servePageNumber(this);
  +    public void addLayoutManager(List list) {         
  +        PageNumberLayoutManager lm = new PageNumberLayoutManager(this);
  +        list.add(lm);
  +    }
  +
  +    public String getName() {
  +        return "fo:page-number";
       }
   }
  
  
  
  1.51      +1 -40     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.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- AddLMVisitor.java 7 Aug 2004 13:01:17 -0000       1.50
  +++ AddLMVisitor.java 8 Aug 2004 17:52:35 -0000       1.51
  @@ -32,7 +32,6 @@
   import org.apache.fop.area.inline.InlineArea;
   import org.apache.fop.area.inline.InlineParent;
   import org.apache.fop.area.inline.Space;
  -import org.apache.fop.area.inline.UnresolvedPageNumber;
   import org.apache.fop.area.inline.Viewport;
   import org.apache.fop.area.inline.TextArea;
   import org.apache.fop.datatypes.Length;
  @@ -45,7 +44,6 @@
   import org.apache.fop.fo.flow.Inline;
   import org.apache.fop.fo.flow.InstreamForeignObject;
   import org.apache.fop.fo.flow.Leader;
  -import org.apache.fop.fo.flow.PageNumber;
   import org.apache.fop.fo.flow.RetrieveMarker;
   import org.apache.fop.fo.flow.Table;
   import org.apache.fop.fo.flow.TableAndCaption;
  @@ -415,43 +413,6 @@
            areaCurrent.setOffset(0);
   
            return areaCurrent;
  -     }
  -
  -     /**
  -      * Overridden from FObj
  -      * @param lms the list to which the layout manager(s) should be added
  -      */
  -     public void servePageNumber(final PageNumber node) {
  -         LayoutManager lm;
  -         lm = new LeafNodeLayoutManager(node) {
  -                     public InlineArea get(LayoutContext context) {
  -                         // get page string from parent, build area
  -                         TextArea inline = new TextArea();
  -                         String str = parentLM.getCurrentPageNumber();
  -                         int width = 0;
  -                     for (int count = 0; count < str.length(); count++) {
  -                             width += node.getFontState().getCharWidth(
  -                                        str.charAt(count));
  -                         }
  -                         inline.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()));
  -
  -                         return inline;
  -                     }
  -
  -                     protected void offsetArea(LayoutContext context) {
  -                         curArea.setOffset(context.getBaseline());
  -                     }
  -                 };
  -         currentLMList.add(lm);
        }
   
        public void serveTable(Table node) {
  
  
  
  1.1                  
xml-fop/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java
  
  Index: PageNumberLayoutManager.java
  ===================================================================
  /*
   * Copyright 1999-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: PageNumberLayoutManager.java,v 1.1 2004/08/08 17:52:35 gmazza Exp $ */
  
  package org.apache.fop.layoutmgr;
  
  import org.apache.fop.fo.flow.PageNumber;
  import org.apache.fop.area.inline.InlineArea;
  import org.apache.fop.area.inline.TextArea;
  import org.apache.fop.area.Trait;
  import org.apache.fop.fonts.Font;
  
  /**
   * LayoutManager for the fo:basic-link formatting object
   */
  public class PageNumberLayoutManager extends LeafNodeLayoutManager {
  
      Font font = null;
      
      /**
       * Constructor
       *
       * @param node the fo:page-number formatting object that creates the area
       * @todo better null checking of node, font
       */
      public PageNumberLayoutManager(PageNumber node) {
          super(node);
          font = node.getFontState();
      }
  
      public InlineArea get(LayoutContext context) {
          // get page string from parent, build area
          TextArea inline = new TextArea();
          String str = parentLM.getCurrentPageNumber();
          int width = 0;
          for (int count = 0; count < str.length(); count++) {
              width += font.getCharWidth(str.charAt(count));
          }
          inline.setTextArea(str);
          inline.setIPD(width);
          inline.setHeight(font.getAscender() - font.getDescender());
          inline.setOffset(font.getAscender());
          inline.addTrait(Trait.FONT_NAME, font.getFontName());
          inline.addTrait(Trait.FONT_SIZE,
                          new Integer(font.getFontSize()));
  
          return inline;
      }
      
      protected void offsetArea(LayoutContext context) {
          curArea.setOffset(context.getBaseline());
      }
  }
  
  
  
  

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

Reply via email to