diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-05-24 09:38:02 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-05-24 09:38:02 +0000 |
commit | 1af57e403ba314e8acc33bb696b140bb3f9ccafa (patch) | |
tree | 0dbbdf96de79ec976ca3537ef8209655763cd173 /src/java/org/apache/fop/fo/flow | |
parent | a20b446f7dcbbad9ee89ef3edf3cc9fde2e54473 (diff) | |
download | xmlgraphics-fop-1af57e403ba314e8acc33bb696b140bb3f9ccafa.tar.gz xmlgraphics-fop-1af57e403ba314e8acc33bb696b140bb3f9ccafa.zip |
More keep accessors where needed.
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
Diffstat (limited to 'src/java/org/apache/fop/fo/flow')
-rw-r--r-- | src/java/org/apache/fop/fo/flow/AbstractListItemPart.java | 104 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/ListBlock.java | 15 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/ListItem.java | 17 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/ListItemBody.java | 60 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/ListItemLabel.java | 60 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/TableRow.java | 18 |
6 files changed, 162 insertions, 112 deletions
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 index 000000000..34764e933 --- /dev/null +++ b/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java @@ -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; + } + +} + diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index 941c7e6c1..070262cad 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.java @@ -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. */ diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index dad896e94..01d0c37ca 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -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; diff --git a/src/java/org/apache/fop/fo/flow/ListItemBody.java b/src/java/org/apache/fop/fo/flow/ListItemBody.java index a3f7e776a..e1fe463b8 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/java/org/apache/fop/fo/flow/ListItemBody.java @@ -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 @@ public class ListItemBody extends FObj { } /** - * @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() */ diff --git a/src/java/org/apache/fop/fo/flow/ListItemLabel.java b/src/java/org/apache/fop/fo/flow/ListItemLabel.java index 86a44d121..891feaf04 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/java/org/apache/fop/fo/flow/ListItemLabel.java @@ -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 @@ public class ListItemLabel extends FObj { } /** - * @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() { diff --git a/src/java/org/apache/fop/fo/flow/TableRow.java b/src/java/org/apache/fop/fo/flow/TableRow.java index a1ce4489e..0c50edcf3 100644 --- a/src/java/org/apache/fop/fo/flow/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/TableRow.java @@ -163,6 +163,24 @@ public class TableRow extends FObj { } /** + * 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() { |