From c578ceae802518be510f14b2bc9023f1be0ad21a Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Sat, 7 Aug 2004 13:01:17 +0000 Subject: [PATCH] 1. new FONode.invalidChildError method added that will takes a "ruleViolated" string for more detailed error messages. 2. FO_URI added to FONode to decrease the number of imports of FOElementMapping within the FONode subclasses. 3. Layout logic moved from fo.flow.BasicLink to a new BasicLinkLayoutManager class. 4. BidiLayoutManager constructor modified, now needs the flow.BidiOverride object. 5. ListItemLayoutManager setup moved from AddLMManager to flow.Listitem and layoutmgr.list.ListItemLayoutManager. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197859 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/FONode.java | 21 +++- .../org/apache/fop/fo/flow/BasicLink.java | 109 ++++++++---------- .../org/apache/fop/fo/flow/BidiOverride.java | 45 ++++---- src/java/org/apache/fop/fo/flow/Block.java | 15 ++- .../fop/fo/flow/InstreamForeignObject.java | 3 +- src/java/org/apache/fop/fo/flow/ListItem.java | 57 +++------ .../fop/fo/pagination/Declarations.java | 3 +- .../org/apache/fop/fo/pagination/Flow.java | 3 +- .../fop/fo/pagination/LayoutMasterSet.java | 3 +- .../fop/fo/pagination/PageSequence.java | 4 +- .../fop/fo/pagination/PageSequenceMaster.java | 3 +- .../RepeatablePageMasterAlternatives.java | 3 +- .../org/apache/fop/fo/pagination/Root.java | 3 +- .../fop/fo/pagination/StaticContent.java | 1 - .../apache/fop/layoutmgr/AddLMVisitor.java | 32 ----- .../fop/layoutmgr/BasicLinkLayoutManager.java | 68 +++++++++++ .../fop/layoutmgr/BidiLayoutManager.java | 4 +- .../layoutmgr/list/ListItemLayoutManager.java | 23 ++-- 18 files changed, 208 insertions(+), 192 deletions(-) create mode 100644 src/java/org/apache/fop/layoutmgr/BasicLinkLayoutManager.java diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 7288b97b3..73204f27d 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -40,6 +40,8 @@ import org.apache.fop.fo.extensions.svg.SVGElementMapping; */ public abstract class FONode { + protected static String FO_URI = FOElementMapping.URI; + /** Parent FO node */ protected FONode parent; @@ -277,10 +279,25 @@ public abstract class FONode { */ protected void invalidChildError(Locator loc, String nsURI, String lName) throws SAXParseException { - throw new SAXParseException (errorText(loc) + getNodeString(nsURI, lName) + - " is not a valid child element of " + getName() + ".", loc); + invalidChildError(loc, nsURI, lName, null); } + /** + * Helper function to return "invalid child" exceptions with more + * complex validation rules (i.e., needing more explanation of the problem) + * @param loc org.xml.sax.Locator object of the error (*not* parent node) + * @param nsURI namespace URI of incoming invalid node + * @param lName local name (i.e., no prefix) of incoming node + * @param ruleViolated text explanation of problem + */ + protected void invalidChildError(Locator loc, String nsURI, String lName, + String ruleViolated) + throws SAXParseException { + throw new SAXParseException (errorText(loc) + getNodeString(nsURI, lName) + + " is not a valid child element of " + getName() + + ((ruleViolated != null) ? ": " + ruleViolated : "."), loc); + } + /** * Helper function to return missing child element errors * (e.g., fo:layout-master-set not having any page-master child element) diff --git a/src/java/org/apache/fop/fo/flow/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java index 1f2501644..e26eb3484 100644 --- a/src/java/org/apache/fop/fo/flow/BasicLink.java +++ b/src/java/org/apache/fop/fo/flow/BasicLink.java @@ -27,33 +27,25 @@ import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP -import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.area.inline.InlineParent; -import org.apache.fop.area.LinkResolver; -import org.apache.fop.area.PageViewport; -import org.apache.fop.area.Trait; -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.LayoutManager; -import org.apache.fop.layoutmgr.LMiter; -import org.apache.fop.layoutmgr.InlineStackingLayoutManager; -import org.apache.fop.fo.properties.CommonAccessibility; -import org.apache.fop.fo.properties.CommonAural; -import org.apache.fop.fo.properties.CommonBorderAndPadding; -import org.apache.fop.fo.properties.CommonBackground; -import org.apache.fop.fo.properties.CommonMarginInline; -import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.layoutmgr.BasicLinkLayoutManager; /** - * The basic link. - * This sets the basic link trait on the inline parent areas - * that are created by the fo element. + * The fo:basic-link formatting object. + * + * This class contains the logic to determine the link represented by this FO, + * and whether that link is external (uses a URI) or internal (an id + * reference). */ public class BasicLink extends Inline { + + // link represented by this FO private String link = null; - private boolean external = false; + + // indicator of whether link is internal or external + private boolean isExternalLink = false; - // used for FO validation + // used only for FO validation private boolean blockOrInlineItemFound = false; /** @@ -68,17 +60,18 @@ public class BasicLink extends Inline { */ protected void addProperties(Attributes attlist) throws SAXParseException { super.addProperties(attlist); - setupID(); + + // This logic is for determining the link represented by this FO. String ext = propertyList.get(PR_EXTERNAL_DESTINATION).getString(); String internal = propertyList.get(PR_INTERNAL_DESTINATION).getString(); - // per spec, internal takes precedence if both specified - if (internal.length() > 0) { + // per spec, internal takes precedence if both specified + if (internal.length() > 0) { link = internal; } else if (ext.length() > 0) { link = ext; - external = true; + isExternalLink = true; } else { // slightly stronger than spec "should be specified" attributeError("Missing attribute: Either external-destination or " + @@ -94,7 +87,7 @@ public class BasicLink extends Inline { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (nsURI == FOElementMapping.URI && localName.equals("marker")) { + if (nsURI == FO_URI && localName.equals("marker")) { if (blockOrInlineItemFound) { nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)"); } @@ -113,50 +106,40 @@ public class BasicLink extends Inline { getFOInputHandler().endLink(); } - /** - * @return true (BasicLink can contain Markers) - */ - protected boolean containsMarkers() { - return true; - } - /** * @see org.apache.fop.fo.FObj#addLayoutManager(List) - * @todo create a subclass for InlineStackingLayoutManager, moving the formatting - * logic to the layoutmgr package - */ + */ public void addLayoutManager(List list) { - InlineStackingLayoutManager lm; - lm = new InlineStackingLayoutManager(this) { - protected InlineParent createArea() { - InlineParent area = super.createArea(); - setupBasicLinkArea(parentLM, area); - return area; - } - }; - lm.setLMiter(new LMiter(lm, getChildNodes())); + BasicLinkLayoutManager lm = new BasicLinkLayoutManager(this); list.add(lm); } - - protected void setupBasicLinkArea(LayoutManager parentLM, - InlineParent area) { - if (link == null) { - return; - } - if (external) { - area.addTrait(Trait.EXTERNAL_LINK, link); - } else { - PageViewport page = parentLM.resolveRefID(link); - if (page != null) { - area.addTrait(Trait.INTERNAL_LINK, page.getKey()); - } else { - LinkResolver res = new LinkResolver(link, area); - parentLM.addUnresolvedArea(link, res); - } - } - } - + + /** + * @return link represented by this fo:basic-link + */ + public String getLink() { + return link; + } + + /** + * @return true if link is external, false if internal + */ + public boolean isExternalLink() { + return isExternalLink; + } + + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:basic-link"; } + + /** + * @return true (BasicLink can contain Markers) + * @todo see if can remove in favor of a BitSet for all FO's + */ + protected boolean containsMarkers() { + return true; + } } diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java index 52eb0451f..ebd29f34f 100644 --- a/src/java/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/java/org/apache/fop/fo/flow/BidiOverride.java @@ -28,15 +28,11 @@ import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObjMixed; import org.apache.fop.layoutmgr.BidiLayoutManager; import org.apache.fop.layoutmgr.InlineStackingLayoutManager; import org.apache.fop.layoutmgr.LayoutManager; -import org.apache.fop.fo.properties.CommonAural; -import org.apache.fop.fo.properties.CommonRelativePosition; - /** * fo:bidi-override element. @@ -77,6 +73,8 @@ public class BidiOverride extends FObjMixed { /** * @see org.apache.fop.fo.FObj#addProperties + * @todo see if can use a BitSet to determine if an FO should + * have its ID setup; then move setupID() instances to FObj. */ protected void addProperties(Attributes attlist) throws SAXParseException { super.addProperties(attlist); @@ -93,7 +91,7 @@ public class BidiOverride extends FObjMixed { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (nsURI == FOElementMapping.URI && localName.equals("marker")) { + if (nsURI == FO_URI && localName.equals("marker")) { if (blockOrInlineItemFound) { nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)"); @@ -101,25 +99,20 @@ public class BidiOverride extends FObjMixed { } else if (!isBlockOrInlineItem(nsURI, localName)) { invalidChildError(loc, nsURI, localName); } else if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName)) { - invalidChildError(loc, nsURI, localName); + String ruleViolated = "An fo:bidi-override" + + " that is a descendant of an fo:leader or of the fo:inline child" + + " of an fo:footnote may not have block-level children, unless it" + + " has a nearer ancestor that is an fo:inline-container."; + invalidChildError(loc, nsURI, localName, ruleViolated); } else { blockOrInlineItemFound = true; } } - public String getName() { - return "fo:bidi-override"; - } - - /** - * @return true (BidiOverride can contain Markers) - */ - protected boolean containsMarkers() { - return true; - } - /** * @see org.apache.fop.fo.FObj#addLayoutManager(List) + * @todo see if can/should move the child iteration logic + * to BidiLayoutManager */ public void addLayoutManager(List list) { if (false) { @@ -130,8 +123,8 @@ public class BidiOverride extends FObjMixed { for (int count = childList.size() - 1; count >= 0; count--) { LayoutManager lm = (LayoutManager) childList.get(count); if (lm.generatesInlineAreas()) { - LayoutManager blm = new BidiLayoutManager((InlineStackingLayoutManager) lm); - blm.setFObj(this); + LayoutManager blm = new BidiLayoutManager(this, + (InlineStackingLayoutManager) lm); list.add(blm); } else { list.add(lm); @@ -140,5 +133,17 @@ public class BidiOverride extends FObjMixed { } } - + /** + * @see org.apache.fop.fo.FObj#getName() + */ + public String getName() { + return "fo:bidi-override"; + } + + /** + * @return true (BidiOverride can contain Markers) + */ + protected boolean containsMarkers() { + return true; + } } diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index 2e35396e3..bdcf7c61d 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -141,13 +141,6 @@ public class Block extends FObjMixed { getFOInputHandler().startBlock(this); } - /** - * @return true (Block can contain Markers) - */ - protected boolean containsMarkers() { - return true; - } - /** * @return span for this Block, in millipoints (??) */ @@ -347,8 +340,14 @@ public class Block extends FObjMixed { list.add(blm); } - public String getName() { + public String getName() { return "fo:block"; } + /** + * @return true (Block can contain Markers) + */ + protected boolean containsMarkers() { + return true; + } } diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java index 5b977cbf4..1a763844d 100644 --- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -26,7 +26,6 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.fo.LMVisited; -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.FObj; @@ -54,7 +53,7 @@ public class InstreamForeignObject extends FObj implements LMVisited { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (nsURI == FOElementMapping.URI) { + if (nsURI == FO_URI) { invalidChildError(loc, nsURI, localName); } else if (hasNonXSLNamespaceElement) { tooManyNodesError(loc, "child element"); diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index cd4c2127b..4ccde913a 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -18,28 +18,23 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // XML import org.xml.sax.Attributes; import org.xml.sax.SAXParseException; // FOP -import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.properties.CommonAccessibility; -import org.apache.fop.fo.properties.CommonAural; -import org.apache.fop.fo.properties.CommonBackground; -import org.apache.fop.fo.properties.CommonBorderAndPadding; -import org.apache.fop.fo.properties.CommonMarginBlock; -import org.apache.fop.fo.properties.CommonRelativePosition; -import org.apache.fop.fo.LMVisited; +import org.apache.fop.layoutmgr.list.ListItemLayoutManager; /** * Class modelling the fo:list-item object. See Sec. 6.8.3 of the XSL-FO * Standard. */ -public class ListItem extends FObj implements LMVisited { +public class ListItem extends FObj { private ListItemLabel label = null; private ListItemBody body = null; @@ -70,31 +65,7 @@ public class ListItem extends FObj implements LMVisited { } private void setup() { - - // Common Accessibility Properties - CommonAccessibility mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - CommonAural mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - CommonBorderAndPadding bap = propMgr.getBorderAndPadding(); - CommonBackground bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Block - CommonMarginBlock mProps = propMgr.getMarginProps(); - - // Common Relative Position Properties - CommonRelativePosition mRelProps = propMgr.getRelativePositionProps(); - - // this.propertyList.get("break-after"); - // this.propertyList.get("break-before"); setupID(); - // this.propertyList.get("keep-together"); - // this.propertyList.get("keep-with-next"); - // this.propertyList.get("keep-with-previous"); - // this.propertyList.get("relative-align"); - this.align = this.propertyList.get(PR_TEXT_ALIGN).getEnum(); this.alignLast = this.propertyList.get(PR_TEXT_ALIGN_LAST).getEnum(); this.lineHeight = @@ -103,7 +74,6 @@ public class ListItem extends FObj implements LMVisited { this.propertyList.get(PR_SPACE_BEFORE | CP_OPTIMUM).getLength().getValue(); this.spaceAfter = this.propertyList.get(PR_SPACE_AFTER | CP_OPTIMUM).getLength().getValue(); - } /** @@ -135,6 +105,19 @@ public class ListItem extends FObj implements LMVisited { return true; } + /** + * @see org.apache.fop.fo.FObj#addLayoutManager(List) + * @todo remove checks for non-nulls after validateChildNode() added + */ + public void addLayoutManager(List list) { + if (label != null && body != null) { + ListItemLayoutManager blm = new ListItemLayoutManager(this); + list.add(blm); + } else { + getLogger().error("list-item requires list-item-label and list-item-body"); + } + } + public ListItemLabel getLabel() { return label; } @@ -143,10 +126,6 @@ public class ListItem extends FObj implements LMVisited { return body; } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveListItem(this); - } - protected void endOfNode() throws SAXParseException { super.endOfNode(); getFOInputHandler().endListItem(this); diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java index f16b4fb82..7cc553385 100644 --- a/src/java/org/apache/fop/fo/pagination/Declarations.java +++ b/src/java/org/apache/fop/fo/pagination/Declarations.java @@ -29,7 +29,6 @@ import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.XMLObj; @@ -62,7 +61,7 @@ public class Declarations extends FObj { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (nsURI == FOElementMapping.URI) { + if (nsURI == FO_URI) { if (!localName.equals("color-profile")) { invalidChildError(loc, nsURI, localName); } diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index 9c38cdd57..88d4f1d8b 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -30,7 +30,6 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.layoutmgr.FlowLayoutManager; /** @@ -74,7 +73,7 @@ public class Flow extends FObj { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (nsURI == FOElementMapping.URI && localName.equals("marker")) { + if (nsURI == FO_URI && localName.equals("marker")) { if (blockItemFound) { nodesOutOfOrderError(loc, "fo:marker", "(%block;)"); } diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java index 21e2b123c..ec5c5fff7 100644 --- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -30,7 +30,6 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.apps.FOPException; /** @@ -60,7 +59,7 @@ public class LayoutMasterSet extends FObj { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (nsURI == FOElementMapping.URI) { + if (nsURI == FO_URI) { if (!localName.equals("simple-page-master") && !localName.equals("page-sequence-master")) { invalidChildError(loc, nsURI, localName); diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index 8e26a2dbb..7802a63c7 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -30,8 +30,6 @@ import org.xml.sax.SAXParseException; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.FOElementMapping; -import org.apache.fop.apps.FOPException; /** * This provides pagination of flows onto pages. Much of the @@ -139,7 +137,7 @@ public class PageSequence extends FObj { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (nsURI == FOElementMapping.URI) { + if (nsURI == FO_URI) { if (localName.equals("title")) { if (titleFO != null) { tooManyNodesError(loc, "fo:title"); diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java index 7e2ee40df..6d87d5315 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -30,7 +30,6 @@ import org.xml.sax.SAXParseException; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.apps.FOPException; /** @@ -69,7 +68,7 @@ public class PageSequenceMaster extends FObj { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (nsURI == FOElementMapping.URI) { + if (nsURI == FO_URI) { if (!localName.equals("single-page-master-reference") && !localName.equals("repeatable-page-master-reference") && !localName.equals("repeatable-page-master-alternatives")) { diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index cc929aec9..f7f37757b 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java @@ -27,7 +27,6 @@ import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; @@ -64,7 +63,7 @@ public class RepeatablePageMasterAlternatives extends FObj */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (!(nsURI == FOElementMapping.URI && + if (!(nsURI == FO_URI && localName.equals("conditional-page-master-reference"))) { invalidChildError(loc, nsURI, localName); } diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index 5b02c4136..5b7d0b5b9 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -28,7 +28,6 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fo.extensions.Bookmarks; import org.apache.fop.fo.FOInputHandler; @@ -75,7 +74,7 @@ public class Root extends FObj { */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws SAXParseException { - if (nsURI == FOElementMapping.URI) { + if (nsURI == FO_URI) { if (localName.equals("layout-master-set")) { if (layoutMasterSet != null) { tooManyNodesError(loc, "fo:layout-master-set"); diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java index 59f24818b..06ab42bc9 100644 --- a/src/java/org/apache/fop/fo/pagination/StaticContent.java +++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java @@ -24,7 +24,6 @@ import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP -import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FONode; /** diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index 3634fe517..5411a4d18 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -45,9 +45,6 @@ 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; -import org.apache.fop.fo.flow.ListItem; -import org.apache.fop.fo.flow.ListItemBody; -import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.flow.RetrieveMarker; import org.apache.fop.fo.flow.Table; @@ -62,8 +59,6 @@ import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.pagination.Title; import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; -import org.apache.fop.layoutmgr.list.Item; -import org.apache.fop.layoutmgr.list.ListItemLayoutManager; import org.apache.fop.layoutmgr.table.Body; import org.apache.fop.layoutmgr.table.Column; import org.apache.fop.layoutmgr.table.TableLayoutManager; @@ -422,33 +417,6 @@ public class AddLMVisitor { return areaCurrent; } - public void serveListItem(ListItem node) { - if (node.getLabel() != null && node.getBody() != null) { - ListItemLayoutManager blm = new ListItemLayoutManager(node); - blm.setLabel(getListItemLabelLayoutManager(node.getLabel())); - blm.setBody(getListItemBodyLayoutManager(node.getBody())); - currentLMList.add(blm); - } else { - node.getLogger().error("list-item requires list-item-label and list-item-body"); - } - } - - /** - * @return this object's Item layout manager - */ - public Item getListItemLabelLayoutManager(ListItemLabel node) { - Item itemLabel = new Item(node); - return itemLabel; - } - - /** - * @return Item layout manager - */ - public Item getListItemBodyLayoutManager(ListItemBody node) { - Item item = new Item(node); - return item; - } - /** * Overridden from FObj * @param lms the list to which the layout manager(s) should be added diff --git a/src/java/org/apache/fop/layoutmgr/BasicLinkLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BasicLinkLayoutManager.java new file mode 100644 index 000000000..154332e78 --- /dev/null +++ b/src/java/org/apache/fop/layoutmgr/BasicLinkLayoutManager.java @@ -0,0 +1,68 @@ +/* + * 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.BasicLink; +import org.apache.fop.area.inline.InlineParent; +import org.apache.fop.area.Trait; +import org.apache.fop.area.LinkResolver; +import org.apache.fop.area.PageViewport; + +/** + * LayoutManager for the fo:basic-link formatting object + */ +public class BasicLinkLayoutManager extends InlineStackingLayoutManager { + + private String link; + private boolean isExternalLink = false; + + /** + * Create an fo:basic-link layout manager. + * + * @param node the formatting object that creates the area + */ + public BasicLinkLayoutManager(BasicLink node) { + super(node); + setLMiter(new LMiter(this, node.getChildNodes())); + link = node.getLink(); + isExternalLink = node.isExternalLink(); + } + + protected InlineParent createArea() { + InlineParent area = super.createArea(); + setupBasicLinkArea(parentLM, area); + return area; + } + + private void setupBasicLinkArea(LayoutManager parentLM, + InlineParent area) { + if (isExternalLink) { + area.addTrait(Trait.EXTERNAL_LINK, link); + } else { + PageViewport page = parentLM.resolveRefID(link); + if (page != null) { + area.addTrait(Trait.INTERNAL_LINK, page.getKey()); + } else { + LinkResolver res = new LinkResolver(link, area); + parentLM.addUnresolvedArea(link, res); + } + } + } +} + diff --git a/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java index 46d9b74d8..05a9d9fb8 100644 --- a/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.fo.flow.BidiOverride; /** @@ -33,8 +34,9 @@ public class BidiLayoutManager extends LeafNodeLayoutManager { private List children; - public BidiLayoutManager(InlineStackingLayoutManager cLM) { + public BidiLayoutManager(BidiOverride node, InlineStackingLayoutManager cLM) { children = new ArrayList(); + setFObj(node); /* for (int count = cLM.size() - 1; count >= 0; count--) { InlineArea ia = cLM.get(count); diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 0af9e7b45..90f9b0321 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -19,6 +19,9 @@ package org.apache.fop.layoutmgr.list; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.flow.ListItem; +import org.apache.fop.fo.flow.ListItemBody; +import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.PropertyManager; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.LayoutManager; @@ -65,8 +68,10 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { * Create a new list item layout manager. * */ - public ListItemLayoutManager(FObj node) { + public ListItemLayoutManager(ListItem node) { super(node); + setLabel(node.getLabel()); + setBody(node.getBody()); } /** @@ -79,20 +84,20 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { } /** - * Sets the label of the list item - * @param item the label item + * Create a LM for the fo:list-item-label object + * @param node the fo:list-item-label FO */ - public void setLabel(Item item) { - label = item; + public void setLabel(ListItemLabel node) { + label = new Item(node); label.setParent(this); } /** - * Sets the body of the list item - * @param item the body item + * Create a LM for the fo:list-item-body object + * @param node the fo:list-item-body FO */ - public void setBody(Item item) { - body = item; + public void setBody(ListItemBody node) { + body = new Item(node); body.setParent(this); } -- 2.39.5