You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2009/08/26 20:50:11 UTC
svn commit: r808157 [1/2] - in /xmlgraphics/fop/trunk:
src/java/org/apache/fop/layoutmgr/ src/java/org/apache/fop/layoutmgr/inline/
src/java/org/apache/fop/layoutmgr/list/ src/java/org/apache/fop/render/pdf/
test/layoutengine/standard-testcases/
Author: vhennebert
Date: Wed Aug 26 18:50:10 2009
New Revision: 808157
URL: http://svn.apache.org/viewvc?rev=808157&view=rev
Log:
Merged back ChangingIPDHack branch into Trunk
Added:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/flow_changing-ipd_1.xml
- copied unchanged from r808152, xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_1.xml
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/flow_changing-ipd_2.xml
- copied unchanged from r808152, xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_2.xml
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/flow_changing-ipd_3.xml
- copied unchanged from r808152, xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_3.xml
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/flow_changing-ipd_4.xml
- copied unchanged from r808152, xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_4.xml
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/flow_changing-ipd_block-container_1.xml
- copied unchanged from r808152, xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_block-container_1.xml
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/flow_changing-ipd_block-container_2.xml
- copied unchanged from r808152, xmlgraphics/fop/branches/Temp_ChangingIPDHack/test/layoutengine/standard-testcases/flow_changing-ipd_block-container_2.xml
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Position.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFEventProducer.xml
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java Wed Aug 26 18:50:10 2009
@@ -19,8 +19,12 @@
package org.apache.fop.layoutmgr;
+import java.util.List;
+import java.util.Stack;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FObj;
@@ -253,4 +257,20 @@
return fobj;
}
+ /** {@inheritDoc} */
+ public void reset() {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ /** {@inheritDoc} */
+ public boolean isRestartable() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
+ Position positionAtIPDChange, LayoutManager restartAtLM) {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java Wed Aug 26 18:50:10 2009
@@ -19,6 +19,8 @@
package org.apache.fop.layoutmgr;
+import java.util.Collections;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -27,6 +29,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.Constants;
+import org.apache.fop.layoutmgr.BreakingAlgorithm.KnuthNode;
import org.apache.fop.traits.MinOptMax;
import org.apache.fop.util.ListUtil;
@@ -247,6 +250,11 @@
*/
protected abstract List getNextKnuthElements(LayoutContext context, int alignment);
+ protected List getNextKnuthElements(LayoutContext context, int alignment,
+ Position positionAtIPDChange, LayoutManager restartAtLM) {
+ throw new UnsupportedOperationException("TODO: implement acceptable fallback");
+ }
+
/** @return true if there's no content that could be handled. */
public boolean isEmpty() {
return (this.blockLists.isEmpty());
@@ -293,14 +301,6 @@
/**
* Starts the page breaking process.
* @param flowBPD the constant available block-progression-dimension (used for every part)
- */
- public void doLayout(int flowBPD) {
- doLayout(flowBPD, false);
- }
-
- /**
- * Starts the page breaking process.
- * @param flowBPD the constant available block-progression-dimension (used for every part)
* @param autoHeight true if warnings about overflows should be disabled because the
* the BPD is really undefined (for footnote-separators, for example)
*/
@@ -354,7 +354,6 @@
getPageProvider(), createLayoutListener(),
alignment, alignmentLast, footnoteSeparatorLength,
isPartOverflowRecoveryActivated(), autoHeight, isSinglePartFavored());
- int iOptPageCount;
BlockSequence effectiveList;
if (getCurrentDisplayAlign() == Constants.EN_X_FILL) {
@@ -365,22 +364,108 @@
effectiveList = blockList;
}
- //iOptPageCount = alg.firstFit(effectiveList, flowBPD, 1, true);
alg.setConstantLineWidth(flowBPD);
- iOptPageCount = alg.findBreakingPoints(effectiveList, /*flowBPD,*/
- 1, true, BreakingAlgorithm.ALL_BREAKS);
- log.debug("PLM> iOptPageCount= " + iOptPageCount
- + " pageBreaks.size()= " + alg.getPageBreaks().size());
+ int optimalPageCount = alg.findBreakingPoints(effectiveList, 1, true,
+ BreakingAlgorithm.ALL_BREAKS);
+ if (alg.ipdChanged()) {
+ KnuthNode optimalBreak = alg.getBestNodeBeforeIPDChange();
+ int positionIndex = optimalBreak.position;
+ KnuthElement elementAtBreak = alg.getElement(positionIndex);
+ Position positionAtBreak = elementAtBreak.getPosition();
+ if (!(positionAtBreak instanceof SpaceResolver.SpaceHandlingBreakPosition)) {
+ throw new UnsupportedOperationException(
+ "Don't know how to restart at position" + positionAtBreak);
+ }
+ /* Retrieve the original position wrapped into this space position */
+ positionAtBreak = positionAtBreak.getPosition();
+ LayoutManager restartAtLM = null;
+ List firstElements = Collections.EMPTY_LIST;
+ if (containsNonRestartableLM(positionAtBreak)) {
+ firstElements = new LinkedList();
+ boolean boxFound = false;
+ Iterator iter = effectiveList.listIterator(++positionIndex);
+ Position position = null;
+ while (iter.hasNext()
+ && (position == null || containsNonRestartableLM(position))) {
+ KnuthElement element = (KnuthElement) iter.next();
+ positionIndex++;
+ position = element.getPosition();
+ if (element.isBox()) {
+ boxFound = true;
+ firstElements.add(element);
+ } else if (boxFound) {
+ firstElements.add(element);
+ }
+ }
+ if (position instanceof SpaceResolver.SpaceHandlingBreakPosition) {
+ /* Retrieve the original position wrapped into this space position */
+ positionAtBreak = position.getPosition();
+ }
+ }
+ if (positionAtBreak.getIndex() == -1) {
+ /*
+ * This is an indication that we are between two blocks
+ * (possibly surrounded by another block), not inside a
+ * paragraph.
+ */
+ Position position;
+ Iterator iter = effectiveList.listIterator(positionIndex + 1);
+ do {
+ KnuthElement nextElement = (KnuthElement) iter.next();
+ position = nextElement.getPosition();
+ } while (position == null
+ || position instanceof SpaceResolver.SpaceHandlingPosition
+ || position instanceof SpaceResolver.SpaceHandlingBreakPosition
+ && position.getPosition().getIndex() == -1);
+ LayoutManager surroundingLM = positionAtBreak.getLM();
+ while (position.getLM() != surroundingLM) {
+ position = position.getPosition();
+ }
+ restartAtLM = position.getPosition().getLM();
+ }
+ log.trace("IPD changes after page " + optimalPageCount + " at index "
+ + optimalBreak.position);
+ doPhase3(alg, optimalPageCount, blockList, effectiveList);
+
+ blockLists.clear();
+ blockListIndex = -1;
+ nextSequenceStartsOn = getNextBlockList(childLC, Constants.EN_COLUMN,
+ positionAtBreak, restartAtLM, firstElements);
+ } else {
+ log.debug("PLM> iOptPageCount= " + optimalPageCount
+ + " pageBreaks.size()= " + alg.getPageBreaks().size());
- //*** Phase 3: Add areas ***
- doPhase3(alg, iOptPageCount, blockList, effectiveList);
+ //*** Phase 3: Add areas ***
+ doPhase3(alg, optimalPageCount, blockList, effectiveList);
+ }
}
}
}
/**
+ * Returns {@code true} if the given position or one of its descendants
+ * corresponds to a non-restartable LM.
+ *
+ * @param position a position
+ * @return {@code true} if there is a non-restartable LM in the hierarchy
+ */
+ private boolean containsNonRestartableLM(Position position) {
+ LayoutManager lm = position.getLM();
+ if (lm != null && !lm.isRestartable()) {
+ return true;
+ } else {
+ Position subPosition = position.getPosition();
+ if (subPosition == null) {
+ return false;
+ } else {
+ return containsNonRestartableLM(subPosition);
+ }
+ }
+ }
+
+ /**
* Phase 3 of Knuth algorithm: Adds the areas
* @param alg PageBreakingAlgorithm instance which determined the breaks
* @param partCount number of parts (pages) to be rendered
@@ -559,6 +644,7 @@
protected int handleSpanChange(LayoutContext childLC, int nextSequenceStartsOn) {
return nextSequenceStartsOn;
}
+
/**
* Gets the next block list (sequence) and adds it to a list of block lists if it's not empty.
* @param childLC LayoutContext to use
@@ -567,12 +653,38 @@
*/
protected int getNextBlockList(LayoutContext childLC,
int nextSequenceStartsOn) {
+ return getNextBlockList(childLC, nextSequenceStartsOn, null, null, null);
+ }
+
+ /**
+ * Gets the next block list (sequence) and adds it to a list of block lists
+ * if it's not empty.
+ *
+ * @param childLC LayoutContext to use
+ * @param nextSequenceStartsOn indicates on what page the next sequence
+ * should start
+ * @param positionAtIPDChange last element on the part before an IPD change
+ * @param restartAtLM the layout manager from which to restart, if IPD
+ * change occurs between two LMs
+ * @param firstElements elements from non-restartable LMs on the new page
+ * @return the page on which the next content should appear after a hard
+ * break
+ */
+ protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn,
+ Position positionAtIPDChange, LayoutManager restartAtLM, List firstElements) {
updateLayoutContext(childLC);
//Make sure the span change signal is reset
childLC.signalSpanChange(Constants.NOT_SET);
BlockSequence blockList;
- List returnedList = getNextKnuthElements(childLC, alignment);
+ List returnedList;
+ if (positionAtIPDChange == null) {
+ returnedList = getNextKnuthElements(childLC, alignment);
+ } else {
+ returnedList = getNextKnuthElements(childLC, alignment, positionAtIPDChange,
+ restartAtLM);
+ returnedList.addAll(0, firstElements);
+ }
if (returnedList != null) {
if (returnedList.isEmpty()) {
nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Wed Aug 26 18:50:10 2009
@@ -47,22 +47,22 @@
private static Log log = LogFactory.getLog(AbstractLayoutManager.class);
/** Parent LayoutManager for this LayoutManager */
- protected LayoutManager parentLM = null;
+ protected LayoutManager parentLM;
/** List of child LayoutManagers */
- protected List childLMs = null;
+ protected List childLMs;
/** Iterator for child LayoutManagers */
- protected ListIterator fobjIter = null;
+ protected ListIterator fobjIter;
/** Marker map for markers related to this LayoutManager */
- private Map markers = null;
+ private Map markers;
/** True if this LayoutManager has handled all of its content. */
- private boolean isFinished = false;
+ private boolean isFinished;
/** child LM during getNextKnuthElement phase */
- protected LayoutManager curChildLM = null;
+ protected LayoutManager curChildLM;
/** child LM iterator during getNextKnuthElement phase */
- protected ListIterator childLMiter = null;
+ protected ListIterator childLMiter;
private int lastGeneratedPosition = -1;
private int smallestPosNumberChecked = Integer.MAX_VALUE;
@@ -122,6 +122,14 @@
return null;
}
+ protected void setCurrentChildLM(LayoutManager childLM) {
+ curChildLM = childLM;
+ childLMiter = new LMiter(this);
+ do {
+ curChildLM = (LayoutManager) childLMiter.next();
+ } while (curChildLM != childLM);
+ }
+
/**
* Return indication if getChildLM will return another LM.
* @return true if another child LM is still available
@@ -450,4 +458,22 @@
return (super.toString() + (fobj != null ? "[fobj=" + fobj.toString() + "]" : ""));
}
+ /** {@inheritDoc} */
+ public void reset() {
+ isFinished = false;
+ curChildLM = null;
+ childLMiter = new LMiter(this);
+ /*
+ * Reset the children LM. Can't rely on childLMiter since it may have
+ * been set to null in checkEndOfLayout.
+ */
+ for (LMiter iter = new LMiter(this); iter.hasNext();) {
+ ((LayoutManager) iter.next()).reset();
+ }
+ if (fobj != null) {
+ markers = fobj.getMarkers();
+ }
+ lastGeneratedPosition = -1;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java Wed Aug 26 18:50:10 2009
@@ -382,4 +382,9 @@
}
}
+ /** {@inheritDoc} */
+ public void reset() {
+ throw new IllegalStateException();
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java Wed Aug 26 18:50:10 2009
@@ -117,7 +117,7 @@
// set space after for each LM, in order to implement
// display-align = distribute
lc.setSpaceAfter(layoutContext.getSpaceAfter());
- lc.setStackLimitsFrom(layoutContext);
+ lc.setStackLimitBP(layoutContext.getStackLimitBP());
childLM.addAreas(childPosIter, lc);
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Wed Aug 26 18:50:10 2009
@@ -24,6 +24,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
+import java.util.Stack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -397,6 +398,311 @@
return returnList;
}
+ /** {@inheritDoc} */
+ public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
+ Position restartPosition, LayoutManager restartAtLM) {
+ resetSpaces();
+ if (isAbsoluteOrFixed()) {
+ return getNextKnuthElementsAbsolute(context, alignment);
+ }
+
+ autoHeight = false;
+ //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
+ int maxbpd = context.getStackLimitBP().opt;
+ int allocBPD;
+ if (height.getEnum() == EN_AUTO
+ || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) {
+ //auto height when height="auto" or "if that dimension is not specified explicitly
+ //(i.e., it depends on content's block-progression-dimension)" (XSL 1.0, 7.14.1)
+ allocBPD = maxbpd;
+ autoHeight = true;
+ if (getBlockContainerFO().getReferenceOrientation() == 0) {
+ //Cannot easily inline element list when ref-or="180"
+ inlineElementList = true;
+ }
+ } else {
+ allocBPD = height.getValue(this); //this is the content-height
+ allocBPD += getBPIndents();
+ }
+ vpContentBPD = allocBPD - getBPIndents();
+
+ referenceIPD = context.getRefIPD();
+ if (width.getEnum() == EN_AUTO) {
+ updateContentAreaIPDwithOverconstrainedAdjust();
+ } else {
+ int contentWidth = width.getValue(this);
+ updateContentAreaIPDwithOverconstrainedAdjust(contentWidth);
+ }
+
+ double contentRectOffsetX = 0;
+ contentRectOffsetX += getBlockContainerFO()
+ .getCommonMarginBlock().startIndent.getValue(this);
+ double contentRectOffsetY = 0;
+ contentRectOffsetY += getBlockContainerFO()
+ .getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
+ contentRectOffsetY += getBlockContainerFO()
+ .getCommonBorderPaddingBackground().getPaddingBefore(false, this);
+
+ updateRelDims(contentRectOffsetX, contentRectOffsetY, autoHeight);
+
+ int availableIPD = referenceIPD - getIPIndents();
+ if (getContentAreaIPD() > availableIPD) {
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getBlockContainerFO().getUserAgent().getEventBroadcaster());
+ eventProducer.objectTooWide(this, getBlockContainerFO().getName(),
+ getContentAreaIPD(), context.getRefIPD(),
+ getBlockContainerFO().getLocator());
+ }
+
+ MinOptMax stackLimit = new MinOptMax(relDims.bpd);
+
+ List returnedList;
+ List contentList = new LinkedList();
+ List returnList = new LinkedList();
+
+ if (!breakBeforeServed) {
+ breakBeforeServed = true;
+ if (!context.suppressBreakBefore()) {
+ if (addKnuthElementsForBreakBefore(returnList, context)) {
+ return returnList;
+ }
+ }
+ }
+
+ if (!firstVisibleMarkServed) {
+ addKnuthElementsForSpaceBefore(returnList, alignment);
+ context.updateKeepWithPreviousPending(getKeepWithPrevious());
+ }
+
+ addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
+ firstVisibleMarkServed = true;
+
+ if (autoHeight && inlineElementList) {
+ //Spaces, border and padding to be repeated at each break
+ addPendingMarks(context);
+
+ BlockLevelLayoutManager curLM; // currently active LM
+ BlockLevelLayoutManager prevLM = null; // previously active LM
+
+ LayoutContext childLC = new LayoutContext(0);
+ if (lmStack.isEmpty()) {
+ assert restartAtLM != null && restartAtLM.getParent() == this;
+ curLM = (BlockLevelLayoutManager) restartAtLM;
+ curLM.reset();
+ setCurrentChildLM(curLM);
+
+ childLC.copyPendingMarksFrom(context);
+ childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit));
+ childLC.setRefIPD(relDims.ipd);
+ childLC.setWritingMode(getBlockContainerFO().getWritingMode());
+ if (curLM == this.childLMs.get(0)) {
+ childLC.setFlags(LayoutContext.SUPPRESS_BREAK_BEFORE);
+ //Handled already by the parent (break collapsing, see above)
+ }
+
+ // get elements from curLM
+ returnedList = curLM.getNextKnuthElements(childLC, alignment);
+ } else {
+ curLM = (BlockLevelLayoutManager) lmStack.pop();
+ setCurrentChildLM(curLM);
+
+ childLC.copyPendingMarksFrom(context);
+ childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit));
+ childLC.setRefIPD(relDims.ipd);
+ childLC.setWritingMode(getBlockContainerFO().getWritingMode());
+ if (curLM == this.childLMs.get(0)) {
+ childLC.setFlags(LayoutContext.SUPPRESS_BREAK_BEFORE);
+ //Handled already by the parent (break collapsing, see above)
+ }
+
+ // get elements from curLM
+ returnedList = curLM.getNextKnuthElements(childLC, alignment, lmStack,
+ restartPosition, restartAtLM);
+ }
+ if (contentList.isEmpty() && childLC.isKeepWithPreviousPending()) {
+ //Propagate keep-with-previous up from the first child
+ context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
+ childLC.clearKeepWithPreviousPending();
+ }
+ if (returnedList.size() == 1
+ && ((ListElement)returnedList.get(0)).isForcedBreak()) {
+ // a descendant of this block has break-before
+ /*
+ if (returnList.size() == 0) {
+ // the first child (or its first child ...) has
+ // break-before;
+ // all this block, including space before, will be put in
+ // the
+ // following page
+ bSpaceBeforeServed = false;
+ }*/
+ contentList.addAll(returnedList);
+
+ // "wrap" the Position inside each element
+ // moving the elements from contentList to returnList
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ } else {
+ if (prevLM != null) {
+ // there is a block handled by prevLM
+ // before the one handled by curLM
+ addInBetweenBreak(contentList, context, childLC);
+ }
+ contentList.addAll(returnedList);
+ if (!returnedList.isEmpty()) {
+ if (((ListElement) ListUtil.getLast(returnedList))
+ .isForcedBreak()) {
+ // a descendant of this block has break-after
+ if (curLM.isFinished()) {
+ // there is no other content in this block;
+ // it's useless to add space after before a page break
+ setFinished(true);
+ }
+
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ }
+ }
+ }
+ // propagate and clear
+ context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
+ childLC.clearKeepsPending();
+ prevLM = curLM;
+
+ while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
+ curLM.reset();
+ childLC = new LayoutContext(0);
+ childLC.copyPendingMarksFrom(context);
+ // curLM is a ?
+ childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit));
+ childLC.setRefIPD(relDims.ipd);
+ childLC.setWritingMode(getBlockContainerFO().getWritingMode());
+ if (curLM == this.childLMs.get(0)) {
+ childLC.setFlags(LayoutContext.SUPPRESS_BREAK_BEFORE);
+ //Handled already by the parent (break collapsing, see above)
+ }
+
+ // get elements from curLM
+ returnedList = curLM.getNextKnuthElements(childLC, alignment);
+ if (contentList.isEmpty() && childLC.isKeepWithPreviousPending()) {
+ //Propagate keep-with-previous up from the first child
+ context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
+ childLC.clearKeepWithPreviousPending();
+ }
+ if (returnedList.size() == 1
+ && ((ListElement)returnedList.get(0)).isForcedBreak()) {
+ // a descendant of this block has break-before
+ /*
+ if (returnList.size() == 0) {
+ // the first child (or its first child ...) has
+ // break-before;
+ // all this block, including space before, will be put in
+ // the
+ // following page
+ bSpaceBeforeServed = false;
+ }*/
+ contentList.addAll(returnedList);
+
+ // "wrap" the Position inside each element
+ // moving the elements from contentList to returnList
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ } else {
+ if (prevLM != null) {
+ // there is a block handled by prevLM
+ // before the one handled by curLM
+ addInBetweenBreak(contentList, context, childLC);
+ }
+ contentList.addAll(returnedList);
+ if (returnedList.isEmpty()) {
+ //Avoid NoSuchElementException below (happens with empty blocks)
+ continue;
+ }
+ if (((ListElement) ListUtil.getLast(returnedList))
+ .isForcedBreak()) {
+ // a descendant of this block has break-after
+ if (curLM.isFinished()) {
+ // there is no other content in this block;
+ // it's useless to add space after before a page break
+ setFinished(true);
+ }
+
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ }
+ }
+ // propagate and clear
+ context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
+ childLC.clearKeepsPending();
+ prevLM = curLM;
+ }
+
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ } else {
+ MinOptMax range = new MinOptMax(relDims.ipd);
+ BlockContainerBreaker breaker = new BlockContainerBreaker(this, range);
+ breaker.doLayout(relDims.bpd, autoHeight);
+ boolean contentOverflows = breaker.isOverflow();
+ if (autoHeight) {
+ //Update content BPD now that it is known
+ int newHeight = breaker.deferredAlg.totalWidth;
+ boolean switchedProgressionDirection
+ = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
+ if (switchedProgressionDirection) {
+ setContentAreaIPD(newHeight);
+ } else {
+ vpContentBPD = newHeight;
+ }
+ updateRelDims(contentRectOffsetX, contentRectOffsetY, false);
+ }
+
+ Position bcPosition = new BlockContainerPosition(this, breaker);
+ returnList.add(new KnuthBox(vpContentBPD, notifyPos(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 KnuthGlue(0, 1 * constantLineHeight, 0,
+ LINE_NUMBER_ADJUSTMENT, returnPosition, false));
+ */
+
+ if (contentOverflows) {
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+ getBlockContainerFO().getUserAgent().getEventBroadcaster());
+ boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
+ eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
+ breaker.getOverflowAmount(), needClip(), canRecover,
+ getBlockContainerFO().getLocator());
+ }
+ }
+ addKnuthElementsForBorderPaddingAfter(returnList, true);
+ addKnuthElementsForSpaceAfter(returnList, alignment);
+
+ //All child content is processed. Only break-after can occur now, so...
+ context.clearPendingMarks();
+ addKnuthElementsForBreakAfter(returnList, context);
+
+ context.updateKeepWithNextPending(getKeepWithNext());
+
+ setFinished(true);
+ return returnList;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isRestartable() {
+ return true;
+ }
+
private List getNextKnuthElementsAbsolute(LayoutContext context, int alignment) {
autoHeight = false;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Wed Aug 26 18:50:10 2009
@@ -22,6 +22,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
+import java.util.Stack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -67,9 +68,6 @@
private MinOptMax effSpaceBefore;
private MinOptMax effSpaceAfter;
- /** The list of child BreakPoss instances. */
- protected List childBreaks = new java.util.ArrayList();
-
/**
* Creates a new BlockLayoutManager.
* @param inBlock the block FO object to create the layout manager for.
@@ -114,8 +112,19 @@
/** {@inheritDoc} */
public List getNextKnuthElements(LayoutContext context, int alignment) {
+ return getNextKnuthElements(context, alignment, null, null, null);
+ }
+
+ /** {@inheritDoc} */
+ public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
+ Position restartPosition, LayoutManager restartAtLM) {
resetSpaces();
- return super.getNextKnuthElements(context, alignment);
+ if (lmStack == null) {
+ return super.getNextKnuthElements(context, alignment);
+ } else {
+ return super.getNextKnuthElements(context, alignment, lmStack, restartPosition,
+ restartAtLM);
+ }
}
private void resetSpaces() {
@@ -249,8 +258,8 @@
// and put them in a new list;
LinkedList positionList = new LinkedList();
Position pos;
- boolean bSpaceBefore = false;
- boolean bSpaceAfter = false;
+ boolean spaceBefore = false;
+ boolean spaceAfter = false;
Position firstPos = null;
Position lastPos = null;
while (parentIter.hasNext()) {
@@ -273,11 +282,11 @@
// this means the space was not discarded
if (positionList.size() == 0) {
// pos was in the element representing space-before
- bSpaceBefore = true;
+ spaceBefore = true;
//log.trace(" space before");
} else {
// pos was in the element representing space-after
- bSpaceAfter = true;
+ spaceAfter = true;
//log.trace(" space-after");
}
} else if (innerPosition.getLM() == this
@@ -302,7 +311,7 @@
// the Positions in positionList were inside the elements
// created by the LineLM
childPosIter = new StackingIter(positionList.listIterator());
- } else {
+ } else {
// the Positions in positionList were inside the elements
// created by the BlockLM in the createUnitElements() method
//if (((Position) positionList.getLast()) instanceof
@@ -341,7 +350,7 @@
// + " spacing");
// add space before and / or after the paragraph
// to reach a multiple of bpUnit
- if (bSpaceBefore && bSpaceAfter) {
+ if (spaceBefore && spaceAfter) {
foSpaceBefore = new SpaceVal(getBlockFO()
.getCommonMarginBlock().spaceBefore, this).getSpace();
foSpaceAfter = new SpaceVal(getBlockFO()
@@ -354,7 +363,7 @@
+ foSpaceBefore.min
+ foSpaceAfter.min)
* bpUnit - splitLength - adjustedSpaceBefore;
- } else if (bSpaceBefore) {
+ } else if (spaceBefore) {
adjustedSpaceBefore = neededUnits(splitLength
+ foSpaceBefore.min)
* bpUnit - splitLength;
@@ -547,5 +556,10 @@
}
}
+ /** {@inheritDoc} */
+ public boolean isRestartable() {
+ return true;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Wed Aug 26 18:50:10 2009
@@ -23,6 +23,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
+import java.util.Stack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,12 +31,12 @@
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.area.BlockParent;
-import org.apache.fop.fo.FObj;
import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FObj;
import org.apache.fop.fo.properties.BreakPropertySet;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.SpaceProperty;
import org.apache.fop.fo.properties.KeepProperty;
+import org.apache.fop.fo.properties.SpaceProperty;
import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
import org.apache.fop.layoutmgr.inline.LineLayoutManager;
import org.apache.fop.traits.MinOptMax;
@@ -54,31 +55,26 @@
*/
private static Log log = LogFactory.getLog(BlockStackingLayoutManager.class);
- /**
- * Reference to FO whose areas it's managing or to the traits
- * of the FO.
- */
- //protected LayoutManager curChildLM = null; AbstractLayoutManager also defines this!
- protected BlockParent parentArea = null;
+ protected BlockParent parentArea;
/** Value of the block-progression-unit (non-standard property) */
- protected int bpUnit = 0;
+ protected int bpUnit;
/** space-before value adjusted for block-progression-unit handling */
- protected int adjustedSpaceBefore = 0;
+ protected int adjustedSpaceBefore;
/** space-after value adjusted for block-progression-unit handling */
- protected int adjustedSpaceAfter = 0;
+ protected int adjustedSpaceAfter;
/** Only used to store the original list when createUnitElements is called */
- protected List storedList = null;
+ protected List storedList;
/** Indicates whether break before has been served or not */
- protected boolean breakBeforeServed = false;
+ protected boolean breakBeforeServed;
/** Indicates whether the first visible mark has been returned by this LM, yet */
- protected boolean firstVisibleMarkServed = false;
+ protected boolean firstVisibleMarkServed;
/** Reference IPD available */
- protected int referenceIPD = 0;
+ protected int referenceIPD;
/** the effective start-indent value */
- protected int startIndent = 0;
+ protected int startIndent;
/** the effective end-indent value */
- protected int endIndent = 0;
+ protected int endIndent;
/**
* Holds the (one-time use) fo:block space-before
* and -after properties. Large fo:blocks are split
@@ -88,13 +84,13 @@
* Block and space-after at the end of the last Block
* used in rendering the fo:block.
*/
- protected MinOptMax foSpaceBefore = null;
+ protected MinOptMax foSpaceBefore;
/** see foSpaceBefore */
- protected MinOptMax foSpaceAfter = null;
+ protected MinOptMax foSpaceAfter;
private Position auxiliaryPosition;
- private int contentAreaIPD = 0;
+ private int contentAreaIPD;
/**
* @param node the fo this LM deals with
@@ -248,38 +244,27 @@
/** {@inheritDoc} */
public List getNextKnuthElements(LayoutContext context, int alignment) {
- //log.debug("BLM.getNextKnuthElements> keep-together = "
- // + layoutProps.keepTogether.getType());
- //log.debug(" keep-with-previous = " +
- // layoutProps.keepWithPrevious.getType());
- //log.debug(" keep-with-next = " +
- // layoutProps.keepWithNext.getType());
- BlockLevelLayoutManager curLM; // currently active LM
- BlockLevelLayoutManager prevLM = null; // previously active LM
-
referenceIPD = context.getRefIPD();
-
updateContentAreaIPDwithOverconstrainedAdjust();
- List returnedList = null;
List contentList = new LinkedList();
- List returnList = new LinkedList();
+ List elements = new LinkedList();
if (!breakBeforeServed) {
breakBeforeServed = true;
if (!context.suppressBreakBefore()) {
- if (addKnuthElementsForBreakBefore(returnList, context)) {
- return returnList;
+ if (addKnuthElementsForBreakBefore(elements, context)) {
+ return elements;
}
}
}
if (!firstVisibleMarkServed) {
- addKnuthElementsForSpaceBefore(returnList, alignment);
+ addKnuthElementsForSpaceBefore(elements, alignment);
context.updateKeepWithPreviousPending(getKeepWithPrevious());
}
- addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
+ addKnuthElementsForBorderPaddingBefore(elements, !firstVisibleMarkServed);
firstVisibleMarkServed = true;
//Spaces, border and padding to be repeated at each break
@@ -288,142 +273,311 @@
//Used to indicate a special break-after case when all content has already been generated.
BreakElement forcedBreakAfterLast = null;
- while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
+ LayoutManager currentChildLM;
+ while ((currentChildLM = (LayoutManager) getChildLM()) != null) {
LayoutContext childLC = new LayoutContext(0);
- childLC.copyPendingMarksFrom(context);
- if (curLM instanceof LineLayoutManager) {
- // curLM is a LineLayoutManager
- // set stackLimit for lines (stack limit is now i-p-direction, not b-p-direction!)
- childLC.setStackLimitBP(context.getStackLimitBP());
- childLC.setStackLimitIP(new MinOptMax(getContentAreaIPD()));
- childLC.setRefIPD(getContentAreaIPD());
- } else {
- // curLM is a ?
- //childLC.setStackLimit(MinOptMax.subtract(context
- // .getStackLimit(), stackSize));
- childLC.setStackLimitBP(context.getStackLimitBP());
- childLC.setRefIPD(referenceIPD);
- }
- if (curLM == this.childLMs.get(0)) {
- childLC.setFlags(LayoutContext.SUPPRESS_BREAK_BEFORE);
- //Handled already by the parent (break collapsing, see above)
- }
- // get elements from curLM
- returnedList = curLM.getNextKnuthElements(childLC, alignment);
- if (contentList.isEmpty() && childLC.isKeepWithPreviousPending()) {
+ List childrenElements = getNextChildElements(currentChildLM, context, childLC,
+ alignment);
+
+ if (contentList.isEmpty()) {
//Propagate keep-with-previous up from the first child
context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
- childLC.clearKeepWithPreviousPending();
}
- if (returnedList != null
- && returnedList.size() == 1
- && ((ListElement) returnedList.get(0)).isForcedBreak()) {
+ if (childrenElements != null && !childrenElements.isEmpty()) {
+ if (!contentList.isEmpty()
+ && !ElementListUtils.startsWithForcedBreak(childrenElements)) {
+ // there is a block handled by prevLM before the one
+ // handled by curLM, and the one handled
+ // by the current LM does not begin with a break
+ addInBetweenBreak(contentList, context, childLC);
+ }
+ if (childrenElements.size() == 1
+ && ElementListUtils.startsWithForcedBreak(childrenElements)) {
+
+ if (currentChildLM.isFinished() && !hasNextChildLM()) {
+ // a descendant of this block has break-before
+ forcedBreakAfterLast = (BreakElement) childrenElements.get(0);
+ context.clearPendingMarks();
+ break;
+ }
+
+ if (contentList.isEmpty()) {
+ // Empty fo:block, zero-length box makes sure the IDs and/or markers
+ // are registered and borders/padding are painted.
+ elements.add(new KnuthBox(0, notifyPos(new Position(this)), false));
+ }
+ // a descendant of this block has break-before
+ contentList.addAll(childrenElements);
+
+ wrapPositionElements(contentList, elements);
+
+ return elements;
+ } else {
+ contentList.addAll(childrenElements);
+ if (ElementListUtils.endsWithForcedBreak(childrenElements)) {
+ // a descendant of this block has break-after
+ if (currentChildLM.isFinished() && !hasNextChildLM()) {
+ forcedBreakAfterLast = (BreakElement) ListUtil.removeLast(contentList);
+ context.clearPendingMarks();
+ break;
+ }
+
+ wrapPositionElements(contentList, elements);
+
+ return elements;
+ }
+ }
+ context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
+ }
+ }
+
+ if (!contentList.isEmpty()) {
+ wrapPositionElements(contentList, elements);
+ } else if (forcedBreakAfterLast == null) {
+ // Empty fo:block, zero-length box makes sure the IDs and/or markers
+ // are registered.
+ elements.add(new KnuthBox(0, notifyPos(new Position(this)), true));
+ }
+
+ addKnuthElementsForBorderPaddingAfter(elements, true);
+ addKnuthElementsForSpaceAfter(elements, alignment);
+
+ //All child content is processed. Only break-after can occur now, so...
+ context.clearPendingMarks();
+ if (forcedBreakAfterLast == null) {
+ addKnuthElementsForBreakAfter(elements, context);
+ } else {
+ forcedBreakAfterLast.clearPendingMarks();
+ elements.add(forcedBreakAfterLast);
+ }
+
+ context.updateKeepWithNextPending(getKeepWithNext());
+
+ setFinished(true);
+
+ return elements;
+ }
+
+ /** {@inheritDoc} */
+ public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
+ Position restartPosition, LayoutManager restartAtLM) {
+ referenceIPD = context.getRefIPD();
+ updateContentAreaIPDwithOverconstrainedAdjust();
+
+ List contentList = new LinkedList();
+ List elements = new LinkedList();
+
+ if (!breakBeforeServed) {
+ breakBeforeServed = true;
+ if (!context.suppressBreakBefore()) {
+ if (addKnuthElementsForBreakBefore(elements, context)) {
+ return elements;
+ }
+ }
+ }
+
+ if (!firstVisibleMarkServed) {
+ addKnuthElementsForSpaceBefore(elements, alignment);
+ context.updateKeepWithPreviousPending(getKeepWithPrevious());
+ }
+
+ addKnuthElementsForBorderPaddingBefore(elements, !firstVisibleMarkServed);
+ firstVisibleMarkServed = true;
+
+ //Spaces, border and padding to be repeated at each break
+ addPendingMarks(context);
+
+ //Used to indicate a special break-after case when all content has already been generated.
+ BreakElement forcedBreakAfterLast = null;
+
+ LayoutContext childLC = new LayoutContext(0);
+ List childrenElements;
+ LayoutManager currentChildLM;
+ if (lmStack.isEmpty()) {
+ assert restartAtLM != null && restartAtLM.getParent() == this;
+ currentChildLM = restartAtLM;
+ currentChildLM.reset();
+ setCurrentChildLM(currentChildLM);
+
+ childrenElements = getNextChildElements(currentChildLM, context, childLC,
+ alignment);
+ } else {
+ currentChildLM = (BlockLevelLayoutManager) lmStack.pop();
+ setCurrentChildLM(currentChildLM);
+ childrenElements = getNextChildElements(currentChildLM, context, childLC, alignment,
+ lmStack, restartPosition, restartAtLM);
+ }
+
+ if (contentList.isEmpty()) {
+ //Propagate keep-with-previous up from the first child
+ context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
+ }
+ if (childrenElements != null && !childrenElements.isEmpty()) {
+ if (!contentList.isEmpty()
+ && !ElementListUtils.startsWithForcedBreak(childrenElements)) {
+ // there is a block handled by prevLM before the one
+ // handled by curLM, and the one handled
+ // by the current LM does not begin with a break
+ addInBetweenBreak(contentList, context, childLC);
+ }
+ if (childrenElements.size() == 1
+ && ElementListUtils.startsWithForcedBreak(childrenElements)) {
- if (curLM.isFinished() && !hasNextChildLM()) {
+ if (currentChildLM.isFinished() && !hasNextChildLM()) {
// a descendant of this block has break-before
- forcedBreakAfterLast = (BreakElement) returnedList.get(0);
+ forcedBreakAfterLast = (BreakElement) childrenElements.get(0);
context.clearPendingMarks();
- break;
+// break; TODO
}
if (contentList.isEmpty()) {
// Empty fo:block, zero-length box makes sure the IDs and/or markers
// are registered and borders/padding are painted.
- returnList.add(new KnuthBox(0, notifyPos(new Position(this)), false));
+ elements.add(new KnuthBox(0, notifyPos(new Position(this)), false));
}
// a descendant of this block has break-before
- contentList.addAll(returnedList);
-
- /* extension: conversione di tutta la sequenza fin'ora ottenuta */
- if (bpUnit > 0) {
- storedList = contentList;
- contentList = createUnitElements(contentList);
- }
- /* end of extension */
+ contentList.addAll(childrenElements);
- // "wrap" the Position inside each element
- // moving the elements from contentList to returnList
- returnedList = new LinkedList();
- wrapPositionElements(contentList, returnList);
+ wrapPositionElements(contentList, elements);
- return returnList;
+ return elements;
} else {
- if (returnedList == null || returnedList.isEmpty()) {
- //Avoid NoSuchElementException below (happens with empty blocks)
- continue;
+ contentList.addAll(childrenElements);
+ if (ElementListUtils.endsWithForcedBreak(childrenElements)) {
+ // a descendant of this block has break-after
+ if (currentChildLM.isFinished() && !hasNextChildLM()) {
+ forcedBreakAfterLast = (BreakElement) ListUtil.removeLast(contentList);
+ context.clearPendingMarks();
+// break; TODO
+ }
+
+ wrapPositionElements(contentList, elements);
+
+ return elements;
}
- if (prevLM != null
- && !ElementListUtils.startsWithForcedBreak(returnedList)) {
+ }
+ context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
+ }
+
+ while ((currentChildLM = (LayoutManager) getChildLM()) != null) {
+ currentChildLM.reset(); // TODO won't work with forced breaks
+
+ childLC = new LayoutContext(0);
+
+ childrenElements = getNextChildElements(currentChildLM, context, childLC,
+ alignment);
+
+ if (contentList.isEmpty()) {
+ //Propagate keep-with-previous up from the first child
+ context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
+ }
+ if (childrenElements != null && !childrenElements.isEmpty()) {
+ if (!contentList.isEmpty()
+ && !ElementListUtils.startsWithForcedBreak(childrenElements)) {
// there is a block handled by prevLM before the one
// handled by curLM, and the one handled
// by the current LM does not begin with a break
addInBetweenBreak(contentList, context, childLC);
}
- contentList.addAll(returnedList);
- if (ElementListUtils.endsWithForcedBreak(returnedList)) {
- // a descendant of this block has break-after
- if (curLM.isFinished() && !hasNextChildLM()) {
- forcedBreakAfterLast = (BreakElement) ListUtil
- .removeLast(contentList);
+ if (childrenElements.size() == 1
+ && ElementListUtils.startsWithForcedBreak(childrenElements)) {
+
+ if (currentChildLM.isFinished() && !hasNextChildLM()) {
+ // a descendant of this block has break-before
+ forcedBreakAfterLast = (BreakElement) childrenElements.get(0);
context.clearPendingMarks();
break;
}
- /* extension: conversione di tutta la sequenza fin'ora ottenuta */
- if (bpUnit > 0) {
- storedList = contentList;
- contentList = createUnitElements(contentList);
+ if (contentList.isEmpty()) {
+ // Empty fo:block, zero-length box makes sure the IDs and/or markers
+ // are registered and borders/padding are painted.
+ elements.add(new KnuthBox(0, notifyPos(new Position(this)), false));
}
- /* end of extension */
+ // a descendant of this block has break-before
+ contentList.addAll(childrenElements);
+
+ wrapPositionElements(contentList, elements);
+
+ return elements;
+ } else {
+ contentList.addAll(childrenElements);
+ if (ElementListUtils.endsWithForcedBreak(childrenElements)) {
+ // a descendant of this block has break-after
+ if (currentChildLM.isFinished() && !hasNextChildLM()) {
+ forcedBreakAfterLast = (BreakElement) ListUtil.removeLast(contentList);
+ context.clearPendingMarks();
+ break;
+ }
- returnedList = new LinkedList();
- wrapPositionElements(contentList, returnList);
+ wrapPositionElements(contentList, elements);
- return returnList;
+ return elements;
+ }
}
+ context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
}
- // propagate and clear
- context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
- childLC.clearKeepsPending();
- prevLM = curLM;
- }
-
- /* Extension: conversione di tutta la sequenza fin'ora ottenuta */
- if (bpUnit > 0) {
- storedList = contentList;
- contentList = createUnitElements(contentList);
}
- /* end of extension */
- returnedList = new LinkedList();
if (!contentList.isEmpty()) {
- wrapPositionElements(contentList, returnList);
+ wrapPositionElements(contentList, elements);
} else if (forcedBreakAfterLast == null) {
// Empty fo:block, zero-length box makes sure the IDs and/or markers
// are registered.
- returnList.add(new KnuthBox(0, notifyPos(new Position(this)), true));
+ elements.add(new KnuthBox(0, notifyPos(new Position(this)), true));
}
- addKnuthElementsForBorderPaddingAfter(returnList, true);
- addKnuthElementsForSpaceAfter(returnList, alignment);
+ addKnuthElementsForBorderPaddingAfter(elements, true);
+ addKnuthElementsForSpaceAfter(elements, alignment);
//All child content is processed. Only break-after can occur now, so...
context.clearPendingMarks();
if (forcedBreakAfterLast == null) {
- addKnuthElementsForBreakAfter(returnList, context);
- }
-
- if (forcedBreakAfterLast != null) {
+ addKnuthElementsForBreakAfter(elements, context);
+ } else {
forcedBreakAfterLast.clearPendingMarks();
- returnList.add(forcedBreakAfterLast);
+ elements.add(forcedBreakAfterLast);
}
context.updateKeepWithNextPending(getKeepWithNext());
setFinished(true);
- return returnList;
+ return elements;
+ }
+
+ private List getNextChildElements(LayoutManager childLM, LayoutContext context,
+ LayoutContext childLC, int alignment) {
+ return getNextChildElements(childLM, context, childLC, alignment, null, null, null);
+ }
+
+ private List getNextChildElements(LayoutManager childLM, LayoutContext context,
+ LayoutContext childLC, int alignment, Stack lmStack, Position restartPosition,
+ LayoutManager restartAtLM) {
+ childLC.copyPendingMarksFrom(context);
+ childLC.setStackLimitBP(context.getStackLimitBP());
+ if (childLM instanceof LineLayoutManager) {
+ childLC.setRefIPD(getContentAreaIPD());
+ } else {
+ childLC.setRefIPD(referenceIPD);
+ }
+ if (childLM == this.childLMs.get(0)) {
+ childLC.setFlags(LayoutContext.SUPPRESS_BREAK_BEFORE);
+ //Handled already by the parent (break collapsing, see above)
+ }
+
+ if (lmStack == null) {
+ return childLM.getNextKnuthElements(childLC, alignment);
+ } else {
+ if (childLM instanceof LineLayoutManager) {
+ return ((LineLayoutManager) childLM).getNextKnuthElements(childLC, alignment,
+ (LeafPosition) restartPosition);
+ } else {
+ return childLM.getNextKnuthElements(childLC, alignment,
+ lmStack, restartPosition, restartAtLM);
+ }
+ }
}
/**
@@ -1654,5 +1808,13 @@
return -1;
}
+ /** {@inheritDoc} */
+ public void reset() {
+ super.reset();
+ breakBeforeServed = false;
+ firstVisibleMarkServed = false;
+ // TODO startIndent, endIndent
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java Wed Aug 26 18:50:10 2009
@@ -491,6 +491,9 @@
elementIndex, previousIsBox, allowedBreaks).isBox();
if (activeNodeCount == 0) {
+ if (ipdChanged()) {
+ return handleIpdChange();
+ }
if (!force) {
log.debug("Could not find a set of breaking points " + threshold);
return 0;
@@ -535,6 +538,14 @@
return line;
}
+ protected boolean ipdChanged() {
+ return false;
+ }
+
+ protected int handleIpdChange() {
+ throw new IllegalStateException();
+ }
+
/**
* Recover from a {@link KnuthNode} leading to a line that is too long.
* The default implementation creates a new node corresponding to a break
@@ -1283,12 +1294,8 @@
* @return the width/length in millipoints
*/
protected int getLineWidth(int line) {
- if (this.lineWidth < 0) {
- throw new IllegalStateException("lineWidth must be set"
- + (this.lineWidth != 0 ? " and positive, but it is: " + this.lineWidth : ""));
- } else {
- return this.lineWidth;
- }
+ assert lineWidth >= 0;
+ return this.lineWidth;
}
/** @return the constant line/part width or -1 if there is no such value */
@@ -1321,7 +1328,7 @@
* @param par the corresponding paragraph
* @param total the number of lines into which the paragraph will be broken
*/
- private void calculateBreakPoints(KnuthNode node, KnuthSequence par,
+ protected void calculateBreakPoints(KnuthNode node, KnuthSequence par,
int total) {
KnuthNode bestActiveNode = node;
// use bestActiveNode to determine the optimum breakpoints
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Wed Aug 26 18:50:10 2009
@@ -22,6 +22,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
+import java.util.Stack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -29,8 +30,6 @@
import org.apache.fop.area.Area;
import org.apache.fop.area.BlockParent;
import org.apache.fop.fo.pagination.Flow;
-import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
-import org.apache.fop.layoutmgr.inline.WrapperLayoutManager;
/**
* LayoutManager for an fo:flow object.
@@ -64,108 +63,151 @@
/** {@inheritDoc} */
public List getNextKnuthElements(LayoutContext context, int alignment) {
- // set layout dimensions
- int flowIPD = getCurrentPV().getCurrentSpan().getColumnWidth();
- int flowBPD = getCurrentPV().getBodyRegion().getBPD();
-
- // currently active LM
- LayoutManager curLM;
- List returnedList;
- List returnList = new LinkedList();
+ List elements = new LinkedList();
- while ((curLM = getChildLM()) != null) {
- if (!(curLM instanceof WrapperLayoutManager)
- && curLM instanceof InlineLevelLayoutManager) {
- log.error("inline area not allowed under flow - ignoring");
- curLM.setFinished(true);
- continue;
+ LayoutManager currentChildLM;
+ while ((currentChildLM = getChildLM()) != null) {
+ if (addChildElements(elements, currentChildLM, context, alignment) != null) {
+ return elements;
}
+ }
- int span = EN_NONE;
- int disableColumnBalancing = EN_FALSE;
- if (curLM instanceof BlockLayoutManager) {
- span = ((BlockLayoutManager)curLM).getBlockFO().getSpan();
- disableColumnBalancing = ((BlockLayoutManager) curLM).getBlockFO()
- .getDisableColumnBalancing();
- } else if (curLM instanceof BlockContainerLayoutManager) {
- span = ((BlockContainerLayoutManager)curLM).getBlockContainerFO().getSpan();
- disableColumnBalancing = ((BlockContainerLayoutManager) curLM).getBlockContainerFO()
- .getDisableColumnBalancing();
- }
+ SpaceResolver.resolveElementList(elements);
+ setFinished(true);
- int currentSpan = context.getCurrentSpan();
- if (currentSpan != span) {
- if (span == EN_ALL) {
- context.setDisableColumnBalancing(disableColumnBalancing);
- }
- log.debug("span change from " + currentSpan + " to " + span);
- context.signalSpanChange(span);
- SpaceResolver.resolveElementList(returnList);
- return returnList;
- }
+ assert !elements.isEmpty();
+ return elements;
+ }
+
+ /** {@inheritDoc} */
+ public List getNextKnuthElements(LayoutContext context, int alignment,
+ Position positionAtIPDChange, LayoutManager restartAtLM) {
- // Set up a LayoutContext
- //MinOptMax bpd = context.getStackLimit();
+ List elements = new LinkedList();
- LayoutContext childLC = new LayoutContext(0);
- childLC.setStackLimitBP(context.getStackLimitBP());
- childLC.setRefIPD(context.getRefIPD());
- childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode());
-
- // get elements from curLM
- returnedList = curLM.getNextKnuthElements(childLC, alignment);
- //log.debug("FLM.getNextKnuthElements> returnedList.size() = " + returnedList.size());
- if (returnList.size() == 0 && childLC.isKeepWithPreviousPending()) {
- context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
- childLC.clearKeepWithPreviousPending();
+ LayoutManager currentChildLM = positionAtIPDChange.getLM();
+ if (currentChildLM == null) {
+ throw new IllegalStateException(
+ "Cannot find layout manager from where to re-start layout after IPD change");
+ }
+ if (restartAtLM != null && restartAtLM.getParent() == this) {
+ currentChildLM = restartAtLM;
+ setCurrentChildLM(currentChildLM);
+ currentChildLM.reset();
+ if (addChildElements(elements, currentChildLM, context, alignment) != null) {
+ return elements;
}
+ } else {
+ Stack lmStack = new Stack();
+ while (currentChildLM.getParent() != this) {
+ lmStack.push(currentChildLM);
+ currentChildLM = currentChildLM.getParent();
+ }
+ setCurrentChildLM(currentChildLM);
+ if (addChildElements(elements, currentChildLM, context, alignment, lmStack,
+ positionAtIPDChange, restartAtLM) != null) {
+ return elements;
+ }
+ }
- // "wrap" the Position inside each element
- List tempList = returnedList;
- returnedList = new LinkedList();
- wrapPositionElements(tempList, returnedList);
-
- if (returnedList.size() == 1
- && ElementListUtils.endsWithForcedBreak(returnedList)) {
- // a descendant of this flow has break-before
- returnList.addAll(returnedList);
- SpaceResolver.resolveElementList(returnList);
- return returnList;
- } else if (returnedList.size() > 0) {
- if (returnList.size() > 0
- && !ElementListUtils.startsWithForcedBreak(returnedList)) {
- addInBetweenBreak(returnList, context, childLC);
- }
- returnList.addAll(returnedList);
- if (ElementListUtils.endsWithForcedBreak(returnList)) {
- if (curLM.isFinished() && !hasNextChildLM()) {
- //If the layout manager is finished at this point, the pending
- //marks become irrelevant.
- childLC.clearPendingMarks();
- //setFinished(true);
- break;
- }
- // a descendant of this flow has break-after
- SpaceResolver.resolveElementList(returnList);
- return returnList;
- }
+ while ((currentChildLM = getChildLM()) != null) {
+ currentChildLM.reset(); // TODO won't work with forced breaks
+ if (addChildElements(elements, currentChildLM, context, alignment) != null) {
+ return elements;
}
+ }
- //Propagate and clear
- context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
- childLC.clearKeepWithNextPending();
+ SpaceResolver.resolveElementList(elements);
+ setFinished(true);
- context.updateKeepWithNextPending(getKeepWithNext());
+ assert !elements.isEmpty();
+ return elements;
+ }
+
+ private List addChildElements(List elements, LayoutManager childLM, LayoutContext context,
+ int alignment) {
+ return addChildElements(elements, childLM, context, alignment, null, null, null);
+ }
+
+ private List addChildElements(List elements, LayoutManager childLM, LayoutContext context,
+ int alignment, Stack lmStack, Position position, LayoutManager restartAtLM) {
+ if (handleSpanChange(childLM, elements, context)) {
+ SpaceResolver.resolveElementList(elements);
+ return elements;
}
- SpaceResolver.resolveElementList(returnList);
- setFinished(true);
+ LayoutContext childLC = new LayoutContext(0);
+ List childrenElements = getNextChildElements(childLM, context, childLC, alignment, lmStack,
+ position, restartAtLM);
+ if (elements.isEmpty()) {
+ context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
+ }
+ if (!elements.isEmpty()
+ && !ElementListUtils.startsWithForcedBreak(childrenElements)) {
+ addInBetweenBreak(elements, context, childLC);
+ }
+ context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
+
+ elements.addAll(childrenElements);
+
+ if (ElementListUtils.endsWithForcedBreak(elements)) {
+ // a descendant of this flow has break-before or break-after
+ if (childLM.isFinished() && !hasNextChildLM()) {
+ setFinished(true);
+ }
+ SpaceResolver.resolveElementList(elements);
+ return elements;
+ }
+ return null;
+ }
+
+ private boolean handleSpanChange(LayoutManager childLM, List elements, LayoutContext context) {
+ int span = EN_NONE;
+ int disableColumnBalancing = EN_FALSE;
+ if (childLM instanceof BlockLayoutManager) {
+ span = ((BlockLayoutManager)childLM).getBlockFO().getSpan();
+ disableColumnBalancing = ((BlockLayoutManager) childLM).getBlockFO()
+ .getDisableColumnBalancing();
+ } else if (childLM instanceof BlockContainerLayoutManager) {
+ span = ((BlockContainerLayoutManager)childLM).getBlockContainerFO().getSpan();
+ disableColumnBalancing = ((BlockContainerLayoutManager) childLM).getBlockContainerFO()
+ .getDisableColumnBalancing();
+ }
+
+ int currentSpan = context.getCurrentSpan();
+ if (currentSpan != span) {
+ if (span == EN_ALL) {
+ context.setDisableColumnBalancing(disableColumnBalancing);
+ }
+ log.debug("span change from " + currentSpan + " to " + span);
+ context.signalSpanChange(span);
+ return true;
+ } else {
+ return false;
+ }
+ }
- if (returnList.size() > 0) {
- return returnList;
+ private List getNextChildElements(LayoutManager childLM, LayoutContext context,
+ LayoutContext childLC, int alignment, Stack lmStack, Position restartPosition,
+ LayoutManager restartLM) {
+ childLC.setStackLimitBP(context.getStackLimitBP());
+ childLC.setRefIPD(context.getRefIPD());
+ childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode());
+
+ List childrenElements;
+ if (lmStack == null) {
+ childrenElements = childLM.getNextKnuthElements(childLC, alignment);
} else {
- return null;
+ childrenElements = childLM.getNextKnuthElements(childLC,
+ alignment, lmStack, restartPosition, restartLM);
}
+ assert !childrenElements.isEmpty();
+
+ // "wrap" the Position inside each element
+ List tempList = childrenElements;
+ childrenElements = new LinkedList();
+ wrapPositionElements(tempList, childrenElements);
+ return childrenElements;
}
/**
@@ -353,5 +395,10 @@
return getCurrentPV().getBodyRegion().getBPD();
}
+ /** {@inheritDoc} */
+ public boolean isRestartable() {
+ return true;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java Wed Aug 26 18:50:10 2009
@@ -57,16 +57,12 @@
return true;
}
- /* (non-Javadoc)
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean canAppendSequence(KnuthSequence sequence) {
return sequence.isInlineSequence() && !isClosed;
}
- /* (non-Javadoc)
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean appendSequence(KnuthSequence sequence) {
if (!canAppendSequence(sequence)) {
return false;
@@ -83,18 +79,14 @@
return true;
}
- /* (non-Javadoc)
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean appendSequence(KnuthSequence sequence, boolean keepTogether,
BreakElement breakElement) {
return appendSequence(sequence);
}
- /* (non-Javadoc)
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public KnuthSequence endSequence() {
if (!isClosed) {
add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false));
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java Wed Aug 26 18:50:10 2009
@@ -78,15 +78,6 @@
* level LM to allow them to optimize returned break possibilities.
*/
private MinOptMax stackLimitBP;
- /**
- * Total available stacking dimension for a "galley-level" layout
- * manager in inline-progression-direction. It is passed by the
- * parent LM. For LineLM, the block LM determines this based on
- * indent properties.
- * These LM <b>may</b> wish to pass this information down to lower
- * level LM to allow them to optimize returned break possibilities.
- */
- private MinOptMax stackLimitIP;
/** to keep track of spanning in multi-column layout */
private int currentSpan = Constants.NOT_SET;
@@ -158,7 +149,7 @@
this.flags = parentLC.flags;
this.refIPD = parentLC.refIPD;
this.writingMode = parentLC.writingMode;
- setStackLimitsFrom(parentLC);
+ setStackLimitBP(parentLC.getStackLimitBP());
this.leadingSpace = parentLC.leadingSpace; //???
this.trailingSpace = parentLC.trailingSpace; //???
this.hyphContext = parentLC.hyphContext;
@@ -183,7 +174,6 @@
this.flags = flags;
this.refIPD = 0;
stackLimitBP = new MinOptMax(0);
- stackLimitIP = new MinOptMax(0);
leadingSpace = null;
trailingSpace = null;
}
@@ -398,31 +388,6 @@
}
/**
- * Sets the stack limit in inline-progression-dimension.
- * @param limit the stack limit
- */
- public void setStackLimitIP(MinOptMax limit) {
- stackLimitIP = limit;
- }
-
- /**
- * Returns the stack limit in inline-progression-dimension.
- * @return the stack limit
- */
- public MinOptMax getStackLimitIP() {
- return stackLimitIP;
- }
-
- /**
- * Sets (Copies) the stack limits in both directions from another layout context.
- * @param context the layout context to take the values from
- */
- public void setStackLimitsFrom(LayoutContext context) {
- setStackLimitBP(context.getStackLimitBP());
- setStackLimitIP(context.getStackLimitIP());
- }
-
- /**
* Sets the inline-progression-dimension of the nearest ancestor reference area.
*/
public void setRefIPD(int ipd) {
@@ -662,8 +627,6 @@
return "Layout Context:"
+ "\nStack Limit BPD: \t"
+ (getStackLimitBP() == null ? "null" : getStackLimitBP().toString())
- + "\nStack Limit IPD: \t"
- + (getStackLimitIP() == null ? "null" : getStackLimitIP().toString())
+ "\nTrailing Space: \t"
+ (getTrailingSpace() == null ? "null" : getTrailingSpace().toString())
+ "\nLeading Space: \t"
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutManager.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutManager.java Wed Aug 26 18:50:10 2009
@@ -20,6 +20,7 @@
package org.apache.fop.layoutmgr;
import java.util.List;
+import java.util.Stack;
import org.apache.fop.area.Area;
import org.apache.fop.datatypes.PercentBaseContext;
@@ -219,4 +220,36 @@
* @return the same Position but with a position index
*/
Position notifyPos(Position pos);
+
+ /**
+ * Re-initializes this layout manager in order to re-generate its Knuth
+ * elements according to a new IPD value.
+ */
+ void reset();
+
+ /**
+ * Returns {@code true} if this layout manager is able to re-generate its
+ * Knuth elements after an IPD change.
+ *
+ * @return {@code true} if this layout manager can be restarted after an IPD
+ * change
+ */
+ boolean isRestartable();
+
+ /**
+ * Returns an updated list of Knuth elements corresponding to this layout
+ * manager, after a change of IPD has been detected.
+ *
+ * @param context the layout context
+ * @param alignment the alignment
+ * @param lmStack the stack of LMs that are active at the IPD change
+ * @param positionAtIPDChange the position corresponding to the element
+ * finishing the page before the IPD change
+ * @param restartAtLM if not null, the layout manager from which to restart.
+ * That is, the IPD change occurs between two block elements and not inside
+ * a paragraph
+ * @return an updated list of elements, taking the new IPD into account
+ */
+ List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
+ Position positionAtIPDChange, LayoutManager restartAtLM);
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java Wed Aug 26 18:50:10 2009
@@ -21,15 +21,20 @@
public class LeafPosition extends Position {
- private int iLeafPos;
+ private int leafPos;
public LeafPosition(LayoutManager lm, int pos) {
super(lm);
- iLeafPos = pos;
+ leafPos = pos;
+ }
+
+ public LeafPosition(LayoutManager layoutManager, int pos, int index) {
+ super(layoutManager, index);
+ leafPos = pos;
}
public int getLeafPos() {
- return iLeafPos;
+ return leafPos;
}
public boolean generatesAreas() {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=808157&r1=808156&r2=808157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java Wed Aug 26 18:50:10 2009
@@ -77,6 +77,14 @@
return pslm.getPageProvider();
}
+ /**
+ * Starts the page breaking process.
+ * @param flowBPD the constant available block-progression-dimension (used for every part)
+ */
+ void doLayout(int flowBPD) {
+ doLayout(flowBPD, false);
+ }
+
/** {@inheritDoc} */
protected PageBreakingLayoutListener createLayoutListener() {
return new PageBreakingLayoutListener() {
@@ -121,6 +129,12 @@
/** {@inheritDoc} */
protected int getNextBlockList(LayoutContext childLC,
int nextSequenceStartsOn) {
+ return getNextBlockList(childLC, nextSequenceStartsOn, null, null, null);
+ }
+
+ /** {@inheritDoc} */
+ protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn,
+ Position positionAtIPDChange, LayoutManager restartLM, List firstElements) {
if (!firstPart) {
// if this is the first page that will be created by
// the current BlockSequence, it could have a break
@@ -132,7 +146,8 @@
pageBreakHandled = true;
pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(),
pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
- return super.getNextBlockList(childLC, nextSequenceStartsOn);
+ return super.getNextBlockList(childLC, nextSequenceStartsOn, positionAtIPDChange,
+ restartLM, firstElements);
}
private boolean containsFootnotes(List contentList, LayoutContext context) {
@@ -209,6 +224,24 @@
return contentList;
}
+ /** {@inheritDoc} */
+ protected List getNextKnuthElements(LayoutContext context, int alignment,
+ Position positionAtIPDChange, LayoutManager restartAtLM) {
+ List contentList = null;
+
+ do {
+ contentList = childFLM.getNextKnuthElements(context, alignment, positionAtIPDChange,
+ restartAtLM);
+ } while (!childFLM.isFinished() && contentList == null);
+
+ // scan contentList, searching for footnotes
+ if (containsFootnotes(contentList, context)) {
+ // handle the footnote separator
+ handleFootnoteSeparator();
+ }
+ return contentList;
+ }
+
/**
* @return current display alignment
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org