You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2002/08/11 09:31:30 UTC
cvs commit: xml-fop/src/org/apache/fop/layoutmgr BlockLayoutManager.java FlowLayoutManager.java LayoutContext.java LeafNodeLayoutManager.java LineBPLayoutManager.java PageLayoutManager.java
keiron 2002/08/11 00:31:30
Modified: src/org/apache/fop/layoutmgr BlockLayoutManager.java
FlowLayoutManager.java LayoutContext.java
LeafNodeLayoutManager.java LineBPLayoutManager.java
PageLayoutManager.java
Log:
get some page breaking working
properly resets leaf node
Revision Changes Path
1.12 +50 -68 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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- BlockLayoutManager.java 9 Aug 2002 07:11:15 -0000 1.11
+++ BlockLayoutManager.java 11 Aug 2002 07:31:30 -0000 1.12
@@ -30,6 +30,8 @@
int lineHeight = 14000;
int follow = 2000;
+ ArrayList childBreaks = new ArrayList();
+
public BlockLayoutManager(FObj fobj) {
super(fobj);
}
@@ -52,15 +54,6 @@
return curBlockArea.getIPD();
}
- private static class BlockBreakPosition extends LeafPosition {
- List blockps;
-
- BlockBreakPosition(BPLayoutManager lm, int iBreakIndex, List bps) {
- super(lm, iBreakIndex);
- blockps = bps;
- }
- }
-
protected BPLayoutManager getChildLM() {
if (m_curChildLM != null && !m_curChildLM.isFinished()) {
return m_curChildLM;
@@ -77,7 +70,7 @@
inlines.add(lm);
//lms.remove(count + 1);
} else {
- m_childLMiter.previousIndex();
+ m_childLMiter.previous();
break;
}
}
@@ -106,19 +99,27 @@
Position prevLineBP) {
BPLayoutManager curLM ; // currently active LM
- ArrayList list = new ArrayList();
+
+ MinOptMax stackSize = new MinOptMax();
+ // if starting add space before
+ // stackSize.add(spaceBefore);
while ((curLM = getChildLM()) != null) {
- // Make break positions and return lines!
+ // Make break positions and return blocks!
// Set up a LayoutContext
int ipd = 0;
BreakPoss bp;
- ArrayList vecBreakPoss = new ArrayList();
// Force area creation on first call
// NOTE: normally not necessary when fully integrated!
LayoutContext childLC =
new LayoutContext(LayoutContext.CHECK_REF_AREA);
+ if(curLM.generatesInlineAreas()) {
+ // Reset stackLimit for non-first lines
+ childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents*/));
+ } else {
+ childLC.setStackLimit(MinOptMax.subtract(context.getStackLimit(), stackSize));
+ }
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC, null)) != null) {
@@ -133,30 +134,54 @@
ipd = getContentIPD();
childLC.flags &= ~LayoutContext.CHECK_REF_AREA;
childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents -
- m_iTextIndent*/));
+ m_iTextIndent*/));
} else {
- vecBreakPoss.add(bp);
+ stackSize.add(bp.getStackingSize());
+ if(stackSize.min > context.getStackLimit().max) {
+ // reset to last break
+ // curLM.reset();
+ break;
+ }
+ childBreaks.add(bp);
+
+ if(curLM.generatesInlineAreas()) {
// Reset stackLimit for non-first lines
childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents*/));
+ } else {
+ childLC.setStackLimit(MinOptMax.subtract(context.getStackLimit(), stackSize));
+ }
}
}
}
- list.add(vecBreakPoss);
- return new BreakPoss(
- new BlockBreakPosition(curLM, 0, vecBreakPoss));
+ BreakPoss breakPoss = new BreakPoss(
+ new LeafPosition(this, childBreaks.size() - 1));
+ breakPoss.setStackingSize(stackSize);
+ return breakPoss;
}
setFinished(true);
- return new BreakPoss(new BlockBreakPosition(this, 0, list));
+ return null;
}
- public void addAreas(PositionIterator parentIter, LayoutContext lc) {
+ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
+ BPLayoutManager childLM ;
+ int iStartPos = 0;
+ LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
- BlockBreakPosition bbp = (BlockBreakPosition) parentIter.next();
- bbp.getLM().addAreas( new BreakPossPosIter(bbp.blockps, 0,
- bbp.blockps.size()), null);
+ LeafPosition lfp = (LeafPosition) parentIter.next();
+ // Add the block areas to Area
+ PositionIterator breakPosIter =
+ new BreakPossPosIter(childBreaks, iStartPos,
+ lfp.getLeafPos() + 1);
+ iStartPos = lfp.getLeafPos() + 1;
+ while ((childLM = breakPosIter.getNextChildLM()) != null) {
+ childLM.addAreas(breakPosIter, lc);
+ }
}
+
flush();
+
+ childBreaks.clear();
}
/**
@@ -208,48 +233,5 @@
return false;
}
-
-
- // /**
- // * Called by child LayoutManager when it has filled one of its areas.
- // * If no current container, make one.
- // * See if the area will fit in the current container.
- // * If so, add it.
- // * @param childArea the area to add: will either be a LineArea or
- // * a BlockArea.
- // */
- // public void addChild(Area childArea) {
- // /* If the childArea fits entirely in the maximum available BPD
- // * add it and return an OK status.
- // * If it doesn't all fit, overrun or ask for split?
- // * Might as well just add it since the page layout process
- // * may need to make other adjustments, resulting in changing
- // * split point.
- // */
- // // Things like breaks on child area can cause premature
- // // termination of the current area.
- // /* We go past the theoretical maximum to be able to handle things
- // * like widows.
- // */
- // // WARNING: this doesn't take into account space-specifier
- // // adujstment between childArea and last content of blockArea!
- // if (blockArea.getContentBPD().min + childArea.getAllocationBPD().min
- // > blockArea.getAvailBPD().max) {
- // if (++extraLines <= iWidows) {
- // blockArea.add(childArea);
- // }
- // else {
- // blockArea.setIsLast(false);
- // parentLM.addChildArea(blockArea);
- // // Make a new one for this area
- // blockArea = makeAreaForChild(childArea);
- // extraLines = 0; // Count potential widows
- // blockArea.add(childArea);
- // }
- // }
- // else {
- // blockArea.add(childArea);
- // }
- // }
-
}
+
1.6 +48 -24 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FlowLayoutManager.java 9 Aug 2002 07:11:15 -0000 1.5
+++ FlowLayoutManager.java 11 Aug 2002 07:31:30 -0000 1.6
@@ -23,14 +23,7 @@
*/
public class FlowLayoutManager extends BlockStackingLayoutManager {
- private static class BlockBreakPosition extends LeafPosition {
- List blockps;
-
- BlockBreakPosition(BPLayoutManager lm, int iBreakIndex, List bps) {
- super(lm, iBreakIndex);
- blockps = bps;
- }
- }
+ ArrayList blockBreaks = new ArrayList();
/** Array of areas currently being filled stored by area class */
private BlockParent[] currentAreas = new BlockParent[Area.CLASS_MAX];
@@ -47,40 +40,71 @@
Position prevLineBP) {
BPLayoutManager curLM ; // currently active LM
+ MinOptMax stackSize = new MinOptMax();
while ((curLM = getChildLM()) != null) {
- // Make break positions and return lines!
+ // Make break positions and return page break
// Set up a LayoutContext
- int bpd = 0;
+ MinOptMax bpd = context.getStackLimit();
BreakPoss bp;
- ArrayList vecBreakPoss = new ArrayList();
- // Force area creation on first call
- // NOTE: normally not necessary when fully integrated!
LayoutContext childLC = new LayoutContext(0);
+ boolean breakPage = false;
+ childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
- while (!curLM.isFinished()) {
+ if (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC, null)) != null) {
- vecBreakPoss.add(bp);
- // Reset stackLimit for non-first lines
- childLC.setStackLimit(new MinOptMax(bpd));
+ stackSize.add(bp.getStackingSize());
+ blockBreaks.add(bp);
+ // set stackLimit for remaining space
+ childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
+
+ if(bp.isForcedBreak()) {
+ breakPage = true;
+ break;
+ }
}
}
- return new BreakPoss(
- new BlockBreakPosition(curLM, 0, vecBreakPoss));
+ // check the stack bpd and if greater than available
+ // height then go to the last best break and return
+ // break position
+ if(stackSize.min > context.getStackLimit().opt) {
+ breakPage = true;
+ }
+ if(breakPage) {
+ return new BreakPoss(
+ new LeafPosition(this, blockBreaks.size() - 1));
+ }
}
setFinished(true);
+ if(blockBreaks.size() > 0) {
+ return new BreakPoss(
+ new LeafPosition(this, blockBreaks.size() - 1));
+ }
return null;
}
- public void addAreas(PositionIterator parentIter, LayoutContext lc) {
+ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
+
+ BPLayoutManager childLM ;
+ int iStartPos = 0;
+ LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
- BlockBreakPosition bbp = (BlockBreakPosition) parentIter.next();
- bbp.getLM().addAreas( new BreakPossPosIter(bbp.blockps, 0,
- bbp.blockps.size()), null);
+ LeafPosition lfp = (LeafPosition) parentIter.next();
+ // Add the block areas to Area
+ PositionIterator breakPosIter =
+ new BreakPossPosIter(blockBreaks, iStartPos,
+ lfp.getLeafPos() + 1);
+ iStartPos = lfp.getLeafPos() + 1;
+ while ((childLM = breakPosIter.getNextChildLM()) != null) {
+ childLM.addAreas(breakPosIter, lc);
+ }
}
+
flush();
+ // clear the breaks for the page to start for the next page
+ blockBreaks.clear();
}
1.6 +2 -2 xml-fop/src/org/apache/fop/layoutmgr/LayoutContext.java
Index: LayoutContext.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LayoutContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LayoutContext.java 8 Aug 2002 15:08:08 -0000 1.5
+++ LayoutContext.java 11 Aug 2002 07:31:30 -0000 1.6
@@ -149,7 +149,7 @@
}
public MinOptMax getStackLimit() {
- return m_stackLimit ;
+ return m_stackLimit;
}
public void setHyphContext(HyphContext hyphContext) {
1.8 +7 -3 xml-fop/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java
Index: LeafNodeLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- LeafNodeLayoutManager.java 9 Aug 2002 07:11:15 -0000 1.7
+++ LeafNodeLayoutManager.java 11 Aug 2002 07:31:30 -0000 1.8
@@ -59,7 +59,6 @@
return false;
}
-
/**
* This is a leaf-node, so this method is never called.
*/
@@ -77,10 +76,15 @@
BreakPoss bp = new BreakPoss(new LeafPosition(this, 0),
BreakPoss.CAN_BREAK_AFTER |
BreakPoss.CAN_BREAK_BEFORE | BreakPoss.ISFIRST |
- BreakPoss.ISLAST | BreakPoss.REST_ARE_SUPPRESS_AT_LB);
+ BreakPoss.ISLAST);
bp.setStackingSize(curArea.getAllocationIPD());
+ bp.setNonStackingSize(curArea.getAllocationBPD());
setFinished(true);
return bp;
+ }
+
+ public void resetPosition(Position resetPos) {
+ setFinished(false);
}
public void addAreas(PositionIterator posIter, LayoutContext context) {
1.10 +6 -1 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- LineBPLayoutManager.java 9 Aug 2002 07:11:15 -0000 1.9
+++ LineBPLayoutManager.java 11 Aug 2002 07:31:30 -0000 1.10
@@ -437,6 +437,9 @@
public void addAreas(PositionIterator parentIter,
LayoutContext context) {
addAreas(parentIter, 0.0);
+
+ //m_vecInlineBreaks.clear();
+ m_prevBP = null;
}
// Generate and add areas to parent area
@@ -464,8 +467,10 @@
lc.setLeadingSpace(lc.getTrailingSpace());
lc.setTrailingSpace(new SpaceSpecifier(false));
}
+if(lc.getTrailingSpace() != null) {
addSpace(lineArea, lc.getTrailingSpace().resolve(true),
lc.getSpaceAdjust());
+}
lineArea.verticalAlign(lineHeight, lead, follow);
parentLM.addChild(lineArea);
}
1.10 +12 -14 xml-fop/src/org/apache/fop/layoutmgr/PageLayoutManager.java
Index: PageLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/PageLayoutManager.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- PageLayoutManager.java 9 Aug 2002 07:11:16 -0000 1.9
+++ PageLayoutManager.java 11 Aug 2002 07:31:30 -0000 1.10
@@ -44,10 +44,11 @@
/** Number of columns in current span area. */
private int curSpanColumns;
-
/** Current flow-reference-area (column) being filled. */
private Flow curFlow;
+ private int flowBPD = 0;
+
/** Manager which handles a queue of all pages which are completely
* laid out and ready for rendering, except for resolution of ID
* references?
@@ -82,7 +83,7 @@
public void doLayout() {
- //ArrayList vecBreakPoss = new ArrayList();
+ makeNewPage(false, false);
BreakPoss bp;
LayoutContext childLC = new LayoutContext(0);
@@ -92,13 +93,13 @@
vecBreakPoss.add(bp);
addAreas( new BreakPossPosIter(vecBreakPoss, 0,
vecBreakPoss.size()), null);
+ // add static areas and resolve any new id areas
+
+ // finish page and add to area tree
finishPage();
}
}
- //addAreas( new BreakPossPosIter(vecBreakPoss, 0,
- // vecBreakPoss.size()), null);
-
}
@@ -108,16 +109,11 @@
BPLayoutManager curLM ; // currently active LM
while ((curLM = getChildLM()) != null) {
- // Make break positions and return lines!
- // Set up a LayoutContext
- int bpd = 0;
BreakPoss bp;
ArrayList vecBreakPoss = new ArrayList();
- // Force area creation on first call
- // NOTE: normally not necessary when fully integrated!
LayoutContext childLC = new LayoutContext(0);
- childLC.setStackLimit(new MinOptMax(bpd));
+ childLC.setStackLimit(new MinOptMax(flowBPD));
if (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC, null)) != null) {
@@ -218,8 +214,10 @@
} catch (FOPException fopex) { /* ???? */
fopex.printStackTrace();
}
- curBody = (BodyRegion) curPage.getPage(). getRegion(
- RegionReference.BODY).getRegion();
+ RegionViewport reg = curPage.getPage(). getRegion(
+ RegionReference.BODY);
+ curBody = (BodyRegion) reg.getRegion();
+ flowBPD = (int)reg.getViewArea().getHeight();
return curPage;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org