diff options
Diffstat (limited to 'src/org/apache')
17 files changed, 384 insertions, 225 deletions
diff --git a/src/org/apache/fop/area/AreaTree.java b/src/org/apache/fop/area/AreaTree.java index 387646815..83d1a3ff8 100644 --- a/src/org/apache/fop/area/AreaTree.java +++ b/src/org/apache/fop/area/AreaTree.java @@ -60,6 +60,32 @@ public class AreaTree { model.addPage(page); } + public void addIDRef(String id, PageViewport pv) { + ArrayList list = (ArrayList)idLocations.get(id); + if(list == null) { + list = new ArrayList(); + idLocations.put(id, list); + } + list.add(pv); + + ArrayList todo = (ArrayList)resolve.get(id); + if(todo != null) { + for(int count = 0; count < todo.size(); count++) { + Resolveable res = (Resolveable)todo.get(count); + res.resolve(id, list); + } + } + } + + public void addUnresolvedID(String id, Resolveable res) { + ArrayList todo = (ArrayList)resolve.get(id); + if(todo == null) { + todo = new ArrayList(); + resolve.put(id, todo); + } + todo.add(res); + } + public void addTreeExtension(TreeExt ext) { treeExtensions.add(ext); if(ext.isResolveable()) { @@ -72,11 +98,9 @@ public class AreaTree { ArrayList todo = (ArrayList)resolve.get(ids[count]); if(todo == null) { todo = new ArrayList(); - todo.add(ext); resolve.put(ids[count], todo); - } else { - todo.add(ext); } + todo.add(ext); } } } diff --git a/src/org/apache/fop/area/PageViewport.java b/src/org/apache/fop/area/PageViewport.java index 09f5b71b3..b09048808 100644 --- a/src/org/apache/fop/area/PageViewport.java +++ b/src/org/apache/fop/area/PageViewport.java @@ -18,11 +18,7 @@ public class PageViewport implements Cloneable { Page page; Rectangle2D viewArea; boolean clip = false; - - public PageViewport(Page p, Rectangle2D bounds) { - page = p; - viewArea = bounds; - } + String pageNumber = null; // this list is only used when the page is discarded // the information is kept for future reference @@ -33,6 +29,11 @@ public class PageViewport implements Cloneable { // when this is empty the page can be rendered ArrayList unresolved = null; + public PageViewport(Page p, Rectangle2D bounds) { + page = p; + viewArea = bounds; + } + public void setClip(boolean c) { clip = c; } @@ -46,6 +47,14 @@ public class PageViewport implements Cloneable { return page; } + public void setPageNumber(String num) { + pageNumber = num; + } + + public String getPageNumber() { + return pageNumber; + } + public void savePage(ObjectOutputStream out) throws Exception { out.writeObject(page); page = null; diff --git a/src/org/apache/fop/area/inline/InlineArea.java b/src/org/apache/fop/area/inline/InlineArea.java index 98a8fc992..0b38a54a6 100644 --- a/src/org/apache/fop/area/inline/InlineArea.java +++ b/src/org/apache/fop/area/inline/InlineArea.java @@ -12,6 +12,7 @@ import org.apache.fop.area.MinOptMax; import org.apache.fop.area.Trait; import org.apache.fop.render.Renderer; import org.apache.fop.traits.BorderProps; +import org.apache.fop.fo.properties.VerticalAlign; import java.util.List; import java.util.ArrayList; @@ -29,7 +30,7 @@ public class InlineArea extends Area { protected int contentIPD = 0; // position within the line area, either top or baseline - int verticalPosition; + int verticalPosition = VerticalAlign.BASELINE; // store properties in array list, need better solution ArrayList props = null; @@ -49,11 +50,11 @@ public class InlineArea extends Area { } public void setIPD(int ipd) { - this.contentIPD = ipd; + this.contentIPD = ipd; } public void increaseIPD(int ipd) { - this.contentIPD += ipd; + this.contentIPD += ipd; } public void setHeight(int h) { @@ -65,26 +66,26 @@ public class InlineArea extends Area { } public int getAllocIPD() { - // If start or end border or padding is non-zero, add to content IPD - int iBP = contentIPD; - Object t; - if ((t = getTrait(Trait.PADDING_START)) != null) { - iBP += ((Integer)t).intValue(); - } - if ((t = getTrait(Trait.PADDING_END)) != null) { - iBP += ((Integer)t).intValue(); - } - if ((t = getTrait(Trait.BORDER_START)) != null) { - iBP += ((BorderProps)t).width;; - } - if ((t = getTrait(Trait.BORDER_END)) != null) { - iBP += ((BorderProps)t).width;; - } - return iBP; + // If start or end border or padding is non-zero, add to content IPD + int iBP = contentIPD; + Object t; + if ((t = getTrait(Trait.PADDING_START)) != null) { + iBP += ((Integer) t).intValue(); + } + if ((t = getTrait(Trait.PADDING_END)) != null) { + iBP += ((Integer) t).intValue(); + } + if ((t = getTrait(Trait.BORDER_START)) != null) { + iBP += ((BorderProps) t).width; + } + if ((t = getTrait(Trait.BORDER_END)) != null) { + iBP += ((BorderProps) t).width; + } + return iBP; } public MinOptMax getAllocationIPD() { - return new MinOptMax(getAllocIPD()); + return new MinOptMax(getAllocIPD()); } public void setOffset(int v) { @@ -94,5 +95,5 @@ public class InlineArea extends Area { public int getOffset() { return verticalPosition; } - } + diff --git a/src/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/org/apache/fop/area/inline/UnresolvedPageNumber.java index ddc85d327..98a17de0b 100644 --- a/src/org/apache/fop/area/inline/UnresolvedPageNumber.java +++ b/src/org/apache/fop/area/inline/UnresolvedPageNumber.java @@ -7,13 +7,18 @@ package org.apache.fop.area.inline; +import org.apache.fop.area.PageViewport; +import org.apache.fop.area.Resolveable; + import java.util.ArrayList; -public class UnresolvedPageNumber extends Unresolved { +public class UnresolvedPageNumber extends Word implements Resolveable { + boolean resolved = false; String pageRefId; public UnresolvedPageNumber(String id) { pageRefId = id; + word = "?"; } public String[] getIDs() { @@ -22,5 +27,12 @@ public class UnresolvedPageNumber extends Unresolved { public void resolve(String id, ArrayList pages) { resolved = true; + PageViewport page = (PageViewport)pages.get(0); + String str = page.getPageNumber(); + word = str; + } + + public boolean isResolved() { + return resolved; } } diff --git a/src/org/apache/fop/area/inline/Word.java b/src/org/apache/fop/area/inline/Word.java index 047433c89..55a3231d9 100644 --- a/src/org/apache/fop/area/inline/Word.java +++ b/src/org/apache/fop/area/inline/Word.java @@ -28,10 +28,10 @@ public class Word extends InlineArea { } public int getWSadjust() { - return iWSadjust; + return iWSadjust; } public void setWSadjust(int iWSadjust) { - this.iWSadjust = iWSadjust; + this.iWSadjust = iWSadjust; } } diff --git a/src/org/apache/fop/fo/FObj.java b/src/org/apache/fop/fo/FObj.java index e4a0f5503..53dead6a1 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -159,6 +159,10 @@ public class FObj extends FONode { } } + public String getID() { + return id; + } + /** * Return the "content width" of the areas generated by this FO. * This is used by percent-based properties to get the dimension of diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java index e9f186b7d..449413488 100644 --- a/src/org/apache/fop/fo/flow/PageNumber.java +++ b/src/org/apache/fop/fo/flow/PageNumber.java @@ -9,20 +9,27 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.layout.*; +import org.apache.fop.layout.FontInfo; +import org.apache.fop.layout.FontState; import org.apache.fop.datatypes.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; +import org.apache.fop.util.CharUtilities; +import org.apache.fop.apps.StructureHandler; import org.apache.fop.layoutmgr.LeafNodeLayoutManager; +import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.inline.Word; +import org.apache.fop.area.Trait; // Java import java.util.List; public class PageNumber extends FObj { + protected FontInfo fontInfo = null; + protected FontState fontState; float red; float green; @@ -35,70 +42,87 @@ public class PageNumber extends FObj { super(parent); } + public void setStructHandler(StructureHandler st) { + super.setStructHandler(st); + fontInfo = st.getFontInfo(); + } + public void addLayoutManager(List lms) { + setup(); lms.add(new LeafNodeLayoutManager(this) { - public InlineArea get(int index) { - if(index > 0) - return null; - // get page string from parent, build area - Word inline = new Word(); - //String parentLM.getCurrentPageNumber(); - inline.setWord("01"); - return inline; - } - - public boolean resolved() { - return true; - } - }); + public InlineArea get(LayoutContext context) { + // get page string from parent, build area + Word inline = new Word(); + String str = parentLM.getCurrentPageNumber(); + int width = 0; + for (int count = 0; count < str.length(); count++) { + width += CharUtilities.getCharWidth( + str.charAt(count), fontState); + } + inline.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())); + + return inline; + } + } + ); } - public void setup() throws FOPException { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(structHandler.getFontInfo()); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("dominant-baseline"); - setupID(); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("letter-spacing"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("score-spaces"); - // this.properties.get("text-decoration"); - // this.properties.get("text-shadow"); - // this.properties.get("text-transform"); - // this.properties.get("word-spacing"); - - ColorType c = this.properties.get("color").getColorType(); - this.red = c.red(); - this.green = c.green(); - this.blue = c.blue(); - - this.wrapOption = this.properties.get("wrap-option").getEnum(); - this.whiteSpaceCollapse = - this.properties.get("white-space-collapse").getEnum(); - ts = new TextState(); + public void setup() { + + // Common Accessibility Properties + AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); + + // Common Aural Properties + AuralProps mAurProps = propMgr.getAuralProps(); + + // Common Border, Padding, and Background Properties + BorderAndPadding bap = propMgr.getBorderAndPadding(); + BackgroundProps bProps = propMgr.getBackgroundProps(); + + // Common Font Properties + this.fontState = propMgr.getFontState(fontInfo); + + // Common Margin Properties-Inline + MarginInlineProps mProps = propMgr.getMarginInlineProps(); + + // Common Relative Position Properties + RelativePositionProps mRelProps = + propMgr.getRelativePositionProps(); + + // this.properties.get("alignment-adjust"); + // this.properties.get("alignment-baseline"); + // this.properties.get("baseline-shift"); + // this.properties.get("dominant-baseline"); + setupID(); + // this.properties.get("keep-with-next"); + // this.properties.get("keep-with-previous"); + // this.properties.get("letter-spacing"); + // this.properties.get("line-height"); + // this.properties.get("line-height-shift-adjustment"); + // this.properties.get("score-spaces"); + // this.properties.get("text-decoration"); + // this.properties.get("text-shadow"); + // this.properties.get("text-transform"); + // this.properties.get("word-spacing"); + + ColorType c = this.properties.get("color").getColorType(); + this.red = c.red(); + this.green = c.green(); + this.blue = c.blue(); + + this.wrapOption = this.properties.get("wrap-option").getEnum(); + this.whiteSpaceCollapse = + this.properties.get("white-space-collapse").getEnum(); + ts = new TextState(); } diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java index e9f2979e0..7d343cb2e 100644 --- a/src/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java @@ -16,65 +16,28 @@ import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; import org.apache.fop.layoutmgr.LeafNodeLayoutManager; import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.util.CharUtilities; +import org.apache.fop.apps.StructureHandler; +import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.area.inline.Word; +import org.apache.fop.area.inline.UnresolvedPageNumber; +import org.apache.fop.area.Resolveable; +import org.apache.fop.area.Trait; import java.util.List; import java.util.ArrayList; /** - * 6.6.11 fo:page-number-citation - * - * Common Usage: - * The fo:page-number-citation is used to reference the page-number for the page containing the first normal area returned by - * the cited formatting object. - * - * NOTE: - * It may be used to provide the page-numbers in the table of contents, cross-references, and index entries. - * - * Areas: - * The fo:page-number-citation formatting object generates and returns a single normal inline-area. - * Constraints: - * - * The cited page-number is the number of the page containing, as a descendant, the first normal area returned by the - * formatting object with an id trait matching the ref-id trait of the fo:page-number-citation (the referenced formatting - * object). - * - * The cited page-number string is obtained by converting the cited page-number in accordance with the number to string - * conversion properties specified on the ancestor fo:page-sequence of the referenced formatting object. - * - * The child areas of the generated inline-area are the same as the result of formatting a result-tree fragment consisting of - * fo:character flow objects; one for each character in the cited page-number string and with only the "character" property - * specified. - * - * Contents: - * - * EMPTY - * - * The following properties apply to this formatting object: - * - * [7.3 Common Accessibility Properties] - * [7.5 Common Aural Properties] - * [7.6 Common Border, Padding, and Background Properties] - * [7.7 Common Font Properties] - * [7.10 Common Margin Properties-Inline] - * [7.11.1 "alignment-adjust"] - * [7.11.2 "baseline-identifier"] - * [7.11.3 "baseline-shift"] - * [7.11.5 "dominant-baseline"] - * [7.36.2 "id"] - * [7.17.4 "keep-with-next"] - * [7.17.5 "keep-with-previous"] - * [7.14.2 "letter-spacing"] - * [7.13.4 "line-height"] - * [7.13.5 "line-height-shift-adjustment"] - * [7.36.5 "ref-id"] - * [7.18.4 "relative-position"] - * [7.36.6 "score-spaces"] - * [7.14.4 "text-decoration"] - * [7.14.5 "text-shadow"] - * [7.14.6 "text-transform"] - * [7.14.8 "word-spacing"] + * Page number citation. + * This inline fo is replaced with the text for a page number. + * 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 { + protected FontInfo fontInfo = null; + protected FontState fontState; float red; float green; @@ -84,77 +47,138 @@ public class PageNumberCitation extends FObj { String pageNumber; String refId; TextState ts; - + InlineArea inline = null; + boolean unresolved = false; public PageNumberCitation(FONode parent) { super(parent); } + public void setStructHandler(StructureHandler st) { + super.setStructHandler(st); + fontInfo = st.getFontInfo(); + } + public void addLayoutManager(List lms) { - LeafNodeLayoutManager lnlm = new LeafNodeLayoutManager(this); - lnlm.setCurrentArea(getInlineArea()); - lms.add(lnlm); + setup(); + lms.add(new LeafNodeLayoutManager(this) { + public InlineArea get(LayoutContext context) { + return getInlineArea(parentLM); + } + + public void addAreas(PositionIterator posIter, + LayoutContext context) { + super.addAreas(posIter, context); + if(unresolved) { + parentLM.addUnresolvedArea(refId, (Resolveable)inline); + } + } + } + ); } // is id can be resolved then simply return a word, otherwise // return a resolveable area - private InlineArea getInlineArea() { - return null; + private InlineArea getInlineArea(LayoutManager parentLM) { + if (refId.equals("")) { + getLogger().error("page-number-citation must contain \"ref-id\""); + return null; + } + String str = parentLM.resolveRefID(refId); + if(str != null) { + // 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())); + } else { + unresolved = true; + inline = new UnresolvedPageNumber(refId); + 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; + } + + protected int getStringWidth(String str) { + int width = 0; + for (int count = 0; count < str.length(); count++) { + width += CharUtilities.getCharWidth(str.charAt(count), + fontState); + } + return width; } public void setup() { - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = - propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("dominant-baseline"); - setupID(); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("letter-spacing"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("ref-id"); - // this.properties.get("score-spaces"); - // this.properties.get("text-decoration"); - // this.properties.get("text-shadow"); - // this.properties.get("text-transform"); - // this.properties.get("word-spacing"); - - ColorType c = this.properties.get("color").getColorType(); - this.red = c.red(); - this.green = c.green(); - this.blue = c.blue(); - - this.wrapOption = this.properties.get("wrap-option").getEnum(); - this.whiteSpaceCollapse = - this.properties.get("white-space-collapse").getEnum(); - - this.refId = this.properties.get("ref-id").getString(); - - if (this.refId.equals("")) { - //throw new FOPException("page-number-citation must contain \"ref-id\""); - } + // Common Accessibility Properties + AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); + + // Common Aural Properties + AuralProps mAurProps = propMgr.getAuralProps(); + + // Common Border, Padding, and Background Properties + BorderAndPadding bap = propMgr.getBorderAndPadding(); + BackgroundProps bProps = propMgr.getBackgroundProps(); + + // Common Font Properties + this.fontState = propMgr.getFontState(fontInfo); + + // Common Margin Properties-Inline + MarginInlineProps mProps = propMgr.getMarginInlineProps(); + + // Common Relative Position Properties + RelativePositionProps mRelProps = + propMgr.getRelativePositionProps(); + + // this.properties.get("alignment-adjust"); + // this.properties.get("alignment-baseline"); + // this.properties.get("baseline-shift"); + // this.properties.get("dominant-baseline"); + setupID(); + // this.properties.get("keep-with-next"); + // this.properties.get("keep-with-previous"); + // this.properties.get("letter-spacing"); + // this.properties.get("line-height"); + // this.properties.get("line-height-shift-adjustment"); + // this.properties.get("ref-id"); + // this.properties.get("score-spaces"); + // this.properties.get("text-decoration"); + // this.properties.get("text-shadow"); + // this.properties.get("text-transform"); + // this.properties.get("word-spacing"); + + ColorType c = this.properties.get("color").getColorType(); + this.red = c.red(); + this.green = c.green(); + this.blue = c.blue(); + + this.wrapOption = this.properties.get("wrap-option").getEnum(); + this.whiteSpaceCollapse = + this.properties.get("white-space-collapse").getEnum(); + + this.refId = this.properties.get("ref-id").getString(); + + if (this.refId.equals("")) { + //throw new FOPException("page-number-citation must contain \"ref-id\""); + } } diff --git a/src/org/apache/fop/layout/TextState.java b/src/org/apache/fop/layout/TextState.java index 3774facf0..b76b98349 100644 --- a/src/org/apache/fop/layout/TextState.java +++ b/src/org/apache/fop/layout/TextState.java @@ -19,7 +19,7 @@ public class TextState { protected boolean overlined; protected boolean linethrough; - public TextState() throws FOPException {} + public TextState() {} /** * @return true if text should be underlined diff --git a/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java index e64e7c81b..d18b7c186 100644 --- a/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -10,6 +10,7 @@ package org.apache.fop.layoutmgr; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FONode; import org.apache.fop.area.Area; +import org.apache.fop.area.Resolveable; import org.apache.fop.fo.PropertyManager; import java.util.ListIterator; @@ -21,6 +22,7 @@ import java.util.ArrayList; public abstract class AbstractLayoutManager implements LayoutManager { protected LayoutManager parentLM; protected FObj fobj; + protected String foID = null; /** True if this LayoutManager has handled all of its content. */ private boolean m_bFinished = false; @@ -41,6 +43,7 @@ public abstract class AbstractLayoutManager implements LayoutManager { public AbstractLayoutManager(FObj fobj, ListIterator lmIter) { this.fobj = fobj; + foID = fobj.getID(); this.parentLM = null; m_childLMiter = lmIter; } @@ -49,10 +52,6 @@ public abstract class AbstractLayoutManager implements LayoutManager { this.parentLM = lm; } - public int getContentIPD() { - return 0; - } - // /** // * Ask the parent LayoutManager to add the current (full) area to the // * appropriate parent area. @@ -256,5 +255,27 @@ public abstract class AbstractLayoutManager implements LayoutManager { public boolean addChild(Area childArea) { return false; } + + public String getCurrentPageNumber() { + return parentLM.getCurrentPageNumber(); + } + + public String resolveRefID(String ref) { + return parentLM.resolveRefID(ref); + } + + protected void addID() { + if(foID != null) { + addIDToPage(foID); + } + } + + public void addIDToPage(String id) { + parentLM.addIDToPage(id); + } + + public void addUnresolvedArea(String id, Resolveable res) { + parentLM.addUnresolvedArea(id, res); + } } diff --git a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java index a381129e4..bf507a965 100644 --- a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -96,18 +96,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { lineHeight = ti.lineHeight; } - /** - * Called by child layout manager to get the available space for - * content in the inline progression direction. - * Note that a manager may need to ask its parent for this. - * For a block area, available IPD is determined by indents. - */ - public int getContentIPD() { - // adjust for side floats and indents - getParentArea(null); // make if not existing - return curBlockArea.getIPD(); - } - public BreakPoss getNextBreakPoss(LayoutContext context) { LayoutManager curLM ; // currently active LM @@ -172,6 +160,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); + addID(); LayoutManager childLM ; int iStartPos = 0; diff --git a/src/org/apache/fop/layoutmgr/ContentLayoutManager.java b/src/org/apache/fop/layoutmgr/ContentLayoutManager.java index e9238c7d9..7c39a6206 100644 --- a/src/org/apache/fop/layoutmgr/ContentLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/ContentLayoutManager.java @@ -10,6 +10,7 @@ package org.apache.fop.layoutmgr; import org.apache.fop.area.Area; import org.apache.fop.area.MinOptMax; +import org.apache.fop.area.Resolveable; import java.util.ArrayList; @@ -77,10 +78,6 @@ public class ContentLayoutManager implements LayoutManager { public void setParentLM(LayoutManager lm) { } - public int getContentIPD() { - return 10000000; - } - public boolean canBreakBefore(LayoutContext lc) { return false; } @@ -108,5 +105,19 @@ public class ContentLayoutManager implements LayoutManager { public void getWordChars(StringBuffer sbChars, Position bp1, Position bp2) { } + + public String getCurrentPageNumber() { + return ""; + } + + public String resolveRefID(String ref) { + return null; + } + + public void addIDToPage(String id) { + } + + public void addUnresolvedArea(String id, Resolveable res) { + } } diff --git a/src/org/apache/fop/layoutmgr/LayoutManager.java b/src/org/apache/fop/layoutmgr/LayoutManager.java index 422979cf9..455dc8f0c 100644 --- a/src/org/apache/fop/layoutmgr/LayoutManager.java +++ b/src/org/apache/fop/layoutmgr/LayoutManager.java @@ -9,6 +9,7 @@ package org.apache.fop.layoutmgr; import org.apache.fop.area.Area; +import org.apache.fop.area.Resolveable; /** * The interface for all LayoutManagers. @@ -18,7 +19,6 @@ public interface LayoutManager { public Area getParentArea (Area childArea); public boolean addChild (Area childArea); public void setParentLM(LayoutManager lm); - public int getContentIPD(); /** * Return true if the next area which would be generated by this @@ -62,4 +62,12 @@ public interface LayoutManager { public void getWordChars(StringBuffer sbChars, Position bp1, Position bp2); + + public String getCurrentPageNumber(); + + public String resolveRefID(String ref); + + public void addIDToPage(String id); + + public void addUnresolvedArea(String id, Resolveable res); } diff --git a/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java b/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java index f05d026e8..a0f7ea24f 100644 --- a/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java @@ -111,6 +111,8 @@ public class LeafNodeLayoutManager extends AbstractLayoutManager { public void addAreas(PositionIterator posIter, LayoutContext context) { parentLM.addChild(curArea); + addID(); + int bpd = curArea.getHeight(); switch(alignment) { case VerticalAlign.MIDDLE: diff --git a/src/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/org/apache/fop/layoutmgr/LineLayoutManager.java index a21d41ce5..81e983900 100644 --- a/src/org/apache/fop/layoutmgr/LineLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/LineLayoutManager.java @@ -20,6 +20,7 @@ import org.apache.fop.area.Area; import org.apache.fop.area.LineArea; import org.apache.fop.area.MinOptMax; import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.area.Resolveable; import org.apache.fop.fo.properties.TextAlign; import org.apache.fop.area.inline.Word; @@ -569,5 +570,12 @@ if(lc.getTrailingSpace() != null) { setCurrentArea(null); // ?? necessary } + public void addUnresolvedArea(String id, Resolveable res) { + // create a resolveable class that handles ipd + // adjustment for the current line + + parentLM.addUnresolvedArea(id, res); + } + } diff --git a/src/org/apache/fop/layoutmgr/PageLayoutManager.java b/src/org/apache/fop/layoutmgr/PageLayoutManager.java index d34fee09a..00e9b6c3e 100644 --- a/src/org/apache/fop/layoutmgr/PageLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/PageLayoutManager.java @@ -60,6 +60,8 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable private AreaTree areaTree; private PageSequence pageSequence; + private int pageCount = 0; + /** * This is the top level layout manager. * It is created by the PageSequence FO. @@ -96,6 +98,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable BreakPoss bp; LayoutContext childLC = new LayoutContext(0); while (!isFinished()) { + pageCount++; if ((bp = getNextBreakPoss(childLC)) != null) { addAreas((BlockBreakPosition)bp.getPosition()); // add static areas and resolve any new id areas @@ -131,6 +134,14 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable return null; } + public String getCurrentPageNumber() { + return "" + pageCount; + } + + public String resolveRefID(String ref) { + return null; + } + public void addAreas(BlockBreakPosition bbp) { List list = new ArrayList(); list.add(bbp.breakps); @@ -138,6 +149,15 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable 1), null); } + public void addIDToPage(String id) { + areaTree.addIDRef(id, curPage); + } + + public void addUnresolvedArea(String id, Resolveable res) { + // add unresolved to tree + areaTree.addUnresolvedID(id, res); + } + /** * For now, only handle normal flow areas. */ @@ -214,6 +234,8 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable } catch (FOPException fopex) { /* ???? */ fopex.printStackTrace(); } + + curPage.setPageNumber(getCurrentPageNumber()); RegionViewport reg = curPage.getPage().getRegion( RegionReference.BODY); curBody = (BodyRegion) reg.getRegion(); diff --git a/src/org/apache/fop/layoutmgr/PositionIterator.java b/src/org/apache/fop/layoutmgr/PositionIterator.java index e3d5bc262..66d5e3a3e 100644 --- a/src/org/apache/fop/layoutmgr/PositionIterator.java +++ b/src/org/apache/fop/layoutmgr/PositionIterator.java @@ -11,7 +11,7 @@ package org.apache.fop.layoutmgr; import java.util.Iterator; import java.util.NoSuchElementException; -abstract class PositionIterator implements Iterator { +public abstract class PositionIterator implements Iterator { Iterator m_parentIter; Object m_nextObj; LayoutManager m_childLM; |