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 je...@apache.org on 2005/05/24 11:38:02 UTC

cvs commit: xml-fop/src/java/org/apache/fop/fo/flow AbstractListItemPart.java ListItem.java TableRow.java ListBlock.java ListItemLabel.java ListItemBody.java

jeremias    2005/05/24 02:38:02

  Modified:    src/java/org/apache/fop/fo/flow ListItem.java TableRow.java
                        ListBlock.java ListItemLabel.java ListItemBody.java
  Added:       src/java/org/apache/fop/fo/flow AbstractListItemPart.java
  Log:
  More keep accessors where needed.
  Common abstract base class for ListItemLabel and ListItemBody to make code in the LM more readable.
  
  Revision  Changes    Path
  1.37      +16 -1     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.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- ListItem.java	28 Jan 2005 16:56:51 -0000	1.36
  +++ ListItem.java	24 May 2005 09:38:02 -0000	1.37
  @@ -171,8 +171,23 @@
           return breakBefore;
       }
   
  +    /** @return the "keep-with-next" property.  */
  +    public KeepProperty getKeepWithNext() {
  +        return keepWithNext;
  +    }
  +
  +    /** @return the "keep-with-previous" property.  */
  +    public KeepProperty getKeepWithPrevious() {
  +        return keepWithPrevious;
  +    }
  +
  +    /** @return the "keep-together" property.  */
  +    public KeepProperty getKeepTogether() {
  +        return keepTogether;
  +    }
  +
       /**
  -     * Return the "id" property.
  +     * @return the "id" property.
        */
       public String getId() {
           return id;
  
  
  
  1.48      +18 -0     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.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- TableRow.java	23 May 2005 13:02:41 -0000	1.47
  +++ TableRow.java	24 May 2005 09:38:02 -0000	1.48
  @@ -163,6 +163,24 @@
       }
       
       /**
  +     * Convenience method to check if a keep-with-next constraint is specified.
  +     * @return true if keep-with-next is active.
  +     */
  +    public boolean mustKeepWithNext() {
  +        return !getKeepWithNext().getWithinPage().isAuto()
  +                || !getKeepWithNext().getWithinColumn().isAuto();
  +    }
  +    
  +    /**
  +     * Convenience method to check if a keep-with-previous constraint is specified.
  +     * @return true if keep-with-previous is active.
  +     */
  +    public boolean mustKeepWithPrevious() {
  +        return !getKeepWithPrevious().getWithinPage().isAuto()
  +                || !getKeepWithPrevious().getWithinColumn().isAuto();
  +    }
  +    
  +    /**
        * @return the "block-progression-dimension" property.
        */
       public LengthRangeProperty getBlockProgressionDimension() {
  
  
  
  1.38      +15 -0     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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- ListBlock.java	28 Jan 2005 16:56:51 -0000	1.37
  +++ ListBlock.java	24 May 2005 09:38:02 -0000	1.38
  @@ -151,6 +151,21 @@
           return breakBefore;
       }
   
  +    /** @return the "keep-with-next" property.  */
  +    public KeepProperty getKeepWithNext() {
  +        return keepWithNext;
  +    }
  +
  +    /** @return the "keep-with-previous" property.  */
  +    public KeepProperty getKeepWithPrevious() {
  +        return keepWithPrevious;
  +    }
  +
  +    /** @return the "keep-together" property.  */
  +    public KeepProperty getKeepTogether() {
  +        return keepTogether;
  +    }
  +
       /**
        * @return the "id" property.
        */
  
  
  
  1.32      +4 -56     xml-fop/src/java/org/apache/fop/fo/flow/ListItemLabel.java
  
  Index: ListItemLabel.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ListItemLabel.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ListItemLabel.java	5 Mar 2005 04:52:06 -0000	1.31
  +++ ListItemLabel.java	24 May 2005 09:38:02 -0000	1.32
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 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.
  @@ -18,29 +18,13 @@
   
   package org.apache.fop.fo.flow;
   
  -import org.xml.sax.Locator;
  -
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.fo.FONode;
  -import org.apache.fop.fo.FObj;
  -import org.apache.fop.fo.PropertyList;
  -import org.apache.fop.fo.ValidationException;
  -import org.apache.fop.fo.properties.CommonAccessibility;
  -import org.apache.fop.fo.properties.KeepProperty;
   
   /**
    * Class modelling the fo:list-item-label object.
  - * @todo implement validateChildNode()
    */
  -public class ListItemLabel extends FObj {
  -    // The value of properties relevant for fo:list-item-label.
  -    private CommonAccessibility commonAccessibility;
  -    private String id;
  -    private KeepProperty keepTogether;
  -    // End of property values
  -
  -    /** used for FO validation */
  -    private boolean blockItemFound = false;
  +public class ListItemLabel extends AbstractListItemPart {
   
       /**
        * @param parent FONode that is the parent of this object
  @@ -50,58 +34,22 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FObj#bind(PropertyList)
  -     */
  -    public void bind(PropertyList pList) throws FOPException {
  -        commonAccessibility = pList.getAccessibilityProps();
  -        id = pList.get(PR_ID).getString();
  -        keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FONode#startOfNode
        */
       protected void startOfNode() throws FOPException {
  -        checkId(id);
  +        super.startOfNode();
           getFOEventHandler().startListLabel();
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
  -     * XSL Content Model: marker* (%block;)+
  -     */
  -    protected void validateChildNode(Locator loc, String nsURI, String localName) 
  -        throws ValidationException {
  -        if (nsURI == FO_URI && localName.equals("marker")) {
  -            if (blockItemFound) {
  -               nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
  -            }
  -        } else if (!isBlockItem(nsURI, localName)) {
  -            invalidChildError(loc, nsURI, localName);
  -        } else {
  -            blockItemFound = true;
  -        }
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FONode#endOfNode
        */
       protected void endOfNode() throws FOPException {
  -        if (!blockItemFound) {
  -            missingChildElementError("marker* (%block;)+");
  -        }
  -
  +        super.endOfNode();
           getFOEventHandler().endListLabel();
       }
   
       /**
  -     * Return the "id" property.
  -     */
  -    public String getId() {
  -        return id;
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#getName()
        */
       public String getName() {
  
  
  
  1.24      +5 -55     xml-fop/src/java/org/apache/fop/fo/flow/ListItemBody.java
  
  Index: ListItemBody.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ListItemBody.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ListItemBody.java	5 Mar 2005 04:52:06 -0000	1.23
  +++ ListItemBody.java	24 May 2005 09:38:02 -0000	1.24
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 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.
  @@ -18,28 +18,13 @@
   
   package org.apache.fop.fo.flow;
   
  -import org.xml.sax.Locator;
  -
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.fo.FONode;
  -import org.apache.fop.fo.FObj;
  -import org.apache.fop.fo.PropertyList;
  -import org.apache.fop.fo.ValidationException;
  -import org.apache.fop.fo.properties.CommonAccessibility;
  -import org.apache.fop.fo.properties.KeepProperty;
   
   /**
    * Class modelling the fo:list-item-body object.
    */
  -public class ListItemBody extends FObj {
  -    // The value of properties relevant for fo:list-item-body.
  -    private CommonAccessibility commonAccessibility;
  -    private String id;
  -    private KeepProperty keepTogether;
  -    // End of property values
  -
  -    /** used for FO validation */
  -    private boolean blockItemFound = false;
  +public class ListItemBody extends AbstractListItemPart {
   
       /**
        * @param parent FONode that is the parent of this object
  @@ -49,56 +34,21 @@
       }
   
       /**
  -     * @see org.apache.fop.fo.FObj#bind(PropertyList)
  -     */
  -    public void bind(PropertyList pList) throws FOPException {
  -        commonAccessibility = pList.getAccessibilityProps();
  -        id = pList.get(PR_ID).getString();
  -        keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FONode#startOfNode
        */
       protected void startOfNode() throws FOPException {
  -        checkId(id);
  +        super.startOfNode();
           getFOEventHandler().startListBody();
       }
   
       /**
  -     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
  -     * XSL Content Model: marker* (%block;)+
  -     */
  -    protected void validateChildNode(Locator loc, String nsURI, String localName) 
  -        throws ValidationException {
  -        if (nsURI == FO_URI && localName.equals("marker")) {
  -            if (blockItemFound) {
  -               nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
  -            }
  -        } else if (!isBlockItem(nsURI, localName)) {
  -            invalidChildError(loc, nsURI, localName);
  -        } else {
  -            blockItemFound = true;
  -        }
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FONode#endOfNode
        */
       protected void endOfNode() throws FOPException {
  -        if (!blockItemFound) {
  -            missingChildElementError("marker* (%block;)+");
  -        }
  +        super.endOfNode();
           getFOEventHandler().endListBody();
       }
  -
  -    /**
  -     * Return the "id" property.
  -     */
  -    public String getId() {
  -        return id;
  -    }
  -
  +    
       /**
        * @see org.apache.fop.fo.FObj#getName()
        */
  
  
  
  1.1                  xml-fop/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java
  
  Index: AbstractListItemPart.java
  ===================================================================
  /*
   * Copyright 1999-2005 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: AbstractListItemPart.java,v 1.1 2005/05/24 09:38:02 jeremias Exp $ */
  
  package org.apache.fop.fo.flow;
  
  import org.xml.sax.Locator;
  
  import org.apache.fop.apps.FOPException;
  import org.apache.fop.fo.FONode;
  import org.apache.fop.fo.FObj;
  import org.apache.fop.fo.PropertyList;
  import org.apache.fop.fo.ValidationException;
  import org.apache.fop.fo.properties.CommonAccessibility;
  import org.apache.fop.fo.properties.KeepProperty;
  
  /**
   * Class modelling the fo:list-item-body object.
   */
  public abstract class AbstractListItemPart extends FObj {
      // The value of properties relevant for fo:list-item-label and fo:list-item-body.
      private CommonAccessibility commonAccessibility;
      private String id;
      private KeepProperty keepTogether;
      // End of property values
  
      /** used for FO validation */
      private boolean blockItemFound = false;
  
      /**
       * @param parent FONode that is the parent of this object
       */
      public AbstractListItemPart(FONode parent) {
          super(parent);
      }
  
      /**
       * @see org.apache.fop.fo.FObj#bind(PropertyList)
       */
      public void bind(PropertyList pList) throws FOPException {
          commonAccessibility = pList.getAccessibilityProps();
          id = pList.get(PR_ID).getString();
          keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
      }
  
      /**
       * @see org.apache.fop.fo.FONode#startOfNode
       */
      protected void startOfNode() throws FOPException {
          checkId(id);
      }
  
      /**
       * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
       * XSL Content Model: marker* (%block;)+
       */
      protected void validateChildNode(Locator loc, String nsURI, String localName) 
          throws ValidationException {
          if (nsURI == FO_URI && localName.equals("marker")) {
              if (blockItemFound) {
                 nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
              }
          } else if (!isBlockItem(nsURI, localName)) {
              invalidChildError(loc, nsURI, localName);
          } else {
              blockItemFound = true;
          }
      }
  
      /**
       * @see org.apache.fop.fo.FONode#endOfNode
       */
      protected void endOfNode() throws FOPException {
          if (!blockItemFound) {
              missingChildElementError("marker* (%block;)+");
          }
      }
  
      /** @return the "keep-together" property.  */
      public KeepProperty getKeepTogether() {
          return keepTogether;
      }
  
      /** @return the "id" property. */
      public String getId() {
          return id;
      }
  
  }
  
  
  
  

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