aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2008-03-23 19:36:36 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2008-03-23 19:36:36 +0000
commit40cdce2da150ea5b0061d0ed2250d30ce0e5584c (patch)
treeded4afe9d4295ea8c7f018f4a058df4fe259e50f /src/java
parent486aaffb5c0357779f252775db5d6aa51ab020a9 (diff)
downloadxmlgraphics-fop-40cdce2da150ea5b0061d0ed2250d30ce0e5584c.tar.gz
xmlgraphics-fop-40cdce2da150ea5b0061d0ed2250d30ce0e5584c.zip
Cleanup and minor refactoring:
* consolidate addId() in AbstractLayoutManager * replace getPSLM().addIdToPage(getXXX().getId()) in various LMs Smaller changes/cleanup in the affected LMs include: * removal of some redundant casts * simplified conditionals * avoid duplicating the reference to the FObj as much as possible: the reference is already stored in AbstractLM, yet every subclass seems to add another reference... git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@640242 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java16
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java16
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java8
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java7
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java17
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java23
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java5
-rwxr-xr-xsrc/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java9
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java26
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java12
-rw-r--r--src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java20
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java7
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java6
19 files changed, 79 insertions, 139 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
index f75fffc0d..656b5e2df 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
@@ -113,7 +113,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
if (curChildLM != null && !curChildLM.isFinished()) {
return curChildLM;
}
- while (childLMiter.hasNext()) {
+ if (childLMiter.hasNext()) {
curChildLM = (LayoutManager) childLMiter.next();
curChildLM.initialize();
return curChildLM;
@@ -350,6 +350,10 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
/**
* Registers the FO's markers on the current PageViewport
+ *
+ * @param isStarting boolean indicating whether the markers qualify as 'starting'
+ * @param isFirst boolean indicating whether the markers qualify as 'first'
+ * @param isLast boolean indicating whether the markers qualify as 'last'
*/
protected void addMarkersToPage(boolean isStarting, boolean isFirst, boolean isLast) {
if (this.markers != null) {
@@ -361,10 +365,18 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
}
}
+ /**
+ * Registers the FO's id on the current PageViewport
+ */
+ protected void addId() {
+ if (fobj != null) {
+ getPSLM().addIDToPage(fobj.getId());
+ }
+ }
+
/** {@inheritDoc} */
public String toString() {
return (super.toString() + (fobj != null ? "[fobj=" + fobj.toString() + "]" : ""));
}
-
}
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index 5e5613898..e8ca88c1c 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -248,7 +248,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
MinOptMax stackLimit = new MinOptMax(relDims.bpd);
- LinkedList returnedList = null;
+ LinkedList returnedList;
LinkedList contentList = new LinkedList();
LinkedList returnList = new LinkedList();
@@ -602,11 +602,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
public boolean isOverflow() {
- if (isEmpty()) {
- return false;
- } else {
- return (deferredAlg.getPageBreaks().size() > 1);
- }
+ return !isEmpty() && (deferredAlg.getPageBreaks().size() > 1);
}
protected LayoutManager getTopLevelLM() {
@@ -708,7 +704,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
}
- LayoutManager childLM = null;
+ LayoutManager childLM;
LayoutManager lastLM = null;
LayoutContext lc = new LayoutContext(0);
lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
@@ -737,7 +733,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
Position innerPosition = pos;
if (pos instanceof NonLeafPosition) {
- innerPosition = ((NonLeafPosition)pos).getPosition();
+ innerPosition = pos.getPosition();
}
if (pos instanceof BlockContainerPosition) {
if (bcpos != null) {
@@ -773,7 +769,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
}
- getPSLM().addIDToPage(getBlockContainerFO().getId());
+ addId();
addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
@@ -874,7 +870,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
referenceArea = null;
resetSpaces();
- getPSLM().notifyEndOfLayout(((BlockContainer)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
}
/**
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
index a65c0ed9b..f5270107c 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
@@ -147,7 +147,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager
* @return true if there are more child lms
*/
public boolean hasNext() {
- return (curPos < listLMs.size()) ? true : createNextChildLMs(curPos);
+ return (curPos < listLMs.size()) || createNextChildLMs(curPos);
}
/**
@@ -250,7 +250,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager
addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
}
- LayoutManager childLM = null;
+ LayoutManager childLM;
LayoutManager lastLM = null;
LayoutContext lc = new LayoutContext(0);
lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
@@ -280,7 +280,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager
Position innerPosition = pos;
if (pos instanceof NonLeafPosition) {
//Not all elements are wrapped
- innerPosition = ((NonLeafPosition) pos).getPosition();
+ innerPosition = pos.getPosition();
}
if (innerPosition == null) {
// pos was created by this BlockLM and was inside an element
@@ -309,7 +309,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager
}
}
- getPSLM().addIDToPage(getBlockFO().getId());
+ addId();
addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
index 6426f15db..38e0c35bc 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
@@ -124,13 +124,6 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage
}
/**
- * {@inheritDoc}
- */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
-
- /**
* Returns the image of foreign object area to be put into
* the viewport.
* @return the appropriate area
diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
index 41d4af1c1..c92bdb6fc 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
@@ -51,7 +51,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
* Constructor
*
* @param node the formatting object that creates this area
- * @todo better retrieval of font info
+ * TODO better retrieval of font info
*/
public AbstractPageNumberCitationLayoutManager(AbstractPageNumberCitation node) {
super(node);
@@ -83,7 +83,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
/** {@inheritDoc} */
public InlineArea get(LayoutContext context) {
- curArea = getPageNumberCitationInlineArea(parentLM);
+ curArea = getPageNumberCitationInlineArea();
return curArea;
}
@@ -99,12 +99,15 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
}
/**
- * if id can be resolved then simply return a word, otherwise
+ * If id can be resolved then simply return a word, otherwise
* return a resolvable area
+ *
+ * @param parentLM the parent LayoutManager
+ * @return a corresponding InlineArea
*/
- private InlineArea getPageNumberCitationInlineArea(LayoutManager parentLM) {
+ private InlineArea getPageNumberCitationInlineArea() {
PageViewport page = getPSLM().getFirstPVWithID(fobj.getRefId());
- TextArea text = null;
+ TextArea text;
if (page != null) {
String str = page.getPageNumberString();
// get page string from parent, build area
@@ -150,9 +153,5 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
return width;
}
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
index 0430eef0c..b53e442d4 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
@@ -45,7 +45,6 @@ import org.apache.fop.util.CharUtilities;
* LayoutManager for the fo:character formatting object
*/
public class CharacterLayoutManager extends LeafNodeLayoutManager {
- private Character fobj;
private MinOptMax letterSpaceIPD;
private int hyphIPD;
private Font font;
@@ -57,13 +56,13 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager {
* @param node the fo:character formatting object
*/
public CharacterLayoutManager(Character node) {
- // @todo better null checking of node
super(node);
- fobj = node;
}
/** {@inheritDoc} */
public void initialize() {
+ Character fobj = (Character)this.fobj;
+
FontInfo fi = fobj.getFOEventHandler().getFontInfo();
FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
@@ -90,7 +89,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager {
text.addWord(String.valueOf(ch), 0);
}
TraitSetter.setProducerID(text, node.getId());
- TraitSetter.addTextDecoration(text, fobj.getTextDecoration());
+ TraitSetter.addTextDecoration(text, node.getTextDecoration());
return text;
}
@@ -105,6 +104,8 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager {
return null;
}
+ Character fobj = (Character)this.fobj;
+
ipd = new MinOptMax(font.getCharWidth(fobj.getCharacter()));
curArea.setIPD(ipd.opt);
@@ -178,14 +179,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager {
/** {@inheritDoc} */
public boolean applyChanges(List oldList) {
setFinished(false);
- if (isSomethingChanged) {
- // there is nothing to do,
- // possible changes have already been applied
- // in the hyphenate() method
- return true;
- } else {
- return false;
- }
+ return isSomethingChanged;
}
/** {@inheritDoc} */
@@ -238,10 +232,5 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager {
return returnList;
}
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
-
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java
index 4ffafb061..7ca9e0d5e 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java
@@ -31,12 +31,10 @@ import org.apache.fop.fo.flow.InlineContainer;
* and id areas are maintained for later retrieval.
*/
public class ICLayoutManager extends LeafNodeLayoutManager {
- private InlineContainer fobj;
private List childrenLM;
public ICLayoutManager(InlineContainer node, List childLM) {
super(node);
- fobj = node;
childrenLM = childLM;
}
@@ -44,7 +42,4 @@ public class ICLayoutManager extends LeafNodeLayoutManager {
return null;
}
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
index 1f53e792e..e9919e02f 100755
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
@@ -297,7 +297,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
);
}
- while ((curLM = (LayoutManager) getChildLM()) != null) {
+ while ((curLM = getChildLM()) != null) {
if (!(curLM instanceof InlineLevelLayoutManager)) {
// A block LM
@@ -436,7 +436,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
// layout context given to lastLM, but must be cleared in the
// layout context given to the other LMs.
LinkedList positionList = new LinkedList();
- NonLeafPosition pos = null;
+ NonLeafPosition pos;
LayoutManager lastLM = null;// last child LM in this iterator
Position lastPos = null;
while (parentIter.hasNext()) {
@@ -600,9 +600,4 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
return this.auxiliaryPosition;
}
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
-
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
index 4d0872a6d..bf1538a7c 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
@@ -75,15 +75,9 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
private Area currentArea; // LineArea or InlineParent
- //private BreakPoss prevBP;
-
/** The child layout context */
protected LayoutContext childLC;
- private boolean bAreaCreated = false;
-
- //private LayoutManager currentLM = null;
-
/** Used to store previous content IPD for each child LM. */
private HashMap hmPrevIPD = new HashMap();
@@ -171,14 +165,6 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
}
/**
- * This method is called by addAreas() so IDs can be added to a page for FOs that
- * support the 'id' property.
- */
- protected void addId() {
- // Do nothing here, overriden in subclasses that have an 'id' property.
- }
-
- /**
* Returns the current area.
* @return the current area
*/
@@ -255,7 +241,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
// "unwrap" the Position stored in each element of oldList
while (oldListIterator.hasNext()) {
element = (KnuthElement) oldListIterator.next();
- element.setPosition(((NonLeafPosition)element.getPosition()).getPosition());
+ element.setPosition(element.getPosition().getPosition());
}
// The last element may not have a layout manager (its position == null);
@@ -288,7 +274,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
// "unwrap" the Position stored in each element of oldList
while (oldListIterator.hasNext()) {
element = (KnuthElement) oldListIterator.next();
- element.setPosition(((NonLeafPosition)element.getPosition()).getPosition());
+ element.setPosition(element.getPosition().getPosition());
}
((InlineLevelLayoutManager)
@@ -298,14 +284,14 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
/** {@inheritDoc} */
public void getWordChars(StringBuffer sbChars, Position pos) {
- Position newPos = ((NonLeafPosition) pos).getPosition();
+ Position newPos = pos.getPosition();
((InlineLevelLayoutManager)
newPos.getLM()).getWordChars(sbChars, newPos);
}
/** {@inheritDoc} */
public void hyphenate(Position pos, HyphContext hc) {
- Position newPos = ((NonLeafPosition) pos).getPosition();
+ Position newPos = pos.getPosition();
((InlineLevelLayoutManager)
newPos.getLM()).hyphenate(newPos, hc);
}
@@ -318,7 +304,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement) oldListIterator.next();
oldElement.setPosition
- (((NonLeafPosition) oldElement.getPosition()).getPosition());
+ (oldElement.getPosition().getPosition());
}
// reset the iterator
oldListIterator = oldList.listIterator();
@@ -385,7 +371,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement) oldListIterator.next();
oldElement.setPosition
- (((NonLeafPosition) oldElement.getPosition()).getPosition());
+ (oldElement.getPosition().getPosition());
}
// reset the iterator
oldListIterator = oldList.listIterator();
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
index 5f93ab98c..f4bcde96f 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
@@ -339,11 +339,6 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
return returnList;
}
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
-
/**
* {@inheritDoc}
*/
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
index 78d126194..fb5e9ee4d 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
@@ -65,8 +65,6 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager
/** The alignment context applying to this area */
protected AlignmentContext alignmentContext = null;
- private MinOptMax ipd;
-
/** Flag to indicate if something was changed as part of the getChangeKnuthElements sequence */
protected boolean isSomethingChanged = false;
/** Our area info for the Knuth elements */
@@ -205,14 +203,6 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager
}
/**
- * This method is called by addAreas() so IDs can be added to a page for FOs that
- * support the 'id' property.
- */
- protected void addId() {
- // Do nothing here, overriden in subclasses that have an 'id' property.
- }
-
- /**
* Offset this area.
* Offset the inline area in the bpd direction when adding the
* inline area.
diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
index 88f1d283c..1aaaaf527 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
@@ -42,7 +42,7 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager {
* Constructor
*
* @param node the fo:page-number formatting object that creates the area
- * @todo better null checking of node, font
+ * TODO better null checking of node, font
*/
public PageNumberLayoutManager(PageNumber node) {
super(node);
@@ -131,9 +131,5 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager {
return width;
}
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
}
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
index e17880e59..c17ddc711 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
@@ -156,11 +156,11 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager
addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
}
- getPSLM().addIDToPage(getListBlockFO().getId());
+ addId();
// the list block contains areas stacked from each list item
- LayoutManager childLM = null;
+ LayoutManager childLM;
LayoutContext lc = new LayoutContext(0);
LayoutManager firstLM = null;
LayoutManager lastLM = null;
@@ -181,10 +181,10 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager
}
if (pos instanceof NonLeafPosition
&& (pos.getPosition() != null)
- && ((NonLeafPosition) pos).getPosition().getLM() != this) {
+ && pos.getPosition().getLM() != this) {
// pos was created by a child of this ListBlockLM
- positionList.add(((NonLeafPosition) pos).getPosition());
- lastLM = ((NonLeafPosition) pos).getPosition().getLM();
+ positionList.add(pos.getPosition());
+ lastLM = pos.getPosition().getLM();
if (firstLM == null) {
firstLM = lastLM;
}
@@ -218,7 +218,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager
curBlockArea = null;
resetSpaces();
- getPSLM().notifyEndOfLayout(((ListBlock)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
}
/**
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
index 363f6493f..8b0028a8f 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
@@ -115,9 +115,9 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager {
LayoutContext layoutContext) {
getParentArea(null);
- getPSLM().addIDToPage(getPartFO().getId());
+ addId();
- LayoutManager childLM = null;
+ LayoutManager childLM;
LayoutContext lc = new LayoutContext(0);
LayoutManager firstLM = null;
LayoutManager lastLM = null;
@@ -141,8 +141,8 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager {
}
if (pos instanceof NonLeafPosition) {
// pos was created by a child of this ListBlockLM
- positionList.add(((NonLeafPosition) pos).getPosition());
- lastLM = ((NonLeafPosition) pos).getPosition().getLM();
+ positionList.add(pos.getPosition());
+ lastLM = pos.getPosition().getLM();
if (firstLM == null) {
firstLM = lastLM;
}
@@ -172,7 +172,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager {
curBlockArea = null;
- getPSLM().notifyEndOfLayout(((AbstractListItemPart)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
}
/**
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
index 5c6e9aeb1..c6b5b8cf9 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
@@ -73,8 +73,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
private LinkedList labelList = null;
private LinkedList bodyList = null;
- private int listItemHeight;
-
private boolean discardBorderBefore;
private boolean discardBorderAfter;
private boolean discardPaddingBefore;
@@ -84,7 +82,9 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
private boolean keepWithNextPendingOnLabel;
private boolean keepWithNextPendingOnBody;
-
+
+ private int listItemHeight;
+
private class ListItemPosition extends Position {
private int iLabelFirstIndex;
private int iLabelLastIndex;
@@ -307,12 +307,12 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
int additionalPenaltyHeight = 0;
KnuthElement endEl = (KnuthElement)elementLists[0].get(end[0]);
if (endEl instanceof KnuthPenalty) {
- additionalPenaltyHeight = ((KnuthPenalty)endEl).getW();
+ additionalPenaltyHeight = endEl.getW();
}
endEl = (KnuthElement)elementLists[1].get(end[1]);
if (endEl instanceof KnuthPenalty) {
additionalPenaltyHeight = Math.max(
- additionalPenaltyHeight, ((KnuthPenalty)endEl).getW());
+ additionalPenaltyHeight, endEl.getW());
}
int boxHeight = step - addedBoxHeight - penaltyHeight;
@@ -419,10 +419,10 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
// body
// "unwrap" the Positions stored in the elements
ListIterator oldListIterator = oldList.listIterator();
- KnuthElement oldElement = null;
+ KnuthElement oldElement;
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement)oldListIterator.next();
- Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition();
+ Position innerPosition = oldElement.getPosition().getPosition();
//log.debug(" BLM> unwrapping: " + (oldElement.isBox()
// ? "box " : (oldElement.isGlue() ? "glue " : "penalty"))
// + " creato da " + oldElement.getLayoutManager().getClass().getName());
@@ -465,7 +465,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
LayoutContext layoutContext) {
getParentArea(null);
- getPSLM().addIDToPage(getListItemFO().getId());
+ addId();
LayoutContext lc = new LayoutContext(0);
Position firstPos = null;
@@ -484,7 +484,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
}
if (pos instanceof NonLeafPosition && pos.getPosition() != null) {
// pos contains a ListItemPosition created by this ListBlockLM
- positionList.add(((NonLeafPosition) pos).getPosition());
+ positionList.add(pos.getPosition());
}
}
@@ -560,7 +560,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
curBlockArea = null;
resetSpaces();
- getPSLM().notifyEndOfLayout(((ListItem)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
}
/**
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
index 6d2e49e96..2e5bbdf1f 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
@@ -23,7 +23,6 @@ import org.apache.fop.fo.flow.table.TableAndCaption;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
@@ -36,8 +35,7 @@ import org.apache.fop.area.Block;
* @todo Implement getNextKnuthElements()
*/
public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
- private TableAndCaption fobj;
-
+
private Block curBlockArea;
//private List childBreaks = new java.util.ArrayList();
@@ -48,7 +46,6 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
*/
public TableAndCaptionLayoutManager(TableAndCaption node) {
super(node);
- fobj = node;
}
/**
@@ -134,7 +131,7 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
- getPSLM().addIDToPage(fobj.getId());
+ addId();
/* TODO: Reimplement using Knuth approach
LayoutManager childLM;
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
index 4c21df937..674fd9a90 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
@@ -23,7 +23,6 @@ import org.apache.fop.fo.flow.table.TableCaption;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
@@ -34,7 +33,6 @@ import org.apache.fop.area.Block;
* @todo Implement getNextKnuthElements()
*/
public class TableCaptionLayoutManager extends BlockStackingLayoutManager {
- private TableCaption fobj;
private Block curBlockArea;
@@ -46,7 +44,6 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager {
*/
public TableCaptionLayoutManager(TableCaption node) {
super(node);
- fobj = node;
}
/**
@@ -133,7 +130,7 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager {
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
- getPSLM().addIDToPage(fobj.getId());
+ addId();
/* TODO: Reimplement using Knuth approach
LayoutManager childLM;
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
index df23838f9..8acfebca0 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
@@ -136,7 +136,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
cellIPD = referenceIPD;
cellIPD -= getIPIndents();
- LinkedList returnedList = null;
+ LinkedList returnedList;
LinkedList contentList = new LinkedList();
LinkedList returnList = new LinkedList();
@@ -242,7 +242,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
p.setP(0);
}
- getPSLM().notifyEndOfLayout(((TableCell)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
setFinished(true);
return returnList;
@@ -330,7 +330,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
int firstRowHeight) {
getParentArea(null);
- getPSLM().addIDToPage(getTableCell().getId());
+ addId();
int borderBeforeWidth = primaryGridUnit.getBeforeBorderWidth(startRow, borderBeforeWhich);
int borderAfterWidth = primaryGridUnit.getAfterBorderWidth(endRow, borderAfterWhich);
@@ -419,7 +419,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
int dx = xoffset;
for (int x = 0; x < gridUnits.length; x++) {
int ipd = getTable().getColumn(primaryGridUnit.getColIndex() + x)
- .getColumnWidth().getValue((PercentBaseContext) getParent());
+ .getColumnWidth().getValue(getParent());
if (blocks[y][x] != null) {
Block block = blocks[y][x];
adjustYOffset(block, dy);
@@ -491,7 +491,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
Block rowBackgroundArea = getBackgroundArea(paddingRectBPD, borderBeforeWidth);
((TableLayoutManager) parentLM).addBackgroundArea(rowBackgroundArea);
TraitSetter.addBackground(rowBackgroundArea, row.getCommonBorderPaddingBackground(),
- (TableLayoutManager) parentLM,
+ parentLM,
-xoffset - startIndent, -borderBeforeWidth,
parentLM.getContentAreaIPD(), firstRowHeight);
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
index 0b3967643..d6bba5cb5 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
@@ -233,7 +233,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager
// Elements for the table-header/footer/body
- LinkedList contentKnuthElements = null;
+ LinkedList contentKnuthElements;
contentLM = new TableContentLayoutManager(this);
LayoutContext childLC = new LayoutContext(0);
/*
@@ -319,7 +319,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
- getPSLM().addIDToPage(getTable().getId());
+ addId();
// add space before, in order to implement display-align = "center" or "after"
if (layoutContext.getSpaceBefore() != 0) {
@@ -379,7 +379,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager
resetSpaces();
curBlockArea = null;
- getPSLM().notifyEndOfLayout(((Table)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
}
/**