aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/layoutmgr
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/apache/fop/layoutmgr')
-rw-r--r--src/org/apache/fop/layoutmgr/AbstractLayoutManager.java14
-rw-r--r--src/org/apache/fop/layoutmgr/BlockLayoutManager.java12
-rw-r--r--src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java50
-rw-r--r--src/org/apache/fop/layoutmgr/ContentLayoutManager.java6
-rw-r--r--src/org/apache/fop/layoutmgr/FlowLayoutManager.java12
-rw-r--r--src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java7
-rw-r--r--src/org/apache/fop/layoutmgr/LineLayoutManager.java31
-rw-r--r--src/org/apache/fop/layoutmgr/PageLayoutManager.java34
-rw-r--r--src/org/apache/fop/layoutmgr/PositionIterator.java4
-rw-r--r--src/org/apache/fop/layoutmgr/TextLayoutManager.java14
-rw-r--r--src/org/apache/fop/layoutmgr/TraitSetter.java8
-rw-r--r--src/org/apache/fop/layoutmgr/table/Body.java2
12 files changed, 88 insertions, 106 deletions
diff --git a/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java
index 34682b143..64b052b7b 100644
--- a/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java
@@ -62,13 +62,13 @@ public abstract class AbstractLayoutManager implements LayoutManager {
// * is enough space to place the float(s) anchored in the line.
// */
// protected void flush(Area area, boolean bFinished) {
- // if (area != null) {
- // // area.setFinished(true);
- // parentLM.addChild(area, bFinished); // ????
- // if (bFinished) {
- // setCurrentArea(null);
- // }
- // }
+ // if (area != null) {
+ // // area.setFinished(true);
+ // parentLM.addChild(area, bFinished); // ????
+ // if (bFinished) {
+ // setCurrentArea(null);
+ // }
+ // }
// }
/**
diff --git a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
index 280963eb4..bbd68253f 100644
--- a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
@@ -1,6 +1,6 @@
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
@@ -244,22 +244,22 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
return curBlockArea;
}
- public void addBorders(Block curBlockArea) {
+ public void addBorders(Block curBlock) {
BorderProps bps = getBorderProps(BorderAndPadding.TOP);
if(bps.width != 0) {
- curBlockArea.addTrait(Trait.BORDER_START, bps);
+ curBlock.addTrait(Trait.BORDER_START, bps);
}
bps = getBorderProps(BorderAndPadding.BOTTOM);
if(bps.width != 0) {
- curBlockArea.addTrait(Trait.BORDER_END, bps);
+ curBlock.addTrait(Trait.BORDER_END, bps);
}
bps = getBorderProps(BorderAndPadding.LEFT);
if(bps.width != 0) {
- curBlockArea.addTrait(Trait.BORDER_BEFORE, bps);
+ curBlock.addTrait(Trait.BORDER_BEFORE, bps);
}
bps = getBorderProps(BorderAndPadding.RIGHT);
if(bps.width != 0) {
- curBlockArea.addTrait(Trait.BORDER_AFTER, bps);
+ curBlock.addTrait(Trait.BORDER_AFTER, bps);
}
}
diff --git a/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 7c8fba848..89a7cbb26 100644
--- a/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -20,11 +20,12 @@ import java.util.Iterator;
* areas in the block-progression direction, such as Flow, Block, ListBlock.
*/
public abstract class BlockStackingLayoutManager extends AbstractLayoutManager {
- /** Reference to FO whose areas it's managing or to the traits
+ /**
+ * Reference to FO whose areas it's managing or to the traits
* of the FO.
*/
- LayoutManager curChildLM = null;
- BlockParent parentArea = null;
+ protected LayoutManager curChildLM = null;
+ protected BlockParent parentArea = null;
public BlockStackingLayoutManager(FObj fobj) {
super(fobj);
@@ -50,11 +51,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager {
protected MinOptMax resolveSpaceSpecifier(Area nextArea) {
SpaceSpecifier spaceSpec = new SpaceSpecifier(false);
- // Area prevArea = getCurrentArea().getLast();
- // if (prevArea != null) {
- // spaceSpec.addSpace(prevArea.getSpaceAfter());
- // }
- // spaceSpec.addSpace(nextArea.getSpaceBefore());
+ // Area prevArea = getCurrentArea().getLast();
+ // if (prevArea != null) {
+ // spaceSpec.addSpace(prevArea.getSpaceAfter());
+ // }
+ // spaceSpec.addSpace(nextArea.getSpaceBefore());
return spaceSpec.resolve(false);
}
@@ -96,36 +97,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager {
return false;
}
- // See if the whole thing fits, including space before
- // Calculate space between last child in curFlow and childArea
- //MinOptMax targetDim = parentArea.getAvailBPD();
MinOptMax spaceBefore = resolveSpaceSpecifier(childArea);
- //targetDim.subtract(spaceBefore);
- //if (targetDim.max >= childArea.getAllocationBPD().min) {
- //parentArea.addBlock(new InterBlockSpace(spaceBefore));
- // parentArea.addBlock((Block) childArea);
- // return false;
- //} else {
- parentArea.addBlock((Block) childArea);
- flush(); // hand off current area to parent
- // Probably need something like max BPD so we don't get into
- // infinite loops with large unbreakable chunks
-
- /*LayoutManager childLM =
- childArea.getGeneratingFObj(). getLayoutManager();
- if (childLM.splitArea(childArea, splitContext)) {
- //parentArea.addBlock(new InterBlockSpace(spaceBefore));
- parentArea.addBlock((Block) childArea);
- }*/
- //flush(); // hand off current area to parent
- //getParentArea(splitContext.nextArea);
- //getParentArea(childArea);
- // Check that reference IPD hasn't changed!!!
- // If it has, we must "reflow" the content
- //addChild(splitContext.nextArea);
- //addChild(childArea);
- return true;
- //}
+ parentArea.addBlock((Block) childArea);
+ flush(); // hand off current area to parent
+
+ return true;
}
diff --git a/src/org/apache/fop/layoutmgr/ContentLayoutManager.java b/src/org/apache/fop/layoutmgr/ContentLayoutManager.java
index a27d7f120..957d6edf5 100644
--- a/src/org/apache/fop/layoutmgr/ContentLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/ContentLayoutManager.java
@@ -60,8 +60,9 @@ public class ContentLayoutManager implements LayoutManager {
int middlefollow = maxtb;
while (!curLM.isFinished()) {
+ MinOptMax lastSize = null;
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stack.add(bp.getStackingSize());
+ lastSize = bp.getStackingSize();
childBreaks.add(bp);
if (bp.getLead() > lineLead) {
@@ -74,6 +75,9 @@ public class ContentLayoutManager implements LayoutManager {
middlefollow = bp.getMiddle();
}
}
+ if(lastSize != null) {
+ stack.add(lastSize);
+ }
}
if (maxtb - lineLead > middlefollow) {
diff --git a/src/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/org/apache/fop/layoutmgr/FlowLayoutManager.java
index 7ef504481..57b7e123f 100644
--- a/src/org/apache/fop/layoutmgr/FlowLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/FlowLayoutManager.java
@@ -1,6 +1,6 @@
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
@@ -42,7 +42,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
MinOptMax stackSize = new MinOptMax();
while ((curLM = getChildLM()) != null) {
- if(curLM.generatesInlineAreas()) {
+ if (curLM.generatesInlineAreas()) {
// problem
curLM.setFinished(true);
continue;
@@ -65,7 +65,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
// set stackLimit for remaining space
childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
- if(bp.isForcedBreak()) {
+ if (bp.isForcedBreak()) {
breakPage = true;
break;
}
@@ -75,16 +75,16 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
// check the stack bpd and if greater than available
// height then go to the last best break and return
// break position
- if(stackSize.opt > context.getStackLimit().opt) {
+ if (stackSize.opt > context.getStackLimit().opt) {
breakPage = true;
}
- if(breakPage) {
+ if (breakPage) {
return new BreakPoss(
new LeafPosition(this, blockBreaks.size() - 1));
}
}
setFinished(true);
- if(blockBreaks.size() > 0) {
+ if (blockBreaks.size() > 0) {
return new BreakPoss(
new LeafPosition(this, blockBreaks.size() - 1));
}
diff --git a/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java b/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
index 4788edf9c..99efc8809 100644
--- a/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
@@ -1,6 +1,6 @@
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
@@ -170,8 +170,9 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
LayoutManager lm = getChildLM();
if (lm != null) {
return lm.canBreakBefore(context);
- } else
+ } else {
return false; // ??? NO child LM?
+ }
}
protected MinOptMax getPrevIPD(LayoutManager lm) {
@@ -322,7 +323,7 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
m_prevBP = bp;
// if (bIsLast) {
- // setFinished(true); // Our last area, so indicate done
+ // setFinished(true); // Our last area, so indicate done
// }
return myBP;
}
diff --git a/src/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/org/apache/fop/layoutmgr/LineLayoutManager.java
index 36b798d59..445ce66cb 100644
--- a/src/org/apache/fop/layoutmgr/LineLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/LineLayoutManager.java
@@ -1,6 +1,6 @@
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
@@ -101,9 +101,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
}
/**
- * Call child layout managers to generate content as long as they
- * generate inline areas. If a block-level generating LM is found,
- * finish any line being filled and return to the parent LM.
+ * Call child layout managers to generate content.
+ * This gets the next break which is a full line.
+ *
*/
public BreakPoss getNextBreakPoss(LayoutContext context) {
// Get a break from currently active child LM
@@ -269,7 +269,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
// Don't justify last line in the sequence or if forced line-end
int talign = bTextAlignment;
- if((bTextAlignment == TextAlign.JUSTIFY
+ if ((bTextAlignment == TextAlign.JUSTIFY
&& (m_prevBP.isForcedBreak()
|| isFinished()))) {
talign = TextAlign.START;
@@ -384,8 +384,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
// points remain. Choose the best break.
if (hyph != null) {
return new HyphContext(hyph.getHyphenationPoints());
- } else
+ } else {
return null;
+ }
}
@@ -413,27 +414,27 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
for(Iterator iter = m_vecInlineBreaks.listIterator(prevLineEnd);
iter.hasNext(); ) {
BreakPoss bp = (BreakPoss)iter.next();
- if(bp.getLead() > lineLead) {
+ if (bp.getLead() > lineLead) {
lineLead = bp.getLead();
}
- if(bp.getTotal() > maxtb) {
+ if (bp.getTotal() > maxtb) {
maxtb = bp.getTotal();
}
- if(bp.getMiddle() > middlefollow) {
+ if (bp.getMiddle() > middlefollow) {
middlefollow = bp.getMiddle();
}
// the stacking size of textLM accumulate for each break
// so the ipd is only added at the end of each LM
- if(bp.getLayoutManager() != lastLM) {
- if(lastLM != null) {
+ if (bp.getLayoutManager() != lastLM) {
+ if (lastLM != null) {
actual.add(lastBP.getStackingSize());
}
lastLM = bp.getLayoutManager();
}
lastBP = bp;
}
- if(lastBP != null) {
+ if (lastBP != null) {
// add final ipd
actual.add(lastBP.getStackingSize());
// ATTENTION: make sure this hasn't gotten start space for next
@@ -441,7 +442,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
actual.add(lastBP.resolveTrailingSpace(true));
}
- if(maxtb - lineLead > middlefollow) {
+ if (maxtb - lineLead > middlefollow) {
middlefollow = maxtb - lineLead;
}
@@ -481,7 +482,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
int indent = 0;
switch (textalign) {
case TextAlign.JUSTIFY:
- if(realWidth != 0) {
+ if (realWidth != 0) {
dAdjust = (targetWith - realWidth) / realWidth;
}
break;
@@ -562,10 +563,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
lc.setLeadingSpace(lc.getTrailingSpace());
lc.setTrailingSpace(new SpaceSpecifier(false));
}
-if(lc.getTrailingSpace() != null) {
addSpace(lineArea, lc.getTrailingSpace().resolve(true),
lc.getSpaceAdjust());
-}
parentLM.addChild(lineArea);
}
setCurrentArea(null); // ?? necessary
diff --git a/src/org/apache/fop/layoutmgr/PageLayoutManager.java b/src/org/apache/fop/layoutmgr/PageLayoutManager.java
index b1d3e3cba..2e3199915 100644
--- a/src/org/apache/fop/layoutmgr/PageLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/PageLayoutManager.java
@@ -181,12 +181,14 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
* For now, only handle normal flow areas.
*/
public boolean addChild(Area childArea) {
- if (childArea == null)
+ if (childArea == null) {
return false;
+ }
if (childArea.getAreaClass() == Area.CLASS_NORMAL) {
return placeFlowRefArea(childArea);
- } else
+ } else {
; // TODO: all the others!
+ }
return false;
}
@@ -421,20 +423,20 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
*/
private boolean needEmptyPage(int breakValue) {
return false;
- // if (breakValue == Constants.PAGE || curPage.isEmpty()) {
- // // any page is OK or we already have an empty page
- // return false;
- // }
- // else {
- // /* IF we are on the kind of page we need, we'll need a new page. */
- // if (curPage.getPageNumber()%2 != 0) {
- // // Current page is odd
- // return (breakValue == Constants.ODD_PAGE);
- // }
- // else {
- // return (breakValue == Constants.EVEN_PAGE);
- // }
- // }
+ // if (breakValue == Constants.PAGE || curPage.isEmpty()) {
+ // // any page is OK or we already have an empty page
+ // return false;
+ // }
+ // else {
+ // /* IF we are on the kind of page we need, we'll need a new page. */
+ // if (curPage.getPageNumber()%2 != 0) {
+ // // Current page is odd
+ // return (breakValue == Constants.ODD_PAGE);
+ // }
+ // else {
+ // return (breakValue == Constants.EVEN_PAGE);
+ // }
+ // }
}
/**
diff --git a/src/org/apache/fop/layoutmgr/PositionIterator.java b/src/org/apache/fop/layoutmgr/PositionIterator.java
index 5e951a09f..5032f50a4 100644
--- a/src/org/apache/fop/layoutmgr/PositionIterator.java
+++ b/src/org/apache/fop/layoutmgr/PositionIterator.java
@@ -32,9 +32,9 @@ public abstract class PositionIterator implements Iterator {
return m_childLM;
}
- abstract protected LayoutManager getLM(Object nextObj);
+ protected abstract LayoutManager getLM(Object nextObj);
- abstract protected Position getPos(Object nextObj);
+ protected abstract Position getPos(Object nextObj);
private void lookAhead() {
if (m_parentIter.hasNext()) {
diff --git a/src/org/apache/fop/layoutmgr/TextLayoutManager.java b/src/org/apache/fop/layoutmgr/TextLayoutManager.java
index 0eb1b977e..a406d7e57 100644
--- a/src/org/apache/fop/layoutmgr/TextLayoutManager.java
+++ b/src/org/apache/fop/layoutmgr/TextLayoutManager.java
@@ -55,7 +55,7 @@ public class TextLayoutManager extends AbstractLayoutManager {
private ArrayList m_vecAreaInfo;
/** Non-space characters on which we can end a line. */
- static private final String s_breakChars = "-/" ;
+ private static final String s_breakChars = "-/" ;
private char[] chars;
private TextInfo textInfo;
@@ -450,19 +450,19 @@ public class TextLayoutManager extends AbstractLayoutManager {
double dSpaceAdjust = context.getSpaceAdjust();
if (dSpaceAdjust > 0.0) {
// Stretch by factor
- // System.err.println("Potential stretch = " +
- // (ai.m_ipdArea.max - ai.m_ipdArea.opt));
+ // System.err.println("Potential stretch = " +
+ // (ai.m_ipdArea.max - ai.m_ipdArea.opt));
iAdjust = (int)((double)(ai.m_ipdArea.max -
ai.m_ipdArea.opt) * dSpaceAdjust);
} else if (dSpaceAdjust < 0.0) {
// Shrink by factor
- // System.err.println("Potential shrink = " +
- // (ai.m_ipdArea.opt - ai.m_ipdArea.min));
+ // System.err.println("Potential shrink = " +
+ // (ai.m_ipdArea.opt - ai.m_ipdArea.min));
iAdjust = (int)((double)(ai.m_ipdArea.opt -
ai.m_ipdArea.min) * dSpaceAdjust);
}
- // System.err.println("Text adjustment factor = " + dSpaceAdjust +
- // " total=" + iAdjust);
+ // System.err.println("Text adjustment factor = " + dSpaceAdjust +
+ // " total=" + iAdjust);
// Make an area containing all characters between start and end.
Word word = null;
diff --git a/src/org/apache/fop/layoutmgr/TraitSetter.java b/src/org/apache/fop/layoutmgr/TraitSetter.java
index 6244e1424..0e2cb4f53 100644
--- a/src/org/apache/fop/layoutmgr/TraitSetter.java
+++ b/src/org/apache/fop/layoutmgr/TraitSetter.java
@@ -56,10 +56,10 @@ public class TraitSetter {
Object oTrait) {
int iBP = bpProps.getBorderWidth(iSide, bDiscard);
if (iBP > 0) {
- // area.addTrait(new Trait(oTrait,
- // new BorderProps(bpProps.getBorderStyle(iSide),
- // iBP,
- // bpProps.getBorderColor(iSide))));
+ // area.addTrait(new Trait(oTrait,
+ // new BorderProps(bpProps.getBorderStyle(iSide),
+ // iBP,
+ // bpProps.getBorderColor(iSide))));
area.addTrait(oTrait,
new BorderProps(bpProps.getBorderStyle(iSide),
iBP, bpProps.getBorderColor(iSide)));
diff --git a/src/org/apache/fop/layoutmgr/table/Body.java b/src/org/apache/fop/layoutmgr/table/Body.java
index ff69e1d05..784eaddc3 100644
--- a/src/org/apache/fop/layoutmgr/table/Body.java
+++ b/src/org/apache/fop/layoutmgr/table/Body.java
@@ -87,7 +87,7 @@ public class Body extends BlockStackingLayoutManager {
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
stackSize.add(bp.getStackingSize());
- if (stackSize.min > context.getStackLimit().max) {
+ if (stackSize.opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
reset(lastPos.getPosition());