diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2009-01-28 15:33:02 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2009-01-28 15:33:02 +0000 |
commit | 490204ba3a03ee172c2a2f19675aea1cc059c2ba (patch) | |
tree | 2f146a71833d4b2898acbee138c41a26019554af /src/java | |
parent | 092551c26f8a1ab688ed826beb9568d63f7f6dbe (diff) | |
download | xmlgraphics-fop-490204ba3a03ee172c2a2f19675aea1cc059c2ba.tar.gz xmlgraphics-fop-490204ba3a03ee172c2a2f19675aea1cc059c2ba.zip |
Bugzilla #46315: extension to disable column balancing before blocks spanning the whole page, in multiple-column documents.
Patch submitted by Georg Datterl, applied with some modifications (mainly Checkstyle issues)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@738514 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
8 files changed, 71 insertions, 9 deletions
diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java index 91ff780bd..a1ccb20e7 100644 --- a/src/java/org/apache/fop/fo/Constants.java +++ b/src/java/org/apache/fop/fo/Constants.java @@ -766,8 +766,13 @@ public interface Constants { int PR_X_WIDOW_CONTENT_LIMIT = 271; /** Property constant - FOP proprietary: limit for orphan content in lists and tables */ int PR_X_ORPHAN_CONTENT_LIMIT = 272; + /** + * Property constant - FOP proprietary: disable balancing of columns in + * multi-column layouts. + */ + int PR_X_DISABLE_COLUMN_BALANCING = 273; /** Number of property constants defined */ - int PROPERTY_COUNT = 272; + int PROPERTY_COUNT = 273; // compound property constants diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index e890b9e24..b4a864e43 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -1895,6 +1895,13 @@ public final class FOPropertyMapping implements Constants { m.addEnum("all", getEnumProperty(EN_ALL, "ALL")); m.setDefault("none"); addPropertyMaker("span", m); + + // fox:disable-column-balancing + m = new EnumProperty.Maker(PR_X_DISABLE_COLUMN_BALANCING); + m.useGeneric(genericBoolean); + m.setInherited(true); + m.setDefault("false"); + addPropertyMaker("fox:disable-column-balancing", m); } private void createLeaderAndRuleProperties() { diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java index 56521b7e8..927bed0f7 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java @@ -45,6 +45,7 @@ public class ExtensionElementMapping extends ElementMapping { propertyAttributes.add("widow-content-limit"); propertyAttributes.add("orphan-content-limit"); propertyAttributes.add("internal-destination"); + propertyAttributes.add("disable-column-balancing"); } /** diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index 4645734b2..daaebd6d0 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -21,8 +21,6 @@ package org.apache.fop.fo.flow; import java.awt.Color; -import org.xml.sax.Locator; - import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.Numeric; @@ -40,6 +38,7 @@ import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.SpaceProperty; +import org.xml.sax.Locator; /** * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_block"> @@ -80,6 +79,7 @@ public class Block extends FObjMixed implements BreakPropertySet { private int whiteSpaceCollapse; private Numeric widows; private int wrapOption; + private int disableColumnBalancing; // Unused but valid items, commented out for performance: // private CommonAccessibility commonAccessibility; // private CommonAural commonAural; @@ -130,6 +130,7 @@ public class Block extends FObjMixed implements BreakPropertySet { whiteSpaceCollapse = pList.get(PR_WHITE_SPACE_COLLAPSE).getEnum(); widows = pList.get(PR_WIDOWS).getNumeric(); wrapOption = pList.get(PR_WRAP_OPTION).getEnum(); + disableColumnBalancing = pList.get(PR_X_DISABLE_COLUMN_BALANCING).getEnum(); } /** {@inheritDoc} */ @@ -318,6 +319,15 @@ public class Block extends FObjMixed implements BreakPropertySet { return this.lineHeightShiftAdjustment; } + /** + * @return the "fox:disable-column-balancing" property, one of + * {@link Constants#EN_TRUE}, {@link Constants#EN_FALSE} + */ + public int getDisableColumnBalancing() { + return disableColumnBalancing; + } + + /** {@inheritDoc} */ public CharIterator charIterator() { return NullCharIterator.getInstance(); diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java index b0bfb3a32..2a8d73002 100644 --- a/src/java/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java @@ -19,10 +19,7 @@ package org.apache.fop.fo.flow; -import org.xml.sax.Locator; - import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.Numeric; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; @@ -34,6 +31,7 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.LengthRangeProperty; +import org.xml.sax.Locator; /** * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_block-container"> @@ -56,6 +54,7 @@ public class BlockContainer extends FObj implements BreakPropertySet { private int overflow; private Numeric referenceOrientation; private int span; + private int disableColumnBalancing; private int writingMode; // Unused but valid items, commented out for performance: // private int intrusionDisplace; @@ -94,6 +93,7 @@ public class BlockContainer extends FObj implements BreakPropertySet { referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric(); span = pList.get(PR_SPAN).getEnum(); writingMode = pList.get(PR_WRITING_MODE).getEnum(); + disableColumnBalancing = pList.get(PR_X_DISABLE_COLUMN_BALANCING).getEnum(); } /** {@inheritDoc} */ @@ -217,6 +217,15 @@ public class BlockContainer extends FObj implements BreakPropertySet { return this.span; } + /** + * @return the "fox:disable-column-balancing" property, one of + * {@link Constants#EN_TRUE}, {@link Constants#EN_FALSE} + */ + public int getDisableColumnBalancing() { + return disableColumnBalancing; + } + + /** @return the "writing-mode" property */ public int getWritingMode() { return writingMode; diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java index 42f08a42d..245fa7235 100644 --- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java @@ -25,7 +25,6 @@ import java.util.ListIterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.fop.area.Area; import org.apache.fop.area.BlockParent; import org.apache.fop.fo.pagination.Flow; @@ -82,14 +81,22 @@ public class FlowLayoutManager extends BlockStackingLayoutManager } 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(); } 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); diff --git a/src/java/org/apache/fop/layoutmgr/LayoutContext.java b/src/java/org/apache/fop/layoutmgr/LayoutContext.java index 3526ed239..4d56d1657 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutContext.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutContext.java @@ -148,6 +148,8 @@ public class LayoutContext { private int pendingKeepWithNext = BlockLevelLayoutManager.KEEP_AUTO; private int pendingKeepWithPrevious = BlockLevelLayoutManager.KEEP_AUTO; + private int disableColumnBalancing; + /** * Copy constructor for creating child layout contexts. * @param parentLC the parent layout context to copy from @@ -170,6 +172,7 @@ public class LayoutContext { this.pendingKeepWithNext = parentLC.pendingKeepWithNext; this.pendingKeepWithPrevious = parentLC.pendingKeepWithPrevious; // Copy other fields as necessary. + this.disableColumnBalancing = parentLC.disableColumnBalancing; } /** @@ -412,7 +415,7 @@ public class LayoutContext { /** * Sets (Copies) the stack limits in both directions from another layout context. - * @param context the layout context to taje the values from + * @param context the layout context to take the values from */ public void setStackLimitsFrom(LayoutContext context) { setStackLimitBP(context.getStackLimitBP()); @@ -681,5 +684,23 @@ public class LayoutContext { + (breakAfter != Constants.EN_AUTO ? "break-after" : "") + "]"; } + /** + * Returns whether the column balancer should be disabled before a spanning block + * + * @return one of {@link Constants#EN_TRUE}, {@link Constants#EN_FALSE} + */ + public int getDisableColumnBalancing() { + return disableColumnBalancing; + } + + /** + * Sets whether the column balancer should be disabled before a spanning block + * + * @param disableColumnBalancing the value of the fox:disable-column-balancing property + * @see #getDisableColumnBalancing() + */ + public void setDisableColumnBalancing(int disableColumnBalancing) { + this.disableColumnBalancing = disableColumnBalancing; + } } diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java index 9ff520804..5dc1576c7 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.java @@ -108,7 +108,9 @@ public class PageBreaker extends AbstractBreaker { if (childLC.getNextSpan() != Constants.NOT_SET) { //Next block list will have a different span. nextSequenceStartsOn = childLC.getNextSpan(); - needColumnBalancing = (childLC.getNextSpan() == Constants.EN_ALL); + needColumnBalancing = childLC.getNextSpan() == Constants.EN_ALL + && childLC.getDisableColumnBalancing() == Constants.EN_FALSE; + } if (needColumnBalancing) { AbstractBreaker.log.debug( |