gmazza      2004/08/13 05:29:51

  Modified:    src/java/org/apache/fop/fo FObj.java
               src/java/org/apache/fop/fo/flow Character.java
                        FootnoteBody.java
               src/java/org/apache/fop/layoutmgr AddLMVisitor.java
  Added:       src/java/org/apache/fop/layoutmgr
                        CharacterLayoutManager.java
  Log:
  1. Character LM initialization moved from AllLMVisitor to fo.Character.
  
  2. Character layout logic moved from AllLMVisitor to new CharacterLayoutManager.
  
  3. validateChildNode() implemented for fo:footnote-body.
  
  Revision  Changes    Path
  1.66      +11 -9     xml-fop/src/java/org/apache/fop/fo/FObj.java
  
  Index: FObj.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObj.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- FObj.java 11 Aug 2004 04:15:25 -0000      1.65
  +++ FObj.java 13 Aug 2004 12:29:51 -0000      1.66
  @@ -79,10 +79,12 @@
           if (parent != null && parent instanceof FObj) {
               if (((FObj)parent).getIsOutOfLineFODescendant() == true) {
                   isOutOfLineFODescendant = true;
  -            } else if ("fo:float".equals(getName())
  -                || "fo:footnote".equals(getName())
  -                || "fo:footnote-body".equals(getName())) {
  -                isOutOfLineFODescendant = true;
  +            } else {
  +                int foID = getNameId();
  +                if (foID == FO_FLOAT || foID == FO_FOOTNOTE
  +                    || foID == FO_FOOTNOTE_BODY) {
  +                        isOutOfLineFODescendant = true;
  +                }
               }
           }
           
  @@ -114,10 +116,10 @@
           PropertyList parentPL = null;
   
           if (parentFO != null) {
  -            parentPL = parentFO.getPropertiesForNamespace(FOElementMapping.URI);
  +            parentPL = parentFO.getPropertiesForNamespace(FO_URI);
           }
   
  -        propertyList = new PropertyList(this, parentPL, FOElementMapping.URI);
  +        propertyList = new PropertyList(this, parentPL, FO_URI);
           propertyList.addAttributesToList(attlist);
           propMgr = new PropertyManager(propertyList);
           setWritingMode();
  @@ -457,7 +459,7 @@
        * @return true if a member, false if not
        */
       protected boolean isBlockItem(String nsURI, String lName) {
  -        return (nsURI == FOElementMapping.URI && 
  +        return (nsURI == FO_URI && 
               (lName.equals("block") 
               || lName.equals("table") 
               || lName.equals("table-and-caption") 
  @@ -476,7 +478,7 @@
        * @return true if a member, false if not
        */
       protected boolean isInlineItem(String nsURI, String lName) {
  -        return (nsURI == FOElementMapping.URI && 
  +        return (nsURI == FO_URI && 
               (lName.equals("bidi-override") 
               || lName.equals("character") 
               || lName.equals("external-graphic") 
  @@ -513,7 +515,7 @@
        * @return true if a member, false if not
        */
       protected boolean isNeutralItem(String nsURI, String lName) {
  -        return (nsURI == FOElementMapping.URI && 
  +        return (nsURI == FO_URI && 
               (lName.equals("multi-switch") 
               || lName.equals("multi-properties")
               || lName.equals("wrapper") 
  
  
  
  1.17      +12 -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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Character.java    11 Aug 2004 04:15:25 -0000      1.16
  +++ Character.java    13 Aug 2004 12:29:51 -0000      1.17
  @@ -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;
  @@ -28,8 +31,7 @@
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.OneCharIterator;
  -import org.apache.fop.layoutmgr.AddLMVisitor;
  -import org.apache.fop.fo.LMVisited;
  +import org.apache.fop.layoutmgr.CharacterLayoutManager;
   
   /**
    * This class represents the flow object 'fo:character'. Its use is defined by
  @@ -44,7 +46,7 @@
    * Overrides may be specified in an implementation-specific manner." (6.6.3)
    *
    */
  -public class Character extends FObj implements LMVisited {
  +public class Character extends FObj {
   
       /** constant indicating that the character is OK */
       public static final int OK = 0;
  @@ -78,12 +80,14 @@
       }
   
       /**
  -     * 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) {
  -        aLMV.serveCharacter(this);
  +    public void addLayoutManager(List list) {         
  +        String str = getProperty(PR_CHARACTER).getString();
  +        if (str.length() == 1) {
  +            CharacterLayoutManager lm = new CharacterLayoutManager(this);
  +            list.add(lm);
  +        }
       }
   
       /**
  
  
  
  1.18      +25 -12    xml-fop/src/java/org/apache/fop/fo/flow/FootnoteBody.java
  
  Index: FootnoteBody.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/FootnoteBody.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- FootnoteBody.java 8 Aug 2004 18:39:22 -0000       1.17
  +++ FootnoteBody.java 13 Aug 2004 12:29:51 -0000      1.18
  @@ -20,7 +20,7 @@
   
   // XML
   import org.xml.sax.Attributes;
  -import org.xml.sax.SAXException;
  +import org.xml.sax.Locator;
   import org.xml.sax.SAXParseException;
   
   // FOP
  @@ -28,18 +28,10 @@
   import org.apache.fop.fo.FObj;
   
   /**
  - * Class modelling the fo:footnote-body object. See Sec. 6.10.4 of the XSL-FO
  - * Standard.
  + * Class modelling the fo:footnote-body object.
    */
   public class FootnoteBody extends FObj {
   
  -    private int align;
  -    private int alignLast;
  -    private int lineHeight;
  -    private int startIndent;
  -    private int endIndent;
  -    private int textIndent;
  -
       /**
        * @param parent FONode that is the parent of this object
        */
  @@ -55,11 +47,32 @@
           getFOInputHandler().startFootnoteBody(this);
       }
   
  +    /**
  +     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
  +     * XSL Content Model: (%block;)+
  +     */
  +    protected void validateChildNode(Locator loc, String nsURI, String localName) 
  +        throws SAXParseException {
  +            if (!isBlockItem(nsURI, localName)) {
  +                invalidChildError(loc, nsURI, localName);
  +            }
  +    }
  +
  +    /**
  +     * Make sure content model satisfied, if so then tell the
  +     * StructureRenderer that we are at the end of the flow.
  +     * @see org.apache.fop.fo.FONode#end
  +     */
       protected void endOfNode() throws SAXParseException {
  -        super.endOfNode();
  +        if (childNodes == null) {
  +            missingChildElementError("(%block;)+");
  +        }
           getFOInputHandler().endFootnoteBody(this);
       }
  -    
  +
  +    /**
  +     * @see org.apache.fop.fo.FObj#getName()
  +     */
       public String getName() {
           return "fo:footnote-body";
       }
  
  
  
  1.55      +1 -24     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.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- AddLMVisitor.java 13 Aug 2004 00:03:49 -0000      1.54
  +++ AddLMVisitor.java 13 Aug 2004 12:29:51 -0000      1.55
  @@ -27,9 +27,7 @@
   import org.apache.fop.area.Trait;
   import org.apache.fop.area.inline.FilledArea;
   import org.apache.fop.area.inline.ForeignObject;
  -import org.apache.fop.area.inline.Image;
   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.Viewport;
   import org.apache.fop.area.inline.TextArea;
  @@ -39,7 +37,6 @@
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.XMLObj;
   import org.apache.fop.fo.flow.Block;
  -import org.apache.fop.fo.flow.Character;
   import org.apache.fop.fo.flow.Inline;
   import org.apache.fop.fo.flow.InstreamForeignObject;
   import org.apache.fop.fo.flow.Leader;
  @@ -211,26 +208,6 @@
                leaderArea = fa;
            }
            return leaderArea;
  -     }
  -
  -     public void serveCharacter(Character node) {
  -         InlineArea inline = getCharacterInlineArea(node);
  -         if (inline != null) {
  -             LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node);
  -             lm.setCurrentArea(inline);
  -             currentLMList.add(lm);
  -         }
  -     }
  -
  -     public InlineArea getCharacterInlineArea(Character node) {
  -         String str = node.getProperty(Constants.PR_CHARACTER).getString();
  -         if (str.length() == 1) {
  -             org.apache.fop.area.inline.Character ch =
  -               new org.apache.fop.area.inline.Character(
  -                 str.charAt(0));
  -             return ch;
  -         }
  -         return null;
        }
   
        public void serveInstreamForeignObject(InstreamForeignObject node) {
  
  
  
  1.1                  
xml-fop/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java
  
  Index: CharacterLayoutManager.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: CharacterLayoutManager.java,v 1.1 2004/08/13 12:29:51 gmazza Exp $ */
  
  package org.apache.fop.layoutmgr;
  
  import org.apache.fop.fo.flow.Character;
  import org.apache.fop.area.inline.InlineArea;
  
  /**
   * LayoutManager for the fo:character formatting object
   */
  public class CharacterLayoutManager extends LeafNodeLayoutManager {
  
      /**
       * Constructor
       *
       * @param node the fo:character formatting object
       * @todo better null checking of node
       */
      public CharacterLayoutManager(Character node) {
          super(node);
          InlineArea inline = getCharacterInlineArea(node);
          setCurrentArea(inline);
      }
  
      private InlineArea getCharacterInlineArea(Character node) {
          String str = node.getProperty(Character.PR_CHARACTER).getString();
          org.apache.fop.area.inline.Character ch =
              new org.apache.fop.area.inline.Character(str.charAt(0));
          return ch;
      }
  }
  
  
  
  

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

Reply via email to