--- src/java/org/apache/fop/layoutmgr/PageBreaker.java (revision 721992) +++ src/java/org/apache/fop/layoutmgr/PageBreaker.java Wed Nov 26 13:40:07 CET 2008 @@ -108,7 +108,8 @@ 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.getFoxNeedsBalancing(); } if (needColumnBalancing) { AbstractBreaker.log.debug( --- src/java/org/apache/fop/fo/flow/Block.java (revision 721992) +++ src/java/org/apache/fop/fo/flow/Block.java Wed Nov 26 11:18:09 CET 2008 @@ -80,6 +80,7 @@ private int whiteSpaceCollapse; private Numeric widows; private int wrapOption; + private int foxNeedsBalancing; // Unused but valid items, commented out for performance: // private CommonAccessibility commonAccessibility; // private CommonAural commonAural; @@ -130,6 +131,7 @@ whiteSpaceCollapse = pList.get(PR_WHITE_SPACE_COLLAPSE).getEnum(); widows = pList.get(PR_WIDOWS).getNumeric(); wrapOption = pList.get(PR_WRAP_OPTION).getEnum(); + foxNeedsBalancing = pList.get(PR_X_NEEDS_BALANCING).getEnum(); } /** {@inheritDoc} */ @@ -318,6 +320,12 @@ return this.lineHeightShiftAdjustment; } + /** @return the "foxNeedsBalancing" property */ + public int getFoxNeedsBalancing() { + return foxNeedsBalancing; + } + + /** {@inheritDoc} */ public CharIterator charIterator() { return NullCharIterator.getInstance(); --- src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java (revision 721992) +++ src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java Wed Nov 26 12:05:16 CET 2008 @@ -117,6 +117,7 @@ // set space after for each LM, in order to implement // display-align = distribute lc.setSpaceAfter(layoutContext.getSpaceAfter()); + lc.setFoxNeedsBalancing(layoutContext.getFoxNeedsBalancing()); lc.setStackLimitsFrom(layoutContext); childLM.addAreas(childPosIter, lc); } --- src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (revision 721992) +++ src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Wed Nov 26 12:05:16 CET 2008 @@ -247,7 +247,7 @@ lc.setSpaceAfter(layoutContext.getSpaceAfter()); } PositionIterator childPosIter; - + lc.setFoxNeedsBalancing(layoutContext.getFoxNeedsBalancing()); // "unwrap" the NonLeafPositions stored in parentIter // and put them in a new list; LinkedList positionList = new LinkedList(); --- src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (revision 721992) +++ src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Wed Nov 26 12:05:16 CET 2008 @@ -731,6 +731,7 @@ if (layoutContext.getSpaceAfter() > 0) { lc.setSpaceAfter(layoutContext.getSpaceAfter()); } + lc.setFoxNeedsBalancing(layoutContext.getFoxNeedsBalancing()); BlockContainerPosition bcpos = null; PositionIterator childPosIter; --- src/java/org/apache/fop/fo/Constants.java (revision 721992) +++ src/java/org/apache/fop/fo/Constants.java Wed Nov 26 15:24:59 CET 2008 @@ -766,8 +766,10 @@ 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: Balancing needed */ + int PR_X_NEEDS_BALANCING = 273; /** Number of property constants defined */ - int PROPERTY_COUNT = 272; + int PROPERTY_COUNT = 273; // compound property constants --- src/java/org/apache/fop/fo/pagination/Flow.java (revision 721992) +++ src/java/org/apache/fop/fo/pagination/Flow.java Mon Dec 01 08:56:31 CET 2008 @@ -35,6 +35,7 @@ public class Flow extends FObj { // The value of properties relevant for fo:flow. private String flowName; + private int foxNeedsBalancing; // End of property values /** used for FO validation */ @@ -52,6 +53,7 @@ public void bind(PropertyList pList) throws FOPException { super.bind(pList); flowName = pList.get(PR_FLOW_NAME).getString(); + foxNeedsBalancing = pList.get(PR_X_NEEDS_BALANCING).getEnum(); } /** {@inheritDoc} */ @@ -120,6 +122,13 @@ return flowName; } + /** @return "fox-needs-balancing" property. */ + public int getFoxNeedsBalancing() { + return foxNeedsBalancing; + } + public boolean hasFoxNeedsBalancing() { + return EN_TRUE == foxNeedsBalancing; + } /** {@inheritDoc} */ public String getLocalName() { return "flow"; --- src/java/org/apache/fop/layoutmgr/LayoutContext.java (revision 721992) +++ src/java/org/apache/fop/layoutmgr/LayoutContext.java Wed Nov 26 16:21:42 CET 2008 @@ -170,6 +170,7 @@ this.pendingKeepWithNext = parentLC.pendingKeepWithNext; this.pendingKeepWithPrevious = parentLC.pendingKeepWithPrevious; // Copy other fields as necessary. + this.foxNeedsBalancing = parentLC.foxNeedsBalancing; } /** @@ -412,7 +413,7 @@ /** * 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 +682,12 @@ + (breakAfter != Constants.EN_AUTO ? "break-after" : "") + "]"; } + private boolean foxNeedsBalancing; + public boolean getFoxNeedsBalancing() { + return foxNeedsBalancing; -} + } + public void setFoxNeedsBalancing(boolean foxNeedsBalancing) { + this.foxNeedsBalancing=foxNeedsBalancing; + } +} --- src/java/org/apache/fop/fo/FOPropertyMapping.java (revision 721992) +++ src/java/org/apache/fop/fo/FOPropertyMapping.java Mon Dec 01 11:00:02 CET 2008 @@ -1648,6 +1648,15 @@ m.setDefault("wrap"); m.addShorthand(s_generics[PR_WHITE_SPACE]); addPropertyMaker("wrap-option", m); + + // fox-needs-balancing + m = new EnumProperty.Maker(PR_X_NEEDS_BALANCING); + m.setInherited(true); + m.addEnum("true", getEnumProperty(EN_TRUE, "TRUE")); + m.addEnum("false", getEnumProperty(EN_FALSE, "FALSE")); + m.setDefault("inherit"); + addPropertyMaker("fox-needs-balancing", m); + } private void createCharacterProperties() { @@ -1859,7 +1868,7 @@ m = new LengthProperty.Maker(PR_X_ORPHAN_CONTENT_LIMIT); m.setInherited(true); m.setDefault("0pt"); - addPropertyMaker("fox:orphan-content-limit", m); + addPropertyMaker("fox:orphan-content-limit", m); } private void createLayoutProperties() { @@ -2286,6 +2295,15 @@ m.setInherited(false); m.setDefault(""); addPropertyMaker("region-name", m); + + // fox-needs-balancing + m = new EnumProperty.Maker(PR_X_NEEDS_BALANCING); + m.setInherited(true); + m.addEnum("true", getEnumProperty(EN_TRUE, "TRUE")); + m.addEnum("false", getEnumProperty(EN_FALSE, "FALSE")); + m.setDefault("true"); + addPropertyMaker("fox-needs-balancing", m); + } private void createTableProperties() {