From: Karen Lease Date: Sun, 11 Nov 2001 22:14:45 +0000 (+0000) Subject: Move generatesInlineAreas from LayoutManager to FObj X-Git-Tag: fop-0_20_4-doc~203 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=796089b1fa8af9af83b2c4a21d2d3030bce210ea;p=xmlgraphics-fop.git Move generatesInlineAreas from LayoutManager to FObj git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194560 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java index 4c7c67f14..56fbc72f5 100644 --- a/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -87,9 +87,9 @@ public abstract class AbstractLayoutManager implements LayoutManager { - public boolean generatesInlineAreas() { - return false; - } +// public boolean generatesInlineAreas() { +// return false; +// } /** diff --git a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java index 7b4bfbc80..d398fdaba 100644 --- a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -44,14 +44,17 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { */ public void generateAreas() { ListIterator children = fobj.getChildren(); + LayoutManager lm=null; while (children.hasNext()) { - LayoutManager lm = ((FObj)children.next()).getLayoutManager(); - if (lm != null) { - if (lm.generatesInlineAreas()) { - // Back up one - children.previous(); - lm = new LineLayoutManager(children); - } + FObj childFO = (FObj)children.next(); + if (childFO.generatesInlineAreas()) { + children.previous(); + lm = new LineLayoutManager(children); + } + else { + lm = childFO.getLayoutManager(); + } + if (lm != null) { lm.setParentLM(this); lm.generateAreas(); } diff --git a/src/org/apache/fop/layoutmgr/LayoutManager.java b/src/org/apache/fop/layoutmgr/LayoutManager.java index e7a3130e4..7f8b4756b 100644 --- a/src/org/apache/fop/layoutmgr/LayoutManager.java +++ b/src/org/apache/fop/layoutmgr/LayoutManager.java @@ -15,7 +15,7 @@ import org.apache.fop.area.Area; */ public interface LayoutManager { public void generateAreas(); - public boolean generatesInlineAreas(); + //public boolean generatesInlineAreas(); public Area getParentArea (Area childArea); public void addChild (Area childArea); public boolean splitArea(Area areaToSplit, SplitContext context); diff --git a/src/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/org/apache/fop/layoutmgr/LineLayoutManager.java index 38451354b..060575231 100644 --- a/src/org/apache/fop/layoutmgr/LineLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/LineLayoutManager.java @@ -44,16 +44,16 @@ public class LineLayoutManager extends AbstractLayoutManager { public void generateAreas() { this.bFirstLine = true; while (fobjIter.hasNext()) { - FObj fobj = (FObj)fobjIter.next(); - curLM = fobj.getLayoutManager(); - if (curLM != null) { - if (curLM.generatesInlineAreas()==false) { - // It generates blocks, pass back to parent - // Back up one - fobjIter.previous(); - break; - } - else { // generates inline area + FObj childFO = (FObj)fobjIter.next(); + if (childFO.generatesInlineAreas()==false) { + // It generates blocks, pass back to parent + // Back up one + fobjIter.previous(); + break; + } + else { // generates inline area + curLM = childFO.getLayoutManager(); + if (curLM != null) { curLM.setParentLM(this); curLM.generateAreas(); } diff --git a/src/org/apache/fop/layoutmgr/TextLayoutManager.java b/src/org/apache/fop/layoutmgr/TextLayoutManager.java index aa88340ab..570515d60 100644 --- a/src/org/apache/fop/layoutmgr/TextLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/TextLayoutManager.java @@ -8,6 +8,7 @@ package org.apache.fop.layoutmgr; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FOText; // For TextInfo: TODO: make independent! import org.apache.fop.area.Area; import org.apache.fop.area.inline.Word; @@ -17,52 +18,34 @@ import java.util.ListIterator; * LayoutManager for text (a sequence of characters) which generates one * more inline areas. */ -public class TextLayoutManager extends AbstractLayoutManager { +public class TextLayoutManager extends LeafNodeLayoutManager { private char[] chars; - private Word curWordArea; + private FOText.TextInfo textInfo; - public TextLayoutManager(FObj fobj, char[] chars) { + public TextLayoutManager(FObj fobj, char[] chars, + FOText.TextInfo textInfo) { super(fobj); this.chars = chars; + this.textInfo = textInfo; } - /** * Generate inline areas for words in text. */ public void generateAreas() { + // Handle white-space characteristics. Maybe there is no area to + // generate.... + // Iterate over characters and make text areas. // Add each one to parent. Handle word-space. - curWordArea = new Word(); + Word curWordArea = new Word(); curWordArea.setWord(new String(chars)); + setCurrentArea(curWordArea); flush(); } - protected void flush() { - parentLM.addChild(curWordArea); - } - - - public boolean generatesInlineAreas() { - return true; - } - - /** - * This is a leaf-node, so this method is never called. - */ - public void addChild(Area childArea) {} - - - /** - * This is a leaf-node, so this method is never called. - */ - public Area getParentArea(Area childArea) { - return null; - } - - /** Try to split the word area by hyphenating the word. */ public boolean splitArea(Area areaToSplit, SplitContext context) { @@ -70,4 +53,5 @@ public class TextLayoutManager extends AbstractLayoutManager { return false; } + }