aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-05-17 17:00:25 +0000
committerJeremias Maerki <jeremias@apache.org>2005-05-17 17:00:25 +0000
commitedf6eeea2518fc8ed99b91f4dc85fc98f11d4edf (patch)
treefb1d945aa1ea2478c84702e250e017af863a051b /src
parent907fad82cc5494c0aba8679e0ea7523257540144 (diff)
downloadxmlgraphics-fop-edf6eeea2518fc8ed99b91f4dc85fc98f11d4edf.tar.gz
xmlgraphics-fop-edf6eeea2518fc8ed99b91f4dc85fc98f11d4edf.zip
Removed a lot of obsolete code from the old page breaking approach.
Some style improvements here and there. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198643 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java11
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java406
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java187
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java254
-rw-r--r--src/java/org/apache/fop/layoutmgr/BreakCost.java58
-rw-r--r--src/java/org/apache/fop/layoutmgr/BreakPoss.java291
-rw-r--r--src/java/org/apache/fop/layoutmgr/BreakPossPosIter.java75
-rw-r--r--src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java224
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutManager.java11
-rw-r--r--src/java/org/apache/fop/layoutmgr/LineLayoutManager.java107
-rw-r--r--src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java84
-rw-r--r--src/java/org/apache/fop/layoutmgr/TextLayoutManager.java216
-rw-r--r--src/java/org/apache/fop/layoutmgr/list/Item.java81
-rw-r--r--src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java87
-rw-r--r--src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java127
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/Caption.java26
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/Cell.java123
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java26
18 files changed, 264 insertions, 2130 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
index 738e5ccde..c43a9eda5 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
@@ -204,17 +204,6 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
/**
- * Generate and return the next break possibility.
- * Each layout manager must implement this.
- * TODO: should this be abstract or is there some reasonable
- * default implementation?
- */
- public BreakPoss getNextBreakPoss(LayoutContext context) {
- return null;
- }
-
-
- /**
* Return value indicating whether the next area to be generated could
* start a new line or flow area.
* In general, if can't break at the current level, delegate to
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index 76ed74224..bf9095fcf 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -96,8 +96,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
*/
protected void initProperties() {
abProps = getBlockContainerFO().getCommonAbsolutePosition();
- foBlockSpaceBefore = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceBefore).getSpace();
- foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceAfter).getSpace();
+ foBlockSpaceBefore = new SpaceVal(getBlockContainerFO().getCommonMarginBlock()
+ .spaceBefore).getSpace();
+ foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock()
+ .spaceAfter).getSpace();
boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
if (rotated) {
@@ -108,21 +110,26 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
width = getBlockContainerFO().getInlineProgressionDimension().getOptimum().getLength();
}
-/*LF*/ bpUnit = 0; //layoutProps.blockProgressionUnit;
-/*LF*/ if (bpUnit == 0) {
-/*LF*/ // use optimum space values
-/*LF*/ adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock().spaceBefore.getSpace().getOptimum().getLength().getValue();
-/*LF*/ adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock().spaceAfter.getSpace().getOptimum().getLength().getValue();
-/*LF*/ } else {
-/*LF*/ // use minimum space values
-/*LF*/ adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock().spaceBefore.getSpace().getMinimum().getLength().getValue();
-/*LF*/ adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock().spaceAfter.getSpace().getMinimum().getLength().getValue();
-/*LF*/ }
+ bpUnit = 0; //layoutProps.blockProgressionUnit;
+ if (bpUnit == 0) {
+ // use optimum space values
+ adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock()
+ .spaceBefore.getSpace().getOptimum().getLength().getValue();
+ adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock()
+ .spaceAfter.getSpace().getOptimum().getLength().getValue();
+ } else {
+ // use minimum space values
+ adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock()
+ .spaceBefore.getSpace().getMinimum().getLength().getValue();
+ adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock()
+ .spaceAfter.getSpace().getMinimum().getLength().getValue();
+ }
}
/** @return the content IPD */
protected int getRotatedIPD() {
- return getBlockContainerFO().getInlineProgressionDimension().getOptimum().getLength().getValue();
+ return getBlockContainerFO().getInlineProgressionDimension()
+ .getOptimum().getLength().getValue();
}
private int getSpaceBefore() {
@@ -131,9 +138,12 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
private int getBPIndents() {
int indents = 0;
- indents += getBlockContainerFO().getCommonMarginBlock().spaceBefore.getOptimum().getLength().getValue();
- indents += getBlockContainerFO().getCommonMarginBlock().spaceAfter.getOptimum().getLength().getValue();
- indents += getBlockContainerFO().getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
+ indents += getBlockContainerFO().getCommonMarginBlock()
+ .spaceBefore.getOptimum().getLength().getValue();
+ indents += getBlockContainerFO().getCommonMarginBlock()
+ .spaceAfter.getOptimum().getLength().getValue();
+ indents += getBlockContainerFO().getCommonBorderPaddingBackground()
+ .getBPPaddingAndBorder(false);
return indents;
}
@@ -162,7 +172,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
}
autoHeight = false;
- boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); //vals[0] == 0.0;
+ //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
referenceIPD = context.getRefIPD();
int maxbpd = context.getStackLimit().opt;
int allocBPD, allocIPD;
@@ -186,10 +196,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
double contentRectOffsetX = 0;
contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
double contentRectOffsetY = 0;
- //contentRectOffsetY += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
- //contentRectOffsetY += getSpaceBefore();
- contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
- contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getPaddingBefore(false);
+ contentRectOffsetY += getBlockContainerFO()
+ .getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
+ contentRectOffsetY += getBlockContainerFO()
+ .getCommonBorderPaddingBackground().getPaddingBefore(false);
Rectangle2D rect = new Rectangle2D.Double(
contentRectOffsetX, contentRectOffsetY,
@@ -235,8 +245,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
// get elements from curLM
returnedList = curLM.getNextKnuthElements(childLC, alignment);
if (returnedList.size() == 1
- && ((KnuthElement) returnedList.getFirst()).isPenalty()
- && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
+ && ((KnuthElement)returnedList.getFirst()).isPenalty()
+ && ((KnuthPenalty)returnedList.getFirst()).getP()
+ == -KnuthElement.INFINITE) {
// a descendant of this block has break-before
if (returnList.size() == 0) {
// the first child (or its first child ...) has
@@ -282,7 +293,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
continue;
}
if (((KnuthElement) returnedList.getLast()).isPenalty()
- && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
+ && ((KnuthPenalty) returnedList.getLast()).getP()
+ == -KnuthElement.INFINITE) {
// a descendant of this block has break-after
if (curLM.isFinished()) {
// there is no other content in this block;
@@ -315,7 +327,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
returnList.add(new KnuthBox(vpContentBPD, bcPosition, false));
//TODO Handle min/opt/max for block-progression-dimension
/* These two elements will be used to add stretchability to the above box
- returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, returnPosition, false));
+ returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE,
+ false, returnPosition, false));
returnList.add(new KnuthGlue(0, 1 * constantLineHeight, 0,
LINE_NUMBER_ADJUSTMENT, returnPosition, false));
*/
@@ -339,7 +352,6 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
}
private LinkedList getNextKnuthElementsAbsolute(LayoutContext context, int alignment) {
- MinOptMax stackSize = new MinOptMax();
autoHeight = false;
Point offset = getAbsOffset();
@@ -387,8 +399,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
double contentRectOffsetY = offset.getY();
contentRectOffsetY += getSpaceBefore();
- contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
- contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getPaddingBefore(false);
+ contentRectOffsetY += getBlockContainerFO()
+ .getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
+ contentRectOffsetY += getBlockContainerFO()
+ .getCommonBorderPaddingBackground().getPaddingBefore(false);
Rectangle2D rect = new Rectangle2D.Double(
contentRectOffsetX, contentRectOffsetY,
@@ -543,170 +557,6 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
}
- /**
- * @see org.apache.fop.layoutmgr.LayoutManager#getNextBreakPoss(org.apache.fop.layoutmgr.LayoutContext)
- */
- public BreakPoss getNextBreakPoss(LayoutContext context) {
-
- if (isAbsoluteOrFixed()) {
- return getAbsoluteBreakPoss(context);
- }
-
- autoHeight = false;
- boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); //vals[0] == 0.0;
- referenceIPD = context.getRefIPD();
- int maxbpd = context.getStackLimit().opt;
- int allocBPD, allocIPD;
- if (height.getEnum() != EN_AUTO) {
- allocBPD = height.getValue(); //this is the content-height
- allocBPD += getBPIndents();
- } else {
- allocBPD = maxbpd;
- autoHeight = true;
- }
- if (width.getEnum() != EN_AUTO) {
- allocIPD = width.getValue(); //this is the content-width
- allocIPD += getIPIndents();
- } else {
- allocIPD = referenceIPD;
- }
-
- vpContentBPD = allocBPD - getBPIndents();
- vpContentIPD = allocIPD - getIPIndents();
-
- double contentRectOffsetX = 0;
- contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
- double contentRectOffsetY = 0;
- //contentRectOffsetY += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
- //contentRectOffsetY += getSpaceBefore();
- contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
- contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getPaddingBefore(false);
-
- Rectangle2D rect = new Rectangle2D.Double(
- contentRectOffsetX, contentRectOffsetY,
- vpContentIPD, vpContentBPD);
- relDims = new FODimension(0, 0);
- absoluteCTM = CTM.getCTMandRelDims(getBlockContainerFO().getReferenceOrientation(),
- getBlockContainerFO().getWritingMode(), rect, relDims);
- //double[] vals = absoluteCTM.toArray();
-
- MinOptMax stackLimit;
- if (rotated) {
- // rotated 90 degrees
- /*
- if (relDims.ipd > context.getRefIPD()) {
- relDims.ipd = context.getRefIPD();
- }*/
- //stackLimit = new MinOptMax(relDims.ipd);
- /*
- if (width.getEnum() == EN_AUTO) {
- relDims.bpd = context.getStackLimit().opt;
- }
- absoluteCTM = new CTM(vals[0], vals[1], vals[2], vals[3], 0, 0);
- */
- //absoluteCTM = new CTM(vals[0], vals[1], vals[2], vals[3], vals[5], vals[4]);
- } else {
- /*
- if (vals[0] == -1.0) {
- absoluteCTM = new CTM(vals[0], vals[1], vals[2], vals[3], 0, 0);
- }*/
- //stackLimit = context.getStackLimit();
- }
- stackLimit = new MinOptMax(relDims.bpd);
-
- LayoutManager curLM; // currently active LM
-
- MinOptMax stackSize = new MinOptMax();
- // if starting add space before
- // stackSize.add(spaceBefore);
- BreakPoss lastPos = null;
-
- //TODO fix layout dimensions!
- getBlockContainerFO().setLayoutDimension(PercentBase.BLOCK_IPD, allocIPD);
- getBlockContainerFO().setLayoutDimension(PercentBase.BLOCK_BPD, allocBPD);
- getBlockContainerFO().setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, relDims.ipd);
- getBlockContainerFO().setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, relDims.bpd);
-
- while ((curLM = getChildLM()) != null) {
- //Treat bc with fixed BPD as non-breakable
- if (!autoHeight && (stackLimit.max > context.stackLimit.max)) {
- if (log.isDebugEnabled()) {
- log.debug("block-container does not fit in the available area "
- + "(available: " + context.stackLimit.max
- + ", needed: " + stackLimit.max + ")");
- }
- BreakPoss breakPoss = new BreakPoss(new LeafPosition(this, -1));
- breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
- breakPoss.setStackingSize(new MinOptMax());
- return breakPoss;
- }
-
- // Make break positions and return blocks!
- // Set up a LayoutContext
- BreakPoss bp;
-
- LayoutContext childLC = new LayoutContext(0);
- childLC.setStackLimit(
- MinOptMax.subtract(stackLimit,
- stackSize));
- childLC.setRefIPD(relDims.ipd);
-
- boolean over = false;
- while (!curLM.isFinished()) {
- if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- if (stackSize.opt + bp.getStackingSize().opt > stackLimit.max) {
- // reset to last break
- if (lastPos != null) {
- reset(lastPos.getPosition());
- } else {
- curLM.resetPosition(null);
- }
- over = true;
- break;
- }
- if (bp.nextBreakOverflows()) {
- over = true;
- break;
- }
-
- stackSize.add(bp.getStackingSize());
- lastPos = bp;
- childBreaks.add(bp);
-
- childLC.setStackLimit(MinOptMax.subtract(
- stackLimit, stackSize));
- }
- }
- if (!rotated && autoHeight) {
- BreakPoss breakPoss;
- breakPoss = new BreakPoss(new LeafPosition(this,
- childBreaks.size() - 1));
- breakPoss.setStackingSize(stackSize);
- if (over) {
- breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
- }
- return breakPoss;
- }
- }
- setFinished(true);
- if (rotated) {
- BreakPoss breakPoss;
- breakPoss = new BreakPoss(new LeafPosition(this,
- childBreaks.size() - 1));
- breakPoss.setStackingSize(new MinOptMax(relDims.ipd));
- return breakPoss;
- }
- if (!rotated && !autoHeight) {
- //Treated as if all content is kept together
- BreakPoss breakPoss;
- breakPoss = new BreakPoss(new LeafPosition(this,
- childBreaks.size() - 1));
- breakPoss.setStackingSize(new MinOptMax(relDims.bpd));
- return breakPoss;
- }
- return null;
- }
-
private Point getAbsOffset() {
int x = 0;
int y = 0;
@@ -720,115 +570,6 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
}
/**
- * Generate and return the next break possibility for absolutely positioned
- * block-containers.
- * @param context LayoutContext to work with
- * @return the next break position
- * @see org.apache.fop.layoutmgr.LayoutManager#getNextBreakPoss(org.apache.fop.layoutmgr.LayoutContext)
- */
- public BreakPoss getAbsoluteBreakPoss(LayoutContext context) {
-
- LayoutManager curLM; // currently active LM
-
- MinOptMax stackSize = new MinOptMax();
- autoHeight = false;
-
- Point offset = getAbsOffset();
- int allocBPD, allocIPD;
- if (height.getEnum() != EN_AUTO) {
- allocBPD = height.getValue(); //this is the content-height
- allocBPD += getBPIndents();
- } else {
- allocBPD = 0;
- if (abProps.bottom.getEnum() != EN_AUTO) {
- if (isFixed()) {
- allocBPD = (int)getCurrentPV().getViewArea().getHeight();
- } else {
- allocBPD = context.getStackLimit().opt;
- }
- allocBPD -= offset.y;
- if (abProps.bottom.getEnum() != EN_AUTO) {
- allocBPD -= abProps.bottom.getValue();
- }
- } else {
- autoHeight = true;
- }
- }
- if (width.getEnum() != EN_AUTO) {
- allocIPD = width.getValue(); //this is the content-width
- allocIPD += getIPIndents();
- } else {
- if (isFixed()) {
- allocIPD = (int)getCurrentPV().getViewArea().getWidth();
- } else {
- allocIPD = context.getRefIPD();
- }
- if (abProps.left.getEnum() != EN_AUTO) {
- allocIPD -= abProps.left.getValue();
- }
- if (abProps.right.getEnum() != EN_AUTO) {
- allocIPD -= abProps.right.getValue();
- }
- }
-
- vpContentBPD = allocBPD - getBPIndents();
- vpContentIPD = allocIPD - getIPIndents();
-
- double contentRectOffsetX = offset.getX();
- contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
- double contentRectOffsetY = offset.getY();
- contentRectOffsetY += getSpaceBefore();
- contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
- contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getPaddingBefore(false);
-
- Rectangle2D rect = new Rectangle2D.Double(
- contentRectOffsetX, contentRectOffsetY,
- vpContentIPD, vpContentBPD);
- relDims = new FODimension(0, 0);
- absoluteCTM = CTM.getCTMandRelDims(
- getBlockContainerFO().getReferenceOrientation(),
- getBlockContainerFO().getWritingMode(),
- rect, relDims);
-
- while ((curLM = getChildLM()) != null) {
- // Make break positions and return blocks!
- // Set up a LayoutContext
- BreakPoss bp;
-
- LayoutContext childLC = new LayoutContext(0);
- childLC.setStackLimit(new MinOptMax(1000000));
- childLC.setRefIPD(relDims.ipd);
-
- while (!curLM.isFinished()) {
- if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stackSize.add(bp.getStackingSize());
- childBreaks.add(bp);
- }
- }
- }
- setFinished(true);
- BreakPoss breakPoss = new BreakPoss(
- new LeafPosition(this, childBreaks.size() - 1));
- // absolutely positioned areas do not contribute
- // to the normal stacking
- breakPoss.setStackingSize(new MinOptMax(0));
- usedBPD = stackSize.opt;
-
- //TODO Maybe check for page overflow when autoHeight=true
- if (!autoHeight & (usedBPD > relDims.bpd)) {
- log.warn("Contents overflow block-container viewport: clipping");
- if (getBlockContainerFO().getOverflow() == EN_HIDDEN) {
- clip = true;
- } else if (getBlockContainerFO().getOverflow() == EN_ERROR_IF_OVERFLOW) {
- //TODO Throw layout exception
- clip = true;
- }
- }
-
- return breakPoss;
- }
-
- /**
* @see org.apache.fop.layoutmgr.LayoutManager#addAreas(org.apache.fop.layoutmgr.PositionIterator, org.apache.fop.layoutmgr.LayoutContext)
*/
public void addAreas(PositionIterator parentIter,
@@ -947,8 +688,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
// add space before and / or after the paragraph
// to reach a multiple of bpUnit
if (bSpaceBefore && bSpaceAfter) {
- foBlockSpaceBefore = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceBefore).getSpace();
- foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceAfter).getSpace();
+ foBlockSpaceBefore = new SpaceVal(getBlockContainerFO()
+ .getCommonMarginBlock().spaceBefore).getSpace();
+ foBlockSpaceAfter = new SpaceVal(getBlockContainerFO()
+ .getCommonMarginBlock().spaceAfter).getSpace();
adjustedSpaceBefore = (neededUnits(splitLength
+ foBlockSpaceBefore.min
+ foBlockSpaceAfter.min)
@@ -996,7 +739,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
bcpos.getBreaker().addContainedAreas();
}
- int bIndents = getBlockContainerFO().getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
+ //int bIndents = getBlockContainerFO().getCommonBorderPaddingBackground()
+ // .getBPPaddingAndBorder(false);
getCurrentPV().addMarkers(markers, false, false, true);
@@ -1011,52 +755,6 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
referenceArea = null;
}
- public void addAreasOLDOLDOLD(PositionIterator parentIter,
- LayoutContext layoutContext) {
- getParentArea(null);
-
- /* taken from BlockLM, check first if we should use space-before|after traits
- double adjust = layoutContext.getSpaceAdjust();
- if (!isAbsoluteOrFixed()) {
- // if adjusted space before
- addBlockSpacing(adjust, foBlockSpaceBefore);
- foBlockSpaceBefore = null;
- }*/
-
- BreakPoss bp1 = (BreakPoss)parentIter.peekNext();
- getPSLM().addIDToPage(getBlockContainerFO().getId());
- getCurrentPV().addMarkers(markers, true, bp1.isFirstArea(), bp1.isLastArea());
-
- LayoutManager childLM;
- int iStartPos = 0;
- LayoutContext lc = new LayoutContext(0);
- while (parentIter.hasNext()) {
- 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();
- getCurrentPV().addMarkers(markers, true, bp1.isFirstArea(), bp1.isLastArea());
-
- /*
- if (!isAbsoluteOrFixed()) {
- // if adjusted space after
- foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceAfter).getSpace();
- addBlockSpacing(adjust, foBlockSpaceAfter);
- }*/
-
- childBreaks.clear();
- viewportBlockArea = null;
- referenceArea = null;
- }
-
/**
* Get the parent area for children of this block container.
* This returns the current block container area
@@ -1075,8 +773,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
viewportBlockArea.setBPD(vpContentBPD);
}
- TraitSetter.addBorders(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground());
- TraitSetter.addBackground(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground());
+ TraitSetter.addBorders(viewportBlockArea,
+ getBlockContainerFO().getCommonBorderPaddingBackground());
+ TraitSetter.addBackground(viewportBlockArea,
+ getBlockContainerFO().getCommonBorderPaddingBackground());
TraitSetter.addMargins(viewportBlockArea,
getBlockContainerFO().getCommonBorderPaddingBackground(),
getBlockContainerFO().getCommonMarginBlock());
@@ -1214,7 +914,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
}
/**
- * convenience method that returns the BlockContainer node
+ * @return the BlockContainer node
*/
protected BlockContainer getBlockContainerFO() {
return (BlockContainer) fobj;
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
index 4f194b924..b7352367b 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
@@ -22,7 +22,6 @@ import java.util.LinkedList;
import java.util.ListIterator;
import java.util.List;
-import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.fonts.Font;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
@@ -35,8 +34,6 @@ import org.apache.fop.traits.MinOptMax;
*/
public class BlockLayoutManager extends BlockStackingLayoutManager {
- private static final int FINISHED_LEAF_POS = -2;
-
private Block curBlockArea;
/** Iterator over the child layout managers. */
@@ -51,27 +48,16 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
used in rendering the fo:block.
*/
private MinOptMax foBlockSpaceBefore = null;
- // need to retain foBlockSpaceAfter from previous instantiation
- //TODO this is very bad for multi-threading. fix me!
- private static MinOptMax foBlockSpaceAfter = null;
- private MinOptMax prevFoBlockSpaceAfter = null;
+ private MinOptMax foBlockSpaceAfter = null;
private int lead = 12000;
private int lineHeight = 14000;
private int follow = 2000;
private int middleShift = 0;
- private int iStartPos = 0;
-
- //private int contentIPD = 0;
-
/** The list of child BreakPoss instances. */
protected List childBreaks = new java.util.ArrayList();
- private boolean isfirst = true;
-
- private LineLayoutManager childLLM = null;
-
/**
* Creates a new BlockLayoutManager.
* @param inBlock the block FO object to create the layout manager for.
@@ -96,7 +82,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
*/
protected void initProperties() {
foBlockSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore).getSpace();
- prevFoBlockSpaceAfter = foBlockSpaceAfter;
/*LF*/ bpUnit = 0; //layoutProps.blockProgressionUnit;
/*LF*/ if (bpUnit == 0) {
/*LF*/ // use optimum space values
@@ -189,117 +174,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
}
/**
- * @see org.apache.fop.layoutmgr.LayoutManager#getNextBreakPoss(org.apache.fop.layoutmgr.LayoutContext)
- */
- public BreakPoss getNextBreakPossOLDOLDOLD(LayoutContext context) {
- LayoutManager curLM; // currently active LM
-
- //int refipd = context.getRefIPD();
- referenceIPD = context.getRefIPD();
- int contentipd = referenceIPD - getIPIndents();
-
- MinOptMax stackSize = new MinOptMax();
-
- if (prevFoBlockSpaceAfter != null) {
- stackSize.add(prevFoBlockSpaceAfter);
- prevFoBlockSpaceAfter = null;
- }
-
- if (foBlockSpaceBefore != null) {
- // this function called before addAreas(), so
- // resetting foBlockSpaceBefore = null in addAreas()
- stackSize.add(foBlockSpaceBefore);
- }
-
- BreakPoss lastPos = null;
-
- // Set context for percentage property values.
- getBlockFO().setLayoutDimension(PercentBase.BLOCK_IPD, contentipd);
- getBlockFO().setLayoutDimension(PercentBase.BLOCK_BPD, -1);
-
- while ((curLM = getChildLM()) != null) {
- // Make break positions and return blocks!
- // Set up a LayoutContext
- BreakPoss bp;
-
- 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(contentipd));
- childLC.setRefIPD(contentipd);
- } else {
- childLC.setStackLimit(
- MinOptMax.subtract(context.getStackLimit(),
- stackSize));
- childLC.setRefIPD(referenceIPD);
- }
- boolean over = false;
- while (!curLM.isFinished()) {
- if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
- // reset to last break
- if (lastPos != null) {
- 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(contentipd));
- } else {
- childLC.setStackLimit(MinOptMax.subtract(
- context.getStackLimit(), stackSize));
- }
- }
- }
- if (getChildLM() == null || over) {
- if (getChildLM() == null) {
- setFinished(true);
- stackSize.add(new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter).getSpace());
- }
- BreakPoss breakPoss = new BreakPoss(
- new LeafPosition(this, childBreaks.size() - 1));
- if (over) {
- breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
- }
- breakPoss.setStackingSize(stackSize);
- if (isfirst && breakPoss.getStackingSize().opt > 0) {
- breakPoss.setFlag(BreakPoss.ISFIRST, true);
- isfirst = false;
- }
- if (isFinished()) {
- breakPoss.setFlag(BreakPoss.ISLAST, true);
- }
- return breakPoss;
- }
- }
- setFinished(true);
- BreakPoss breakPoss = new BreakPoss(new LeafPosition(this, FINISHED_LEAF_POS));
- breakPoss.setStackingSize(stackSize);
- breakPoss.setFlag(BreakPoss.ISFIRST, isfirst);
- breakPoss.setFlag(BreakPoss.ISLAST, true);
- return breakPoss;
- }
-
- /**
* @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether()
*/
public boolean mustKeepTogether() {
@@ -325,64 +199,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
|| !getBlockFO().getKeepWithNext().getWithinColumn().isAuto();
}
- //TODO this method is no longer used
- public BreakPoss getNextBreakPoss(LayoutContext context) {
- setFinished(true);
- return null;
- }
-
- /**
- * @see org.apache.fop.layoutmgr.LayoutManager#addAreas(org.apache.fop.layoutmgr.PositionIterator, org.apache.fop.layoutmgr.LayoutContext)
- */
- public void addAreasOLDOLDOLD(PositionIterator parentIter,
- LayoutContext layoutContext) {
- getParentArea(null);
-
- BreakPoss bp1 = (BreakPoss)parentIter.peekNext();
- bBogus = !bp1.generatesAreas();
-
- // if adjusted space before
- double adjust = layoutContext.getSpaceAdjust();
- addBlockSpacing(adjust, foBlockSpaceBefore);
- foBlockSpaceBefore = null;
-
- if (!isBogus()) {
- getPSLM().addIDToPage(getBlockFO().getId());
- getCurrentPV().addMarkers(markers, true, bp1.isFirstArea(),
- bp1.isLastArea());
- }
-
- try {
- LayoutManager childLM;
- LayoutContext lc = new LayoutContext(0);
- while (parentIter.hasNext()) {
- LeafPosition lfp = (LeafPosition) parentIter.next();
- if (lfp.getLeafPos() == FINISHED_LEAF_POS) {
- return;
- }
- // 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);
- }
- }
- } finally {
- if (!isBogus()) {
- getCurrentPV().addMarkers(markers, false, bp1.isFirstArea(),
- bp1.isLastArea());
- }
- flush();
-
- // if adjusted space after
- foBlockSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter).getSpace();
- addBlockSpacing(adjust, foBlockSpaceAfter);
- curBlockArea = null;
- }
- }
-
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
/* LF *///System.out.println(" BLM.addAreas>");
@@ -625,7 +441,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
if (resetPos == null) {
reset(null);
childBreaks.clear();
- iStartPos = 0;
} else {
//reset(resetPos);
LayoutManager lm = resetPos.getLM();
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 82faa794b..6e6e6fdc0 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -27,10 +27,8 @@ import org.apache.fop.area.Area;
import org.apache.fop.area.BlockParent;
import org.apache.fop.area.Block;
import org.apache.fop.datatypes.PercentBase;
-import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.CommonMarginBlock;
import org.apache.fop.fo.properties.SpaceProperty;
import org.apache.fop.traits.MinOptMax;
@@ -67,10 +65,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
fobj = node;
}
- private BreakCost evaluateBreakCost(Area parent, Area child) {
- return new BreakCost(child, 0);
- }
-
/** return current area being filled
*/
protected BlockParent getCurrentArea() {
@@ -184,9 +178,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
int iIndents = 0;
int bIndents = 0;
if (fobj instanceof org.apache.fop.fo.flow.Block) {
- iIndents = ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().startIndent.getValue()
- + ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().endIndent.getValue();
- bIndents = ((org.apache.fop.fo.flow.Block) fobj).getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
+ org.apache.fop.fo.flow.Block block = (org.apache.fop.fo.flow.Block)fobj;
+ iIndents = block.getCommonMarginBlock().startIndent.getValue()
+ + block.getCommonMarginBlock().endIndent.getValue();
+ bIndents = block.getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
}
int ipd = referenceIPD - iIndents;
@@ -292,7 +287,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
}
contentList.addAll(returnedList);
if (((KnuthElement) returnedList.getLast()).isPenalty()
- && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
+ && ((KnuthPenalty) returnedList.getLast()).getP()
+ == -KnuthElement.INFINITE) {
// a descendant of this block has break-after
if (curLM.isFinished()) {
// there is no other content in this block;
@@ -329,7 +325,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
/* end of extension */
returnedList = new LinkedList();
- wrapPositionElements(contentList, returnList);
+ if (contentList.size() > 0) {
+ wrapPositionElements(contentList, returnList);
+ } else {
+ //Empty fo:block, zero-length box makes sure the IDs are registered.
+ returnList.add(new KnuthBox(0, new Position(this), true));
+ }
addKnuthElementsForBorderPaddingAfter(returnList, returnPosition);
addKnuthElementsForSpaceAfter(returnList, returnPosition, alignment);
@@ -342,7 +343,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> " + adj);
-/*LF*/ //System.out.println(" lastElement e' " + (lastElement.isPenalty() ? "penalty" : (lastElement.isGlue() ? "glue" : "box" )));
+/*LF*/ //System.out.println(" lastElement e' " + (lastElement.isPenalty()
+ // ? "penalty" : (lastElement.isGlue() ? "glue" : "box" )));
/*LF*/ //System.out.println(" position e' " + lastElement.getPosition().getClass().getName());
/*LF*/ //System.out.println(" " + (bpUnit > 0 ? "unit" : ""));
Position innerPosition = ((NonLeafPosition) lastElement.getPosition()).getPosition();
@@ -363,20 +365,25 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// this block has block-progression-unit > 0: the adjustment can concern
// - the space-before or space-after of this block,
// - the line number of a descendant of this block
+ MappingPosition mappingPos = (MappingPosition)innerPosition;
if (lastElement.isGlue()) {
// lastElement is a glue
/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> bpunit con glue");
- ListIterator storedListIterator = storedList.listIterator(((MappingPosition) innerPosition).getFirstIndex());
+ ListIterator storedListIterator = storedList.listIterator(
+ mappingPos.getFirstIndex());
int newAdjustment = 0;
- while (storedListIterator.nextIndex() <= ((MappingPosition) innerPosition).getLastIndex()) {
- KnuthElement storedElement = (KnuthElement) storedListIterator.next();
+ while (storedListIterator.nextIndex() <= mappingPos.getLastIndex()) {
+ KnuthElement storedElement = (KnuthElement)storedListIterator.next();
if (storedElement.isGlue()) {
- newAdjustment += ((BlockLevelLayoutManager) storedElement.getLayoutManager()).negotiateBPDAdjustment(adj - newAdjustment, storedElement);
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> (progressivo) righe: " + newAdjustment);
+ newAdjustment += ((BlockLevelLayoutManager)storedElement
+ .getLayoutManager()).negotiateBPDAdjustment(
+ adj - newAdjustment, storedElement);
+/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> (progressivo) righe: "
+ // + newAdjustment);
}
}
newAdjustment = (newAdjustment > 0 ? bpUnit * neededUnits(newAdjustment)
- : - bpUnit * neededUnits(- newAdjustment));
+ : -bpUnit * neededUnits(-newAdjustment));
return newAdjustment;
} else {
// lastElement is a penalty: this means that the paragraph
@@ -384,12 +391,13 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// this may involve a change in the number of lines
/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> bpunit con penalty");
KnuthPenalty storedPenalty = (KnuthPenalty)
- storedList.get(((MappingPosition) innerPosition).getLastIndex());
+ storedList.get(mappingPos.getLastIndex());
if (storedPenalty.getW() > 0) {
// the original penalty has width > 0
/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> chiamata passata");
- return ((BlockLevelLayoutManager) storedPenalty.getLayoutManager())
- .negotiateBPDAdjustment(storedPenalty.getW(), (KnuthElement) storedPenalty);
+ return ((BlockLevelLayoutManager)storedPenalty.getLayoutManager())
+ .negotiateBPDAdjustment(storedPenalty.getW(),
+ (KnuthElement)storedPenalty);
} else {
// the original penalty has width = 0
// the adjustment involves only the spaces before and after
@@ -401,7 +409,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// this adjustment concerns another LM
NonLeafPosition savedPos = (NonLeafPosition) lastElement.getPosition();
lastElement.setPosition(innerPosition);
- int returnValue = ((BlockLevelLayoutManager) lastElement.getLayoutManager()).negotiateBPDAdjustment(adj, lastElement);
+ int returnValue = ((BlockLevelLayoutManager)lastElement.getLayoutManager())
+ .negotiateBPDAdjustment(adj, lastElement);
lastElement.setPosition(savedPos);
/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> righe: " + returnValue);
return returnValue;
@@ -437,9 +446,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
}
}
- public LinkedList getChangedKnuthElements(List oldList, /*int flaggedPenalty,*/ int alignment) {
+ public LinkedList getChangedKnuthElements(List oldList, int alignment) {
/*LF*/ //System.out.println("");
-/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> inizio: oldList.size() = " + oldList.size());
+/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> inizio: oldList.size() = "
+ // + oldList.size());
ListIterator oldListIterator = oldList.listIterator();
KnuthElement returnedElement;
KnuthElement currElement = null;
@@ -453,8 +463,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement)oldListIterator.next();
Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition();
-/*LF*/ //System.out.println(" BLM> unwrapping: " + (oldElement.isBox() ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) + " creato da " + oldElement.getLayoutManager().getClass().getName());
-/*LF*/ //System.out.println(" BLM> unwrapping: " + oldElement.getPosition().getClass().getName());
+ //System.out.println(" BLM> unwrapping: "
+ // + (oldElement.isBox() ? "box " : (oldElement.isGlue() ? "glue " : "penalty"))
+ // + " creato da " + oldElement.getLayoutManager().getClass().getName());
+ //System.out.println(" BLM> unwrapping: "
+ // + oldElement.getPosition().getClass().getName());
if (innerPosition != null) {
// oldElement was created by a descendant of this BlockLM
oldElement.setPosition(innerPosition);
@@ -490,17 +503,20 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
}
int iLast = ((MappingPosition) el.getPosition()).getLastIndex();
-/*LF*/ //System.out.println(" si usa storedList da " + iFirst + " a " + iLast + " compresi su " + storedList.size() + " elementi totali");
+ //System.out.println(" si usa storedList da " + iFirst + " a " + iLast
+ // + " compresi su " + storedList.size() + " elementi totali");
workList = storedList.subList(iFirst, iLast + 1);
}
ListIterator workListIterator = workList.listIterator();
-/*LF*/ //System.out.println("");
-/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> workList.size() = " + workList.size() + " da 0 a " + (workList.size() - 1));
+ //System.out.println("");
+ //System.out.println(" BLM.getChangedKnuthElements> workList.size() = "
+ // + workList.size() + " da 0 a " + (workList.size() - 1));
while (workListIterator.hasNext()) {
currElement = (KnuthElement) workListIterator.next();
-/*LF*/ //System.out.println("elemento n. " + workListIterator.previousIndex() + " nella workList");
+ //System.out.println("elemento n. " + workListIterator.previousIndex()
+ // + " nella workList");
if (prevElement != null
&& prevElement.getLayoutManager() != currElement.getLayoutManager()) {
// prevElement is the last element generated by the same LM
@@ -510,14 +526,18 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
currElement.getLayoutManager();
boolean bSomethingAdded = false;
if (prevLM != this) {
-/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> chiamata da " + fromIndex + " a " + workListIterator.previousIndex() + " su " + prevLM.getClass().getName());
- returnedList.addAll(prevLM.getChangedKnuthElements(workList.subList(fromIndex, workListIterator.previousIndex()),
- /*flaggedPenalty,*/ alignment));
+ //System.out.println(" BLM.getChangedKnuthElements> chiamata da "
+ // + fromIndex + " a " + workListIterator.previousIndex() + " su "
+ // + prevLM.getClass().getName());
+ returnedList.addAll(prevLM.getChangedKnuthElements(workList.subList(
+ fromIndex, workListIterator.previousIndex()), alignment));
bSomethingAdded = true;
} else {
// prevLM == this
// do nothing
-/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> elementi propri, ignorati, da " + fromIndex + " a " + workListIterator.previousIndex() + " su " + prevLM.getClass().getName());
+ //System.out.println(" BLM.getChangedKnuthElements> elementi propri, "
+ // + "ignorati, da " + fromIndex + " a " + workListIterator.previousIndex()
+ // + " su " + prevLM.getClass().getName());
}
fromIndex = workListIterator.previousIndex();
@@ -527,7 +547,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
|| prevLM.mustKeepWithNext()
|| currLM.mustKeepWithPrevious())) {
// add an infinite penalty to forbid a break between blocks
- returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new Position(this), false));
+ returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
+ new Position(this), false));
} else if (bSomethingAdded && !((KnuthElement) returnedList.getLast()).isGlue()) {
// add a null penalty to allow a break between blocks
returnedList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
@@ -539,9 +560,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
BlockLevelLayoutManager currLM = (BlockLevelLayoutManager)
currElement.getLayoutManager();
if (currLM != this) {
-/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> chiamata da " + fromIndex + " a " + oldList.size() + " su " + currLM.getClass().getName());
- returnedList.addAll(currLM.getChangedKnuthElements(workList.subList(fromIndex, workList.size()),
- /*flaggedPenalty,*/ alignment));
+ //System.out.println(" BLM.getChangedKnuthElements> chiamata da " + fromIndex
+ // + " a " + oldList.size() + " su " + currLM.getClass().getName());
+ returnedList.addAll(currLM.getChangedKnuthElements(
+ workList.subList(fromIndex, workList.size()), alignment));
} else {
// currLM == this
// there are no more elements to add
@@ -549,15 +571,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
if (returnedList.size() > 0) {
returnedList.removeLast();
}
-/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> elementi propri, ignorati, da " + fromIndex + " a " + workList.size());
+ //System.out.println(" BLM.getChangedKnuthElements> elementi propri, ignorati, da "
+ // + fromIndex + " a " + workList.size());
}
}
// append elements representing space-before
boolean spaceBeforeIsConditional = true;
if (fobj instanceof org.apache.fop.fo.flow.Block) {
- spaceBeforeIsConditional =
- ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceBefore.getSpace().isDiscard();
+ spaceBeforeIsConditional = ((org.apache.fop.fo.flow.Block)fobj)
+ .getCommonMarginBlock().spaceBefore.getSpace().isDiscard();
}
if (bpUnit > 0
|| adjustedSpaceBefore != 0) {
@@ -570,14 +593,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
}
if (bpUnit > 0) {
returnList.add(new KnuthGlue(0, 0, 0,
- SPACE_BEFORE_ADJUSTMENT, new NonLeafPosition(this, null), true));
+ SPACE_BEFORE_ADJUSTMENT, new NonLeafPosition(this, null), true));
} else {
returnList.add(new KnuthGlue(adjustedSpaceBefore, 0, 0,
- SPACE_BEFORE_ADJUSTMENT, new NonLeafPosition(this, null), true));
+ SPACE_BEFORE_ADJUSTMENT, new NonLeafPosition(this, null), true));
}
}
-/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> intermedio: returnedList.size() = " + returnedList.size());
+ //System.out.println(" BLM.getChangedKnuthElements> intermedio: returnedList.size() = "
+ // + returnedList.size());
/* estensione: conversione complessiva */
/*LF*/ if (bpUnit > 0) {
@@ -598,31 +622,34 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// append elements representing space-after
boolean spaceAfterIsConditional = true;
if (fobj instanceof org.apache.fop.fo.flow.Block) {
- spaceAfterIsConditional =
- ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceAfter.getSpace().isDiscard();
+ spaceAfterIsConditional = ((org.apache.fop.fo.flow.Block)fobj)
+ .getCommonMarginBlock().spaceAfter.getSpace().isDiscard();
}
- if (bpUnit > 0
- || adjustedSpaceAfter != 0) {
+ if (bpUnit > 0 || adjustedSpaceAfter != 0) {
if (!spaceAfterIsConditional) {
- returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
- new NonLeafPosition(this, null), false));
+ returnList.add(new KnuthPenalty(0,
+ KnuthElement.INFINITE, false,
+ new NonLeafPosition(this, null), false));
}
if (bpUnit > 0) {
returnList.add(new KnuthGlue(0, 0, 0,
- SPACE_AFTER_ADJUSTMENT, new NonLeafPosition(this, null),
- (!spaceAfterIsConditional) ? false : true));
+ SPACE_AFTER_ADJUSTMENT,
+ new NonLeafPosition(this, null),
+ (!spaceAfterIsConditional) ? false : true));
} else {
returnList.add(new KnuthGlue(adjustedSpaceAfter, 0, 0,
- SPACE_AFTER_ADJUSTMENT, new NonLeafPosition(this, null),
- (!spaceAfterIsConditional) ? false : true));
+ SPACE_AFTER_ADJUSTMENT,
+ new NonLeafPosition(this, null),
+ (!spaceAfterIsConditional) ? false : true));
}
if (!spaceAfterIsConditional) {
returnList.add(new KnuthBox(0,
- new NonLeafPosition(this, null), true));
+ new NonLeafPosition(this, null), true));
}
}
-/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> fine: returnList.size() = " + returnList.size());
+ //System.out.println(" BLM.getChangedKnuthElements> finished: returnList.size() = "
+ // + returnList.size());
return returnList;
}
@@ -657,11 +684,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
//Border and Padding (before)
CommonBorderPaddingBackground borderAndPadding = null;
if (fobj instanceof org.apache.fop.fo.flow.Block) {
- borderAndPadding =
- ((org.apache.fop.fo.flow.Block) fobj).getCommonBorderPaddingBackground();
+ borderAndPadding = ((org.apache.fop.fo.flow.Block)fobj)
+ .getCommonBorderPaddingBackground();
} else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
- borderAndPadding =
- ((org.apache.fop.fo.flow.BlockContainer) fobj).getCommonBorderPaddingBackground();
+ borderAndPadding = ((org.apache.fop.fo.flow.BlockContainer)fobj)
+ .getCommonBorderPaddingBackground();
}
if (borderAndPadding != null) {
//TODO Handle conditionality
@@ -683,11 +710,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
//Border and Padding (after)
CommonBorderPaddingBackground borderAndPadding = null;
if (fobj instanceof org.apache.fop.fo.flow.Block) {
- borderAndPadding =
- ((org.apache.fop.fo.flow.Block) fobj).getCommonBorderPaddingBackground();
+ borderAndPadding = ((org.apache.fop.fo.flow.Block)fobj)
+ .getCommonBorderPaddingBackground();
} else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
- borderAndPadding =
- ((org.apache.fop.fo.flow.BlockContainer) fobj).getCommonBorderPaddingBackground();
+ borderAndPadding = ((org.apache.fop.fo.flow.BlockContainer)fobj)
+ .getCommonBorderPaddingBackground();
}
if (borderAndPadding != null) {
//TODO Handle conditionality
@@ -763,9 +790,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
Position returnPosition, int alignment) {
SpaceProperty spaceBefore = null;
if (fobj instanceof org.apache.fop.fo.flow.Block) {
- spaceBefore = ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceBefore;
+ spaceBefore = ((org.apache.fop.fo.flow.Block)fobj)
+ .getCommonMarginBlock().spaceBefore;
} else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
- spaceBefore = ((org.apache.fop.fo.flow.BlockContainer) fobj).getCommonMarginBlock().spaceBefore;
+ spaceBefore = ((org.apache.fop.fo.flow.BlockContainer)fobj)
+ .getCommonMarginBlock().spaceBefore;
}
// append elements representing space-before
if (bpUnit > 0
@@ -810,9 +839,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
int alignment) {
SpaceProperty spaceAfter = null;
if (fobj instanceof org.apache.fop.fo.flow.Block) {
- spaceAfter = ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceAfter;
+ spaceAfter = ((org.apache.fop.fo.flow.Block)fobj)
+ .getCommonMarginBlock().spaceAfter;
} else if (fobj instanceof org.apache.fop.fo.flow.Block) {
- spaceAfter = ((org.apache.fop.fo.flow.BlockContainer) fobj).getCommonMarginBlock().spaceAfter;
+ spaceAfter = ((org.apache.fop.fo.flow.BlockContainer)fobj)
+ .getCommonMarginBlock().spaceAfter;
}
// append elements representing space-after
if (bpUnit > 0
@@ -850,8 +881,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
protected LinkedList createUnitElements(LinkedList oldList) {
//System.out.println(" ");
- //System.out.println("Inizio conversione: " + oldList.size() + " elementi, spazio minimo prima= " + layoutProps.spaceBefore.getSpace().min
- // + " spazio minimo dopo= " + layoutProps.spaceAfter.getSpace().min);
+ //System.out.println("Start conversion: " + oldList.size()
+ // + " elements, space-before.min=" + layoutProps.spaceBefore.getSpace().min
+ // + " space-after.min=" + layoutProps.spaceAfter.getSpace().min);
// add elements at the beginning and at the end of oldList
// representing minimum spaces
LayoutManager lm = ((KnuthElement)oldList.getFirst()).getLayoutManager();
@@ -879,15 +911,17 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
while (oldListIterator.hasNext()) {
KnuthElement element = (KnuthElement) oldListIterator.next();
if (element.isBox()) {
-/*LF*/ totalLength.add(new MinOptMax(element.getW()));
-/*LF*/ //System.out.println("box " + element.getW());
-/*LF*/ } else if (element.isGlue()) {
-/*LF*/ totalLength.min -= ((KnuthGlue) element).getZ();
-/*LF*/ totalLength.max += ((KnuthGlue) element).getY();
-/*LF*/ //leafValue = ((LeafPosition) element.getPosition()).getLeafPos();
-/*LF*/ //System.out.println("glue " + element.getW() + " + " + ((KnuthGlue) element).getY() + " - " + ((KnuthGlue) element).getZ());
-/*LF*/ } else {
-/*LF*/ //System.out.println((((KnuthPenalty)element).getP() == KnuthElement.INFINITE ? "PENALTY " : "penalty ") + element.getW());
+ totalLength.add(new MinOptMax(element.getW()));
+ //System.out.println("box " + element.getW());
+ } else if (element.isGlue()) {
+ totalLength.min -= ((KnuthGlue) element).getZ();
+ totalLength.max += ((KnuthGlue) element).getY();
+ //leafValue = ((LeafPosition) element.getPosition()).getLeafPos();
+ //System.out.println("glue " + element.getW() + " + "
+ // + ((KnuthGlue) element).getY() + " - " + ((KnuthGlue) element).getZ());
+ } else {
+ //System.out.println((((KnuthPenalty)element).getP() == KnuthElement.INFINITE
+ // ? "PENALTY " : "penalty ") + element.getW());
}
}
// compute the total amount of "units"
@@ -913,7 +947,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
int lastIndex = -1;
while (oldListIterator.hasNext()) {
KnuthElement element = (KnuthElement) oldListIterator.next();
- lastIndex ++;
+ lastIndex++;
if (element.isBox()) {
lengthBeforeBreak.add(new MinOptMax(element.getW()));
lengthAfterBreak.subtract(new MinOptMax(element.getW()));
@@ -931,8 +965,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// create the new elements
if (element.isPenalty() && ((KnuthPenalty) element).getP() < KnuthElement.INFINITE
- || element.isGlue() && bPrevIsBox
- || !oldListIterator.hasNext()) {
+ || element.isGlue() && bPrevIsBox
+ || !oldListIterator.hasNext()) {
// suppress elements after the breaking point
int iStepsForward = 0;
while (oldListIterator.hasNext()) {
@@ -969,9 +1003,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// compute changes in length, stretch and shrink
int uLengthChange = unitsBeforeBreak.opt + unitsAfterBreak.opt - totalUnits.opt;
int uStretchChange = (unitsBeforeBreak.max + unitsAfterBreak.max - totalUnits.max)
- - (unitsBeforeBreak.opt + unitsAfterBreak.opt - totalUnits.opt);
+ - (unitsBeforeBreak.opt + unitsAfterBreak.opt - totalUnits.opt);
int uShrinkChange = (unitsBeforeBreak.opt + unitsAfterBreak.opt - totalUnits.opt)
- - (unitsBeforeBreak.min + unitsAfterBreak.min - totalUnits.min);
+ - (unitsBeforeBreak.min + unitsAfterBreak.min - totalUnits.min);
// compute the number of normal, stretch and shrink unit
// that must be added to the new sequence
@@ -981,13 +1015,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
int uNewShrink = (unitsBeforeBreak.opt - unitsBeforeBreak.min)
- (unsuppressibleUnits.opt - unsuppressibleUnits.min);
-/*LF*/ //System.out.println("(" + unsuppressibleUnits.min + "-" + unsuppressibleUnits.opt + "-" + unsuppressibleUnits.max + ") "
-/*LF*/ // + " -> " + unitsBeforeBreak.min + "-" + unitsBeforeBreak.opt + "-" + unitsBeforeBreak.max
-/*LF*/ // + " + " + unitsAfterBreak.min + "-" + unitsAfterBreak.opt + "-" + unitsAfterBreak.max
-/*LF*/ // + (uLengthChange != 0 ? " [length " + uLengthChange + "] " : "")
-/*LF*/ // + (uStretchChange != 0 ? " [stretch " + uStretchChange + "] " : "")
-/*LF*/ // + (uShrinkChange != 0 ? " [shrink " + uShrinkChange + "]" : "")
-/*LF*/ // );
+ //System.out.println("("
+ // + unsuppressibleUnits.min + "-" + unsuppressibleUnits.opt + "-"
+ // + unsuppressibleUnits.max + ") "
+ // + " -> " + unitsBeforeBreak.min + "-" + unitsBeforeBreak.opt + "-"
+ // + unitsBeforeBreak.max
+ // + " + " + unitsAfterBreak.min + "-" + unitsAfterBreak.opt + "-"
+ // + unitsAfterBreak.max
+ // + (uLengthChange != 0 ? " [length " + uLengthChange + "] " : "")
+ // + (uStretchChange != 0 ? " [stretch " + uStretchChange + "] " : "")
+ // + (uShrinkChange != 0 ? " [shrink " + uShrinkChange + "]" : ""));
// create the MappingPosition which will be stored in the new elements
// correct firstIndex and lastIndex
@@ -995,12 +1032,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
int lastIndexCorrection = 0;
if (bAddedBoxBefore) {
if (firstIndex != 0) {
- firstIndexCorrection ++;
+ firstIndexCorrection++;
}
- lastIndexCorrection ++;
+ lastIndexCorrection++;
}
if (bAddedBoxAfter && lastIndex == (oldList.size() - 1)) {
- lastIndexCorrection ++;
+ lastIndexCorrection++;
}
MappingPosition mappingPos = new MappingPosition(this,
firstIndex - firstIndexCorrection,
@@ -1016,8 +1053,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// new infinite penalty, glue and box, if necessary
if (uNewStretch - uStretchChange > 0
|| uNewShrink - uShrinkChange > 0) {
- int iStretchUnits = (uNewStretch - uStretchChange > 0 ? (uNewStretch - uStretchChange) : 0);
- int iShrinkUnits = (uNewShrink - uShrinkChange > 0 ? (uNewShrink - uShrinkChange) : 0);
+ int iStretchUnits = (uNewStretch - uStretchChange > 0
+ ? (uNewStretch - uStretchChange) : 0);
+ int iShrinkUnits = (uNewShrink - uShrinkChange > 0
+ ? (uNewShrink - uShrinkChange) : 0);
newList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
mappingPos,
false));
@@ -1055,16 +1094,17 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
newList.add(new KnuthPenalty(uLengthChange * bpUnit,
0, false, element.getPosition(), false));
newList.add(new KnuthGlue(0,
- - uStretchChange * bpUnit,
- - uShrinkChange * bpUnit,
+ -uStretchChange * bpUnit,
+ -uShrinkChange * bpUnit,
LINE_NUMBER_ADJUSTMENT,
mappingPos,
false));
//System.out.println(" PENALTY");
//System.out.println(" glue 0 " + uStretchChange + " " + uShrinkChange);
//System.out.println(" penalty " + uLengthChange + " * unit");
- //System.out.println(" glue 0 " + (- uStretchChange) + " " + (- uShrinkChange));
- } else if (oldListIterator.hasNext()){
+ //System.out.println(" glue 0 " + (- uStretchChange) + " "
+ // + (- uShrinkChange));
+ } else if (oldListIterator.hasNext()) {
// new penalty
newList.add(new KnuthPenalty(uLengthChange * bpUnit,
0, false,
@@ -1094,8 +1134,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// if space-before.conditionality is "discard", correct newList
boolean correctFirstElement = false;
if (fobj instanceof org.apache.fop.fo.flow.Block) {
- correctFirstElement =
- ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceBefore.getSpace().isDiscard();
+ correctFirstElement = ((org.apache.fop.fo.flow.Block)fobj)
+ .getCommonMarginBlock().spaceBefore.getSpace().isDiscard();
}
if (correctFirstElement) {
// remove the wrong element
@@ -1112,14 +1152,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
wrongBox.getPosition(), false));
//System.out.println(" rimosso box " + neededUnits(wrongBox.getW()));
//System.out.println(" aggiunto glue " + neededUnits(decreasedLength) + " 0 0");
- //System.out.println(" aggiunto box " + neededUnits(wrongBox.getW() - decreasedLength));
+ //System.out.println(" aggiunto box " + neededUnits(
+ // wrongBox.getW() - decreasedLength));
}
// if space-after.conditionality is "discard", correct newList
boolean correctLastElement = false;
if (fobj instanceof org.apache.fop.fo.flow.Block) {
- correctLastElement =
- ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceAfter.getSpace().isDiscard();
+ correctLastElement = ((org.apache.fop.fo.flow.Block)fobj)
+ .getCommonMarginBlock().spaceAfter.getSpace().isDiscard();
}
if (correctLastElement) {
// remove the wrong element
@@ -1151,7 +1192,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
newList.addLast(new KnuthGlue(decreasedLength, 0, 0, SPACE_AFTER_ADJUSTMENT,
wrongBox.getPosition(), false));
//System.out.println(" rimosso box " + neededUnits(wrongBox.getW()));
- //System.out.println(" aggiunto box " + neededUnits(wrongBox.getW() - decreasedLength));
+ //System.out.println(" aggiunto box " + neededUnits(
+ // wrongBox.getW() - decreasedLength));
//System.out.println(" aggiunto glue " + neededUnits(decreasedLength) + " 0 0");
}
diff --git a/src/java/org/apache/fop/layoutmgr/BreakCost.java b/src/java/org/apache/fop/layoutmgr/BreakCost.java
deleted file mode 100644
index 1241f654b..000000000
--- a/src/java/org/apache/fop/layoutmgr/BreakCost.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.layoutmgr;
-
-import org.apache.fop.area.Area;
-
-
-/**
- * Evaluate and store the cost of breaking an Area at a given point.
- */
-public class BreakCost {
- private Area breakArea;
- private BreakPoss bp;
-
- private int cost; // Will be more complicated than this!
-
- public BreakCost(Area breakArea, int cost) {
- this.breakArea = breakArea;
- this.cost = cost;
- }
-
- public BreakCost(BreakPoss bp, int cost) {
- this.bp = bp;
- this.cost = cost;
- }
-
- BreakPoss getBP() {
- return this.bp;
- }
-
- Area getArea() {
- return this.breakArea;
- }
-
- int getCost() {
- return this.cost;
- }
-
- public BreakCost chooseLowest(BreakCost otherCost) {
- return this;
- }
-}
diff --git a/src/java/org/apache/fop/layoutmgr/BreakPoss.java b/src/java/org/apache/fop/layoutmgr/BreakPoss.java
deleted file mode 100644
index 6dca0522b..000000000
--- a/src/java/org/apache/fop/layoutmgr/BreakPoss.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.layoutmgr;
-
-import org.apache.fop.traits.LayoutProps;
-import org.apache.fop.traits.MinOptMax;
-
-/**
- * Represents a break possibility for the layout manager.
- * Used to pass information between different levels of layout manager concerning
- * the break positions. In an inline context, before and after are interpreted as
- * start and end.
- * The position field is opaque represents where the break occurs. It is a
- * nested structure with one level for each layout manager involved in generating
- * the BreakPoss..
- * @author Karen Lease
- */
-public class BreakPoss {
-
- // --- Values for flags returned from lower level LM. ---
- /** May break after */
- public static final int CAN_BREAK_AFTER = 0x01;
- /** Last area generated by FO */
- public static final int ISLAST = 0x02;
- /** First area generated by FO */
- public static final int ISFIRST = 0x04;
- /** Forced break (ie LF) */
- public static final int FORCE = 0x08;
- /** May break before */
- public static final int CAN_BREAK_BEFORE = 0x10;
- /** has anchors */
- public static final int HAS_ANCHORS = 0x40;
- /**
- * Set this flag if all fo:character generated Areas would
- * suppressed at the end or beginning of a line */
- public static final int ALL_ARE_SUPPRESS_AT_LB = 0x80;
- /** This break possibility is a hyphenation */
- public static final int HYPHENATED = 0x100;
- /**
- * If this break possibility ends the line, all remaining characters
- * in the lowest level text LM will be suppressed.
- */
- public static final int REST_ARE_SUPPRESS_AT_LB = 0x200;
- /** Next area for LM overflows */
- public static final int NEXT_OVERFLOWS = 0x400;
-
- /** The opaque position object used by m_lm to record its
- * break position.
- */
- private Position position;
-
- /**
- * The size range in the stacking direction of the area which would be
- * generated if this BreakPoss were used.
- */
- private MinOptMax stackSize;
-
- /**
- * Max height above and below the baseline. These are cumulative.
- */
- private int lead;
- // the max height of before and after alignment
- private int total;
- // middle alignment height for after
- private int middle;
-
- /** Size in the non-stacking direction (perpendicular). */
- private MinOptMax nonStackSize;
-
- private long flags = 0;
- private LayoutProps layoutProps = new LayoutProps();
-
- /** Store space-after (or end) and space-before (or start) to be
- * added if this break position is used.
- */
- private SpaceSpecifier spaceSpecTrailing;
- private SpaceSpecifier spaceSpecLeading;
-
- public BreakPoss(Position position) {
- this(position, 0);
- }
-
- public BreakPoss(Position position, long flags) {
- this.position = position;
- this.flags = flags;
- }
-
- /**
- * The top-level layout manager responsible for this break
- */
- public LayoutManager getLayoutManager() {
- return position.getLM();
- }
-
- // public void setLayoutManager(LayoutManager lm) {
- // m_lm = lm;
- // }
-
- /**
- * An object representing the break position in this layout manager.
- */
- public Position getPosition() {
- return position;
- }
-
- public void setPosition(Position pos) {
- position = pos;
- }
-
- public void setStackingSize(MinOptMax size) {
- this.stackSize = size;
- }
-
- public MinOptMax getStackingSize() {
- return this.stackSize ;
- }
-
- public void setNonStackingSize(MinOptMax size) {
- this.nonStackSize = size;
- }
-
- public MinOptMax getNonStackingSize() {
- return this.nonStackSize ;
- }
-
- public long getFlags() {
- return flags;
- }
-
- public void setFlag(int flagBit) {
- setFlag(flagBit, true);
- }
-
- public void setFlag(int flagBit, boolean bSet) {
- if (bSet) {
- flags |= flagBit;
- } else {
- flags &= ~flagBit;
- }
- }
-
- public boolean isLastArea() {
- return ((flags & ISLAST) != 0);
- }
-
- public boolean isFirstArea() {
- return ((flags & ISFIRST) != 0);
- }
-
- public boolean canBreakAfter() {
- return ((flags & CAN_BREAK_AFTER) != 0);
- }
-
- public boolean canBreakBefore() {
- return ((flags & CAN_BREAK_BEFORE) != 0);
- }
-
- public boolean couldEndLine() {
- return ((flags & REST_ARE_SUPPRESS_AT_LB) != 0);
- }
-
- public boolean isForcedBreak() {
- return ((flags & FORCE) != 0);
- }
-
- public boolean nextBreakOverflows() {
- return ((flags & NEXT_OVERFLOWS) != 0);
- }
-
- public boolean isSuppressible() {
- return ((flags & ALL_ARE_SUPPRESS_AT_LB) != 0);
- }
-
- /**
- * @return true if the BreakPoss results in an area being created.
- */
- public boolean generatesAreas() {
- return !(nextBreakOverflows() && getStackingSize().opt <= 0);
- }
-
- public SpaceSpecifier getLeadingSpace() {
- return spaceSpecLeading;
- }
-
- public MinOptMax resolveLeadingSpace() {
- if (spaceSpecLeading != null) {
- return spaceSpecLeading.resolve(false);
- } else {
- return new MinOptMax(0);
- }
- }
-
- public SpaceSpecifier getTrailingSpace() {
- return spaceSpecTrailing;
- }
-
- public MinOptMax resolveTrailingSpace(boolean bEndsRefArea) {
- if (spaceSpecTrailing != null) {
- return spaceSpecTrailing.resolve(bEndsRefArea);
- } else {
- return new MinOptMax(0);
- }
- }
-
-
- public void setLeadingSpace(SpaceSpecifier spaceSpecLeading) {
- this.spaceSpecLeading = spaceSpecLeading;
- }
-
- public void setTrailingSpace(SpaceSpecifier spaceSpecTrailing) {
- this.spaceSpecTrailing = spaceSpecTrailing;
- }
-
- public LayoutProps getLayoutProps() {
- return layoutProps;
- }
-
- public int getLead() {
- return lead;
- }
-
- public int getTotal() {
- return total;
- }
-
- public int getMiddle() {
- return middle;
- }
-
- /**
- * set lead height of baseline positioned element
- * @param ld new lead value
- */
- public void setLead(int ld) {
- lead = ld;
- }
-
- /**
- * Set total height of top or bottom aligned element
- * @param t new total height
- */
- public void setTotal(int t) {
- total = t;
- }
-
- /**
- * Set distance below baseline of middle aligned element
- * @param t new value
- */
- public void setMiddle(int t) {
- middle = t;
- }
-
- /** @see java.lang.Object#toString() */
- public String toString() {
- StringBuffer sb = new StringBuffer("BreakPoss");
- if (isFirstArea()) {
- sb.append(", first area");
- }
- if (isLastArea()) {
- sb.append(", last area");
- }
- if (isForcedBreak()) {
- sb.append(", forced break");
- }
- if (nextBreakOverflows()) {
- sb.append(", next break overflows");
- }
- sb.append(", stackSize={");
- sb.append(stackSize);
- sb.append("}, pos=");
- sb.append(position);
- return sb.toString();
- }
-}
diff --git a/src/java/org/apache/fop/layoutmgr/BreakPossPosIter.java b/src/java/org/apache/fop/layoutmgr/BreakPossPosIter.java
deleted file mode 100644
index 5f37ee92c..000000000
--- a/src/java/org/apache/fop/layoutmgr/BreakPossPosIter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.layoutmgr;
-
-import java.util.List;
-
-/**
- * Position iterator for break possibilities.
- */
-public class BreakPossPosIter extends PositionIterator {
-
- private int iterCount;
-
- /**
- * Main constructor
- * @param bpList List of break possibilities
- * @param startPos starting position
- * @param endPos ending position
- */
- public BreakPossPosIter(List bpList, int startPos, int endPos) {
- super((bpList.size() > 0 ? bpList.listIterator(startPos) : bpList.listIterator()));
- iterCount = endPos - startPos;
- }
-
- // Check position < endPos
-
- /**
- * @see org.apache.fop.layoutmgr.PositionIterator#checkNext()
- */
- protected boolean checkNext() {
- if (iterCount > 0) {
- return super.checkNext();
- } else {
- endIter();
- return false;
- }
- }
-
- /**
- * @see java.util.Iterator#next()
- */
- public Object next() {
- --iterCount;
- return super.next();
- }
-
- public BreakPoss getBP() {
- return (BreakPoss) peekNext();
- }
-
- protected LayoutManager getLM(Object nextObj) {
- return ((BreakPoss) nextObj).getLayoutManager();
- }
-
- protected Position getPos(Object nextObj) {
- return ((BreakPoss) nextObj).getPosition();
- }
-
-}
diff --git a/src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
index fbff4ff0f..b62f6e1a0 100644
--- a/src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
@@ -25,9 +25,7 @@ import java.util.ListIterator;
import java.util.HashMap;
import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.SpaceProperty;
-import org.apache.fop.traits.InlineProps;
import org.apache.fop.traits.SpaceVal;
import org.apache.fop.area.Area;
import org.apache.fop.area.inline.InlineArea;
@@ -72,13 +70,13 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager
private Area currentArea; // LineArea or InlineParent
- private BreakPoss prevBP;
+ //private BreakPoss prevBP;
protected LayoutContext childLC;
private LayoutManager lastChildLM = null; // Set when return last breakposs
private boolean bAreaCreated = false;
- private LayoutManager currentLM = null;
+ //private LayoutManager currentLM = null;
/** Used to store previous content IPD for each child LM. */
private HashMap hmPrevIPD = new HashMap();
@@ -151,14 +149,16 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager
// Back up the child LM Position
Position childPos = prevPos.getPosition();
reset(childPos);
+ /*
if (prevBP != null
&& prevBP.getLayoutManager() != childPos.getLM()) {
childLC = null;
}
prevBP = new BreakPoss(childPos);
+ */
} else {
// Backup to start of first child layout manager
- prevBP = null;
+ //prevBP = null;
// super.resetPosition(prevPos);
reset(prevPos);
// If any areas created, we are restarting!
@@ -195,218 +195,6 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager
hmPrevIPD.clear();
}
- /**
- * Get the next break position for this layout manager.
- * The next break position will be an position within the
- * areas return by the child inline layout managers.
- *
- * @param lc the layout context for finding breaks
- * @return the next break position
- */
- public BreakPoss getNextBreakPoss(LayoutContext lc) {
- // Get a break from currently active child LM
- BreakPoss bp = null;
- LayoutManager curLM;
- SpaceSpecifier leadingSpace = lc.getLeadingSpace();
-
- if (lc.startsNewArea()) {
- // First call to this LM in new parent "area", but this may
- // not be the first area created by this inline
- childLC = new LayoutContext(lc);
- if (getSpaceStart() != null) {
- lc.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart()));
- }
-
- // Check for "fence"
- if (hasLeadingFence(!lc.isFirstArea())) {
- // Reset leading space sequence for child areas
- leadingSpace = new SpaceSpecifier(false);
- }
- // Reset state variables
- clearPrevIPD(); // Clear stored prev content dimensions
- }
-
- // We only do this loop more than once if a childLM returns
- // a null BreakPoss, meaning it has nothing (more) to layout.
- while ((curLM = getChildLM()) != null) {
-
- // ignore nested blocks for now
- if (!curLM.generatesInlineAreas()) {
- log.warn("ignoring block inside inline fo");
- curLM.setFinished(true);
- continue;
- }
- /* If first break for this child LM, set START_AREA flag
- * and initialize pending space from previous LM sibling's
- * trailing space specifiers.
- */
- boolean bFirstChildBP = (prevBP == null
- || prevBP.getLayoutManager() != curLM);
-
- initChildLC(childLC, prevBP, lc.startsNewArea(),
- bFirstChildBP, leadingSpace);
- if (lc.tryHyphenate()) {
- childLC.setHyphContext(lc.getHyphContext());
- }
-
- if (((bp = curLM.getNextBreakPoss(childLC)) != null)
- || (lc.tryHyphenate()
- && !lc.getHyphContext().hasMoreHyphPoints())) {
- break;
- }
- // If LM has no content, should it generate any area? If not,
- // should trailing space from a previous area interact with
- // leading space from a following area?
- }
- if (bp == null) {
- setFinished(true);
- return null; // There was no childLM with anything to layout
- // Alternative is to return a BP with the isLast flag set
- } else {
- boolean bIsLast = false;
- if (getChildLM() == null) {
- bIsLast = true;
- setFinished(true);
- } else if (bp.couldEndLine()) {
- /* Child LM ends with suppressible spaces. See if it could
- * end this LM's area too. Child LM finish flag is NOT set!
- */
- bIsLast = !hasMoreLM(bp.getLayoutManager());
- }
- return makeBreakPoss(bp, lc, bIsLast);
- }
- }
-
- /** ATTENTION: ALSO USED BY LineLayoutManager! */
- protected void initChildLC(LayoutContext childLC, BreakPoss prevBP,
- boolean bStartParent, boolean bFirstChildBP,
- SpaceSpecifier leadingSpace) {
-
- childLC.setFlags(LayoutContext.NEW_AREA,
- (bFirstChildBP || bStartParent));
- if (bStartParent) {
- // Start of a new line area or inline parent area
- childLC.setFlags(LayoutContext.FIRST_AREA, bFirstChildBP);
- childLC.setLeadingSpace(leadingSpace);
- } else if (bFirstChildBP) {
- // Space-after sequence from previous "area"
- childLC.setFlags(LayoutContext.FIRST_AREA, true);
- childLC.setLeadingSpace(prevBP.getTrailingSpace());
- } else {
- childLC.setLeadingSpace(null);
- }
- }
-
-
- private BreakPoss makeBreakPoss(BreakPoss bp, LayoutContext lc,
- boolean bIsLast) {
- NonLeafPosition inlbp = new NonLeafPosition(this, bp.getPosition());
- BreakPoss myBP = new BreakPoss(inlbp, bp.getFlags());
-
- myBP.setFlag(BreakPoss.ISFIRST, lc.isFirstArea());
- myBP.setFlag(BreakPoss.ISLAST, bIsLast);
-
- if (bIsLast) {
- lastChildLM = bp.getLayoutManager();
- }
-
- // Update dimension information for our allocation area,
- // including child areas
- // generated by previous childLM which have completed layout
- // Update pending area measure
- // This includes all previous breakinfo
-
- MinOptMax bpDim = (MinOptMax) bp.getStackingSize().clone();
- MinOptMax prevIPD = updatePrevIPD(bp, prevBP, lc.startsNewArea(),
- lc.isFirstArea());
-
- if (lc.startsNewArea()) {
- myBP.setLeadingSpace(lc.getLeadingSpace());
- }
-
-
- // Add size of previous child areas which are finished
- bpDim.add(prevIPD);
-
- SpaceSpecifier trailingSpace = bp.getTrailingSpace();
- if (hasTrailingFence(!bIsLast)) {
- bpDim.add(bp.resolveTrailingSpace(false));
- trailingSpace = new SpaceSpecifier(false);
- } else {
- // Need this to avoid modifying pending space specifiers
- // on previous BP from child as we use these on the next
- // call in this LM
- trailingSpace = (SpaceSpecifier) trailingSpace.clone();
- }
- if (getSpaceEnd() != null) {
- trailingSpace.addSpace(new SpaceVal(getSpaceEnd()));
- }
- myBP.setTrailingSpace(trailingSpace);
-
- // Add start and end borders and padding
- bpDim.add(getExtraIPD(!lc.isFirstArea(), !bIsLast));
- myBP.setStackingSize(bpDim);
- myBP.setNonStackingSize(
- MinOptMax.add(bp.getNonStackingSize(), extraBPD));
-
- prevBP = bp;
- // if (bIsLast) {
- // setFinished(true); // Our last area, so indicate done
- // }
- return myBP;
- }
-
-
- /** ATTENTION: ALSO USED BY LineLayoutManager! */
- protected MinOptMax updatePrevIPD(BreakPoss bp, BreakPoss prevBP,
- boolean bStartParent, boolean bFirstArea) {
- MinOptMax prevIPD = new MinOptMax(0);
-
- if (bStartParent) {
- if (hasLeadingFence(!bFirstArea)) {
- // Space-start before first child area placed
- prevIPD.add(bp.resolveLeadingSpace());
- }
- hmPrevIPD.put(bp.getLayoutManager(), prevIPD);
- } else {
- // In case of reset to a previous position, it may already
- // be calculated
- prevIPD = (MinOptMax) hmPrevIPD.get(bp.getLayoutManager());
- if (prevIPD == null) {
- // ASSERT(prevBP.getLayoutManager() != bp.getLayoutManager());
- /* This is first bp generated by child (in this parent area).
- * Calculate space-start on this area in combination with any
- * pending space-end with previous break.
- * Corresponds to Space between two child areas.
- */
- prevIPD = (MinOptMax) hmPrevIPD.get(
- prevBP.getLayoutManager());
- prevIPD = MinOptMax.add(prevIPD, bp.resolveLeadingSpace());
- prevIPD.add(prevBP.getStackingSize());
- hmPrevIPD.put(bp.getLayoutManager(), prevIPD);
- }
- }
- return prevIPD;
- }
-
- public void getWordChars(StringBuffer sbChars, Position bp1,
- Position bp2) {
- Position endPos = ((NonLeafPosition) bp2).getPosition();
- Position prevPos = null;
- if (bp1 != null) {
- prevPos = ((NonLeafPosition) bp1).getPosition();
- if (prevPos.getLM() != endPos.getLM()) {
- prevPos = null;
- }
- }
- endPos.getLM().getWordChars(sbChars, prevPos, endPos);
- }
-
- /******
- protected BreakableText getText(BreakPoss prevBP, BreakPoss lastBP) {
- }
- *****/
-
protected InlineParent createArea() {
return new InlineParent();
}
@@ -466,7 +254,7 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager
= new StackingIter(positionList.listIterator());
LayoutManager prevLM = null;
- InlineLevelLayoutManager childLM ;
+ InlineLevelLayoutManager childLM;
while ((childLM = (InlineLevelLayoutManager) childPosIter.getNextChildLM())
!= null) {
getContext().setFlags(LayoutContext.LAST_AREA,
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManager.java b/src/java/org/apache/fop/layoutmgr/LayoutManager.java
index 84a53cf64..bd8ec91eb 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManager.java
@@ -83,17 +83,6 @@ public interface LayoutManager {
boolean canBreakBefore(LayoutContext lc);
/**
- * Generate and return the next break possibility.
- *
- * @param context The layout context contains information about pending
- * space specifiers from ancestor areas or previous areas, reference
- * area inline-progression-dimension and various other layout-related
- * information.
- * @return the next break position
- */
- BreakPoss getNextBreakPoss(LayoutContext context);
-
- /**
* Reset to the position.
*
* @param position
diff --git a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
index 83da8ba22..79d9b1957 100644
--- a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
@@ -112,7 +112,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
/** Break positions returned by inline content. */
private List vecInlineBreaks = new java.util.ArrayList();
- private BreakPoss prevBP = null; // Last confirmed break position
private int bTextAlignment = EN_JUSTIFY;
private int bTextAlignmentLast;
private int effectiveAlignment;
@@ -128,7 +127,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
private int middleShift;
private List knuthParagraphs = null;
- private List breakpoints = null;
private int iReturnedLBP = 0;
private int iStartElement = 0;
private int iEndElement = 0;
@@ -483,19 +481,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
initialize(); // Normally done when started by parent!
}
- /**
- * Call child layout managers to generate content.
- * This gets the next break which is a full line.
- *
- * @param context the layout context for finding breaks
- * @return the next break position
- */
- // this method is no longer used
- public BreakPoss getNextBreakPoss(LayoutContext context) {
- setFinished(true);
- return null;
- }
-
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
// Get a break from currently active child LM
// Set up constraints for inline level managers
@@ -510,7 +495,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
if (iPrevLineEnd == 0 && bTextAlignment == EN_START) {
availIPD.subtract(new MinOptMax(textIndent.getValue()));
}
- prevBP = null;
//PHASE 1: Create Knuth elements
if (knuthParagraphs == null) {
@@ -1307,56 +1291,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
updateList.clear();
}
- private void resetBP(BreakPoss resetBP) {
- if (resetBP == null) {
- reset((Position) null);
- } else {
- while (vecInlineBreaks.get(vecInlineBreaks.size() - 1) != resetBP) {
- vecInlineBreaks.remove(vecInlineBreaks.size() - 1);
- }
- reset(resetBP.getPosition());
- }
- }
-
- private void reset() {
- resetBP(prevBP);
- }
-
- protected boolean couldEndLine(BreakPoss bp) {
- if (bp.canBreakAfter()) {
- return true; // no keep, ends on break char
- } else if (bp.isSuppressible()) {
- // NOTE: except at end of content for this LM!!
- // Never break after only space chars or any other sequence
- // of areas which would be suppressed at the end of the line.
- return false;
- } else {
- // See if could break before next area
- // TODO: do we need to set anything on the layout context?
- LayoutContext lc = new LayoutContext(0);
- LayoutManager nextLM = getChildLM();
- return (nextLM == null || nextLM.canBreakBefore(lc));
- }
- }
-
- private BreakPoss getBestBP(List vecPossEnd) {
- if (vecPossEnd.size() == 1) {
- return ((BreakCost) vecPossEnd.get(0)).getBP();
- }
- // Choose the best break (use a sort on cost!)
- Iterator iter = vecPossEnd.iterator();
- int minCost = Integer.MAX_VALUE;
- BreakPoss bestBP = null;
- while (iter.hasNext()) {
- BreakCost bc = (BreakCost) iter.next();
- if (bc.getCost() < minCost) {
- minCost = bc.getCost();
- bestBP = bc.getBP();
- }
- }
- return bestBP;
- }
-
/** Line area is always considered to act as a fence. */
protected boolean hasLeadingFence(boolean bNotFirst) {
return true;
@@ -1367,47 +1301,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
return true;
}
- /** Return true if we are at the end of this LM,
- and BPs after prev have been added to vecInlineBreaks
- and all breakposs in vecInlineBreaks
- back to and excluding prev are suppressible */
- private boolean condAllAreSuppressible(BreakPoss prev) {
- if (!isFinished()) {
- return false;
- }
- if (vecInlineBreaks.get(vecInlineBreaks.size() - 1) == prev) {
- return false;
- }
- return allAreSuppressible(prev);
- }
-
- /** Test whether all breakposs in vecInlineBreaks
- back to and excluding prev are suppressible */
- private boolean allAreSuppressible(BreakPoss prev) {
- ListIterator bpIter =
- vecInlineBreaks.listIterator(vecInlineBreaks.size());
- boolean allAreSuppressible = true;
- BreakPoss bp;
- while (bpIter.hasPrevious()
- && (bp = (BreakPoss) bpIter.previous()) != prev
- && (allAreSuppressible = bp.isSuppressible())) {
- }
- return allAreSuppressible;
- }
-
- /** Remove all BPs from the end back to and excluding prev
- from vecInlineBreaks*/
- private void removeAllBP(BreakPoss prev) {
- int iPrev;
- if (prev == null) {
- vecInlineBreaks.clear();
- } else if ((iPrev = vecInlineBreaks.indexOf(prev)) != -1) {
- for (int i = vecInlineBreaks.size()-1; iPrev < i; --i) {
- vecInlineBreaks.remove(i);
- }
- }
- }
-
private HyphContext getHyphenContext(StringBuffer sbChars) {
// Find all hyphenation points in this word
// (get in an array of offsets)
diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
index e305ff48e..c712de228 100644
--- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
@@ -18,6 +18,9 @@
package org.apache.fop.layoutmgr;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
import org.apache.fop.area.RegionReference;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
@@ -26,11 +29,6 @@ import org.apache.fop.fo.pagination.SideRegion;
import org.apache.fop.fo.pagination.StaticContent;
import org.apache.fop.traits.MinOptMax;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
/**
* LayoutManager for an fo:flow object.
* Its parent LM is the PageSequenceLayoutManager.
@@ -38,11 +36,17 @@ import java.util.ListIterator;
* and filling them with block-level areas generated by its children.
*/
public class StaticContentLayoutManager extends BlockStackingLayoutManager {
+
private RegionReference targetRegion;
private Block targetBlock;
- private List blockBreaks = new ArrayList();
private SideRegion regionFO;
+ /**
+ * Creates a new StaticContentLayoutManager.
+ * @param pslm PageSequenceLayoutManager this layout manager belongs to
+ * @param node static-content FO
+ * @param reg side region to layout into
+ */
public StaticContentLayoutManager(PageSequenceLayoutManager pslm,
StaticContent node, SideRegion reg) {
super(node);
@@ -83,17 +87,15 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
// Set up a LayoutContext
MinOptMax bpd = context.getStackLimit();
- BreakPoss bp;
- bp = null;
LayoutContext childLC = new LayoutContext(0);
- boolean breakPage = false;
childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
childLC.setRefIPD(context.getRefIPD());
// get elements from curLM
returnedList = curLM.getNextKnuthElements(childLC, alignment);
-/*LF*/ //System.out.println("FLM.getNextKnuthElements> returnedList.size() = " + returnedList.size());
+ //System.out.println("FLM.getNextKnuthElements> returnedList.size() = "
+ // + returnedList.size());
// "wrap" the Position inside each element
LinkedList tempList = returnedList;
@@ -118,7 +120,9 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
if (prevLM.mustKeepWithNext()
|| curLM.mustKeepWithPrevious()) {
// add an infinite penalty to forbid a break between blocks
- returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new Position(this), false));
+ returnList.add(new KnuthPenalty(0,
+ KnuthElement.INFINITE, false,
+ new Position(this), false));
} else if (!((KnuthElement) returnList.getLast()).isGlue()) {
// add a null penalty to allow a break between blocks
returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
@@ -127,7 +131,8 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
/*LF*/ if (returnedList.size() > 0) { // controllare!
returnList.addAll(returnedList);
if (((KnuthElement)returnedList.getLast()).isPenalty()
- && ((KnuthPenalty)returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
+ && ((KnuthPenalty)returnedList.getLast()).getP()
+ == -KnuthElement.INFINITE) {
// a descendant of this flow has break-after
/*LF*/ //System.out.println("FLM - break after!!");
return returnList;
@@ -147,61 +152,11 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
}
/**
- * @see org.apache.fop.layoutmgr.LayoutManager#getNextBreakPoss(LayoutContext)
- */
- public BreakPoss getNextBreakPoss(LayoutContext context) {
-
- // currently active LM
- LayoutManager curLM;
-
- while ((curLM = getChildLM()) != null) {
- // Make break positions and return page break
- // Set up a LayoutContext
- BreakPoss bp;
- LayoutContext childLC = context;
- if (!curLM.isFinished()) {
- if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- blockBreaks.add(bp);
- if (bp.isForcedBreak()) {
- log.error("Forced breaks are not allowed in "
- + "static content - ignoring");
- return null;
- }
- }
- }
- }
- setFinished(true);
- if (blockBreaks.size() > 0) {
- return new BreakPoss(
- new LeafPosition(this, blockBreaks.size() - 1));
- }
- return null;
- }
-
- /**
* @see org.apache.fop.layoutmgr.LayoutManager#addAreas(PositionIterator, LayoutContext)
*/
public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
AreaAdditionUtil.addAreas(parentIter, layoutContext);
- /*
- LayoutManager childLM;
- int iStartPos = 0;
- LayoutContext lc = new LayoutContext(0);
- while (parentIter.hasNext()) {
- 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);
- }
- }
-
- blockBreaks.clear();
- */
flush();
targetRegion = null;
}
@@ -232,6 +187,9 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
}
}
+ /**
+ * Does the layout for a side region. Called by PageSequenceLayoutManager.
+ */
public void doLayout() {
StaticContentBreaker breaker = new StaticContentBreaker(
this, targetRegion.getIPD(), regionFO.getDisplayAlign());
@@ -255,7 +213,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
private StaticContentLayoutManager lm;
private int displayAlign;
private int ipd;
- boolean overflow = false;
+ private boolean overflow = false;
public StaticContentBreaker(StaticContentLayoutManager lm, int ipd,
int displayAlign) {
diff --git a/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
index 13d6d89ad..58c8786b6 100644
--- a/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
@@ -292,222 +292,6 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
}
/**
- * Return the next break possibility that fits the constraints.
- * @param context An object specifying the flags and input information
- * concerning the context of the BreakPoss.
- * @return BreakPoss An object containing information about the next
- * legal break position or the end of the text run if no break
- * was found.
- * <p>Assumptions: white-space-treatment and
- * linefeed-treatment processing
- * are already done, so there are no TAB or RETURN characters remaining.
- * white-space-collapse handling is also done
- * (but perhaps this shouldn't be true!)
- * There may be LINEFEED characters if they weren't converted
- * into spaces. A LINEFEED always forces a break.
- */
- public BreakPoss getNextBreakPoss(LayoutContext context) {
- /* On first call in a new Line, the START_AREA
- * flag in LC is set.
- */
-
- int iFlags = 0;
-
- if (context.startsNewArea()) {
- /* This could be first call on this LM, or the first call
- * in a new (possible) LineArea.
- */
- ipdTotal = new MinOptMax(0);
- iFlags |= BreakPoss.ISFIRST;
- }
-
-
- /* HANDLE SUPPRESSED LEADING SPACES
- * See W3C XSL Rec. 7.16.3.
- * Suppress characters whose "suppress-at-line-break" property = "suppress"
- * This can only be set on an explicit fo:character object. The default
- * behavior is that U+0020 is suppressed; all other character codes are
- * retained.
- */
- if (context.suppressLeadingSpace()) {
- for (; iNextStart < textArray.length
- && textArray[iNextStart] == SPACE; iNextStart++) {
- }
- // If now at end, nothing to compose here!
- if (iNextStart >= textArray.length) {
- setFinished(true);
- return null; // Or an "empty" BreakPoss?
- }
- }
-
-
- /* Start of this TextArea, plus any non-suppressed leading space.
- * Collapse any remaining word-space with leading space from
- * ancestor FOs.
- * Add up other leading space which is counted in the TextArea IPD.
- */
-
- SpaceSpecifier pendingSpace = new SpaceSpecifier(false);
- short iThisStart = iNextStart; // Index of first character counted
- MinOptMax spaceIPD = new MinOptMax(0); // Extra IPD from word-spacing
- // Sum of glyph IPD of all characters in a word, inc. leading space
- int wordIPD = 0;
- short iWScount = 0; // Count of word spaces
- boolean bSawNonSuppressible = false;
-
- for (; iNextStart < textArray.length; iNextStart++) {
- char c = textArray[iNextStart];
- if (CharUtilities.isAnySpace(c) == false) {
- break;
- }
- if (c == SPACE || c == NBSPACE) {
- ++iWScount;
- // Counted as word-space
- if (iNextStart == iThisStart
- && (iFlags & BreakPoss.ISFIRST) != 0) {
- // If possible, treat as normal inter-word space
- if (context.getLeadingSpace().hasSpaces()) {
- context.getLeadingSpace().addSpace(halfWS);
- } else {
- // Doesn't combine with any other leading spaces
- // from ancestors
- spaceIPD.add(halfWS.getSpace());
- }
- } else {
- pendingSpace.addSpace(halfWS);
- spaceIPD.add(pendingSpace.resolve(false));
- }
- wordIPD += spaceCharIPD; // Space glyph IPD
- pendingSpace.clear();
- pendingSpace.addSpace(halfWS);
- if (c == NBSPACE) {
- bSawNonSuppressible = true;
- }
- } else {
- // If we have letter-space, so we apply this to fixed-
- // width spaces (which are not word-space) also?
- bSawNonSuppressible = true;
- spaceIPD.add(pendingSpace.resolve(false));
- pendingSpace.clear();
- wordIPD += fs.getCharWidth(c);
- }
- }
-
- if (iNextStart < textArray.length) {
- spaceIPD.add(pendingSpace.resolve(false));
- } else {
- // This FO ended with spaces. Return the BP
- if (!bSawNonSuppressible) {
- iFlags |= BreakPoss.ALL_ARE_SUPPRESS_AT_LB;
- }
- return makeBreakPoss(iThisStart, spaceIPD, wordIPD,
- context.getLeadingSpace(), pendingSpace,
- iFlags, iWScount);
- }
-
- if (context.tryHyphenate()) {
- // Get the size of the next syallable
- MinOptMax hyphIPD = new MinOptMax(0);
- if (getHyphenIPD(context.getHyphContext(), hyphIPD)) {
- iFlags |= (BreakPoss.CAN_BREAK_AFTER | BreakPoss.HYPHENATED);
- }
- wordIPD += hyphIPD.opt;
- } else {
- // Look for a legal line-break: breakable white-space and certain
- // characters such as '-' which can serve as word breaks.
- // Don't look for hyphenation points here though
- for (; iNextStart < textArray.length; iNextStart++) {
- char c = textArray[iNextStart];
- // Include any breakable white-space as break char
- if ((c == NEWLINE) || (foText.getWrapOption() == EN_WRAP
- && (CharUtilities.isBreakableSpace(c)
- || (BREAK_CHARS.indexOf(c) >= 0 && (iNextStart == 0
- || Character.isLetterOrDigit(textArray[iNextStart-1])))))) {
- iFlags |= BreakPoss.CAN_BREAK_AFTER;
- if (c != SPACE) {
- iNextStart++;
- if (c != NEWLINE) {
- wordIPD += fs.getCharWidth(c);
- } else {
- iFlags |= BreakPoss.FORCE;
- }
- }
- // If all remaining characters would be suppressed at
- // line-end, set a flag for parent LM.
- int iLastChar;
- for (iLastChar = iNextStart;
- iLastChar < textArray.length
- && textArray[iLastChar] == SPACE; iLastChar++) {
- //nop
- }
- if (iLastChar == textArray.length) {
- iFlags |= BreakPoss.REST_ARE_SUPPRESS_AT_LB;
- }
- return makeBreakPoss(iThisStart, spaceIPD, wordIPD,
- context.getLeadingSpace(), null,
- iFlags, iWScount);
- }
- wordIPD += fs.getCharWidth(c);
- // Note, if a normal non-breaking space, is it stretchable???
- // If so, keep a count of these embedded spaces.
- }
- }
- return makeBreakPoss(iThisStart, spaceIPD, wordIPD,
- context.getLeadingSpace(), null,
- iFlags, iWScount);
- }
-
- private BreakPoss makeBreakPoss(short iWordStart,
- MinOptMax spaceIPD, int wordDim,
- SpaceSpecifier leadingSpace,
- SpaceSpecifier trailingSpace,
- int flags, short iWScount) {
- MinOptMax ipd = new MinOptMax(wordDim);
- ipd.add(spaceIPD);
- if (ipdTotal != null) {
- ipd.add(ipdTotal); // sum of all words so far in line
- }
- // Note: break position now stores total size to here
-
- // Position is the index of the info for this word in the vector
- BreakPoss bp = new BreakPoss(new LeafPosition(this,
- vecAreaInfo.size() - 1));
- ipdTotal = ipd;
- if ((flags & BreakPoss.HYPHENATED) != 0) {
- // Add the hyphen size, but don't change total IPD!
- bp.setStackingSize(MinOptMax.add(ipd, new MinOptMax(hyphIPD)));
- } else {
- bp.setStackingSize(ipd);
- }
- // TODO: make this correct (see Keiron's vertical alignment code)
- bp.setNonStackingSize(new SpaceVal(foText.getLineHeight()).getSpace());
-
- /* Set max ascender and descender (offset from baseline),
- * used for calculating the bpd of the line area containing
- * this text.
- */
- //bp.setDescender(fs.getDescender());
- //bp.setAscender(fs.getAscender());
- if (iNextStart == textArray.length) {
- flags |= BreakPoss.ISLAST;
- setFinished(true);
- }
- bp.setFlag(flags);
- if (trailingSpace != null) {
- bp.setTrailingSpace(trailingSpace);
- } else {
- bp.setTrailingSpace(new SpaceSpecifier(false));
- }
- if (leadingSpace != null) {
- bp.setLeadingSpace(leadingSpace);
- } else {
- bp.setLeadingSpace(new SpaceSpecifier(false));
- }
- return bp;
- }
-
-
- /**
* Generate and add areas to parent area.
* This can either generate an area for each TextArea and each space, or
* an area containing all text with a parameter controlling the size of
diff --git a/src/java/org/apache/fop/layoutmgr/list/Item.java b/src/java/org/apache/fop/layoutmgr/list/Item.java
index 64089245f..a7dd3799e 100644
--- a/src/java/org/apache/fop/layoutmgr/list/Item.java
+++ b/src/java/org/apache/fop/layoutmgr/list/Item.java
@@ -23,15 +23,12 @@ import org.apache.fop.fo.flow.ListItemBody;
import org.apache.fop.fo.flow.ListItemLabel;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LayoutManager;
-import org.apache.fop.layoutmgr.LeafPosition;
-import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
-import org.apache.fop.traits.MinOptMax;
import java.util.ArrayList;
import java.util.Iterator;
@@ -47,8 +44,6 @@ public class Item extends BlockStackingLayoutManager {
private Block curBlockArea;
- private List childBreaks = new ArrayList();
-
private int xoffset;
private int itemIPD;
@@ -83,81 +78,6 @@ public class Item extends BlockStackingLayoutManager {
}
/**
- * Get the next break possibility for this cell.
- * A cell contains blocks so there are breaks around the blocks
- * and inside the blocks.
- *
- * @param context the layout context
- * @return the next break possibility
- */
- public BreakPoss getNextBreakPoss(LayoutContext context) {
- LayoutManager curLM; // currently active LM
-
- MinOptMax stackSize = new MinOptMax();
- // if starting add space before
- // stackSize.add(spaceBefore);
- BreakPoss lastPos = null;
-
- itemIPD = context.getRefIPD();
-
- while ((curLM = getChildLM()) != null) {
- if (curLM.generatesInlineAreas()) {
- // error
- curLM.setFinished(true);
- continue;
- }
- // Set up a LayoutContext
- int ipd = context.getRefIPD();
- BreakPoss bp;
-
- LayoutContext childLC = new LayoutContext(0);
- childLC.setStackLimit(MinOptMax.subtract(context.getStackLimit(),
- stackSize));
- childLC.setRefIPD(ipd);
-
- boolean over = false;
- while (!curLM.isFinished()) {
- if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
- // reset to last break
- if (lastPos != null) {
- 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;
- }
- setFinished(true);
- return null;
- }
-
- /**
* Set the x offset of this list item.
* This offset is used to set the absolute position
* of the list item within the parent block area.
@@ -235,7 +155,6 @@ public class Item extends BlockStackingLayoutManager {
flush();
- childBreaks.clear();
curBlockArea = null;
}
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
index d57bef99f..8a2655954 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
@@ -21,8 +21,6 @@ package org.apache.fop.layoutmgr.list;
import org.apache.fop.fo.flow.ListBlock;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LayoutManager;
-import org.apache.fop.layoutmgr.LeafPosition;
-import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.Position;
@@ -33,7 +31,6 @@ import org.apache.fop.area.Block;
import org.apache.fop.traits.MinOptMax;
import org.apache.fop.traits.SpaceVal;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -48,8 +45,6 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
private Block curBlockArea;
- private List bodyBreaks = new ArrayList();
-
//TODO space-before|after: handle space-resolution rules
private MinOptMax spaceBefore;
private MinOptMax spaceAfter;
@@ -100,86 +95,6 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
return iIndents;
}
- /**
- * Get the next break possibility.
- * The break possibility depends on the height of the header and footer
- * and possible breaks inside the table body.
- *
- * @param context the layout context for finding breaks
- * @return the next break possibility
- */
- public BreakPoss getNextBreakPoss(LayoutContext context) {
- // currently active LM
- LayoutManager curLM;
-
- referenceIPD = context.getRefIPD();
-
- MinOptMax stackSize = new MinOptMax();
-
- //Add spacing
- if (spaceAfter != null) {
- stackSize.add(spaceAfter);
- }
- if (spaceBefore != null) {
- stackSize.add(spaceBefore);
- }
-
- BreakPoss lastPos = null;
-
- while ((curLM = (LayoutManager)getChildLM()) != null) {
- // Make break positions
- // Set up a LayoutContext
- //int ipd = context.getRefIPD();
- BreakPoss bp;
-
- LayoutContext childLC = new LayoutContext(0);
- childLC.setStackLimit(
- MinOptMax.subtract(context.getStackLimit(),
- stackSize));
- childLC.setRefIPD(referenceIPD);
-
- boolean over = false;
- while (!curLM.isFinished()) {
- if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
- // reset to last break
- if (lastPos != null) {
- 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;
- }
- setFinished(true);
- return null;
- }
-
public LinkedList getChangedKnuthElements(List oldList, int alignment) {
//log.debug("LBLM.getChangedKnuthElements>");
return super.getChangedKnuthElements(oldList, alignment);
@@ -241,7 +156,6 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
// if adjusted space after
addBlockSpacing(adjust, spaceAfter);
- bodyBreaks.clear();
curBlockArea = null;
}
@@ -301,7 +215,6 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
*/
public void resetPosition(Position resetPos) {
if (resetPos == null) {
- bodyBreaks.clear();
reset(null);
} else {
//TODO Something to put here?
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
index 36da5f68d..147194718 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
@@ -24,7 +24,6 @@ import org.apache.fop.fo.flow.ListItemLabel;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LeafPosition;
-import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.Position;
@@ -149,121 +148,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
}
/**
- * Get the next break possibility.
- *
- * @param context the layout context for getting breaks
- * @return the next break possibility
- */
- public BreakPoss getNextBreakPoss(LayoutContext context) {
- // currently active LM
- Item curLM;
-
- //int allocBPD = context.
- referenceIPD = context.getRefIPD();
-
- BreakPoss lastPos = null;
- List breakList = new ArrayList();
-
- int min = 0;
- int opt = 0;
- int max = 0;
-
- int stage = 0;
- boolean over = false;
- while (true) {
- if (stage == 0) {
- curLM = label;
- } else if (stage == 1) {
- curLM = body;
- } else {
- break;
- }
- List childBreaks = new ArrayList();
- MinOptMax stackSize = new MinOptMax();
-
- // Set up a LayoutContext
- // the ipd is from the current column
- //int ipd = context.getRefIPD();
- BreakPoss bp;
-
- LayoutContext childLC = new LayoutContext(0);
- childLC.setStackLimit(
- MinOptMax.subtract(context.getStackLimit(),
- stackSize));
- childLC.setRefIPD(referenceIPD);
-
- stage++;
- while (!curLM.isFinished()) {
- if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
- // reset to last break
- if (lastPos != null) {
- LayoutManager lm = lastPos.getLayoutManager();
- lm.resetPosition(lastPos.getPosition());
- if (lm != curLM) {
- curLM.resetPosition(null);
- }
- } else {
- curLM.resetPosition(null);
- }
- over = true;
- break;
- } else {
- lastPos = bp;
- }
- stackSize.add(bp.getStackingSize());
- childBreaks.add(bp);
-
- if (bp.nextBreakOverflows()) {
- over = true;
- break;
- }
-
- childLC.setStackLimit(MinOptMax.subtract(
- context.getStackLimit(), stackSize));
- }
- }
- // the min is the maximum min of the label and body
- if (stackSize.min > min) {
- min = stackSize.min;
- }
- // the optimum is the minimum of all optimums
- if (stackSize.opt > opt) {
- opt = stackSize.opt;
- }
- // the maximum is the largest maximum
- if (stackSize.max > max) {
- max = stackSize.max;
- }
-
- breakList.add(childBreaks);
- }
- listItemHeight = opt;
-
- if (label.isFinished() && body.isFinished()) {
- setFinished(true);
- }
-
- MinOptMax itemSize = new MinOptMax(min, opt, max);
-
- //Add spacing
- if (spaceAfter != null) {
- itemSize.add(spaceAfter);
- }
- if (spaceBefore != null) {
- itemSize.add(spaceBefore);
- }
-
- 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;
- }
-
- /**
* @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(org.apache.fop.layoutmgr.LayoutContext, int)
*/
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
@@ -430,11 +314,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
* @see org.apache.fop.layoutmgr.LayoutManager#getChangedKnuthElements(java.util.List, int)
*/
public LinkedList getChangedKnuthElements(List oldList, int alignment) {
-/*LF*/ //log.debug(" LILM.getChanged> label");
+ //log.debug(" LILM.getChanged> label");
// label
labelList = label.getChangedKnuthElements(labelList, alignment);
-/*LF*/ //log.debug(" LILM.getChanged> body");
+ //log.debug(" LILM.getChanged> body");
// body
// "unwrap" the Positions stored in the elements
ListIterator oldListIterator = oldList.listIterator();
@@ -442,8 +326,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement)oldListIterator.next();
Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition();
-/*LF*/ //System.out.println(" BLM> unwrapping: " + (oldElement.isBox() ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) + " creato da " + oldElement.getLayoutManager().getClass().getName());
-/*LF*/ //System.out.println(" BLM> unwrapping: " + oldElement.getPosition().getClass().getName());
+ //System.out.println(" BLM> unwrapping: " + (oldElement.isBox()
+ // ? "box " : (oldElement.isGlue() ? "glue " : "penalty"))
+ // + " creato da " + oldElement.getLayoutManager().getClass().getName());
+ //System.out.println(" BLM> unwrapping: "
+ // + oldElement.getPosition().getClass().getName());
if (innerPosition != null) {
// oldElement was created by a descendant of this BlockLM
oldElement.setPosition(innerPosition);
diff --git a/src/java/org/apache/fop/layoutmgr/table/Caption.java b/src/java/org/apache/fop/layoutmgr/table/Caption.java
index a311270b4..2101d793f 100644
--- a/src/java/org/apache/fop/layoutmgr/table/Caption.java
+++ b/src/java/org/apache/fop/layoutmgr/table/Caption.java
@@ -20,35 +20,28 @@ package org.apache.fop.layoutmgr.table;
import org.apache.fop.fo.flow.TableCaption;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
-import org.apache.fop.layoutmgr.LayoutManager;
-import org.apache.fop.layoutmgr.LeafPosition;
-import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
-import org.apache.fop.traits.MinOptMax;
-
-import java.util.ArrayList;
-import java.util.List;
/**
* LayoutManager for a table-caption FO.
* The table caption contains blocks that are placed beside the
* table.
+ * @todo Implement getNextKnuthElements()
*/
public class Caption extends BlockStackingLayoutManager {
private TableCaption fobj;
private Block curBlockArea;
- private List childBreaks = new ArrayList();
+ //private List childBreaks = new ArrayList();
/**
* Create a new Caption layout manager.
- *
+ * @param node table-caption FO
*/
public Caption(TableCaption node) {
super(node);
@@ -61,6 +54,7 @@ public class Caption extends BlockStackingLayoutManager {
* @param context the layout context for finding breaks
* @return the next break possibility
*/
+ /*
public BreakPoss getNextBreakPoss(LayoutContext context) {
LayoutManager curLM; // currently active LM
@@ -127,7 +121,7 @@ public class Caption extends BlockStackingLayoutManager {
}
setFinished(true);
return null;
- }
+ }*/
/**
* Add the areas to the parent.
@@ -140,24 +134,24 @@ public class Caption extends BlockStackingLayoutManager {
getParentArea(null);
getPSLM().addIDToPage(fobj.getId());
+ /* TODO: Reimplement using Knuth approach
LayoutManager childLM;
int iStartPos = 0;
LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
LeafPosition lfp = (LeafPosition) parentIter.next();
// Add the block areas to Area
- PositionIterator breakPosIter =
- new BreakPossPosIter(childBreaks, iStartPos,
- lfp.getLeafPos() + 1);
+ 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();
+ //childBreaks.clear();
curBlockArea = null;
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/Cell.java b/src/java/org/apache/fop/layoutmgr/table/Cell.java
index ca8475ba5..32096098b 100644
--- a/src/java/org/apache/fop/layoutmgr/table/Cell.java
+++ b/src/java/org/apache/fop/layoutmgr/table/Cell.java
@@ -22,19 +22,13 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.Table;
import org.apache.fop.fo.flow.TableCell;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.LengthRangeProperty;
import org.apache.fop.layoutmgr.AreaAdditionUtil;
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.KnuthPenalty;
-import org.apache.fop.layoutmgr.LayoutManager;
-import org.apache.fop.layoutmgr.LeafPosition;
-import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.MinOptMaxUtil;
-import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.TraitSetter;
@@ -42,7 +36,6 @@ import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.area.Trait;
import org.apache.fop.traits.MinOptMax;
-import org.apache.tools.ant.taskdefs.condition.IsSet;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -79,7 +72,8 @@ public class Cell extends BlockStackingLayoutManager implements BlockLevelLayout
/**
* Create a new Cell layout manager.
- * @node table-cell FO for which to create the LM
+ * @param node table-cell FO for which to create the LM
+ * @param pgu primary grid unit for the cell
*/
public Cell(TableCell node, PrimaryGridUnit pgu) {
super(node);
@@ -152,11 +146,8 @@ public class Cell extends BlockStackingLayoutManager implements BlockLevelLayout
* @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(org.apache.fop.layoutmgr.LayoutContext, int)
*/
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
- MinOptMax stackSize = new MinOptMax();
MinOptMax stackLimit = new MinOptMax(context.getStackLimit());
- BreakPoss lastPos = null;
-
referenceIPD = context.getRefIPD();
cellIPD = referenceIPD;
cellIPD -= getIPIndents();
@@ -169,7 +160,6 @@ public class Cell extends BlockStackingLayoutManager implements BlockLevelLayout
LinkedList returnedList = null;
LinkedList contentList = new LinkedList();
LinkedList returnList = new LinkedList();
- Position returnPosition = new NonLeafPosition(this, null);
BlockLevelLayoutManager curLM; // currently active LM
BlockLevelLayoutManager prevLM = null; // previously active LM
@@ -229,7 +219,8 @@ public class Cell extends BlockStackingLayoutManager implements BlockLevelLayout
continue;
}
if (((KnuthElement) returnedList.getLast()).isPenalty()
- && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
+ && ((KnuthPenalty) returnedList.getLast()).getP()
+ == -KnuthElement.INFINITE) {
// a descendant of this block has break-after
if (curLM.isFinished()) {
// there is no other content in this block;
@@ -254,103 +245,6 @@ public class Cell extends BlockStackingLayoutManager implements BlockLevelLayout
}
/**
- * Get the next break possibility for this cell.
- * A cell contains blocks so there are breaks around the blocks
- * and inside the blocks.
- *
- * @param context the layout context
- * @return the next break possibility
- */
- public BreakPoss getNextBreakPossOLDOLDOLD(LayoutContext context) {
- LayoutManager curLM; // currently active LM
-
- MinOptMax stackSize = new MinOptMax();
- BreakPoss lastPos = null;
-
- referenceIPD = context.getRefIPD();
- cellIPD = referenceIPD;
- cellIPD -= getIPIndents();
- if (fobj.isSeparateBorderModel()) {
- int borderSep = fobj.getBorderSeparation().getLengthPair()
- .getIPD().getLength().getValue();
- cellIPD -= borderSep;
- }
-
- while ((curLM = getChildLM()) != null) {
- if (curLM.generatesInlineAreas()) {
- log.error("table-cell must contain block areas - ignoring");
- curLM.setFinished(true);
- continue;
- }
- // Set up a LayoutContext
- BreakPoss bp;
-
- LayoutContext childLC = new LayoutContext(0);
- childLC.setStackLimit(MinOptMax.subtract(context.getStackLimit(),
- stackSize));
- childLC.setRefIPD(cellIPD);
-
- boolean over = false;
-
- while (!curLM.isFinished()) {
- if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
- // reset to last break
- if (lastPos != null) {
- 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));
- }
- }
-
- usedBPD = stackSize.opt;
- if (usedBPD > 0) {
- emptyCell = false;
- }
-
- LengthRangeProperty specifiedBPD = fobj.getBlockProgressionDimension();
- if (specifiedBPD.getEnum() != EN_AUTO) {
- if ((specifiedBPD.getMaximum().getEnum() != EN_AUTO)
- && (specifiedBPD.getMaximum().getLength().getValue() < stackSize.min)) {
- log.warn("maximum height of cell is smaller than the minimum "
- + "height of its contents");
- }
- MinOptMaxUtil.restrict(stackSize, specifiedBPD);
- }
- stackSize = MinOptMax.add(stackSize, new MinOptMax(borderAndPaddingBPD));
-
- BreakPoss breakPoss = new BreakPoss(
- new LeafPosition(this, childBreaks.size() - 1));
- if (over) {
- breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
- }
- breakPoss.setStackingSize(stackSize);
- return breakPoss;
- }
- setFinished(true);
- return null;
- }
-
- /**
* Set the y offset of this cell.
* This offset is used to set the absolute position of the cell.
*
@@ -425,8 +319,7 @@ public class Cell extends BlockStackingLayoutManager implements BlockLevelLayout
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
- //BreakPoss bp1 = (BreakPoss)parentIter.peekNext();
- bBogus = false;//!bp1.generatesAreas();
+ bBogus = false; //!bp1.generatesAreas();
if (!isBogus()) {
getPSLM().addIDToPage(fobj.getId());
@@ -486,8 +379,8 @@ public class Cell extends BlockStackingLayoutManager implements BlockLevelLayout
block.setXOffset(dx + borderStartWidth);
int halfCollapsingBorderHeight = 0;
if (!isSeparateBorderModel()) {
- halfCollapsingBorderHeight +=
- gu.getBorders().getBorderBeforeWidth(false) / 2;
+ halfCollapsingBorderHeight
+ += gu.getBorders().getBorderBeforeWidth(false) / 2;
}
block.setYOffset(dy - halfCollapsingBorderHeight);
TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer);
@@ -615,7 +508,7 @@ public class Cell extends BlockStackingLayoutManager implements BlockLevelLayout
// TODO Auto-generated method stub
}
- /* (non-Javadoc)
+ /**
* @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether()
*/
public boolean mustKeepTogether() {
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
index 639eaf3a2..e48531c2c 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
@@ -20,19 +20,11 @@ package org.apache.fop.layoutmgr.table;
import org.apache.fop.fo.flow.TableAndCaption;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
-import org.apache.fop.layoutmgr.LayoutManager;
-import org.apache.fop.layoutmgr.LeafPosition;
-import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
-import org.apache.fop.traits.MinOptMax;
-
-import java.util.ArrayList;
-import java.util.List;
/**
* LayoutManager for a table-and-caption FO.
@@ -40,17 +32,18 @@ import java.util.List;
* The caption contains blocks that are positioned next to the
* table on the caption side.
* The caption blocks have an implicit keep with the table.
+ * @todo Implement getNextKnuthElements()
*/
public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
private TableAndCaption fobj;
private Block curBlockArea;
- private List childBreaks = new ArrayList();
+ //private List childBreaks = new java.util.ArrayList();
/**
* Create a new table and caption layout manager.
- *
+ * @param node table-and-caption FO
*/
public TableAndCaptionLayoutManager(TableAndCaption node) {
super(node);
@@ -63,6 +56,7 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
* @param context the layout context for getting breaks
* @return the next break possibility
*/
+ /*
public BreakPoss getNextBreakPoss(LayoutContext context) {
LayoutManager curLM; // currently active LM
@@ -128,7 +122,7 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
}
setFinished(true);
return null;
- }
+ }*/
/**
* Add the areas.
@@ -141,24 +135,24 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
getParentArea(null);
getPSLM().addIDToPage(fobj.getId());
+ /* TODO: Reimplement using Knuth approach
LayoutManager childLM;
int iStartPos = 0;
LayoutContext lc = new LayoutContext(0);
while (parentIter.hasNext()) {
LeafPosition lfp = (LeafPosition) parentIter.next();
// Add the block areas to Area
- PositionIterator breakPosIter =
- new BreakPossPosIter(childBreaks, iStartPos,
- lfp.getLeafPos() + 1);
+ 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();
+ //childBreaks.clear();
curBlockArea = null;
}