keiron 2002/08/21 02:17:42 Modified: src/org/apache/fop/layoutmgr AbstractBPLayoutManager.java BlockLayoutManager.java FlowLayoutManager.java LMiter.java LineBPLayoutManager.java Log: properly resets blocks use a block lm iter so that it can create line layout manager from inline lm's Revision Changes Path 1.8 +2 -2 xml-fop/src/org/apache/fop/layoutmgr/AbstractBPLayoutManager.java Index: AbstractBPLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/AbstractBPLayoutManager.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- AbstractBPLayoutManager.java 19 Aug 2002 08:01:56 -0000 1.7 +++ AbstractBPLayoutManager.java 21 Aug 2002 09:17:42 -0000 1.8 @@ -90,7 +90,7 @@ BPLayoutManager lm = (pos != null) ? pos.getLM() : null; if (m_curChildLM != lm) { // ASSERT m_curChildLM == (BPLayoutManager)m_childLMiter.previous() - if (m_curChildLM != + if (m_childLMiter.hasPrevious() && m_curChildLM != (BPLayoutManager) m_childLMiter.previous()) { //log.error("LMiter problem!"); } 1.14 +86 -63 xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java Index: BlockLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- BlockLayoutManager.java 18 Aug 2002 13:47:13 -0000 1.13 +++ BlockLayoutManager.java 21 Aug 2002 09:17:42 -0000 1.14 @@ -32,8 +32,62 @@ ArrayList childBreaks = new ArrayList(); + /** + * Iterator for Block layout. + * This iterator combines consecutive inline areas and + * creates a line layout manager. + * The use of this iterator means that it can be reset properly. + */ + protected class BlockLMiter extends LMiter { + + private ListIterator proxy; + + public BlockLMiter(ListIterator pr) { + super(null); + proxy = pr; + } + + protected boolean preLoadNext() { + while (proxy.hasNext()) { + LayoutManager lm = (LayoutManager) proxy.next(); + if(lm.generatesInlineAreas()) { + LineBPLayoutManager lineLM = createLineManager(lm); + m_listLMs.add(lineLM); + } else { + m_listLMs.add(lm); + } + if (m_curPos < m_listLMs.size()) { + return true; + } + } + return false; + } + + protected LineBPLayoutManager createLineManager( + LayoutManager firstlm) { + LayoutManager lm; + ArrayList inlines = new ArrayList(); + inlines.add(firstlm); + while (proxy.hasNext()) { + lm = (LayoutManager) proxy.next(); + if (lm.generatesInlineAreas()) { + inlines.add(lm); + } else { + proxy.previous(); + break; + } + } + LineBPLayoutManager child; + child = new LineBPLayoutManager(fobj, inlines, lineHeight, + lead, follow); + return child; + + } + } + public BlockLayoutManager(FObj fobj) { super(fobj); + m_childLMiter = new BlockLMiter(m_childLMiter); } public void setBlockTextInfo(TextInfo ti) { @@ -54,47 +108,6 @@ return curBlockArea.getIPD(); } - protected BPLayoutManager getChildLM() { - if (m_curChildLM != null && !m_curChildLM.isFinished()) { - return m_curChildLM; - } - while (m_childLMiter.hasNext()) { - LayoutManager lm = (LayoutManager) m_childLMiter.next(); - if (lm.generatesInlineAreas()) { - ArrayList inlines = new ArrayList(); - inlines.add(lm); - //lms.remove(count); - while (m_childLMiter.hasNext()) { - lm = (LayoutManager) m_childLMiter.next(); - if (lm.generatesInlineAreas()) { - inlines.add(lm); - //lms.remove(count + 1); - } else { - m_childLMiter.previous(); - break; - } - } - m_curChildLM = new LineBPLayoutManager(fobj, inlines, - lineHeight, lead, follow); - m_curChildLM.setParentLM(this); - m_curChildLM.init(); - return m_curChildLM; - //lms.set(count, lm); - } else if (lm instanceof BPLayoutManager) { - m_curChildLM = (BPLayoutManager) lm; - m_curChildLM.setParentLM(this); - m_curChildLM.init(); - return m_curChildLM; - } else { - m_childLMiter.remove(); - //log.warn( - // "child LM not a BPLayoutManager: " + - // lm.getClass().getName()); - } - } - return null; - } - public BreakPoss getNextBreakPoss(LayoutContext context, Position prevLineBP) { @@ -111,41 +124,45 @@ int ipd = context.getRefIPD(); BreakPoss bp; - LayoutContext childLC = - new LayoutContext(0); - if(curLM.generatesInlineAreas()) { + LayoutContext childLC = new LayoutContext(0); + // if line layout manager then set stack limit to ipd + // line LM actually generates a LineArea which is a block + if (curLM.generatesInlineAreas()) { // set stackLimit for lines childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents - m_iTextIndent*/)); } else { - childLC.setStackLimit(MinOptMax.subtract(context.getStackLimit(), stackSize)); + childLC.setStackLimit( + MinOptMax.subtract(context.getStackLimit(), + stackSize)); childLC.setRefIPD(ipd); } while (!curLM.isFinished()) { if ((bp = curLM.getNextBreakPoss(childLC, null)) != null) { - stackSize.add(bp.getStackingSize()); - if(stackSize.min > context.getStackLimit().max) { - // reset to last break - if(lastPos != null) { - reset(lastPos.getPosition()); - } else { - curLM.resetPosition(null); - } - break; + stackSize.add(bp.getStackingSize()); + if (stackSize.min > context.getStackLimit().max) { + // reset to last break + if (lastPos != null) { + reset(lastPos.getPosition()); + } else { + curLM.resetPosition(null); } - lastPos = bp; - childBreaks.add(bp); + break; + } + lastPos = bp; + childBreaks.add(bp); - if(curLM.generatesInlineAreas()) { + if (curLM.generatesInlineAreas()) { // Reset stackLimit for non-first lines childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents*/)); - } else { - childLC.setStackLimit(MinOptMax.subtract(context.getStackLimit(), stackSize)); - } + } else { + childLC.setStackLimit( MinOptMax.subtract( + context.getStackLimit(), stackSize)); + } } } BreakPoss breakPoss = new BreakPoss( - new LeafPosition(this, childBreaks.size() - 1)); + new LeafPosition(this, childBreaks.size() - 1)); breakPoss.setStackingSize(stackSize); return breakPoss; } @@ -153,7 +170,8 @@ return null; } - public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { + public void addAreas(PositionIterator parentIter, + LayoutContext layoutContext) { getParentArea(null); BPLayoutManager childLM ; @@ -226,5 +244,10 @@ return false; } + public void resetPosition(Position resetPos) { + if (resetPos == null) { + reset(null); + } + } } 1.8 +6 -1 xml-fop/src/org/apache/fop/layoutmgr/FlowLayoutManager.java Index: FlowLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/FlowLayoutManager.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- FlowLayoutManager.java 18 Aug 2002 13:47:13 -0000 1.7 +++ FlowLayoutManager.java 21 Aug 2002 09:17:42 -0000 1.8 @@ -128,5 +128,10 @@ return parentArea; } + public void resetPosition(Position resetPos) { + if (resetPos == null) { + reset(null); + } + } } 1.4 +4 -4 xml-fop/src/org/apache/fop/layoutmgr/LMiter.java Index: LMiter.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LMiter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- LMiter.java 18 Aug 2002 13:47:13 -0000 1.3 +++ LMiter.java 21 Aug 2002 09:17:42 -0000 1.4 @@ -18,8 +18,8 @@ private ListIterator m_baseIter; private FObj m_curFO; - private ArrayList m_listLMs; - private int m_curPos = 0; + protected ArrayList m_listLMs; + protected int m_curPos = 0; public LMiter(ListIterator baseIter) { m_baseIter = baseIter; @@ -30,7 +30,7 @@ return (m_curPos < m_listLMs.size()) ? true : preLoadNext(); } - private boolean preLoadNext() { + protected boolean preLoadNext() { // skip over child FObj's that don't add lms while (m_baseIter.hasNext()) { FObj fobj = (FObj) m_baseIter.next(); 1.14 +2 -2 xml-fop/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java Index: LineBPLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- LineBPLayoutManager.java 18 Aug 2002 13:47:13 -0000 1.13 +++ LineBPLayoutManager.java 21 Aug 2002 09:17:42 -0000 1.14 @@ -95,7 +95,6 @@ m_hyphProps = propMgr.getHyphenationProps(); } - /** * Call child layout managers to generate content as long as they * generate inline areas. If a block-level generating LM is found, @@ -457,6 +456,7 @@ public void resetPosition(Position resetPos) { if (resetPos == null) { + iStartPos = 0; reset(null); m_vecInlineBreaks.clear(); m_prevBP = null;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]