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 ac...@apache.org on 2008/04/16 10:21:38 UTC
svn commit: r648611 - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources: ./
src/java/org/apache/fop/fo/flow/table/ src/java/org/apache/fop/layoutmgr/
src/java/org/apache/fop/layoutmgr/inline/
src/java/org/apache/fop/layoutmgr/list/ src/java/org/apache...
Author: acumiskey
Date: Wed Apr 16 01:21:34 2008
New Revision: 648611
URL: http://svn.apache.org/viewvc?rev=648611&view=rev
Log:
Merged revisions 648381 via svnmerge from
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r648381 | jeremias | 2008-04-15 20:18:46 +0100 (Tue, 15 Apr 2008) | 1 line
First part of the implementation of stage 1 for advanced keeps (see Wiki): Integer values are treated differently from "always" values in keep-together.within-column for all block-level FOs.
........
Added:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/KeepUtil.java
- copied unchanged from r648381, xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KeepUtil.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/block-container_keep-together_integers_1.xml
- copied unchanged from r648381, xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block-container_keep-together_integers_1.xml
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/block_keep-together_integers_1.xml
- copied unchanged from r648381, xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_keep-together_integers_1.xml
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/block_keep-together_integers_2.xml
- copied unchanged from r648381, xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_keep-together_integers_2.xml
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/ (props changed)
xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/EffRow.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/GridUnit.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/block_keep-together_overflow_1.xml
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-block_keep-together.xml
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/table_keep-together.xml
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Apr 16 01:21:34 2008
@@ -1 +1 @@
-/xmlgraphics/fop/trunk:1-648207
+/xmlgraphics/fop/trunk:1-648608
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/build.xml Wed Apr 16 01:21:34 2008
@@ -924,7 +924,7 @@
<echo message="${hyphenation.message}"/>
</target>
- <target name="junit-layout-standard" depends="junit-compile" if="junit.present" description="Runs FOP's standard JUnit layout tests">
+ <target name="junit-layout-standard" depends="junit-compile, junit-fotree" if="junit.present" description="Runs FOP's standard JUnit layout tests">
<echo message="Running standard layout engine tests"/>
<junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure">
<sysproperty key="basedir" value="${basedir}"/>
@@ -982,7 +982,7 @@
</junit>
</target>
- <target name="junit-intermediate-format" depends="junit-compile" description="Runs FOP's intermediate format JUnit tests" if="xmlunit.present">
+ <target name="junit-intermediate-format" depends="junit-compile, junit-layout" description="Runs FOP's intermediate format JUnit tests" if="xmlunit.present">
<echo message="Running intermediate format tests"/>
<junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure">
<sysproperty key="basedir" value="${basedir}"/>
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/EffRow.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/EffRow.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/EffRow.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/EffRow.java Wed Apr 16 01:21:34 2008
@@ -23,6 +23,8 @@
import java.util.List;
import org.apache.fop.fo.Constants;
+import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
+import org.apache.fop.layoutmgr.KeepUtil;
import org.apache.fop.layoutmgr.table.TableRowIterator;
import org.apache.fop.traits.MinOptMax;
import org.apache.fop.util.BreakUtil;
@@ -211,10 +213,26 @@
* @return true if this row must be kept together
*/
public boolean mustKeepTogether() {
- TableRow row = getTableRow();
- return row != null && row.mustKeepTogether();
+ return getKeepTogetherStrength() != BlockLevelLayoutManager.KEEP_AUTO;
}
+ /**
+ * Returns the keep-together strength for this element. Note: The keep strength returned does
+ * not take the parent table's keeps into account!
+ * @return the keep-together strength
+ */
+ public int getKeepTogetherStrength() {
+ TableRow row = getTableRow();
+ int strength = BlockLevelLayoutManager.KEEP_AUTO;
+ if (row != null) {
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ row.getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ row.getKeepTogether().getWithinColumn()));
+ }
+ return strength;
+ }
+
/**
* Returns the break class for this row. This is a combination of break-before set on
* the first children of any cells starting on this row.
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/GridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/GridUnit.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/GridUnit.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/GridUnit.java Wed Apr 16 01:21:34 2008
@@ -64,11 +64,16 @@
/** flags for the grid unit */
private byte flags = 0;
+ /** the border-before specification */
ConditionalBorder borderBefore;
+ /** the border-after specification */
ConditionalBorder borderAfter;
+ /** the border-start specification */
BorderSpecification borderStart;
+ /** the border-end specification */
BorderSpecification borderEnd;
+ /** The border model helper associated with the table */
protected CollapsingBorderModel collapsingBorderModel;
/**
@@ -146,6 +151,10 @@
}
}
+ /**
+ * Returns the table cell associated with this grid unit.
+ * @return the table cell
+ */
public TableCell getCell() {
return cell;
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -308,22 +308,7 @@
if (prevLM != null) {
// there is a block handled by prevLM
// before the one handled by curLM
- if (mustKeepTogether()
- || prevLM.mustKeepWithNext()
- || curLM.mustKeepWithPrevious()) {
- // add an infinite penalty to forbid a break between
- // blocks
- contentList.add(new BreakElement(
- new Position(this), KnuthElement.INFINITE, context));
- } else if (!((ListElement) contentList.getLast()).isGlue()) {
- // add a null penalty to allow a break between blocks
- contentList.add(new BreakElement(
- new Position(this), 0, context));
- } else {
- // the last element in contentList is a glue;
- // it is a feasible breakpoint, there is no need to add
- // a penalty
- }
+ addInBetweenBreak(contentList, context, childLC);
}
contentList.addAll(returnedList);
if (returnedList.size() == 0) {
@@ -1004,15 +989,19 @@
}
/** {@inheritDoc} */
- public boolean mustKeepTogether() {
- //TODO Keeps will have to be more sophisticated sooner or later
- return super.mustKeepTogether()
- || !getBlockContainerFO().getKeepTogether().getWithinPage().isAuto()
- || !getBlockContainerFO().getKeepTogether().getWithinColumn().isAuto();
+ public int getKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getBlockContainerFO().getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getBlockContainerFO().getKeepTogether().getWithinColumn()));
+ strength = Math.max(strength, getParentKeepTogetherStrength());
+ return strength;
}
/** {@inheritDoc} */
public boolean mustKeepWithPrevious() {
+ //TODO Keeps will have to be more sophisticated sooner or later
return !getBlockContainerFO().getKeepWithPrevious().getWithinPage().isAuto()
|| !getBlockContainerFO().getKeepWithPrevious().getWithinColumn().isAuto();
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -33,7 +33,6 @@
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
-import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
import org.apache.fop.layoutmgr.inline.LineLayoutManager;
import org.apache.fop.traits.MinOptMax;
@@ -79,11 +78,13 @@
proxyLMiter = new ProxyLMiter();
}
+ /** {@inheritDoc} */
public void initialize() {
super.initialize();
FontInfo fi = getBlockFO().getFOEventHandler().getFontInfo();
FontTriplet[] fontkeys = getBlockFO().getCommonFont().getFontState(fi);
- Font initFont = fi.getFontInstance(fontkeys[0], getBlockFO().getCommonFont().fontSize.getValue(this));
+ Font initFont = fi.getFontInstance(fontkeys[0],
+ getBlockFO().getCommonFont().fontSize.getValue(this));
lead = initFont.getAscender();
follow = -initFont.getDescender();
//middleShift = -fs.getXHeight() / 2;
@@ -135,7 +136,7 @@
*/
protected class ProxyLMiter extends LMiter {
- /*
+ /**
* Constructs a proxy iterator for Block LM.
*/
public ProxyLMiter() {
@@ -206,40 +207,31 @@
return llm;
}
- /**
- * {@inheritDoc}
- */
- public boolean mustKeepTogether() {
- // TODO Keeps will have to be more sophisticated sooner or later
- // TODO This is a quick fix for the fact that the parent is not always a BlockLevelLM;
- // eventually mustKeepTogether() must be moved up to the LM interface
- return (!getBlockFO().getKeepTogether().getWithinPage().isAuto()
- || !getBlockFO().getKeepTogether().getWithinColumn().isAuto()
- || (getParent() instanceof BlockLevelLayoutManager
- && ((BlockLevelLayoutManager) getParent()).mustKeepTogether())
- || (getParent() instanceof InlineLayoutManager
- && ((InlineLayoutManager) getParent()).mustKeepTogether()));
+ /** {@inheritDoc} */
+ public int getKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getBlockFO().getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getBlockFO().getKeepTogether().getWithinColumn()));
+ strength = Math.max(strength, getParentKeepTogetherStrength());
+ return strength;
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public boolean mustKeepWithPrevious() {
+ //TODO Keeps will have to be more sophisticated sooner or later
return !getBlockFO().getKeepWithPrevious().getWithinPage().isAuto()
|| !getBlockFO().getKeepWithPrevious().getWithinColumn().isAuto();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean mustKeepWithNext() {
return !getBlockFO().getKeepWithNext().getWithinPage().isAuto()
|| !getBlockFO().getKeepWithNext().getWithinColumn().isAuto();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -35,9 +35,20 @@
/** Adjustment class: adjustment for line height */
int LINE_HEIGHT_ADJUSTMENT = 3;
+ /** The integer value for "auto" keep strength */
+ int KEEP_AUTO = Integer.MIN_VALUE;
+ /** The integer value for "always" keep strength */
+ int KEEP_ALWAYS = Integer.MAX_VALUE;
+
int negotiateBPDAdjustment(int adj, KnuthElement lastElement);
void discardSpace(KnuthGlue spaceGlue);
+
+ /**
+ * Returns the keep-together strength for this element.
+ * @return the keep-together strength
+ */
+ int getKeepTogetherStrength();
/**
* @return true if this element must be kept together
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -335,27 +335,7 @@
if (prevLM != null) {
// there is a block handled by prevLM
// before the one handled by curLM
- if (mustKeepTogether()
- || context.isKeepWithNextPending()
- || childLC.isKeepWithPreviousPending()) {
- // Clear keep pending flag
- context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
- // add an infinite penalty to forbid a break between
- // blocks
- contentList.add(new BreakElement(
- new Position(this), KnuthElement.INFINITE, context));
- } else if (!((ListElement) contentList.getLast()).isGlue()) {
- // add a null penalty to allow a break between blocks
- contentList.add(new BreakElement(
- new Position(this), 0, context));
- } else {
- // the last element in contentList is a glue;
- // it is a feasible breakpoint, there is no need to add
- // a penalty
- log.warn("glue-type break possibility not handled properly, yet");
- //TODO Does this happen? If yes, need to deal with border and padding
- //at the break possibility
- }
+ addInBetweenBreak(contentList, context, childLC);
}
if (returnedList == null || returnedList.size() == 0) {
//Avoid NoSuchElementException below (happens with empty blocks)
@@ -433,6 +413,66 @@
}
/**
+ * Adds a break element to the content list between individual child elements.
+ * @param contentList the content list to populate
+ * @param context the current layout context
+ * @param childLC the currently active child layout context
+ */
+ protected void addInBetweenBreak(LinkedList contentList, LayoutContext context,
+ LayoutContext childLC) {
+ if (mustKeepTogether()
+ || context.isKeepWithNextPending()
+ || childLC.isKeepWithPreviousPending()) {
+
+ int strength = getKeepTogetherStrength();
+ if (context.isKeepWithNextPending()) {
+ context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
+ strength = KEEP_ALWAYS;
+ }
+ if (childLC.isKeepWithPreviousPending()) {
+ childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
+ strength = KEEP_ALWAYS;
+ }
+ int penalty = KeepUtil.getPenaltyForKeep(strength);
+
+ // add a penalty to forbid or discourage a break between blocks
+ contentList.add(new BreakElement(
+ new Position(this), penalty, context));
+ return;
+ }
+
+ ListElement last = (ListElement)contentList.getLast();
+ if (last.isGlue()) {
+ // the last element in contentList is a glue;
+ // it is a feasible breakpoint, there is no need to add
+ // a penalty
+ log.warn("glue-type break possibility not handled properly, yet");
+ //TODO Does this happen? If yes, need to deal with border and padding
+ //at the break possibility
+ } else if (!ElementListUtils.endsWithNonInfinitePenalty(contentList)) {
+
+ // TODO vh: this is hacky
+ // The getNextKnuthElements method of TableCellLM must not be called
+ // twice, otherwise some settings like indents or borders will be
+ // counted several times and lead to a wrong output. Anyway the
+ // getNextKnuthElements methods should be called only once eventually
+ // (i.e., when multi-threading the code), even when there are forced
+ // breaks.
+ // If we add a break possibility after a forced break the
+ // AreaAdditionUtil.addAreas method will act on a sequence starting
+ // with a SpaceResolver.SpaceHandlingBreakPosition element, having no
+ // LM associated to it. Thus it will stop early instead of adding
+ // areas for following Positions. The above test aims at preventing
+ // such a situation from occurring. add a null penalty to allow a break
+ // between blocks
+
+ // add a null penalty to allow a break between blocks
+ contentList.add(new BreakElement(
+ new Position(this), 0, context));
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
@@ -759,26 +799,34 @@
}
/**
- * {@inheritDoc}
+ * Retrieves and returns the keep-together strength from the parent element.
+ * @return the keep-together strength
*/
- // default action: ask parentLM
+ protected int getParentKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
+ if (getParent() instanceof BlockLevelLayoutManager) {
+ strength = ((BlockLevelLayoutManager)getParent()).getKeepTogetherStrength();
+ } else if (getParent() instanceof InlineLayoutManager) {
+ if (((InlineLayoutManager) getParent()).mustKeepTogether()) {
+ strength = KEEP_ALWAYS;
+ }
+ //TODO Fix me
+ //strength = ((InlineLayoutManager) getParent()).getKeepTogetherStrength();
+ }
+ return strength;
+ }
+
+ /** {@inheritDoc} */
public boolean mustKeepTogether() {
- return ((getParent() instanceof BlockLevelLayoutManager
- && ((BlockLevelLayoutManager) getParent()).mustKeepTogether())
- || (getParent() instanceof InlineLayoutManager
- && ((InlineLayoutManager) getParent()).mustKeepTogether()));
+ return getKeepTogetherStrength() > KEEP_AUTO;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean mustKeepWithPrevious() {
return false;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean mustKeepWithNext() {
return false;
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/ElementListUtils.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/ElementListUtils.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/ElementListUtils.java Wed Apr 16 01:21:34 2008
@@ -190,6 +190,23 @@
}
/**
+ * Indicates whether the given element list ends with a penalty with a non-infinite penalty
+ * value.
+ * @param elems the element list
+ * @return true if the list ends with a non-infinite penalty
+ */
+ public static boolean endsWithNonInfinitePenalty(LinkedList elems) {
+ ListElement last = (ListElement)elems.getLast();
+ if (last.isPenalty() && ((KnuthPenalty)last).getP() < KnuthElement.INFINITE) {
+ return true;
+ } else if (last instanceof BreakElement
+ && ((BreakElement)last).getPenaltyValue() < KnuthElement.INFINITE) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Determines the position of the previous break before the start index on an
* element list.
* @param elems the element list
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -208,10 +208,10 @@
}
/** {@inheritDoc} */
- public boolean mustKeepTogether() {
- return false;
+ public int getKeepTogetherStrength() {
+ return KEEP_AUTO;
}
-
+
/** {@inheritDoc} */
public boolean mustKeepWithPrevious() {
return false;
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -19,11 +19,11 @@
package org.apache.fop.layoutmgr;
+import java.util.LinkedList;
+
import org.apache.fop.area.Area;
import org.apache.fop.fo.flow.FootnoteBody;
-import java.util.LinkedList;
-
/**
* Layout manager for footnote bodies.
*/
@@ -91,4 +91,9 @@
return (FootnoteBody) fobj;
}
+ /** {@inheritDoc} */
+ public int getKeepTogetherStrength() {
+ return getParentKeepTogetherStrength();
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -405,5 +405,10 @@
this.contentAreaBPD = contentAreaBPD;
}
+ /** {@inheritDoc} */
+ public int getKeepTogetherStrength() {
+ return KEEP_AUTO;
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -1271,13 +1271,16 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean mustKeepTogether() {
return ((BlockLevelLayoutManager) getParent()).mustKeepTogether();
}
+ /** {@inheritDoc} */
+ public int getKeepTogetherStrength() {
+ return ((BlockLevelLayoutManager) getParent()).getKeepTogetherStrength();
+ }
+
/**
* {@inheritDoc}
*/
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -32,6 +32,7 @@
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.ConditionalElementListener;
import org.apache.fop.layoutmgr.ElementListUtils;
+import org.apache.fop.layoutmgr.KeepUtil;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.NonLeafPosition;
@@ -278,15 +279,19 @@
}
/** {@inheritDoc} */
- public boolean mustKeepTogether() {
- //TODO Keeps will have to be more sophisticated sooner or later
- return super.mustKeepTogether()
- || !getListBlockFO().getKeepTogether().getWithinPage().isAuto()
- || !getListBlockFO().getKeepTogether().getWithinColumn().isAuto();
+ public int getKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getListBlockFO().getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getListBlockFO().getKeepTogether().getWithinColumn()));
+ strength = Math.max(strength, getParentKeepTogetherStrength());
+ return strength;
}
-
+
/** {@inheritDoc} */
public boolean mustKeepWithPrevious() {
+ //TODO Keeps will have to be more sophisticated sooner or later
return !getListBlockFO().getKeepWithPrevious().getWithinPage().isAuto()
|| !getListBlockFO().getKeepWithPrevious().getWithinColumn().isAuto();
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -28,8 +28,8 @@
import org.apache.fop.fo.flow.AbstractListItemPart;
import org.apache.fop.fo.flow.ListItemBody;
import org.apache.fop.fo.flow.ListItemLabel;
-import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
+import org.apache.fop.layoutmgr.KeepUtil;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.NonLeafPosition;
@@ -221,12 +221,15 @@
}
/** {@inheritDoc} */
- public boolean mustKeepTogether() {
- //TODO Keeps will have to be more sophisticated sooner or later
- return ((BlockLevelLayoutManager)getParent()).mustKeepTogether()
- || !getPartFO().getKeepTogether().getWithinPage().isAuto()
- || !getPartFO().getKeepTogether().getWithinColumn().isAuto();
+ public int getKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getPartFO().getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getPartFO().getKeepTogether().getWithinColumn()));
+ strength = Math.max(strength, getParentKeepTogetherStrength());
+ return strength;
}
-
+
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -32,12 +32,12 @@
import org.apache.fop.fo.flow.ListItem;
import org.apache.fop.fo.flow.ListItemBody;
import org.apache.fop.fo.flow.ListItemLabel;
-import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.ConditionalElementListener;
import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.layoutmgr.ElementListUtils;
+import org.apache.fop.layoutmgr.KeepUtil;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthPenalty;
@@ -305,14 +305,17 @@
//Additional penalty height from penalties in the source lists
int additionalPenaltyHeight = 0;
+ int stepPenalty = 0;
KnuthElement endEl = (KnuthElement)elementLists[0].get(end[0]);
if (endEl instanceof KnuthPenalty) {
additionalPenaltyHeight = endEl.getW();
+ stepPenalty = Math.max(stepPenalty, endEl.getP());
}
endEl = (KnuthElement)elementLists[1].get(end[1]);
if (endEl instanceof KnuthPenalty) {
additionalPenaltyHeight = Math.max(
additionalPenaltyHeight, endEl.getW());
+ stepPenalty = Math.max(stepPenalty, endEl.getP());
}
int boxHeight = step - addedBoxHeight - penaltyHeight;
@@ -324,10 +327,13 @@
start[0], end[0], start[1], end[1]);
returnList.add(new KnuthBox(boxHeight, stepPosition, false));
if (addedBoxHeight < totalHeight) {
- int p = 0;
- if (keepWithNextActive || mustKeepTogether()) {
+ int p = stepPenalty;
+ if (keepWithNextActive) {
p = KnuthPenalty.INFINITE;
}
+ if (mustKeepTogether()) {
+ p = Math.max(p, KeepUtil.getPenaltyForKeep(getKeepTogetherStrength()));
+ }
returnList.add(new BreakElement(stepPosition, penaltyHeight, p, -1, context));
}
}
@@ -630,15 +636,19 @@
}
/** {@inheritDoc} */
- public boolean mustKeepTogether() {
- //TODO Keeps will have to be more sophisticated sooner or later
- return ((BlockLevelLayoutManager)getParent()).mustKeepTogether()
- || !getListItemFO().getKeepTogether().getWithinPage().isAuto()
- || !getListItemFO().getKeepTogether().getWithinColumn().isAuto();
+ public int getKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getListItemFO().getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getListItemFO().getKeepTogether().getWithinColumn()));
+ strength = Math.max(strength, getParentKeepTogetherStrength());
+ return strength;
}
/** {@inheritDoc} */
public boolean mustKeepWithPrevious() {
+ //TODO Keeps will have to be more sophisticated sooner or later
return !getListItemFO().getKeepWithPrevious().getWithinPage().isAuto()
|| !getListItemFO().getKeepWithPrevious().getWithinColumn().isAuto();
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -19,12 +19,12 @@
package org.apache.fop.layoutmgr.table;
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
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.area.Area;
-import org.apache.fop.area.Block;
/**
* LayoutManager for a table-and-caption FO.
@@ -191,5 +191,18 @@
curBlockArea.addBlock((Block) childArea);
}
}
-}
-
+
+ /** {@inheritDoc} */
+ public int getKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
+ /* TODO Complete me!
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getTableAndCaption().getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getTableAndCaption().getKeepTogether().getWithinColumn()));
+ */
+ strength = Math.max(strength, getParentKeepTogetherStrength());
+ return strength;
+ }
+
+}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -19,12 +19,12 @@
package org.apache.fop.layoutmgr.table;
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
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.area.Area;
-import org.apache.fop.area.Block;
/**
* LayoutManager for a table-caption FO.
@@ -46,6 +46,11 @@
super(node);
}
+ /** @return the table-caption FO */
+ public TableCaption getTableCaption() {
+ return (TableCaption)this.fobj;
+ }
+
/**
* Get the next break position for the caption.
*
@@ -190,5 +195,19 @@
curBlockArea.addBlock((Block) childArea);
}
}
+
+ /** {@inheritDoc} */
+ public int getKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
+ /* TODO Complete me!
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getTableCaption().getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getTableCaption().getKeepTogether().getWithinColumn()));
+ */
+ strength = Math.max(strength, getParentKeepTogetherStrength());
+ return strength;
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -27,7 +27,6 @@
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.area.Trait;
-import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.flow.table.ConditionalBorder;
import org.apache.fop.fo.flow.table.GridUnit;
import org.apache.fop.fo.flow.table.PrimaryGridUnit;
@@ -41,13 +40,12 @@
import org.apache.fop.layoutmgr.AreaAdditionUtil;
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
-import org.apache.fop.layoutmgr.BreakElement;
+import org.apache.fop.layoutmgr.KeepUtil;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.KnuthPenalty;
import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.SpaceResolver;
@@ -162,46 +160,7 @@
if (prevLM != null) {
// there is a block handled by prevLM
// before the one handled by curLM
- if (mustKeepTogether()
- || context.isKeepWithNextPending()
- || childLC.isKeepWithPreviousPending()) {
- //Clear keep pending flag
- context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
- childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
- // add an infinite penalty to forbid a break between
- // blocks
- contentList.add(new BreakElement(
- new Position(this), KnuthElement.INFINITE, context));
- //contentList.add(new KnuthPenalty(0,
- // KnuthElement.INFINITE, false,
- // new Position(this), false));
- } else if (!(((ListElement) contentList.getLast()).isGlue()
- || (((ListElement)contentList.getLast()).isPenalty()
- && ((KnuthPenalty)contentList.getLast()).getP() < KnuthElement.INFINITE)
- || (contentList.getLast() instanceof BreakElement
- && ((BreakElement)contentList.getLast()).getPenaltyValue() < KnuthElement.INFINITE))) {
- // TODO vh: this is hacky
- // The getNextKnuthElements method of TableCellLM must not be called
- // twice, otherwise some settings like indents or borders will be
- // counted several times and lead to a wrong output. Anyway the
- // getNextKnuthElements methods should be called only once eventually
- // (i.e., when multi-threading the code), even when there are forced
- // breaks.
- // If we add a break possibility after a forced break the
- // AreaAdditionUtil.addAreas method will act on a sequence starting
- // with a SpaceResolver.SpaceHandlingBreakPosition element, having no
- // LM associated to it. Thus it will stop early instead of adding
- // areas for following Positions. The above test aims at preventing
- // such a situation from occurring. add a null penalty to allow a break
- // between blocks
- contentList.add(new BreakElement(
- new Position(this), 0, context));
- //contentList.add(new KnuthPenalty(0, 0, false,
- // new Position(this), false));
- } else {
- // the last element in contentList is a feasible breakpoint, there is
- // no need to add a penalty
- }
+ addInBetweenBreak(contentList, context, childLC);
}
contentList.addAll(returnedList);
if (returnedList.size() == 0) {
@@ -596,22 +555,22 @@
// TODO Auto-generated method stub
}
- /**
- * {@inheritDoc}
- */
- public boolean mustKeepTogether() {
- //TODO Keeps will have to be more sophisticated sooner or later
- boolean keep = ((BlockLevelLayoutManager)getParent()).mustKeepTogether();
+ /** {@inheritDoc} */
+ public int getKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
if (primaryGridUnit.getRow() != null) {
- keep |= primaryGridUnit.getRow().mustKeepTogether();
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ primaryGridUnit.getRow().getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ primaryGridUnit.getRow().getKeepTogether().getWithinColumn()));
}
- return keep;
+ strength = Math.max(strength, getParentKeepTogetherStrength());
+ return strength;
}
-
- /**
- * {@inheritDoc}
- */
+
+ /** {@inheritDoc} */
public boolean mustKeepWithPrevious() {
+ //TODO Keeps will have to be more sophisticated sooner or later
return false; //TODO FIX ME
/*
return !fobj.getKeepWithPrevious().getWithinPage().isAuto()
@@ -619,9 +578,7 @@
*/
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean mustKeepWithNext() {
return false; //TODO FIX ME
/*
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
@@ -36,6 +37,7 @@
import org.apache.fop.fo.flow.table.TableBody;
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.ElementListUtils;
+import org.apache.fop.layoutmgr.KeepUtil;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthPossPosIter;
@@ -226,9 +228,12 @@
nextRowGroupElems = rowGroupLM.getNextKnuthElements(context, alignment, bodyType);
int penaltyValue = 0;
keepBetween |= context.isKeepWithPreviousPending();
- if (keepBetween || tableLM.getTable().mustKeepTogether()) {
+ if (keepBetween) {
penaltyValue = KnuthElement.INFINITE;
}
+ penaltyValue = Math.max(penaltyValue,
+ KeepUtil.getPenaltyForKeep(getTableLM().getKeepTogetherStrength()));
+
breakBetween = BreakUtil.compareBreakClasses(breakBetween,
context.getBreakBefore());
if (breakBetween != Constants.EN_AUTO) {
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java Wed Apr 16 01:21:34 2008
@@ -39,6 +39,7 @@
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.ConditionalElementListener;
+import org.apache.fop.layoutmgr.KeepUtil;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.LayoutContext;
@@ -445,16 +446,17 @@
}
- /**
- * {@inheritDoc}
- */
- public boolean mustKeepTogether() {
- //TODO Keeps will have to be more sophisticated sooner or later
- return super.mustKeepTogether()
- || !getTable().getKeepTogether().getWithinPage().isAuto()
- || !getTable().getKeepTogether().getWithinColumn().isAuto();
+ /** {@inheritDoc} */
+ public int getKeepTogetherStrength() {
+ int strength = KEEP_AUTO;
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getTable().getKeepTogether().getWithinPage()));
+ strength = Math.max(strength, KeepUtil.getKeepStrength(
+ getTable().getKeepTogether().getWithinColumn()));
+ strength = Math.max(strength, getParentKeepTogetherStrength());
+ return strength;
}
-
+
/**
* {@inheritDoc}
*/
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java Wed Apr 16 01:21:34 2008
@@ -25,11 +25,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.table.EffRow;
import org.apache.fop.fo.flow.table.GridUnit;
import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.layoutmgr.BreakElement;
+import org.apache.fop.layoutmgr.KeepUtil;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.KnuthPenalty;
@@ -234,13 +236,15 @@
ActiveCell activeCell = (ActiveCell) iter.next();
keepWithNext |= activeCell.keepWithNextSignal();
}
- if (keepWithNext || getTableLM().mustKeepTogether()) {
+ if (keepWithNext) {
p = KnuthPenalty.INFINITE;
}
if (!rowFinished) {
- if (rowGroup[activeRowIndex].mustKeepTogether()) {
- p = KnuthPenalty.INFINITE;
- }
+ p = Math.max(p, KeepUtil.getPenaltyForKeep(
+ rowGroup[activeRowIndex].getKeepTogetherStrength()));
+ //The above call doesn't take the penalty from the table into account, so...
+ p = Math.max(p, KeepUtil.getPenaltyForKeep(
+ getTableLM().getKeepTogetherStrength()));
} else if (activeRowIndex < rowGroup.length - 1) {
if (rowGroup[activeRowIndex].mustKeepWithNext()
|| rowGroup[activeRowIndex + 1].mustKeepWithPrevious()) {
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/block_keep-together_overflow_1.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/block_keep-together_overflow_1.xml?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/block_keep-together_overflow_1.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/block_keep-together_overflow_1.xml Wed Apr 16 01:21:34 2008
@@ -44,7 +44,7 @@
<fo:flow flow-name="xsl-region-body">
<fo:block>block1</fo:block>
<fo:block>block2</fo:block>
- <fo:block keep-together.within-page="10" color="blue">
+ <fo:block keep-together.within-page="always" color="blue">
<fo:block>block3</fo:block>
<fo:block>block4</fo:block>
<fo:block>block5</fo:block>
@@ -53,7 +53,7 @@
</fo:block>
<fo:block>block8</fo:block>
<fo:block>block9</fo:block>
- <fo:block keep-together.within-page="10" color="green">
+ <fo:block keep-together.within-page="always" color="green">
<fo:block>block10</fo:block>
<fo:block>block11</fo:block>
<fo:block>block12</fo:block>
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-block_keep-together.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-block_keep-together.xml?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-block_keep-together.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-block_keep-together.xml Wed Apr 16 01:21:34 2008
@@ -25,14 +25,15 @@
<fo>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" white-space-collapse="true" widows="0" orphans="0">
<fo:layout-master-set>
- <fo:simple-page-master master-name="normal" page-width="5in" page-height="4.5 * 14.4pt">
+ <fo:simple-page-master master-name="normal" page-width="5in" page-height="20 * 14.4pt">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="normal">
<fo:flow flow-name="xsl-region-body">
<fo:block>block1</fo:block>
- <fo:list-block
+ <!-- Keeps on list-block level -->
+ <fo:list-block background-color="rgb(150,150,255)"
provisional-distance-between-starts="25mm"
provisional-label-separation="5mm"
keep-together.within-page="always">
@@ -54,16 +55,16 @@
</fo:list-item>
</fo:list-block>
<fo:block>block2</fo:block>
- <fo:list-block
- provisional-distance-between-starts="25mm"
- provisional-label-separation="5mm">
- <fo:list-item keep-together.within-page="always">
+ <fo:list-block background-color="rgb(230,230,255)"
+ provisional-distance-between-starts="25mm"
+ provisional-label-separation="5mm"
+ keep-together.within-column="1">
+ <fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>label1</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>item1</fo:block>
- <fo:block>item1</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
@@ -76,11 +77,44 @@
</fo:list-item>
</fo:list-block>
<fo:block>block3</fo:block>
+ <!-- Keeps on list-item level -->
<fo:list-block
provisional-distance-between-starts="25mm"
provisional-label-separation="5mm">
+ <fo:list-item keep-together.within-page="always" background-color="rgb(150,150,255)">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>label1</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>item1</fo:block>
+ <fo:block>item1</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item keep-together.within-column="1" background-color="rgb(230,230,255)">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>label1</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>item1</fo:block>
+ <fo:block>item1</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
+ <fo:block>label3</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>item3</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ <fo:block>block4</fo:block>
+ <!-- Keeps on list-item-body level -->
+ <fo:list-block
+ provisional-distance-between-starts="25mm"
+ provisional-label-separation="5mm">
+ <fo:list-item background-color="rgb(150,150,255)">
+ <fo:list-item-label end-indent="label-end()">
<fo:block>label1</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()" keep-together.within-page="always">
@@ -88,47 +122,80 @@
<fo:block>item1</fo:block>
</fo:list-item-body>
</fo:list-item>
- <fo:list-item>
+ <fo:list-item background-color="rgb(230,230,255)">
<fo:list-item-label end-indent="label-end()">
<fo:block>label2</fo:block>
</fo:list-item-label>
- <fo:list-item-body start-indent="body-start()">
+ <fo:list-item-body start-indent="body-start()" keep-together.within-column="1">
+ <fo:block>item2</fo:block>
<fo:block>item2</fo:block>
</fo:list-item-body>
</fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>label3</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>item3</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
</fo:list-block>
- <fo:block>block4</fo:block>
+ <fo:block>block5</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</fo>
<checks>
<element-list category="breaker">
- <box w="14400"/>
+ <box/> <!-- block1 -->
<penalty w="0" p="0"/>
+
<!-- list 1 starts -->
<box w="14400"/>
<penalty w="0" p="INF"/>
<box w="14400"/>
<!-- list 1 end -->
+
<penalty w="0" p="0"/>
- <box w="14400"/>
+ <box/> <!-- block2 -->
<penalty w="0" p="0"/>
+
<!-- list 2 starts -->
- <box w="28800"/>
- <penalty w="0" p="0"/>
+ <box w="14400"/>
+ <penalty w="0" p="999"/>
<box w="14400"/>
<!-- list 2 end -->
+
<penalty w="0" p="0"/>
- <box w="14400"/>
+ <box/> <!-- block3 -->
<penalty w="0" p="0"/>
+
<!-- list 3 starts -->
<box w="28800"/>
<penalty w="0" p="0"/>
<box w="14400"/>
+ <penalty w="0" p="999"/>
+ <box w="14400"/>
+ <penalty w="0" p="0"/>
+ <box w="14400"/>
<!-- list 3 end -->
+
<penalty w="0" p="0"/>
+ <box/> <!-- block4 -->
+ <penalty w="0" p="0"/>
+
+ <!-- list 4 starts -->
+ <box w="28800"/>
+ <penalty w="0" p="0"/>
+ <box w="14400"/>
+ <penalty w="0" p="999"/>
<box w="14400"/>
+ <penalty w="0" p="0"/>
+ <box w="14400"/>
+ <!-- list 4 end -->
+
+ <penalty w="0" p="0"/>
+ <box/> <!-- block5 -->
<skip>3</skip>
</element-list>
</checks>
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/table_keep-together.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/table_keep-together.xml?rev=648611&r1=648610&r2=648611&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/table_keep-together.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/table_keep-together.xml Wed Apr 16 01:21:34 2008
@@ -25,16 +25,16 @@
<fo>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" white-space-collapse="true" widows="0" orphans="0">
<fo:layout-master-set>
- <fo:simple-page-master master-name="normal" page-width="5in" page-height="4.5 * 14.4pt">
+ <fo:simple-page-master master-name="normal" page-width="5in" page-height="5 * 14.4pt">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="normal">
<fo:flow flow-name="xsl-region-body">
<fo:block>block1</fo:block>
- <fo:table table-layout="fixed" keep-together.within-page="always">
- <fo:table-column/>
- <fo:table-column/>
+ <fo:table table-layout="fixed" width="100%" keep-together.within-page="always">
+ <fo:table-column column-width="proportional-column-width(1)"/>
+ <fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell id="cell1">
@@ -58,6 +58,35 @@
<fo:block>block2</fo:block>
</fo:flow>
</fo:page-sequence>
+ <fo:page-sequence master-reference="normal">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>block1b</fo:block>
+ <fo:table table-layout="fixed" width="100%" keep-together.within-column="1">
+ <fo:table-column column-width="proportional-column-width(1)"/>
+ <fo:table-column column-width="proportional-column-width(1)"/>
+ <fo:table-body>
+ <fo:table-row>
+ <fo:table-cell id="cell1b">
+ <fo:block>line1</fo:block>
+ <fo:block>line2</fo:block>
+ </fo:table-cell>
+ <fo:table-cell id="cell2b">
+ <fo:block>line1</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell id="cell3b">
+ <fo:block>line1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell id="cell4b">
+ <fo:block>line1</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+ <fo:block>block2b</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
</fo:root>
</fo>
<checks>
@@ -69,11 +98,33 @@
<element-list category="table-cell" id="cell2">
<box w="14400"/>
</element-list>
- <element-list category="breaker">
+ <element-list category="breaker" index="0">
<box w="14400"/>
<penalty w="0" p="0"/>
<box w="28800"/>
<penalty w="0" p="INF"/>
+ <box w="14400"/>
+ <penalty w="0" p="0"/>
+ <box w="14400"/>
+ <skip>3</skip>
+ </element-list>
+
+ <!-- the same again but this time with keep="1" -->
+ <element-list category="table-cell" id="cell1b">
+ <box w="14400"/>
+ <penalty w="0" p="999"/>
+ <box w="14400"/>
+ </element-list>
+ <element-list category="table-cell" id="cell2b">
+ <box w="14400"/>
+ </element-list>
+ <element-list category="breaker" index="1">
+ <box w="14400"/>
+ <penalty w="0" p="0"/>
+ <box w="14400"/>
+ <penalty w="0" p="999"/>
+ <box w="14400"/>
+ <penalty w="0" p="999"/>
<box w="14400"/>
<penalty w="0" p="0"/>
<box w="14400"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org