userAgent = ua;
}
+ public FOUserAgent getUserAgent() {
+ return userAgent;
+ }
+
public void setStructHandler(StructureHandler st) {
}
InlineStackingLayoutManager lm;
lm = new InlineStackingLayoutManager(this,
new LMiter(children.listIterator()));
+ lm.setUserAgent(getUserAgent());
lm.init();
// get breaks then add areas to title
ContentLayoutManager clm = new ContentLayoutManager(title);
+ clm.setUserAgent(getUserAgent());
lm.setParentLM(clm);
clm.fillArea(lm);
public void addLayoutManager(List list) {
BlockLayoutManager blm = new BlockLayoutManager(this);
+ blm.setUserAgent(getUserAgent());
TextInfo ti = propMgr.getTextLayoutProps(fontInfo);
blm.setBlockTextInfo(ti);
list.add(blm);
}
public void addLayoutManager(List list) {
- list.add(new FlowLayoutManager(this));
+ FlowLayoutManager lm = new FlowLayoutManager(this);
+ lm.setUserAgent(getUserAgent());
+ list.add(lm);
}
}
InlineStackingLayoutManager lm;
lm = new InlineStackingLayoutManager(this,
new LMiter(children.listIterator()));
+ lm.setUserAgent(getUserAgent());
lm.init();
// get breaks then add areas to FilledArea
FilledArea fa = new FilledArea();
ContentLayoutManager clm = new ContentLayoutManager(fa);
+ clm.setUserAgent(getUserAgent());
lm.setParentLM(clm);
clm.fillArea(lm);
blm.setLabel(label.getItemLayoutManager());
blm.setBody(body.getItemLayoutManager());
list.add(blm);
+ } else {
+ getLogger().error("list-item requires list-item-label and list-item-body");
}
}
// This will layout pages and add them to the area tree
PageLayoutManager pageLM = new PageLayoutManager(areaTree, this);
+ pageLM.setUserAgent(getUserAgent());
pageLM.setPageCounting(currentPageNumber, pageNumberGenerator);
// For now, skip the threading and just call run directly.
package org.apache.fop.layoutmgr;
import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.FOUserAgent;
import org.apache.fop.area.Area;
import org.apache.fop.area.Resolveable;
import org.apache.fop.area.PageViewport;
import org.apache.fop.layout.BackgroundProps;
import org.apache.fop.traits.BorderProps;
+import org.apache.avalon.framework.logger.Logger;
+
import java.util.ListIterator;
/**
* The base class for all LayoutManagers.
*/
public abstract class AbstractLayoutManager implements LayoutManager {
+ protected FOUserAgent userAgent;
protected LayoutManager parentLM;
protected FObj fobj;
protected String foID = null;
childLMiter = lmIter;
}
+ /**
+ * Set the user agent.
+ *
+ * @param ua the user agent
+ */
+ public void setUserAgent(FOUserAgent ua) {
+ userAgent = ua;
+ }
+
+ public FOUserAgent getUserAgent() {
+ return userAgent;
+ }
+
+ protected Logger getLogger() {
+ return userAgent.getLogger();
+ }
+
public void setParentLM(LayoutManager lm) {
this.parentLM = lm;
}
}
while (childLMiter.hasNext()) {
curChildLM = (LayoutManager) childLMiter.next();
+ curChildLM.setUserAgent(getUserAgent());
curChildLM.setParentLM(this);
curChildLM.init();
return curChildLM;
if (overflow == Overflow.HIDDEN) {
clip = true;
} else if (overflow == Overflow.ERROR_IF_OVERFLOW) {
- //log.error("contents overflows block-container viewport: clipping");
+ getLogger().error("contents overflows block-container viewport: clipping");
clip = true;
}
}
LineLayoutManager child;
child = new LineLayoutManager(fobj, inlines, lineHeight,
lead, follow);
+ child.setUserAgent(getUserAgent());
return child;
}
boolean over = false;
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- reset(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
over = true;
break;
}
+ stackSize.add(bp.getStackingSize());
lastPos = bp;
childBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
if (curLM.generatesInlineAreas()) {
// Reset stackLimit for non-first lines
childLC.setStackLimit(new MinOptMax(ipd/* - iIndents*/));
}
BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this, childBreaks.size() - 1));
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(stackSize);
return breakPoss;
}
return breakPoss;
}
+ int iStartPos = 0;
+
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
addID();
LayoutManager childLM ;
- int iStartPos = 0;
LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
LeafPosition lfp = (LeafPosition) parentIter.next();
if (lfp.getLeafPos() == -2) {
- childBreaks.clear();
curBlockArea = null;
flush();
return;
// if adjusted space after
addBlockSpacing(adjust, layoutProps.spaceAfter.space);
- childBreaks.clear();
curBlockArea = null;
}
if (resetPos == null) {
reset(null);
childBreaks.clear();
+ iStartPos = 0;
} else {
//reset(resetPos);
LayoutManager lm = resetPos.getLM();
return ((m_flags & FORCE) != 0);
}
+ public boolean nextBreakOverflows() {
+ return ((m_flags & NEXT_OVERFLOWS) != 0);
+ }
+
public boolean isSuppressible() {
return ((m_flags & ALL_ARE_SUPPRESS_AT_LB) != 0);
}
*/
package org.apache.fop.layoutmgr;
+import org.apache.fop.fo.FOUserAgent;
import org.apache.fop.area.Area;
import org.apache.fop.area.MinOptMax;
import org.apache.fop.area.Resolveable;
import org.apache.fop.area.PageViewport;
+import org.apache.avalon.framework.logger.Logger;
+
import java.util.List;
import java.util.ArrayList;
* leader use-content and title.
*/
public class ContentLayoutManager implements LayoutManager {
-
+ private FOUserAgent userAgent;
private Area holder;
private int stackSize;
private LayoutManager parentLM;
holder.addChild(childArea);
}
+ /**
+ * Set the user agent.
+ *
+ * @param ua the user agent
+ */
+ public void setUserAgent(FOUserAgent ua) {
+ userAgent = ua;
+ }
+
+ public FOUserAgent getUserAgent() {
+ return userAgent;
+ }
+
+ protected Logger getLogger() {
+ return userAgent.getLogger();
+ }
+
/** @see org.apache.fop.layoutmgr.LayoutManager */
public void setParentLM(LayoutManager lm) {
parentLM = lm;
public BreakPoss getNextBreakPoss(LayoutContext context) {
- LayoutManager curLM ; // currently active LM
+ // currently active LM
+ LayoutManager curLM;
MinOptMax stackSize = new MinOptMax();
while ((curLM = getChildLM()) != null) {
if (curLM.generatesInlineAreas()) {
- // problem
+ getLogger().error("inline area not allowed under flow - ignoring");
curLM.setFinished(true);
continue;
}
// set stackLimit for remaining space
childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
- if (bp.isForcedBreak()) {
+ if (bp.isForcedBreak() || bp.nextBreakOverflows()) {
breakPage = true;
- break;
}
}
}
return null;
}
+ int iStartPos = 0;
+
public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
- LayoutManager childLM ;
- int iStartPos = 0;
+ LayoutManager childLM;
LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
LeafPosition lfp = (LeafPosition) parentIter.next();
}
flush();
- // clear the breaks for the page to start for the next page
- blockBreaks.clear();
}
*/
public LayoutManager retrieveMarker(String name, int pos, int boundary) {
// error cannot retrieve markers in flow
+ getLogger().error("Cannot retrieve a marker from the flow");
return null;
}
}
if (prevPos != null) {
// ASSERT (prevPos.getLM() == this)
if (prevPos.getLM() != this) {
- //log.error(
+ //getLogger().error(
// "InlineStackingLayoutManager.resetPosition: " +
// "LM mismatch!!!");
}
// ignore nested blocks for now
if (!curLM.generatesInlineAreas()) {
- System.err.println("WARNING: ignoring block inside inline fo");
+ getLogger().warn("ignoring block inside inline fo");
curLM.setFinished(true);
continue;
}
spaceRange.min) * dSpaceAdjust);
}
if (iAdjust != 0) {
- //log.error("Add leading space: " + iAdjust);
+ //getLogger().debug("Add leading space: " + iAdjust);
Space ls = new Space();
ls.setWidth(iAdjust);
parentArea.addChild(ls);
package org.apache.fop.layoutmgr;
+import org.apache.fop.fo.FOUserAgent;
import org.apache.fop.area.Area;
import org.apache.fop.area.Resolveable;
* The interface for all LayoutManagers.
*/
public interface LayoutManager {
- public boolean generatesInlineAreas();
- public Area getParentArea (Area childArea);
- public void addChild (Area childArea);
+
+ /**
+ * Set the user agent.
+ *
+ * @param ua the user agent
+ */
+ public void setUserAgent(FOUserAgent ua);
+
+ /**
+ * Get the user agent.
+ *
+ * @return the user agent
+ */
+ public FOUserAgent getUserAgent();
+
+ /**
+ * Set the parent layout manager.
+ * The parent layout manager is required for adding areas.
+ *
+ * @param lm the parent layout manager
+ */
public void setParentLM(LayoutManager lm);
+ public void init();
+
+ /**
+ * Generates inline areas.
+ * This is used to check if the layout manager generates inline
+ * areas.
+ *
+ * @return true if the layout manager generates inline areas
+ */
+ public boolean generatesInlineAreas();
+
/**
* Return true if the next area which would be generated by this
* LayoutManager could start a new line (or flow for block-level FO).
public BreakPoss getNextBreakPoss(LayoutContext context);
+ public void resetPosition(Position position);
+
+ public void getWordChars(StringBuffer sbChars, Position bp1,
+ Position bp2);
+
/**
* Return a value indicating whether this LayoutManager has laid out
* all its content (or generated BreakPossibilities for all content.)
*/
public void setFinished(boolean isFinished);
+ public Area getParentArea(Area childArea);
+ public void addChild(Area childArea);
+
/**
* Tell the layout manager to add all the child areas implied
* by Position objects which will be returned by the
*/
public void addAreas(PositionIterator posIter, LayoutContext context);
- public void init();
-
- public void resetPosition(Position position);
-
- public void getWordChars(StringBuffer sbChars, Position bp1,
- Position bp2);
-
/**
* Get the string of the current page number.
*
public LayoutManager retrieveMarker(String name, int pos, int boundary);
}
+
while (bpIter.hasPrevious() && bpIter.previous() != prev) {
}
if (bpIter.next() != prev) {
- //log.error("findHyphenPoss: problem!");
+ getLogger().error("findHyphenPoss: problem!");
return null;
}
StringBuffer sbChars = new StringBuffer(30);
prev = bp;
}
vecInlineBreaks.remove(vecInlineBreaks.size() - 1); // remove last
- //log.debug("Word to hyphenate: " + sbChars.toString());
+ getLogger().debug("Word to hyphenate: " + sbChars.toString());
// Now find all hyphenation points in this word (get in an array of offsets)
// hyphProps are from the block level?. Note that according to the spec,
*/
public void addAreas(PositionIterator parentIter, double dSpaceAdjust) {
LayoutManager childLM;
- //int iStartPos = 0;
LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
LineBreakPosition lbp = (LineBreakPosition) parentIter.next();
// end the page.
getParentArea(area);
// Alternatively the child LM indicates to parent that it's full?
- //System.out.println("size: " + area.getAllocationBPD().max +
+ //getLogger().debug("size: " + area.getAllocationBPD().max +
// ":" + curSpan.getMaxBPD().min);
/*if (area.getAllocationBPD().max >= curSpan.getMaxBPD().min) {
// Consider it filled
.getRegion(regionClass);
reg.getRegion().setIPD((int)reg.getViewArea().getWidth());
if (reg == null) {
- System.out.println("no region viewport: shouldn't happen");
+ getLogger().error("no region viewport: shouldn't happen");
}
StaticContentLayoutManager lm = flow.getLayoutManager();
+ lm.setUserAgent(getUserAgent());
lm.init();
lm.setRegionReference(reg.getRegion());
lm.setParentLM(this);
lm.addAreas(new BreakPossPosIter(vecBreakPoss, 0,
vecBreakPoss.size()), null);
} else {
- System.out.println("bp==null cls=" + regionClass);
+ getLogger().error("bp==null cls=" + regionClass);
}
}
//lm.flush();
public BreakPoss getNextBreakPoss(LayoutContext context) {
- LayoutManager curLM; // currently active LM
+ // currently active LM
+ LayoutManager curLM;
while ((curLM = getChildLM()) != null) {
// Make break positions and return page break
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
blockBreaks.add(bp);
if (bp.isForcedBreak()) {
- System.out.println("Forced breaks are not allowed in static content");
+ getLogger().error("Forced breaks are not allowed in static content - ignoring");
return null;
}
}
}
flush();
- // clear the breaks for the page to start for the next page
- blockBreaks.clear();
}
*/
public void addMarker(String name, LayoutManager lm, boolean start) {
// error markers not allowed in static
+ getLogger().error("Cannot add marker to static areas");
}
}
stackSize));
childLC.setRefIPD(ipd);
+ boolean over = false;
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- reset(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
break;
}
+ stackSize.add(bp.getStackingSize());
lastPos = bp;
childBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
}
BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this, childBreaks.size() - 1));
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(stackSize);
return breakPoss;
}
public void resetPosition(Position resetPos) {
if (resetPos == null) {
reset(null);
+ } else {
+ //reset(resetPos);
}
}
}
* @return the next break possibility
*/
public BreakPoss getNextBreakPoss(LayoutContext context) {
- LayoutManager curLM; // currently active LM
+ // currently active LM
+ LayoutManager curLM;
MinOptMax stackSize = new MinOptMax();
// if starting add space before
stackSize));
childLC.setRefIPD(ipd);
+ boolean over = false;
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- reset(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
break;
}
+ stackSize.add(bp.getStackingSize());
lastPos = bp;
bodyBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
}
BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this, bodyBreaks.size() - 1));
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(stackSize);
return breakPoss;
}
if (resetPos == null) {
bodyBreaks.clear();
reset(null);
+ } else {
+
}
}
}
* @return the next break possibility
*/
public BreakPoss getNextBreakPoss(LayoutContext context) {
- Item curLM; // currently active LM
+ // currently active LM
+ Item curLM;
+
+ label.setUserAgent(getUserAgent());
+ body.setUserAgent(getUserAgent());
BreakPoss lastPos = null;
List breakList = new ArrayList();
int max = 0;
int stage = 0;
+ boolean over = false;
while (true) {
if(stage == 0) {
curLM = label;
stage++;
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- curLM.resetPosition(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
} else {
lastPos = bp;
}
+ stackSize.add(bp.getStackingSize());
childBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
setFinished(true);
ItemPosition rp = new ItemPosition(this, breakList.size() - 1, breakList);
BreakPoss breakPoss = new BreakPoss(rp);
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(itemSize);
return breakPoss;
}
package org.apache.fop.layoutmgr.table;
import org.apache.fop.fo.PropertyManager;
+import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LeafPosition;
import org.apache.fop.layoutmgr.BreakPoss;
curLM.setColumns(columns);
+ boolean over = false;
+
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- reset(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
+ over = true;
break;
}
+ stackSize.add(bp.getStackingSize());
lastPos = bp;
childBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
}
BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this, childBreaks.size() - 1));
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(stackSize);
return breakPoss;
}
stackSize));
childLC.setRefIPD(ipd);
+ boolean over = false;
+
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- reset(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
+ over = true;
break;
}
+ stackSize.add(bp.getStackingSize());
lastPos = bp;
childBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
}
BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this, childBreaks.size() - 1));
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(stackSize);
return breakPoss;
}
while ((curLM = getChildLM()) != null) {
if(curLM.generatesInlineAreas()) {
- // error
+ getLogger().error("table-cell must contain block areas - ignoring");
curLM.setFinished(true);
continue;
}
stackSize));
childLC.setRefIPD(ipd);
+ boolean over = false;
+
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- reset(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
+ over = true;
break;
}
+ stackSize.add(bp.getStackingSize());
lastPos = bp;
childBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
}
BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this, childBreaks.size() - 1));
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(stackSize);
return breakPoss;
}
// add cells to list
while (childLMiter.hasNext()) {
curChildLM = (LayoutManager) childLMiter.next();
+ curChildLM.setUserAgent(getUserAgent());
curChildLM.setParentLM(this);
curChildLM.init();
cellList.add(curChildLM);
int max = 0;
int cellcount = 0;
+ boolean over = false;
+
while ((curLM = getCellLM(cellcount++)) != null) {
List childBreaks = new ArrayList();
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- reset(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
+ over = true;
break;
}
+ stackSize.add(bp.getStackingSize());
lastPos = bp;
childBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
setFinished(true);
RowPosition rp = new RowPosition(this, breakList.size() - 1, breakList);
BreakPoss breakPoss = new BreakPoss(rp);
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(rowSize);
return breakPoss;
}
+ /**
+ * Reset the layoutmanager "iterator" so that it will start
+ * with the passed Position's generating LM
+ * on the next call to getChildLM.
+ * @param pos a Position returned by a child layout manager
+ * representing a potential break decision.
+ * If pos is null, then back up to the first child LM.
+ */
+ protected void reset(Position pos) {
+ LayoutManager curLM; // currently active LM
+ int cellcount = 0;
+
+ if (pos == null) {
+ while ((curLM = getCellLM(cellcount++)) != null) {
+ curLM.resetPosition(null);
+ cellcount++;
+ }
+ } else {
+ RowPosition rpos = (RowPosition)pos;
+ List breaks = rpos.cellBreaks;
+
+ while ((curLM = getCellLM(cellcount++)) != null) {
+ List childbreaks = (List)breaks.get(cellcount);
+ curLM.resetPosition((Position)childbreaks.get(childbreaks.size() - 1));
+ cellcount++;
+ }
+ }
+
+ setFinished(false);
+ }
+
/**
* Set the y position offset of this row.
* This is used to set the position of the areas returned by this row.
stackSize));
childLC.setRefIPD(ipd);
+ boolean over = false;
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- reset(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
+ over = true;
break;
}
+ stackSize.add(bp.getStackingSize());
lastPos = bp;
childBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
}
BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this, childBreaks.size() - 1));
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(stackSize);
return breakPoss;
}
curLM.setColumns(columns);
+ boolean over = false;
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- if (stackSize.opt > context.getStackLimit().max) {
+ if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
- reset(lastPos.getPosition());
+ LayoutManager lm = lastPos.getLayoutManager();
+ lm.resetPosition(lastPos.getPosition());
+ if (lm != curLM) {
+ curLM.resetPosition(null);
+ }
} else {
curLM.resetPosition(null);
}
+ over = true;
break;
}
+ stackSize.add(bp.getStackingSize());
lastPos = bp;
bodyBreaks.add(bp);
+ if (bp.nextBreakOverflows()) {
+ over = true;
+ break;
+ }
+
childLC.setStackLimit(MinOptMax.subtract(
context.getStackLimit(), stackSize));
}
}
BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this, bodyBreaks.size() - 1));
+ if (over) {
+ breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+ }
breakPoss.setStackingSize(stackSize);
return breakPoss;
}