diff options
author | William Victor Mote <vmote@apache.org> | 2003-08-26 16:48:28 +0000 |
---|---|---|
committer | William Victor Mote <vmote@apache.org> | 2003-08-26 16:48:28 +0000 |
commit | 53b3de882f968e05217f25f8323f4cc0589f5006 (patch) | |
tree | af110c987872c1e98abd550902ec62687c2fdbeb | |
parent | 6543057246d1405df67c6b57f1ae29e72f614541 (diff) | |
download | xmlgraphics-fop-53b3de882f968e05217f25f8323f4cc0589f5006.tar.gz xmlgraphics-fop-53b3de882f968e05217f25f8323f4cc0589f5006.zip |
move fo/flow/PageNumberCitation.getInlineArea() to layoutmgr/AddLMVisitor.getPageNumberCitationInlineArea()
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196843 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/fo/flow/PageNumberCitation.java | 61 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/AddLMVisitor.java | 49 |
2 files changed, 56 insertions, 54 deletions
diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java index 3bd69a79b..c959d2488 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java @@ -51,11 +51,6 @@ package org.apache.fop.fo.flow; // FOP -import org.apache.fop.area.PageViewport; -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.Word; import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.FOTreeVisitor; import org.apache.fop.fo.FONode; @@ -93,7 +88,6 @@ public class PageNumberCitation extends FObj { private String pageNumber; private String refId; private TextState ts; - private InlineArea inline = null; private boolean unresolved = false; /** @@ -111,52 +105,11 @@ public class PageNumberCitation extends FObj { fontInfo = foih.getFontInfo(); } - // if id can be resolved then simply return a word, otherwise - // return a resolveable area - public InlineArea getInlineArea(LayoutProcessor parentLM) { - if (refId.equals("")) { - getLogger().error("page-number-citation must contain \"ref-id\""); - return null; - } - PageViewport page = parentLM.resolveRefID(refId); - if (page != null) { - String str = page.getPageNumber(); - // get page string from parent, build area - Word word = new Word(); - inline = word; - int width = getStringWidth(str); - word.setWord(str); - inline.setIPD(width); - inline.setHeight(fontState.getAscender() - - fontState.getDescender()); - inline.setOffset(fontState.getAscender()); - - inline.addTrait(Trait.FONT_NAME, fontState.getFontName()); - inline.addTrait(Trait.FONT_SIZE, - new Integer(fontState.getFontSize())); - unresolved = false; - } else { - unresolved = true; - inline = new UnresolvedPageNumber(refId); - String str = "MMM"; // reserve three spaces for page number - int width = getStringWidth(str); - inline.setIPD(width); - inline.setHeight(fontState.getAscender() - - fontState.getDescender()); - inline.setOffset(fontState.getAscender()); - - inline.addTrait(Trait.FONT_NAME, fontState.getFontName()); - inline.addTrait(Trait.FONT_SIZE, - new Integer(fontState.getFontSize())); - } - return inline; - } - /** * @param str string to be measured * @return width (in millipoints ??) of the string */ - protected int getStringWidth(String str) { + public int getStringWidth(String str) { int width = 0; for (int count = 0; count < str.length(); count++) { width += CharUtilities.getCharWidth(str.charAt(count), @@ -222,16 +175,20 @@ public class PageNumberCitation extends FObj { return refId; } - public InlineArea getInline() { - return inline; - } - public boolean getUnresolved() { return unresolved; } + public void setUnresolved(boolean isUnresolved) { + unresolved = isUnresolved; + } + public void acceptVisitor(FOTreeVisitor fotv) { fotv.serveVisitor(this); } + public Font getFontState() { + return fontState; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index 2054d9ca5..1a54440a7 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -60,6 +60,7 @@ import org.apache.fop.area.inline.InlineParent; import org.apache.fop.area.inline.FilledArea; import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.Space; +import org.apache.fop.area.inline.UnresolvedPageNumber; import org.apache.fop.area.inline.Word; import org.apache.fop.area.inline.Image; import org.apache.fop.area.inline.Viewport; @@ -712,7 +713,8 @@ public class AddLMVisitor extends FOTreeVisitor { LayoutManager lm; lm = new LeafNodeLayoutManager() { public InlineArea get(LayoutContext context) { - return node.getInlineArea(parentLM); + curArea = getPageNumberCitationInlineArea(node, parentLM); + return curArea; } public void addAreas(PositionIterator posIter, @@ -720,7 +722,7 @@ public class AddLMVisitor extends FOTreeVisitor { super.addAreas(posIter, context); if (node.getUnresolved()) { parentLM.addUnresolvedArea(node.getRefId(), - (Resolveable) node.getInline()); + (Resolveable) curArea); } } @@ -733,6 +735,49 @@ public class AddLMVisitor extends FOTreeVisitor { currentLMList.add(lm); } + // if id can be resolved then simply return a word, otherwise + // return a resolveable area + public InlineArea getPageNumberCitationInlineArea(PageNumberCitation node, + LayoutProcessor 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 + Word word = new Word(); + inline = word; + int width = node.getStringWidth(str); + word.setWord(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 serveVisitor(Table node) { TableLayoutManager tlm = new TableLayoutManager(); tlm.setUserAgent(node.getUserAgent()); |