From: Glen Mazza Date: Fri, 13 Aug 2004 12:29:51 +0000 (+0000) Subject: 1. Character LM initialization moved from AllLMVisitor to fo.Character. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~620 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=341c5e433096361036a9336e5bec9ba6de90f3fa;p=xmlgraphics-fop.git 1. Character LM initialization moved from AllLMVisitor to fo.Character. 2. Character layout logic moved from AllLMVisitor to new CharacterLayoutManager. 3. validateChildNode() implemented for fo:footnote-body. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197869 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 68089e7f1..03d35f542 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -79,10 +79,12 @@ public class FObj extends FONode implements Constants { if (parent != null && parent instanceof FObj) { if (((FObj)parent).getIsOutOfLineFODescendant() == true) { isOutOfLineFODescendant = true; - } else if ("fo:float".equals(getName()) - || "fo:footnote".equals(getName()) - || "fo:footnote-body".equals(getName())) { - isOutOfLineFODescendant = true; + } else { + int foID = getNameId(); + if (foID == FO_FLOAT || foID == FO_FOOTNOTE + || foID == FO_FOOTNOTE_BODY) { + isOutOfLineFODescendant = true; + } } } @@ -114,10 +116,10 @@ public class FObj extends FONode implements Constants { PropertyList parentPL = null; if (parentFO != null) { - parentPL = parentFO.getPropertiesForNamespace(FOElementMapping.URI); + parentPL = parentFO.getPropertiesForNamespace(FO_URI); } - propertyList = new PropertyList(this, parentPL, FOElementMapping.URI); + propertyList = new PropertyList(this, parentPL, FO_URI); propertyList.addAttributesToList(attlist); propMgr = new PropertyManager(propertyList); setWritingMode(); @@ -457,7 +459,7 @@ public class FObj extends FONode implements Constants { * @return true if a member, false if not */ protected boolean isBlockItem(String nsURI, String lName) { - return (nsURI == FOElementMapping.URI && + return (nsURI == FO_URI && (lName.equals("block") || lName.equals("table") || lName.equals("table-and-caption") @@ -476,7 +478,7 @@ public class FObj extends FONode implements Constants { * @return true if a member, false if not */ protected boolean isInlineItem(String nsURI, String lName) { - return (nsURI == FOElementMapping.URI && + return (nsURI == FO_URI && (lName.equals("bidi-override") || lName.equals("character") || lName.equals("external-graphic") @@ -513,7 +515,7 @@ public class FObj extends FONode implements Constants { * @return true if a member, false if not */ protected boolean isNeutralItem(String nsURI, String lName) { - return (nsURI == FOElementMapping.URI && + return (nsURI == FO_URI && (lName.equals("multi-switch") || lName.equals("multi-properties") || lName.equals("wrapper") diff --git a/src/java/org/apache/fop/fo/flow/Character.java b/src/java/org/apache/fop/fo/flow/Character.java index 681bbfaf3..32f9206cd 100644 --- a/src/java/org/apache/fop/fo/flow/Character.java +++ b/src/java/org/apache/fop/fo/flow/Character.java @@ -18,6 +18,9 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // XML import org.xml.sax.Attributes; import org.xml.sax.Locator; @@ -28,8 +31,7 @@ import org.apache.fop.fo.CharIterator; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.OneCharIterator; -import org.apache.fop.layoutmgr.AddLMVisitor; -import org.apache.fop.fo.LMVisited; +import org.apache.fop.layoutmgr.CharacterLayoutManager; /** * This class represents the flow object 'fo:character'. Its use is defined by @@ -44,7 +46,7 @@ import org.apache.fop.fo.LMVisited; * Overrides may be specified in an implementation-specific manner." (6.6.3) * */ -public class Character extends FObj implements LMVisited { +public class Character extends FObj { /** constant indicating that the character is OK */ public static final int OK = 0; @@ -78,12 +80,14 @@ public class Character extends FObj implements LMVisited { } /** - * 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. + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveCharacter(this); + public void addLayoutManager(List list) { + String str = getProperty(PR_CHARACTER).getString(); + if (str.length() == 1) { + CharacterLayoutManager lm = new CharacterLayoutManager(this); + list.add(lm); + } } /** diff --git a/src/java/org/apache/fop/fo/flow/FootnoteBody.java b/src/java/org/apache/fop/fo/flow/FootnoteBody.java index 9e35352b1..a7f86b6f5 100644 --- a/src/java/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/java/org/apache/fop/fo/flow/FootnoteBody.java @@ -20,7 +20,7 @@ package org.apache.fop.fo.flow; // XML import org.xml.sax.Attributes; -import org.xml.sax.SAXException; +import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP @@ -28,18 +28,10 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; /** - * Class modelling the fo:footnote-body object. See Sec. 6.10.4 of the XSL-FO - * Standard. + * Class modelling the fo:footnote-body object. */ public class FootnoteBody extends FObj { - private int align; - private int alignLast; - private int lineHeight; - private int startIndent; - private int endIndent; - private int textIndent; - /** * @param parent FONode that is the parent of this object */ @@ -55,11 +47,32 @@ public class FootnoteBody extends FObj { getFOInputHandler().startFootnoteBody(this); } + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + * XSL Content Model: (%block;)+ + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws SAXParseException { + if (!isBlockItem(nsURI, localName)) { + invalidChildError(loc, nsURI, localName); + } + } + + /** + * Make sure content model satisfied, if so then tell the + * StructureRenderer that we are at the end of the flow. + * @see org.apache.fop.fo.FONode#end + */ protected void endOfNode() throws SAXParseException { - super.endOfNode(); + if (childNodes == null) { + missingChildElementError("(%block;)+"); + } getFOInputHandler().endFootnoteBody(this); } - + + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:footnote-body"; } diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index 7c9eccba7..0373fd170 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -27,9 +27,7 @@ import java.util.ListIterator; import org.apache.fop.area.Trait; import org.apache.fop.area.inline.FilledArea; import org.apache.fop.area.inline.ForeignObject; -import org.apache.fop.area.inline.Image; import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.area.inline.InlineParent; import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.Viewport; import org.apache.fop.area.inline.TextArea; @@ -39,7 +37,6 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.XMLObj; import org.apache.fop.fo.flow.Block; -import org.apache.fop.fo.flow.Character; import org.apache.fop.fo.flow.Inline; import org.apache.fop.fo.flow.InstreamForeignObject; import org.apache.fop.fo.flow.Leader; @@ -213,26 +210,6 @@ public class AddLMVisitor { return leaderArea; } - public void serveCharacter(Character node) { - InlineArea inline = getCharacterInlineArea(node); - if (inline != null) { - LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node); - lm.setCurrentArea(inline); - currentLMList.add(lm); - } - } - - public InlineArea getCharacterInlineArea(Character node) { - String str = node.getProperty(Constants.PR_CHARACTER).getString(); - if (str.length() == 1) { - org.apache.fop.area.inline.Character ch = - new org.apache.fop.area.inline.Character( - str.charAt(0)); - return ch; - } - return null; - } - public void serveInstreamForeignObject(InstreamForeignObject node) { Viewport areaCurrent = getInstreamForeignObjectInlineArea(node); if (areaCurrent != null) { diff --git a/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java new file mode 100644 index 000000000..68c11a906 --- /dev/null +++ b/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java @@ -0,0 +1,48 @@ +/* + * Copyright 1999-2004 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.layoutmgr; + +import org.apache.fop.fo.flow.Character; +import org.apache.fop.area.inline.InlineArea; + +/** + * LayoutManager for the fo:character formatting object + */ +public class CharacterLayoutManager extends LeafNodeLayoutManager { + + /** + * Constructor + * + * @param node the fo:character formatting object + * @todo better null checking of node + */ + public CharacterLayoutManager(Character node) { + super(node); + InlineArea inline = getCharacterInlineArea(node); + setCurrentArea(inline); + } + + private InlineArea getCharacterInlineArea(Character node) { + String str = node.getProperty(Character.PR_CHARACTER).getString(); + org.apache.fop.area.inline.Character ch = + new org.apache.fop.area.inline.Character(str.charAt(0)); + return ch; + } +} +