From: Glen Mazza Date: Fri, 6 Aug 2004 15:41:12 +0000 (+0000) Subject: PR: X-Git-Tag: Root_Temp_KnuthStylePageBreaking~631 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a8b6d28e90c897e76f817b3fcdda056d6182fc64;p=xmlgraphics-fop.git PR: Obtained from: Submitted by: Reviewed by: Moved three FO's from AddLMVisitor->FObj.AddLayoutManager(); will eventually need to create additional LM's for at least two of them to remove the Area-specific code these FO's now have. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197858 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index 6c8ba742c..70a7db4f8 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -493,7 +493,7 @@ public class FOText extends FObj { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { if (endIndex - startIndex > 0) { diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 0d77a1cc2..b6c6f6f9b 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -76,7 +76,7 @@ public class FObjMixed extends FObj { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { if (getChildNodes() != null) { diff --git a/src/java/org/apache/fop/fo/flow/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java index 4b24bd6c7..1f2501644 100644 --- a/src/java/org/apache/fop/fo/flow/BasicLink.java +++ b/src/java/org/apache/fop/fo/flow/BasicLink.java @@ -18,29 +18,38 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // XML import org.xml.sax.Attributes; 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.AddLMVisitor; +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.fo.LMVisited; /** * The basic link. * This sets the basic link trait on the inline parent areas * that are created by the fo element. */ -public class BasicLink extends Inline implements LMVisited { +public class BasicLink extends Inline { private String link = null; private boolean external = false; @@ -104,24 +113,6 @@ public class BasicLink extends Inline implements LMVisited { 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"; - } - /** * @return true (BasicLink can contain Markers) */ @@ -130,11 +121,42 @@ public class BasicLink extends Inline 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. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveBasicLink(this); + * @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())); + 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); + } + } + } + + public String getName() { + return "fo:basic-link"; } } diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java index 10c10ec40..52eb0451f 100644 --- a/src/java/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/java/org/apache/fop/fo/flow/BidiOverride.java @@ -119,9 +119,7 @@ public class BidiOverride extends FObjMixed { } /** - * 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 addLayoutManager(List list) { if (false) { diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index ffe9afc05..2e35396e3 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -340,7 +340,7 @@ public class Block extends FObjMixed { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { BlockLayoutManager blm = new BlockLayoutManager(this); diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java index b0b4481ef..c05033d84 100644 --- a/src/java/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java @@ -134,7 +134,7 @@ public class BlockContainer extends FObj { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { BlockContainerLayoutManager blm = new BlockContainerLayoutManager(this); diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index 813026b4c..a023c21c0 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -19,6 +19,7 @@ package org.apache.fop.fo.flow; // Java +import java.util.List; import java.awt.geom.Rectangle2D; // XML @@ -26,21 +27,25 @@ import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXParseException; +import org.apache.fop.area.inline.Image; +import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.area.inline.Viewport; import org.apache.fop.datatypes.Length; +import org.apache.fop.fo.properties.CommonBorderAndPadding; +import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.FObj; import org.apache.fop.image.FopImage; import org.apache.fop.image.ImageFactory; -import org.xml.sax.Attributes; -import org.apache.fop.fo.LMVisited; +import org.apache.fop.layoutmgr.LeafNodeLayoutManager; +import org.apache.fop.layoutmgr.TraitSetter; /** * External graphic formatting object. * This FO node handles the external graphic. It creates an image * inline area that can be added to the area tree. */ -public class ExternalGraphic extends FObj implements LMVisited { +public class ExternalGraphic extends FObj { private String url; private int breakAfter; private int breakBefore; @@ -85,6 +90,7 @@ public class ExternalGraphic extends FObj implements LMVisited { * This gets the sizes for the image and the dimensions and clipping. */ private void setup() { + setupID(); url = this.propertyList.get(PR_SRC).getString(); if (url == null) { return; @@ -251,12 +257,46 @@ public class ExternalGraphic 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. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - setup(); - aLMV.serveExternalGraphic(this); + * @see org.apache.fop.fo.FObj#addLayoutManager(List) + */ + public void addLayoutManager(List list) { + setup(); + InlineArea area = getExternalGraphicInlineArea(); + if (area != null) { + LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this); + lm.setCurrentArea(area); + lm.setAlignment(getProperty(PR_VERTICAL_ALIGN).getEnum()); + lm.setLead(getViewHeight()); + list.add(lm); + } } + + /** + * Get the inline area for this external grpahic. + * This creates the image area and puts it inside a viewport. + * + * @return the viewport containing the image area + * @todo see if can move to LM classes. + */ + public InlineArea getExternalGraphicInlineArea() { + if (getURL() == null) { + return null; + } + Image imArea = new Image(getURL()); + Viewport vp = new Viewport(imArea); + vp.setWidth(getViewWidth()); + vp.setHeight(getViewHeight()); + vp.setClip(getClip()); + vp.setContentPosition(getPlacement()); + vp.setOffset(0); + + // Common Border, Padding, and Background Properties + CommonBorderAndPadding bap = getPropertyManager().getBorderAndPadding(); + CommonBackground bProps = getPropertyManager().getBackgroundProps(); + TraitSetter.addBorders(vp, bap); + TraitSetter.addBackground(vp, bProps); + + return vp; + } + } diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java index 5c02ac173..1c16e12cb 100644 --- a/src/java/org/apache/fop/fo/flow/Footnote.java +++ b/src/java/org/apache/fop/fo/flow/Footnote.java @@ -82,7 +82,7 @@ public class Footnote extends FObj { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { if (getInlineFO() == null) { diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java index 9e0d234da..753d6253d 100644 --- a/src/java/org/apache/fop/fo/flow/InlineContainer.java +++ b/src/java/org/apache/fop/fo/flow/InlineContainer.java @@ -94,7 +94,7 @@ public class InlineContainer extends FObj { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { ArrayList childList = new ArrayList(); diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index a426fb187..d3dbf77f1 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.java @@ -102,7 +102,7 @@ public class ListBlock extends FObj { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { ListBlockLayoutManager lm = new ListBlockLayoutManager(this); diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java index 40dc0eed4..514891031 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.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; @@ -25,7 +28,6 @@ import org.xml.sax.SAXParseException; import org.apache.fop.datatypes.ColorType; 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; @@ -34,8 +36,16 @@ import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fonts.Font; -import org.apache.fop.fo.LMVisited; - +import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.LeafNodeLayoutManager; +import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.area.PageViewport; +import org.apache.fop.area.Resolveable; +import org.apache.fop.area.Trait; +import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.area.inline.UnresolvedPageNumber; +import org.apache.fop.area.inline.TextArea; /** * Class modelling the fo:page-number-citation object. See Sec. 6.6.11 of the @@ -44,7 +54,7 @@ import org.apache.fop.fo.LMVisited; * The page number used is the page that contains the start of the * block referenced with the ref-id attribute. */ -public class PageNumberCitation extends FObj implements LMVisited { +public class PageNumberCitation extends FObj { /** Fontstate for this object **/ protected Font fontState; @@ -106,22 +116,7 @@ public class PageNumberCitation extends FObj implements LMVisited { CommonRelativePosition mRelProps = propMgr.getRelativePositionProps(); - // this.propertyList.get("alignment-adjust"); - // this.propertyList.get("alignment-baseline"); - // this.propertyList.get("baseline-shift"); - // this.propertyList.get("dominant-baseline"); setupID(); - // this.propertyList.get("keep-with-next"); - // this.propertyList.get("keep-with-previous"); - // this.propertyList.get("letter-spacing"); - // this.propertyList.get("line-height"); - // this.propertyList.get("line-height-shift-adjustment"); - // this.propertyList.get("ref-id"); - // this.propertyList.get("score-spaces"); - // this.propertyList.get("text-decoration"); - // this.propertyList.get("text-shadow"); - // this.propertyList.get("text-transform"); - // this.propertyList.get("word-spacing"); ColorType c = this.propertyList.get(PR_COLOR).getColorType(); this.red = c.getRed(); @@ -157,8 +152,75 @@ public class PageNumberCitation extends FObj implements LMVisited { return "fo:page-number-citation"; } - public void acceptVisitor(AddLMVisitor aLMV) { - setup(); - aLMV.servePageNumberCitation(this); + /** + * @see org.apache.fop.fo.FObj#addLayoutManager(List) + * @todo create a subclass for LeafNodeLayoutManager, moving the formatting + * logic to the layoutmgr package + */ + public void addLayoutManager(List list) { + setup(); + LayoutManager lm; + lm = new LeafNodeLayoutManager(this) { + public InlineArea get(LayoutContext context) { + curArea = getPageNumberCitationInlineArea(parentLM); + return curArea; + } + + public void addAreas(PositionIterator posIter, + LayoutContext context) { + super.addAreas(posIter, context); + if (getUnresolved()) { + parentLM.addUnresolvedArea(getRefId(), + (Resolveable) curArea); + } + } + + protected void offsetArea(LayoutContext context) { + curArea.setOffset(context.getBaseline()); + } + }; + list.add(lm); } + + // if id can be resolved then simply return a word, otherwise + // return a resolveable area + public InlineArea getPageNumberCitationInlineArea(LayoutManager parentLM) { + if (getRefId().equals("")) { + getLogger().error("page-number-citation must contain \"ref-id\""); + return null; + } + PageViewport page = parentLM.resolveRefID(getRefId()); + InlineArea inline = null; + if (page != null) { + String str = page.getPageNumber(); + // get page string from parent, build area + TextArea text = new TextArea(); + inline = text; + int width = getStringWidth(str); + text.setTextArea(str); + inline.setIPD(width); + inline.setHeight(getFontState().getAscender() + - getFontState().getDescender()); + inline.setOffset(getFontState().getAscender()); + + inline.addTrait(Trait.FONT_NAME, getFontState().getFontName()); + inline.addTrait(Trait.FONT_SIZE, + new Integer(getFontState().getFontSize())); + setUnresolved(false); + } else { + setUnresolved(true); + inline = new UnresolvedPageNumber(getRefId()); + String str = "MMM"; // reserve three spaces for page number + int width = getStringWidth(str); + inline.setIPD(width); + inline.setHeight(getFontState().getAscender() + - getFontState().getDescender()); + inline.setOffset(getFontState().getAscender()); + + inline.addTrait(Trait.FONT_NAME, getFontState().getFontName()); + inline.addTrait(Trait.FONT_SIZE, + new Integer(getFontState().getFontSize())); + } + return inline; + } } diff --git a/src/java/org/apache/fop/fo/flow/TableCell.java b/src/java/org/apache/fop/fo/flow/TableCell.java index 841eeba55..6157de628 100644 --- a/src/java/org/apache/fop/fo/flow/TableCell.java +++ b/src/java/org/apache/fop/fo/flow/TableCell.java @@ -342,7 +342,7 @@ public class TableCell extends FObj { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { Cell clm = new Cell(this); diff --git a/src/java/org/apache/fop/fo/flow/TableRow.java b/src/java/org/apache/fop/fo/flow/TableRow.java index 5259a122e..7ddf4d9d1 100644 --- a/src/java/org/apache/fop/fo/flow/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/TableRow.java @@ -138,7 +138,7 @@ public class TableRow extends FObj { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { Row rlm = new Row(this); diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index ecd6e2fe9..9c38cdd57 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -172,7 +172,7 @@ public class Flow extends FObj { } /** - * @param list the list to which the layout manager(s) should be added + * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { FlowLayoutManager lm = new FlowLayoutManager(this); diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index ccb45de10..3634fe517 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -25,9 +25,6 @@ import java.util.ArrayList; import java.util.List; import java.util.ListIterator; -import org.apache.fop.area.LinkResolver; -import org.apache.fop.area.PageViewport; -import org.apache.fop.area.Resolveable; import org.apache.fop.area.Trait; import org.apache.fop.area.inline.FilledArea; import org.apache.fop.area.inline.ForeignObject; @@ -43,10 +40,8 @@ import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.XMLObj; -import org.apache.fop.fo.flow.BasicLink; import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.Character; -import org.apache.fop.fo.flow.ExternalGraphic; import org.apache.fop.fo.flow.Inline; import org.apache.fop.fo.flow.InstreamForeignObject; import org.apache.fop.fo.flow.Leader; @@ -54,7 +49,6 @@ 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.PageNumberCitation; import org.apache.fop.fo.flow.RetrieveMarker; import org.apache.fop.fo.flow.Table; import org.apache.fop.fo.flow.TableAndCaption; @@ -126,39 +120,22 @@ public class AddLMVisitor { } /** - * Add start and end properties for the link + * @param node Wrapper object to process */ - public void serveBasicLink(final BasicLink node) { - InlineStackingLayoutManager lm; - lm = new InlineStackingLayoutManager(node) { - protected InlineParent createArea() { - InlineParent area = super.createArea(); - setupBasicLinkArea(node, parentLM, area); - return area; + public void serveWrapper(Wrapper node) { + ListIterator baseIter; + baseIter = node.getChildNodes(); + if (baseIter == null) return; + while (baseIter.hasNext()) { + FObj child = (FObj) baseIter.next(); + if (child instanceof LMVisited) { + ((LMVisited) child).acceptVisitor(this); + } else { + child.addLayoutManager(currentLMList); } - }; - lm.setLMiter(new LMiter(lm, node.getChildNodes())); - currentLMList.add(lm); + } } - protected void setupBasicLinkArea(BasicLink node, LayoutManager parentLM, - InlineParent area) { - if (node.getLink() == null) { - return; - } - if (node.getExternal()) { - area.addTrait(Trait.EXTERNAL_LINK, node.getLink()); - } else { - PageViewport page = parentLM.resolveRefID(node.getLink()); - if (page != null) { - area.addTrait(Trait.INTERNAL_LINK, page.getKey()); - } else { - LinkResolver res = new LinkResolver(node.getLink(), area); - parentLM.addUnresolvedArea(node.getLink(), res); - } - } - } - public void serveLeader(final Leader node) { LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node) { public InlineArea get(LayoutContext context) { @@ -285,49 +262,6 @@ public class AddLMVisitor { return null; } - /** - * This adds a leafnode layout manager that deals with the - * created viewport/image area. - */ - public void serveExternalGraphic(ExternalGraphic node) { - InlineArea area = getExternalGraphicInlineArea(node); - if (area != null) { - node.setupID(); - LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node); - lm.setCurrentArea(area); - lm.setAlignment(node.getProperty(Constants.PR_VERTICAL_ALIGN).getEnum()); - lm.setLead(node.getViewHeight()); - currentLMList.add(lm); - } - } - - /** - * Get the inline area for this external grpahic. - * This creates the image area and puts it inside a viewport. - * - * @return the viewport containing the image area - */ - public InlineArea getExternalGraphicInlineArea(ExternalGraphic node) { - if (node.getURL() == null) { - return null; - } - Image imArea = new Image(node.getURL()); - Viewport vp = new Viewport(imArea); - vp.setWidth(node.getViewWidth()); - vp.setHeight(node.getViewHeight()); - vp.setClip(node.getClip()); - vp.setContentPosition(node.getPlacement()); - vp.setOffset(0); - - // Common Border, Padding, and Background Properties - CommonBorderAndPadding bap = node.getPropertyManager().getBorderAndPadding(); - CommonBackground bProps = node.getPropertyManager().getBackgroundProps(); - TraitSetter.addBorders(vp, bap); - TraitSetter.addBackground(vp, bProps); - - return vp; - } - public void serveInstreamForeignObject(InstreamForeignObject node) { Viewport areaCurrent = getInstreamForeignObjectInlineArea(node); if (areaCurrent != null) { @@ -552,73 +486,6 @@ public class AddLMVisitor { currentLMList.add(lm); } - public void servePageNumberCitation(final PageNumberCitation node) { - LayoutManager lm; - lm = new LeafNodeLayoutManager(node) { - public InlineArea get(LayoutContext context) { - curArea = getPageNumberCitationInlineArea(node, parentLM); - return curArea; - } - - public void addAreas(PositionIterator posIter, - LayoutContext context) { - super.addAreas(posIter, context); - if (node.getUnresolved()) { - parentLM.addUnresolvedArea(node.getRefId(), - (Resolveable) curArea); - } - } - - protected void offsetArea(LayoutContext context) { - curArea.setOffset(context.getBaseline()); - } - }; - currentLMList.add(lm); - } - - // if id can be resolved then simply return a word, otherwise - // return a resolveable area - public InlineArea getPageNumberCitationInlineArea(PageNumberCitation node, - LayoutManager parentLM) { - if (node.getRefId().equals("")) { - node.getLogger().error("page-number-citation must contain \"ref-id\""); - return null; - } - PageViewport page = parentLM.resolveRefID(node.getRefId()); - InlineArea inline = null; - if (page != null) { - String str = page.getPageNumber(); - // get page string from parent, build area - TextArea text = new TextArea(); - inline = text; - int width = node.getStringWidth(str); - text.setTextArea(str); - inline.setIPD(width); - inline.setHeight(node.getFontState().getAscender() - - node.getFontState().getDescender()); - inline.setOffset(node.getFontState().getAscender()); - - inline.addTrait(Trait.FONT_NAME, node.getFontState().getFontName()); - inline.addTrait(Trait.FONT_SIZE, - new Integer(node.getFontState().getFontSize())); - node.setUnresolved(false); - } else { - node.setUnresolved(true); - inline = new UnresolvedPageNumber(node.getRefId()); - String str = "MMM"; // reserve three spaces for page number - int width = node.getStringWidth(str); - inline.setIPD(width); - inline.setHeight(node.getFontState().getAscender() - - node.getFontState().getDescender()); - inline.setOffset(node.getFontState().getAscender()); - - inline.addTrait(Trait.FONT_NAME, node.getFontState().getFontName()); - inline.addTrait(Trait.FONT_SIZE, - new Integer(node.getFontState().getFontSize())); - } - return inline; - } - public void serveTable(Table node) { TableLayoutManager tlm = new TableLayoutManager(node); ArrayList columns = node.getColumns(); @@ -667,21 +534,4 @@ public class AddLMVisitor { public void serveTableHeader(TableHeader node) { serveTableBody((TableBody)node); } - - /** - * @param node Wrapper object to process - */ - public void serveWrapper(Wrapper node) { - ListIterator baseIter; - baseIter = node.getChildNodes(); - if (baseIter == null) return; - while (baseIter.hasNext()) { - FObj child = (FObj) baseIter.next(); - if (child instanceof LMVisited) { - ((LMVisited) child).acceptVisitor(this); - } else { - child.addLayoutManager(currentLMList); - } - } - } }