From d8494c1892c5849057ba19449baafcac80a55559 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Sat, 26 Apr 2008 23:07:51 +0000 Subject: [PATCH] Minor refactoring: consolidate getPSLM().notifyEndOfLayout(fobj.getId()) in AbstractLayoutManager.notifyEndOfLayout() git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@651867 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/AbstractLayoutManager.java | 16 +++++++++++++--- .../layoutmgr/BlockContainerLayoutManager.java | 18 +++++++----------- .../fop/layoutmgr/BlockLayoutManager.java | 5 +++-- .../layoutmgr/list/ListBlockLayoutManager.java | 2 +- .../list/ListItemContentLayoutManager.java | 4 ++-- .../layoutmgr/list/ListItemLayoutManager.java | 4 ++-- .../table/TableCellLayoutManager.java | 4 ++-- .../layoutmgr/table/TableLayoutManager.java | 2 +- 8 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index 656b5e2df..76c5ad4da 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -60,7 +60,6 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager /** child LM and child LM iterator during getNextKnuthElement phase */ protected LayoutManager curChildLM = null; - /** child LM and child LM iterator during getNextKnuthElement phase */ protected ListIterator childLMiter = null; private int lastGeneratedPosition = -1; @@ -231,6 +230,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager /** * @see PageSequenceLayoutManager#getCurrentPage() + * @return the {@link Page} instance corresponding to the current page */ public Page getCurrentPage() { return getPSLM().getCurrentPage(); @@ -344,7 +344,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager * @param targetArea the area to set the attributes on */ protected void transferForeignAttributes(Area targetArea) { - Map atts = getFObj().getForeignAttributes(); + Map atts = fobj.getForeignAttributes(); targetArea.setForeignAttributes(atts); } @@ -373,7 +373,17 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager getPSLM().addIDToPage(fobj.getId()); } } - + + /** + * Notifies the {@link PageSequenceLayoutManager} that layout + * for this LM has ended. + */ + protected void notifyEndOfLayout() { + if (fobj != null) { + getPSLM().notifyEndOfLayout(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 a44669371..0e6c2cb40 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -442,8 +442,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } } } else { - int maxbpd = context.getStackLimitBP().opt; - allocBPD = maxbpd; + allocBPD = context.getStackLimitBP().opt; if (!switchedProgressionDirection) { autoHeight = true; } @@ -601,13 +600,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } public boolean isOverflow() { - if (isEmpty()) { - return false; - } else { - return (deferredAlg.getPageBreaks().size() > 1) - || (deferredAlg.totalWidth - deferredAlg.totalShrink) - > deferredAlg.getLineWidth(); - } + return !isEmpty() + && ((deferredAlg.getPageBreaks().size() > 1) + || (deferredAlg.totalWidth - deferredAlg.totalShrink) + > deferredAlg.getLineWidth()); } public int getOverflowAmount() { @@ -879,8 +875,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager viewportBlockArea = null; referenceArea = null; resetSpaces(); - - getPSLM().notifyEndOfLayout(fobj.getId()); + + notifyEndOfLayout(); } /** diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 48bf47caf..d129be666 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -153,6 +153,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager } /** + * @param pos ... * @return true if new child lms were added */ protected boolean createNextChildLMs(int pos) { @@ -210,7 +211,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public int getKeepTogetherStrength() { - KeepProperty keep = getBlockFO().getKeepTogether(); + KeepProperty keep = getBlockFO().getKeepTogether(); int strength = KeepUtil.getCombinedBlockLevelKeepStrength(keep); strength = Math.max(strength, getParentKeepTogetherStrength()); return strength; @@ -392,7 +393,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager resetSpaces(); // Notify end of block layout manager to the PSLM - getPSLM().notifyEndOfLayout(getBlockFO().getId()); + notifyEndOfLayout(); } /** diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java index 57114eee2..7be146d0d 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java @@ -219,7 +219,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager curBlockArea = null; resetSpaces(); - getPSLM().notifyEndOfLayout(fobj.getId()); + notifyEndOfLayout(); } /** diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java index e3b88b0ac..edee772d6 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java @@ -172,7 +172,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { curBlockArea = null; - getPSLM().notifyEndOfLayout(fobj.getId()); + notifyEndOfLayout(); } /** @@ -236,6 +236,6 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { public int getKeepWithPreviousStrength() { return KEEP_AUTO; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 5e7288f04..d0e8665e7 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -288,7 +288,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager if (end[1] + 1 == elementLists[1].size()) { keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnBody); } - + // compute penalty height and box height int penaltyHeight = step + getMaxRemainingHeight(fullHeights, partialHeights) @@ -557,7 +557,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager curBlockArea = null; resetSpaces(); - getPSLM().notifyEndOfLayout(fobj.getId()); + notifyEndOfLayout(); } /** diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index 6067af4bc..430356bec 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -199,7 +199,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager p.setP(0); } - getPSLM().notifyEndOfLayout(fobj.getId()); + notifyEndOfLayout(); setFinished(true); return returnList; @@ -575,7 +575,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager public int getKeepWithPreviousStrength() { return KEEP_AUTO; //TODO FIX ME (table-cell has no keep-with-previous!) } - + // --------- Property Resolution related functions --------- // /** diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index 75189a6b9..0fe47d7b4 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -381,7 +381,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager resetSpaces(); curBlockArea = null; - getPSLM().notifyEndOfLayout(fobj.getId()); + notifyEndOfLayout(); } /** -- 2.39.5