]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
More keep accessors where needed.
authorJeremias Maerki <jeremias@apache.org>
Tue, 24 May 2005 09:38:02 +0000 (09:38 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 24 May 2005 09:38:02 +0000 (09:38 +0000)
Common abstract base class for ListItemLabel and ListItemBody to make code in the LM more readable.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198682 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/flow/AbstractListItemPart.java [new file with mode: 0644]
src/java/org/apache/fop/fo/flow/ListBlock.java
src/java/org/apache/fop/fo/flow/ListItem.java
src/java/org/apache/fop/fo/flow/ListItemBody.java
src/java/org/apache/fop/fo/flow/ListItemLabel.java
src/java/org/apache/fop/fo/flow/TableRow.java

diff --git a/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java b/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java
new file mode 100644 (file)
index 0000000..34764e9
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * 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$ */
+
+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;
+    }
+
+}
+
index 941c7e6c1af4935595dbf8972702ca7caf4a20de..070262cadc5d576ac501310496646b562f2d705e 100644 (file)
@@ -151,6 +151,21 @@ public class ListBlock extends FObj {
         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.
      */
index dad896e943a4252d75a8d5fa3e2fe41dcd87ce97..01d0c37ca8a15e804fefa53a64ee4191a8da62cb 100644 (file)
@@ -171,8 +171,23 @@ public class ListItem extends FObj {
         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;
index a3f7e776a4a9ef2a32d8941bc5ebfdb26c612280..e1fe463b882307ee2afc08319005a5df5ab5df19 100644 (file)
@@ -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.
 
 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
@@ -48,57 +33,22 @@ public class ListItemBody extends FObj {
         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);
+        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()
      */
index 86a44d1218b4575664aa9bd2b09f6b4b7ef378de..891feaf04247e38831be73e642d46060cf34f353 100644 (file)
@@ -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.
 
 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
@@ -49,58 +33,22 @@ public class ListItemLabel extends FObj {
         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);
+        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()
      */
index a1ce4489e098ff30d2c6a141bc63950bd98f810e..0c50edcf37ad580fd1ca36277df0d13f34b9826d 100644 (file)
@@ -162,6 +162,24 @@ public class TableRow extends FObj {
                 || !getKeepTogether().getWithinColumn().isAuto();
     }
     
+    /**
+     * 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.
      */