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-ffa450edef68tags/fop-0_90-alpha1
@@ -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; | |||
} | |||
} | |||
@@ -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. | |||
*/ |
@@ -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; |
@@ -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 | |||
@@ -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() | |||
*/ |
@@ -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 | |||
@@ -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() | |||
*/ |
@@ -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. | |||
*/ |