2. "name" data element removed from FONode, added to its XMLObj subclass (FObj subclasses' getName() uses a string constant instead.) 3. isBlockOrInlineItem() convenience method added to FObj 4. setup() methods within FO's switched to private access. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197846 13f79535-47bb-0310-9956-ffa450edef68tags/Root_Temp_KnuthStylePageBreaking
@@ -47,9 +47,6 @@ public abstract class FONode { | |||
/** Parent FO node */ | |||
protected FONode parent; | |||
/** Name of the node */ | |||
protected String name; | |||
/** Marks input file containing this object **/ | |||
public String systemId; | |||
@@ -118,7 +115,6 @@ public abstract class FONode { | |||
*/ | |||
public void processNode(String elementName, Locator locator, Attributes attlist) throws FOPException { | |||
System.out.println("name = " + elementName); | |||
this.name = elementName; | |||
} | |||
/** | |||
@@ -126,7 +122,7 @@ public abstract class FONode { | |||
* @return the name of this object | |||
*/ | |||
public String getName() { | |||
return this.name; | |||
return null; | |||
} | |||
/** |
@@ -431,16 +431,6 @@ public class FOText extends FObj { | |||
} | |||
} | |||
/** | |||
* 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. | |||
*/ | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
aLMV.serveFOText(this); | |||
} | |||
private class TextCharIterator extends AbstractCharIterator { | |||
private int curIndex = 0; | |||
@@ -496,5 +486,17 @@ public class FOText extends FObj { | |||
} | |||
} | |||
public String getName() { | |||
return "fo:text"; | |||
} | |||
/** | |||
* 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. | |||
*/ | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
aLMV.serveFOText(this); | |||
} | |||
} |
@@ -45,31 +45,30 @@ public class FObj extends FONode implements Constants { | |||
/** Property manager for providing refined properties/traits. */ | |||
protected PropertyManager propMgr; | |||
/** Id of this fo element of null if no id. */ | |||
protected String id = null; | |||
/** The immediate child nodes of this node. */ | |||
public ArrayList childNodes = null; | |||
/** Used to indicate if this FO is either an Out Of Line FO (see rec) | |||
or a descendant of one. Used during validateChildNode() FO | |||
validation. | |||
*/ | |||
private boolean isOutOfLineFODescendant = false; | |||
/** Id of this fo element or null if no id. */ | |||
protected String id = null; | |||
/** Markers added to this element. */ | |||
protected Map markers = null; | |||
/** Dynamic layout dimension. Used to resolve relative lengths. */ | |||
protected Map layoutDimension = null; | |||
/** During input FO validation, certain FO's are not valid as | |||
child nodes if they would be a descendant of an Out Of Line | |||
Formatting Object as defined in specification (See Sect. 6.2 | |||
of spec.) This value is also set to true if this object | |||
itself is an Out Of Line FO. | |||
*/ | |||
protected boolean isOutOfLineFODescendant = false; | |||
/** | |||
* Create a new formatting object. | |||
* All formatting object classes extend this class. | |||
* | |||
* @param parent the parent node | |||
* @todo move propertyListTable initialization someplace else? | |||
*/ | |||
public FObj(FONode parent) { | |||
super(parent); | |||
@@ -95,16 +94,6 @@ public class FObj extends FONode implements Constants { | |||
} | |||
} | |||
/** | |||
* Used to indicate if this FO is the descendant of an out-of-line | |||
* formatting object (From Sect. 6.10, fo:float, fo:footnote, | |||
* fo:footnote-body). Important for validating child nodes. | |||
* @return true if descendant, false otherwise | |||
*/ | |||
public boolean getIsOutOfLineFODescendant() { | |||
return isOutOfLineFODescendant; | |||
} | |||
/** | |||
* @see org.apache.fop.fo.FONode#processNode | |||
*/ | |||
@@ -114,15 +103,6 @@ public class FObj extends FONode implements Constants { | |||
addProperties(attlist); | |||
} | |||
/** | |||
* Set the name of this element. | |||
* The prepends "fo:" to the name to indicate it is in the fo namespace. | |||
* @param str the xml element name | |||
*/ | |||
public void setName(String str) { | |||
name = "fo:" + str; | |||
} | |||
/** | |||
* Set properties for this FO based on node attributes | |||
* @param attlist Collection of attributes passed to us from the parser. | |||
@@ -141,6 +121,14 @@ public class FObj extends FONode implements Constants { | |||
setWritingMode(); | |||
} | |||
/** | |||
* Returns Out Of Line FO Descendant indicator. | |||
* @return true if Out of Line FO or Out Of Line descendant, false otherwise | |||
*/ | |||
public boolean getIsOutOfLineFODescendant() { | |||
return isOutOfLineFODescendant; | |||
} | |||
/** | |||
* Return the PropertyManager object for this FO. PropertyManager | |||
* tends to hold the traits for this FO, and is primarily used in layout. | |||
@@ -174,7 +162,7 @@ public class FObj extends FONode implements Constants { | |||
*/ | |||
protected void addChildNode(FONode child) { | |||
if (containsMarkers() && "fo:marker".equals(child.getName())) { | |||
addMarker((Marker)child); | |||
addMarker((Marker) child); | |||
} else { | |||
if (childNodes == null) { | |||
childNodes = new ArrayList(); | |||
@@ -347,7 +335,8 @@ public class FObj extends FONode implements Constants { | |||
/** | |||
* Check if this formatting object may contain markers. | |||
* | |||
* @return true if this can contian markers | |||
* @return true if this can contain markers | |||
* @todo confirm if still needed after validateChildNode() fully implemented | |||
*/ | |||
protected boolean containsMarkers() { | |||
return false; | |||
@@ -511,6 +500,18 @@ public class FObj extends FONode implements Constants { | |||
|| isNeutralItem(nsURI, lName))); | |||
} | |||
/** | |||
* Convenience method for validity checking. Checks if the | |||
* incoming node is a member of the "%block;" parameter entity | |||
* or "%inline;" parameter entity | |||
* @param nsURI namespace URI of incoming node | |||
* @param lName local name (i.e., no prefix) of incoming node | |||
* @return true if a member, false if not | |||
*/ | |||
protected boolean isBlockOrInlineItem(String nsURI, String lName) { | |||
return (isBlockItem(nsURI, lName) || isInlineItem(nsURI, lName)); | |||
} | |||
/** | |||
* Convenience method for validity checking. Checks if the | |||
* incoming node is a member of the neutral item list |
@@ -53,7 +53,6 @@ public class FObjMixed extends FObj { | |||
FOText ft = new FOText(data, start, length, textInfo, this); | |||
ft.setLocation(locator); | |||
ft.setName("text"); | |||
/* characters() processing empty for FOTreeHandler, not empty for RTF & MIFHandlers */ | |||
getFOInputHandler().characters(ft.ca, ft.startIndex, ft.endIndex); |
@@ -32,11 +32,6 @@ public class ToBeImplementedElement extends FObj { | |||
super(parent); | |||
} | |||
private void setup() { | |||
getLogger().debug("This element \"" + this.name | |||
+ "\" is not yet implemented."); | |||
} | |||
/** | |||
* This is a hook for the AddLMVisitor class to be able to access | |||
* this object. |
@@ -47,6 +47,9 @@ public abstract class XMLObj extends FONode { | |||
/** DOM document containing this node */ | |||
protected Document doc; | |||
/** Name of the node */ | |||
protected String name; | |||
/** | |||
* | |||
* @param parent the parent formatting object | |||
@@ -75,6 +78,14 @@ public abstract class XMLObj extends FONode { | |||
return null; | |||
} | |||
/** | |||
* Returns the name of the object | |||
* @return the name of this object | |||
*/ | |||
public String getName() { | |||
return name; | |||
} | |||
/** | |||
* @return string containing the namespace for this node | |||
*/ |
@@ -20,10 +20,12 @@ package org.apache.fop.fo.flow; | |||
// XML | |||
import org.xml.sax.Attributes; | |||
import org.xml.sax.Locator; | |||
import org.xml.sax.SAXParseException; | |||
// FOP | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.fo.FOElementMapping; | |||
import org.apache.fop.fo.FONode; | |||
import org.apache.fop.layoutmgr.AddLMVisitor; | |||
import org.apache.fop.fo.properties.CommonAccessibility; | |||
@@ -39,10 +41,12 @@ import org.apache.fop.fo.properties.CommonRelativePosition; | |||
* that are created by the fo element. | |||
*/ | |||
public class BasicLink extends Inline { | |||
private String link = null; | |||
private boolean external = false; | |||
// used for FO validation | |||
private boolean blockOrInlineItemFound = false; | |||
/** | |||
* @param parent FONode that is the parent of this object | |||
*/ | |||
@@ -58,7 +62,53 @@ public class BasicLink extends Inline { | |||
getFOInputHandler().startLink(this); | |||
} | |||
public void setup() { | |||
/** | |||
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) | |||
* XSL Content Model: marker* (#PCDATA|%inline;|%block;)* | |||
*/ | |||
protected void validateChildNode(Locator loc, String nsURI, String localName) | |||
throws SAXParseException { | |||
if (nsURI == FOElementMapping.URI && localName.equals("marker")) { | |||
if (blockOrInlineItemFound) { | |||
nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)"); | |||
} | |||
} else if (!isBlockOrInlineItem(nsURI, localName)) { | |||
invalidChildError(loc, nsURI, localName); | |||
} else { | |||
blockOrInlineItemFound = true; | |||
} | |||
} | |||
/** | |||
* @see org.apache.fop.fo.FONode#end | |||
*/ | |||
protected void endOfNode() throws SAXParseException { | |||
super.endOfNode(); | |||
getFOInputHandler().endLink(); | |||
} | |||
/** | |||
* @return the String value of the link | |||
*/ | |||
public String getLink() { | |||
return link; | |||
} | |||
/** | |||
* @return true if the link is external, false otherwise | |||
*/ | |||
public boolean getExternal() { | |||
return external; | |||
} | |||
public String getName() { | |||
return "fo:basic-link"; | |||
} | |||
/** | |||
* @todo check if needed; not being called currently | |||
*/ | |||
private void setup() { | |||
String destination; | |||
int linkType; | |||
@@ -78,15 +128,11 @@ public class BasicLink extends Inline { | |||
// Common Relative Position Properties | |||
CommonRelativePosition mRelProps = propMgr.getRelativePositionProps(); | |||
// this.propertyList.get("alignment-adjust"); | |||
// this.propertyList.get("alignment-baseline"); | |||
// this.propertyList.get("baseline-shift"); | |||
// this.propertyList.get("destination-place-offset"); | |||
// this.propertyList.get("dominant-baseline"); | |||
String ext = propertyList.get(PR_EXTERNAL_DESTINATION).getString(); | |||
setupID(); | |||
// this.propertyList.get("indicate-destination"); | |||
String internal = propertyList.get(PR_INTERNAL_DESTINATION).getString(); | |||
if (ext.length() > 0) { | |||
link = ext; | |||
external = true; | |||
@@ -95,57 +141,22 @@ public class BasicLink extends Inline { | |||
} else { | |||
getLogger().error("basic-link requires an internal or external destination"); | |||
} | |||
// this.propertyList.get("keep-together"); | |||
// this.propertyList.get("keep-with-next"); | |||
// this.propertyList.get("keep-with-previous"); | |||
// this.propertyList.get("line-height"); | |||
// this.propertyList.get("line-height-shift-adjustment"); | |||
// this.propertyList.get("show-destination"); | |||
// this.propertyList.get("target-processing-context"); | |||
// this.propertyList.get("target-presentation-context"); | |||
// this.propertyList.get("target-stylesheet"); | |||
} | |||
/** | |||
* @return true (BasicLink can contain Markers) | |||
*/ | |||
*/ | |||
protected boolean containsMarkers() { | |||
return true; | |||
} | |||
/** | |||
* @return the String value of the link | |||
*/ | |||
public String getLink() { | |||
return link; | |||
} | |||
/** | |||
* @return true if the link is external, false otherwise | |||
*/ | |||
public boolean getExternal() { | |||
return external; | |||
} | |||
/** | |||
* 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. | |||
*/ | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
setup(); | |||
aLMV.serveBasicLink(this); | |||
} | |||
/** | |||
* @see org.apache.fop.fo.FONode#end | |||
*/ | |||
protected void endOfNode() throws SAXParseException { | |||
super.endOfNode(); | |||
getFOInputHandler().endLink(); | |||
} | |||
public String getName() { | |||
return "fo:basic-link"; | |||
} | |||
} |
@@ -84,7 +84,7 @@ public class ExternalGraphic extends FObj { | |||
* Setup this image. | |||
* This gets the sizes for the image and the dimensions and clipping. | |||
*/ | |||
public void setup() { | |||
private void setup() { | |||
url = this.propertyList.get(PR_SRC).getString(); | |||
if (url == null) { | |||
return; | |||
@@ -230,15 +230,6 @@ public class ExternalGraphic extends FObj { | |||
return viewHeight; | |||
} | |||
/** | |||
* 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. | |||
*/ | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
aLMV.serveExternalGraphic(this); | |||
} | |||
public String getURL() { | |||
return url; | |||
} | |||
@@ -259,4 +250,13 @@ public class ExternalGraphic extends FObj { | |||
return "fo:external-graphic"; | |||
} | |||
/** | |||
* 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. | |||
*/ | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
setup(); | |||
aLMV.serveExternalGraphic(this); | |||
} | |||
} |
@@ -33,7 +33,6 @@ public class Float extends ToBeImplementedElement { | |||
*/ | |||
public Float(FONode parent) { | |||
super(parent); | |||
this.name = "fo:float"; | |||
} | |||
private void setup() { |
@@ -53,7 +53,7 @@ public class Leader extends FObjMixed { | |||
super(parent); | |||
} | |||
public void setup() { | |||
private void setup() { | |||
// Common Accessibility Properties | |||
CommonAccessibility mAccProps = propMgr.getAccessibilityProps(); | |||
@@ -162,16 +162,17 @@ public class Leader extends FObjMixed { | |||
return patternWidth; | |||
} | |||
public String getName() { | |||
return "fo:leader"; | |||
} | |||
/** | |||
* 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. | |||
*/ | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
setup(); | |||
aLMV.serveLeader(this); | |||
} | |||
public String getName() { | |||
return "fo:leader"; | |||
} | |||
} |
@@ -75,7 +75,7 @@ public class PageNumber extends FObj { | |||
getFOInputHandler().startPageNumber(this); | |||
} | |||
public void setup() { | |||
private void setup() { | |||
// Common Accessibility Properties | |||
CommonAccessibility mAccProps = propMgr.getAccessibilityProps(); | |||
@@ -129,15 +129,6 @@ public class PageNumber extends FObj { | |||
return fontState; | |||
} | |||
/** | |||
* 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. | |||
*/ | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
aLMV.servePageNumber(this); | |||
} | |||
protected void endOfNode() throws SAXParseException { | |||
getFOInputHandler().endPageNumber(this); | |||
} | |||
@@ -145,4 +136,14 @@ public class PageNumber extends FObj { | |||
public String getName() { | |||
return "fo:page-number"; | |||
} | |||
/** | |||
* 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. | |||
*/ | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
setup(); | |||
aLMV.servePageNumber(this); | |||
} | |||
} |
@@ -83,7 +83,7 @@ public class PageNumberCitation extends FObj { | |||
return width; | |||
} | |||
public void setup() { | |||
private void setup() { | |||
// Common Accessibility Properties | |||
CommonAccessibility mAccProps = propMgr.getAccessibilityProps(); | |||
@@ -148,10 +148,6 @@ public class PageNumberCitation extends FObj { | |||
unresolved = isUnresolved; | |||
} | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
aLMV.servePageNumberCitation(this); | |||
} | |||
public Font getFontState() { | |||
return fontState; | |||
} | |||
@@ -159,4 +155,9 @@ public class PageNumberCitation extends FObj { | |||
public String getName() { | |||
return "fo:page-number-citation"; | |||
} | |||
public void acceptVisitor(AddLMVisitor aLMV) { | |||
setup(); | |||
aLMV.servePageNumberCitation(this); | |||
} | |||
} |
@@ -44,7 +44,7 @@ public class TableCaption extends ToBeImplementedElement { | |||
/** | |||
* Initialize property values. | |||
*/ | |||
public void setup() { | |||
private void setup() { | |||
// Common Accessibility Properties | |||
CommonAccessibility mAccProps = propMgr.getAccessibilityProps(); |
@@ -56,7 +56,7 @@ public class ConditionalPageMasterReference extends FObj { | |||
/** | |||
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) | |||
* XSL/FOP Content Model: empty | |||
* XSL Content Model: empty | |||
*/ | |||
protected void validateChildNode(Locator loc, String nsURI, String localName) | |||
throws SAXParseException { |
@@ -58,9 +58,7 @@ public class Flow extends FObj { | |||
*/ | |||
private int contentWidth; | |||
/** | |||
* Content-width of current column area during layout | |||
*/ | |||
/** used for FO validation */ | |||
private boolean blockItemFound = false; | |||
/** | |||
@@ -72,7 +70,7 @@ public class Flow extends FObj { | |||
/** | |||
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) | |||
* XSL/FOP Content Model: marker* (%block;)+ | |||
* XSL Content Model: marker* (%block;)+ | |||
*/ | |||
protected void validateChildNode(Locator loc, String nsURI, String localName) | |||
throws SAXParseException { |
@@ -135,7 +135,7 @@ public class PageSequence extends FObj { | |||
/** | |||
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) | |||
XSL/FOP Content Model: (title?,static-content*,flow) | |||
XSL Content Model: (title?,static-content*,flow) | |||
*/ | |||
protected void validateChildNode(Locator loc, String nsURI, String localName) | |||
throws SAXParseException { |
@@ -92,7 +92,7 @@ public abstract class Region extends FObj { | |||
if (isReserved(getRegionName()) | |||
&& !getRegionName().equals(getDefaultRegionName())) { | |||
throw new FOPException("region-name '" + regionName | |||
+ "' for " + this.name | |||
+ "' for " + this.getName() | |||
+ " not permitted."); | |||
} | |||
} | |||
@@ -100,7 +100,7 @@ public abstract class Region extends FObj { | |||
if (parent instanceof SimplePageMaster) { | |||
layoutMaster = (SimplePageMaster)parent; | |||
} else { | |||
throw new FOPException(this.name + " must be child " | |||
throw new FOPException(this.getName() + " must be child " | |||
+ "of simple-page-master, not " | |||
+ parent.getName()); | |||
} |
@@ -52,7 +52,7 @@ public class RepeatablePageMasterReference extends PageMasterReference | |||
/** | |||
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) | |||
* XSL/FOP Content Model: empty | |||
* XSL Content Model: empty | |||
*/ | |||
protected void validateChildNode(Locator loc, String nsURI, String localName) | |||
throws SAXParseException { |
@@ -50,7 +50,7 @@ public class SinglePageMasterReference extends PageMasterReference | |||
/** | |||
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) | |||
* XSL/FOP Content Model: empty | |||
* XSL Content Model: empty | |||
*/ | |||
protected void validateChildNode(Locator loc, String nsURI, String localName) | |||
throws SAXParseException { |
@@ -47,7 +47,7 @@ public class StaticContent extends Flow { | |||
/** | |||
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) | |||
* XSL/FOP Content Model: (%block;)+ | |||
* XSL Content Model: (%block;)+ | |||
*/ | |||
protected void validateChildNode(Locator loc, String nsURI, String localName) | |||
throws SAXParseException { |
@@ -241,7 +241,6 @@ public class AddLMVisitor { | |||
* Add start and end properties for the link | |||
*/ | |||
public void serveBasicLink(final BasicLink node) { | |||
node.setup(); | |||
InlineStackingLayoutManager lm; | |||
lm = new InlineStackingLayoutManager(node) { | |||
protected InlineParent createArea() { | |||
@@ -307,7 +306,6 @@ public class AddLMVisitor { | |||
} | |||
private InlineArea getLeaderInlineArea(Leader node, LayoutManager parentLM) { | |||
node.setup(); | |||
InlineArea leaderArea = null; | |||
if (node.getLeaderPattern() == Constants.LeaderPattern.RULE) { | |||
@@ -427,7 +425,6 @@ public class AddLMVisitor { | |||
* @return the viewport containing the image area | |||
*/ | |||
public InlineArea getExternalGraphicInlineArea(ExternalGraphic node) { | |||
node.setup(); | |||
if (node.getURL() == null) { | |||
return null; | |||
} | |||
@@ -652,7 +649,6 @@ public class AddLMVisitor { | |||
* @param lms the list to which the layout manager(s) should be added | |||
*/ | |||
public void servePageNumber(final PageNumber node) { | |||
node.setup(); | |||
LayoutManager lm; | |||
lm = new LeafNodeLayoutManager(node) { | |||
public InlineArea get(LayoutContext context) { | |||
@@ -686,7 +682,6 @@ public class AddLMVisitor { | |||
} | |||
public void servePageNumberCitation(final PageNumberCitation node) { | |||
node.setup(); | |||
LayoutManager lm; | |||
lm = new LeafNodeLayoutManager(node) { | |||
public InlineArea get(LayoutContext context) { |