xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r328010 [1/8] - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/datatypes/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/flow/ src/java/org/apache/fop/layoutmgr/ src/java/org/apache/fop/layoutmgr/inline/ src/java/org/apache/fop/...
Date Mon, 24 Oct 2005 09:24:53 GMT
Author: jeremias
Date: Mon Oct 24 02:21:26 2005
New Revision: 328010

URL: http://svn.apache.org/viewcvs?rev=328010&view=rev
Log:
Merged work on Temp_SpaceResolution branch into trunk (-r 320826:327988).
Source: http://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_SpaceResolution/

Added:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BorderElement.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/BorderElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakElement.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/BreakElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/ConditionalElementListener.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ListElement.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/ListElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PaddingElement.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/PaddingElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/RelSide.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/RelSide.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceElement.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/SpaceElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/UnresolvedListElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java
    xmlgraphics/fop/trunk/test/fotree/testcases/shorthand-prop-mix.fo
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/fotree/testcases/shorthand-prop-mix.fo
    xmlgraphics/fop/trunk/test/fotree/testcases/table_border-separation.fo
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/fotree/testcases/table_border-separation.fo
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block-container_space-before_space-after_1.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block-container_space-before_space-after_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block-container_space-before_space-after_2.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block-container_space-before_space-after_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block-container_space-before_space-after_3.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block-container_space-before_space-after_3.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_4.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block_space-before_space-after_4.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_5.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block_space-before_space-after_5.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_6.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block_space-before_space-after_6.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_7.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block_space-before_space-after_7.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_8.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block_space-before_space-after_8.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_9.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block_space-before_space-after_9.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_9a.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/block_space-before_space-after_9a.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/footnote_space-resolution.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/footnote_space-resolution.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/list-block_space-before_space-after_1.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/list-block_space-before_space-after_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/list-block_space-before_space-after_2.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/list-block_space-before_space-after_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/list-item_space-before_space-after_3.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/list-item_space-before_space-after_3.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/region_side_space-resolution.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/region_side_space-resolution.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/table-cell_border_padding_conditionality.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/table-cell_border_padding_conditionality.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/table_border_padding_2.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/table_border_padding_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/table_space-before_space-after_1.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/table_space-before_space-after_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/table_space-before_space-after_2.xml
      - copied unchanged from r327989, xmlgraphics/fop/branches/Temp_SpaceResolution/test/layoutengine/testcases/table_space-before_space-after_2.xml
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FONode.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableFObj.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.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/ElementListUtils.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthSequence.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java   (contents, props changed)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PositionIterator.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/MinOptMax.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/ext/AssertElement.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/logging/LoggingElementListObserver.java
    xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.txt
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block-container_display-align_space-before.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_border_padding.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_margin.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_margin_inherit.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_margin_percentages.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_margin_shorthands.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_padding_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/block_space-before_space-after_3.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/character_border_padding.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/character_vertical-align.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_alignment-adjust_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_alignment-adjust_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_alignment-baseline_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_alignment-baseline_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_alignment-baseline_3.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_alignment-baseline_4.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_background-color.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_baseline-shift_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_baseline-shift_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_baseline-shift_3.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_baseline-shift_4.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_border_padding.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_border_padding_block_nested_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_border_padding_block_nested_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_border_padding_conditionality_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_border_padding_conditionality_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_border_padding_hyphenate.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_border_padding_hyphenate_de.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_dominant-baseline_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_dominant-baseline_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_dominant-baseline_3.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_vertical-align_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/inline_vertical-align_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/leader_border_padding.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/list-block_border_padding.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/list-item_space-before_space-after_1.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/list-item_space-before_space-after_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/page-breaking_2.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/page-number-citation_border_padding.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/page-number-citation_vertical-align.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/page-number_border_padding.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/page-number_vertical-align.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/table-cell_block_margin_percentage.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/table_margin_space-before_space-after.xml
    xmlgraphics/fop/trunk/test/layoutengine/testcases/table_table-layout_fixed_1.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java?rev=328010&r1=328009&r2=328010&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java Mon Oct 24 02:21:26 2005
@@ -31,7 +31,8 @@
 
     /**
      * @param parentContext the context to be used for all percentages other than lengthBase
-     * @param lengthBase the particular percentage length base for which this context provides a value
+     * @param lengthBase the particular percentage length base for which this context provides 
+     *                   a value
      * @param lengthBaseValue the value to be returned for requests to the given lengthBase
      */
     public SimplePercentBaseContext(PercentBaseContext parentContext,

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FONode.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FONode.java?rev=328010&r1=328009&r2=328010&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FONode.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FONode.java Mon Oct 24 02:21:26 2005
@@ -311,7 +311,7 @@
      * @param problem text to display that indicates the problem
      */
     protected void attributeWarning(String problem) {
-        log.warn(errorText(locator) + getName() + ", " + problem);
+        log.warn(warningText(locator) + getName() + ", " + problem);
     }
 
     /**
@@ -437,7 +437,7 @@
      * @param loc org.xml.sax.Locator object
      * @return String the formatted text
      */
-    protected static String getLocatorString(Locator loc) {
+    public static String getLocatorString(Locator loc) {
         if (loc == null) {
             return "Unknown location";
         } else {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java?rev=328010&r1=328009&r2=328010&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java Mon Oct 24 02:21:26 2005
@@ -24,9 +24,8 @@
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.ValidationPercentBaseContext;
 import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.StaticPropertyList;
 import org.apache.fop.fo.ValidationException;
@@ -129,17 +128,19 @@
         colPList.setWritingMode();
         defaultColumn.bind(colPList);
 
-        /*if (borderCollapse != EN_SEPARATE && commonBorderPaddingBackground.hasPadding()) {
-            //See "17.6.2 The collapsing border model" in CSS2
-            getLogger().warn("Table may not have padding when using the collapsing "
-                    + "border model. Padding will be ignored.");
-        }*/
         if (borderCollapse != EN_SEPARATE) {
-            getLogger().warn("The collapsing border model on an fo:table "
+            attributeWarning("The collapsing border model on an fo:table "
                     + "is currently not supported by FOP");
         }
         if (tableLayout == EN_AUTO) {
-            getLogger().warn("table-layout=\"auto\" is currently not supported by FOP");
+            attributeWarning("table-layout=\"auto\" is currently not supported by FOP");
+        }
+        if (!isSeparateBorderModel() && getCommonBorderPaddingBackground().hasPadding(
+                ValidationPercentBaseContext.getPseudoContextForValidationPurposes())) {
+            //See "17.6.2 The collapsing border model" in CSS2
+            attributeWarning("In collapsing border model a table does not have padding"
+                    + " (see http://www.w3.org/TR/REC-CSS2/tables.html#collapsing-borders)"
+                    + ", but a non-zero value for padding was found. The padding will be ignored.");
         }
     }
 
@@ -217,11 +218,11 @@
      * @see org.apache.fop.fo.FONode#addChildNode(FONode)
      */
     protected void addChildNode(FONode child) throws FOPException {
-        if (child.getName().equals("fo:table-column")) {
+        if ("fo:table-column".equals(child.getName())) {
             addColumnNode((TableColumn) child);
-        } else if (child.getName().equals("fo:table-footer")) {
+        } else if ("fo:table-footer".equals(child.getName())) {
             tableFooter = (TableBody)child;
-        } else if (child.getName().equals("fo:table-header")) {
+        } else if ("fo:table-header".equals(child.getName())) {
             tableHeader = (TableBody)child;
         } else {
             // add bodies

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableFObj.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableFObj.java?rev=328010&r1=328009&r2=328010&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableFObj.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableFObj.java Mon Oct 24 02:21:26 2005
@@ -20,6 +20,7 @@
 
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.ValidationPercentBaseContext;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
@@ -27,9 +28,7 @@
 
 /**
  * Superclass for table-related FOs
- *
  */
-
 public abstract class TableFObj extends FObj {
 
     private Numeric borderAfterPrecedence;
@@ -82,8 +81,17 @@
         if (getNameId() != FO_TABLE && getNameId() != FO_TABLE_CELL
                 && getTable().isSeparateBorderModel()
                 && getCommonBorderPaddingBackground().hasBorderInfo()) {
-            getLogger().warn("Borders on " + getName() 
-                    + " non-applicable for table with border-collapse=\"separate\"");
+            attributeWarning("In the separate border model (border-collapse=\"separate\")"
+                    + ", borders cannot be specified on a " + getName() 
+                    + ", but a non-zero value for border was found. The border will be ignored. ");
+        }
+        if (getNameId() != FO_TABLE //Separate check for fo:table in Table.java
+                && getNameId() != FO_TABLE_CELL
+                && getCommonBorderPaddingBackground().hasPadding(
+                        ValidationPercentBaseContext.getPseudoContextForValidationPurposes())) {
+            attributeWarning(getName() + " does not have padding"
+                    + " (see the property list for " + getName() + " in XSL 1.0)"
+                    + ", but a non-zero value for padding was found. The padding will be ignored.");
         }
     }
     

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=328010&r1=328009&r2=328010&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 Mon Oct 24 02:21:26 2005
@@ -76,8 +76,8 @@
             return this.startOn;
         }
 
-        public BlockSequence endBlockSequence() {
-            KnuthSequence temp = super.endSequence();
+        public BlockSequence endBlockSequence(Position breakPosition) {
+            KnuthSequence temp = super.endSequence(breakPosition);
             if (temp != null) {
                 BlockSequence returnSequence = new BlockSequence(startOn);
                 returnSequence.addAll(temp);
@@ -273,6 +273,7 @@
         ListIterator effectiveListIterator = effectiveList.listIterator();
         int startElementIndex = 0;
         int endElementIndex = 0;
+        int lastBreak = -1;
         for (int p = 0; p < partCount; p++) {
             PageBreakPosition pbp = (PageBreakPosition) alg.getPageBreaks().get(p);
 
@@ -307,6 +308,10 @@
             
             int displayAlign = getCurrentDisplayAlign();
             
+            //The following is needed by SpaceResolver.performConditionalsNotification()
+            //further down as there may be important Position elements in the element list trailer
+            int notificationEndElementIndex = endElementIndex;
+
             // ignore the last elements added by the
             // PageSequenceLayoutManager
             endElementIndex -= (endElementIndex == (originalList.size() - 1)) 
@@ -328,12 +333,13 @@
             while (effectiveListIterator.hasNext()
                     && !(firstElement = (KnuthElement) effectiveListIterator.next())
                             .isBox()) {
-                if (firstElement.isGlue()) {
+                /*
+                if (firstElement.isGlue() && firstElement.getLayoutManager() != null) {
                     // discard the space representd by the glue element
                     ((BlockLevelLayoutManager) firstElement
                             .getLayoutManager())
                             .discardSpace((KnuthGlue) firstElement);
-                }
+                }*/
                 startElementIndex++;
             }
 
@@ -377,6 +383,11 @@
                 }
                 /* *** *** non-standard extension *** *** */
 
+                // Handle SpaceHandling(Break)Positions, see SpaceResolver!
+                SpaceResolver.performConditionalsNotification(effectiveList, 
+                        startElementIndex, notificationEndElementIndex, lastBreak);
+                
+                // Add areas now!
                 addAreas(new KnuthPossPosIter(effectiveList,
                         startElementIndex, endElementIndex + 1), childLC);
             } else {
@@ -386,10 +397,18 @@
 
             finishPart(alg, pbp);
 
+            lastBreak = endElementIndex;
             startElementIndex = pbp.getLeafPos() + 1;
         }
     }
-    
+    /**
+     * Notifies the layout managers about the space and conditional length situation based on
+     * the break decisions.
+     * @param effectiveList Element list to be painted
+     * @param startElementIndex start index of the part
+     * @param endElementIndex end index of the part
+     * @param lastBreak index of the last break element
+     */
     /**
      * Handles span changes reported through the <code>LayoutContext</code>. 
      * Only used by the PSLM and called by <code>getNextBlockList()</code>.
@@ -425,10 +444,12 @@
             //Only implemented by the PSLM
             nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn);
             
+            Position breakPosition = null;
             if (((KnuthElement) returnedList.getLast()).isPenalty()
                     && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
                 KnuthPenalty breakPenalty = (KnuthPenalty) returnedList
                         .removeLast();
+                breakPosition = breakPenalty.getPosition();
                 switch (breakPenalty.getBreakClass()) {
                 case Constants.EN_PAGE:
                     log.debug("PLM> break - PAGE");
@@ -454,7 +475,7 @@
             }
             blockList.addAll(returnedList);
             BlockSequence seq = null;
-            seq = blockList.endBlockSequence();
+            seq = blockList.endBlockSequence(breakPosition);
             if (seq != null) {
                 blockLists.add(seq);
             }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java?rev=328010&r1=328009&r2=328010&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 Mon Oct 24 02:21:26 2005
@@ -21,6 +21,11 @@
 import java.util.Iterator;
 import java.util.LinkedList;
 
+import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition;
+
+/**
+ * Utility class which provides common code for the addAreas stage.
+ */
 public class AreaAdditionUtil {
 
     private static class StackingIter extends PositionIterator {
@@ -37,6 +42,12 @@
         }
     }
 
+    /**
+     * Creates the child areas for the given layout manager.
+     * @param bslm the BlockStackingLayoutManager instance for which "addAreas" is performed.
+     * @param parentIter the position iterator
+     * @param layoutContext the layout context
+     */
     public static void addAreas(BlockStackingLayoutManager bslm, 
             PositionIterator parentIter, LayoutContext layoutContext) {
         LayoutManager childLM = null;
@@ -52,6 +63,9 @@
         Position pos;
         while (parentIter.hasNext()) {
             pos = (Position)parentIter.next();
+            if (pos == null) {
+                continue;
+            }
             if (pos.getIndex() >= 0) {
                 if (firstPos == null) {
                     firstPos = pos;
@@ -65,12 +79,14 @@
                 if (firstLM == null) {
                     firstLM = lastLM;
                 }
+            } else if (pos instanceof SpaceHandlingBreakPosition) {
+                positionList.add(pos);
             } else {
                 // pos was created by this LM, so it must be ignored
             }
         }
         
-        if (bslm.markers != null) {
+        if (bslm != null && bslm.markers != null) {
             bslm.getCurrentPV().addMarkers(bslm.markers, true, 
                     bslm.isFirst(firstPos), bslm.isLast(lastPos));
         }
@@ -91,7 +107,7 @@
             lc.setStackLimit(layoutContext.getStackLimit());
             childLM.addAreas(childPosIter, lc);
         }
-        if (bslm.markers != null) {
+        if (bslm != null && bslm.markers != null) {
             bslm.getCurrentPV().addMarkers(bslm.markers, false, 
                     bslm.isFirst(firstPos), bslm.isLast(lastPos));
         }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=328010&r1=328009&r2=328010&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 Mon Oct 24 02:21:26 2005
@@ -39,7 +39,8 @@
 /**
  * LayoutManager for a block-container FO.
  */
-public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
+public class BlockContainerLayoutManager extends BlockStackingLayoutManager 
+                implements ConditionalElementListener {
     
     private BlockViewport viewportBlockArea;
     private Block referenceArea;
@@ -68,6 +69,14 @@
     private MinOptMax foBlockSpaceBefore;
     private MinOptMax foBlockSpaceAfter;
     
+    private boolean discardBorderBefore;
+    private boolean discardBorderAfter;
+    private boolean discardPaddingBefore;
+    private boolean discardPaddingAfter;
+    private MinOptMax effSpaceBefore;
+    private MinOptMax effSpaceAfter;
+
+    
     /**
      * Create a new block container layout manager.
      * @param node block-container node to create the layout manager for.
@@ -76,6 +85,7 @@
         super(node);
     }
     
+    /** @see org.apache.fop.layoutmgr.LayoutManager#initialize() */
     public void initialize() {
         abProps = getBlockContainerFO().getCommonAbsolutePosition();
         foBlockSpaceBefore = new SpaceVal(getBlockContainerFO().getCommonMarginBlock()
@@ -111,6 +121,15 @@
                 .spaceAfter.getSpace().getMinimum(this).getLength().getValue(this);
         }
     }
+    
+    private void resetSpaces() {
+        this.discardBorderBefore = false;        
+        this.discardBorderAfter = false;        
+        this.discardPaddingBefore = false;        
+        this.discardPaddingAfter = false;
+        this.effSpaceBefore = foSpaceBefore;
+        this.effSpaceAfter = foSpaceAfter;
+    }
 
     /** @return the content IPD */
     protected int getRotatedIPD() {
@@ -151,6 +170,7 @@
     
     /** @see org.apache.fop.layoutmgr.LayoutManager */
     public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+        resetSpaces();
         if (isAbsoluteOrFixed()) {
             return getNextKnuthElementsAbsolute(context, alignment);
         }
@@ -201,7 +221,7 @@
         
         if (!bBreakBeforeServed) {
             try {
-                if (addKnuthElementsForBreakBefore(returnList)) {
+                if (addKnuthElementsForBreakBefore(returnList, context)) {
                     return returnList;
                 }
             } finally {
@@ -209,18 +229,20 @@
             }
         }
 
-        if (!bSpaceBeforeServed) {
-            addKnuthElementsForSpaceBefore(returnList, alignment);
-            bSpaceBeforeServed = true;
-        }
+        addKnuthElementsForSpaceBefore(returnList, alignment);
         
-        addKnuthElementsForBorderPaddingBefore(returnList);
+        addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
+        firstVisibleMarkServed = true;
 
         if (autoHeight) {
+            //Spaces, border and padding to be repeated at each break
+            addPendingMarks(context);
+
             BlockLevelLayoutManager curLM; // currently active LM
             BlockLevelLayoutManager prevLM = null; // previously active LM
             while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
                 LayoutContext childLC = new LayoutContext(0);
+                childLC.copyPendingMarksFrom(context);
                 // curLM is a ?
                 childLC.setStackLimit(MinOptMax.subtract(context
                         .getStackLimit(), stackLimit));
@@ -230,10 +252,9 @@
                 // get elements from curLM
                 returnedList = curLM.getNextKnuthElements(childLC, alignment);
                 if (returnedList.size() == 1
-                        && ((KnuthElement)returnedList.getFirst()).isPenalty()
-                        && ((KnuthPenalty)returnedList.getFirst()).getP() 
-                                == -KnuthElement.INFINITE) {
+                        && ((KnuthElement)returnedList.getFirst()).isForcedBreak()) {
                     // a descendant of this block has break-before
+                    /*
                     if (returnList.size() == 0) {
                         // the first child (or its first child ...) has
                         // break-before;
@@ -241,7 +262,7 @@
                         // the
                         // following page
                         bSpaceBeforeServed = false;
-                    }
+                    }*/
                     contentList.addAll(returnedList);
 
                     // "wrap" the Position inside each element
@@ -259,13 +280,17 @@
                                 || curLM.mustKeepWithPrevious()) {
                             // add an infinite penalty to forbid a break between
                             // blocks
-                            contentList.add(new KnuthPenalty(0,
-                                    KnuthElement.INFINITE, false,
-                                    new Position(this), false));
+                            contentList.add(new BreakElement(
+                                    new Position(this), KnuthElement.INFINITE, context));
+                            //contentList.add(new KnuthPenalty(0,
+                            //        KnuthElement.INFINITE, false,
+                            //        new Position(this), false));
                         } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
                             // add a null penalty to allow a break between blocks
-                            contentList.add(new KnuthPenalty(0, 0, false,
-                                    new Position(this), false));
+                            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 glue;
                             // it is a feasible breakpoint, there is no need to add
@@ -277,9 +302,7 @@
                         //Avoid NoSuchElementException below (happens with empty blocks)
                         continue;
                     }
-                    if (((KnuthElement) returnedList.getLast()).isPenalty()
-                            && ((KnuthPenalty) returnedList.getLast()).getP() 
-                                    == -KnuthElement.INFINITE) {
+                    if (((ListElement)returnedList.getLast()).isForcedBreak()) {
                         // a descendant of this block has break-after
                         if (curLM.isFinished()) {
                             // there is no other content in this block;
@@ -328,9 +351,9 @@
                 }
             }
         }
-        addKnuthElementsForBorderPaddingAfter(returnList);
+        addKnuthElementsForBorderPaddingAfter(returnList, true);
         addKnuthElementsForSpaceAfter(returnList, alignment);
-        addKnuthElementsForBreakAfter(returnList);
+        addKnuthElementsForBreakAfter(returnList, context);
 
         setFinished(true);
         return returnList;
@@ -422,7 +445,7 @@
         contentRectOffsetX += getBlockContainerFO()
                 .getCommonMarginBlock().startIndent.getValue(this);
         double contentRectOffsetY = offset.getY();
-        contentRectOffsetY += getSpaceBefore();
+        contentRectOffsetY += getSpaceBefore(); //TODO Uhm, is that necessary?
         contentRectOffsetY += getBlockContainerFO()
                 .getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
         contentRectOffsetY += getBlockContainerFO()
@@ -544,9 +567,9 @@
                 }
                 if (returnedList != null) {
                     bclm.wrapPositionElements(returnedList, returnList);
-                    //returnList.addAll(returnedList);
                 }
             }
+            SpaceResolver.resolveElementList(returnList);
             setFinished(true);
             return returnList;
         }
@@ -605,9 +628,7 @@
         return new Point(x, y);
     }
     
-    /**
-     * @see org.apache.fop.layoutmgr.LayoutManager#addAreas(org.apache.fop.layoutmgr.PositionIterator, org.apache.fop.layoutmgr.LayoutContext)
-     */
+    /** @see org.apache.fop.layoutmgr.LayoutManager */
     public void addAreas(PositionIterator parentIter,
             LayoutContext layoutContext) {
         getParentArea(null);
@@ -766,11 +787,6 @@
                 //}
             }
     
-            // if adjusted space before
-            if (bSpaceBefore) {
-                addBlockSpacing(0, new MinOptMax(adjustedSpaceBefore));
-            }
-    
             while ((childLM = childPosIter.getNextChildLM()) != null) {
                 // set last area flag
                 lc.setFlags(LayoutContext.LAST_AREA,
@@ -780,30 +796,21 @@
                 childLM.addAreas(childPosIter, lc);
             }
         } else {
-            // if adjusted space before
-            if (bSpaceBefore) {
-                addBlockSpacing(0, new MinOptMax(adjustedSpaceBefore));
-            }
             //Add child areas inside the reference area
             bcpos.getBreaker().addContainedAreas();
         }
 
-        //int bIndents = getBlockContainerFO().getCommonBorderPaddingBackground()
-        //    .getBPPaddingAndBorder(false);
-
         if (markers != null) {
             getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
         }
 
+        TraitSetter.addSpaceBeforeAfter(viewportBlockArea, layoutContext.getSpaceAdjust(), 
+                effSpaceBefore, effSpaceAfter);
         flush();
 
-        // if adjusted space after
-        if (bSpaceAfter) {
-            addBlockSpacing(0, new MinOptMax(adjustedSpaceAfter));
-        }
-
         viewportBlockArea = null;
         referenceArea = null;
+        resetSpaces();
     }
     
     /**
@@ -826,7 +833,11 @@
 
             TraitSetter.setProducerID(viewportBlockArea, getBlockContainerFO().getId());
             TraitSetter.addBorders(viewportBlockArea, 
-                    getBlockContainerFO().getCommonBorderPaddingBackground(), this);
+                    getBlockContainerFO().getCommonBorderPaddingBackground(), 
+                    discardBorderBefore, discardBorderAfter, false, false, this);
+            TraitSetter.addPadding(viewportBlockArea, 
+                    getBlockContainerFO().getCommonBorderPaddingBackground(), 
+                    discardPaddingBefore, discardPaddingAfter, false, false, this);
             // TraitSetter.addBackground(viewportBlockArea, 
             //        getBlockContainerFO().getCommonBorderPaddingBackground(),
             //        this);
@@ -918,17 +929,13 @@
         }
     }
 
-    /**
-     * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement)
-     */
+    /** @see org.apache.fop.layoutmgr.BlockLevelLayoutManager */
     public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
         // TODO Auto-generated method stub
         return 0;
     }
 
-    /**
-     * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#discardSpace(org.apache.fop.layoutmgr.KnuthGlue)
-     */
+    /** @see org.apache.fop.layoutmgr.BlockLevelLayoutManager */
     public void discardSpace(KnuthGlue spaceGlue) {
         // TODO Auto-generated method stub
         
@@ -982,6 +989,51 @@
     public boolean getGeneratesBlockArea() {
         return true;
     }
-   
+
+    /** @see org.apache.fop.layoutmgr.ConditionalElementListener */
+    public void notifySpace(RelSide side, MinOptMax effectiveLength) {
+        if (RelSide.BEFORE == side) {
+            if (log.isDebugEnabled()) {
+                log.debug(this + ": Space " + side + ", " 
+                        + this.effSpaceBefore + "-> " + effectiveLength);
+            }
+            this.effSpaceBefore = effectiveLength;
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug(this + ": Space " + side + ", " 
+                        + this.effSpaceAfter + "-> " + effectiveLength);
+            }
+            this.effSpaceAfter = effectiveLength;
+        }
+    }
+
+    /** @see org.apache.fop.layoutmgr.ConditionalElementListener */
+    public void notifyBorder(RelSide side, MinOptMax effectiveLength) {
+        if (effectiveLength == null) {
+            if (RelSide.BEFORE == side) {
+                this.discardBorderBefore = true;
+            } else {
+                this.discardBorderAfter = true;
+            }
+        }
+        if (log.isDebugEnabled()) {
+            log.debug(this + ": Border " + side + " -> " + effectiveLength);
+        }
+    }
+
+    /** @see org.apache.fop.layoutmgr.ConditionalElementListener */
+    public void notifyPadding(RelSide side, MinOptMax effectiveLength) {
+        if (effectiveLength == null) {
+            if (RelSide.BEFORE == side) {
+                this.discardPaddingBefore = true;
+            } else {
+                this.discardPaddingAfter = true;
+            }
+        }
+        if (log.isDebugEnabled()) {
+            log.debug(this + ": Padding " + side + " -> " + effectiveLength);
+        }
+    }
+
 }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=328010&r1=328009&r2=328010&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 Mon Oct 24 02:21:26 2005
@@ -35,7 +35,8 @@
 /**
  * LayoutManager for a block FO.
  */
-public class BlockLayoutManager extends BlockStackingLayoutManager {
+public class BlockLayoutManager extends BlockStackingLayoutManager 
+            implements ConditionalElementListener {
     
     private Block curBlockArea;
 
@@ -46,6 +47,13 @@
     private Length lineHeight;
     private int follow = 2000;
     private int middleShift = 0;
+    
+    private boolean discardBorderBefore;
+    private boolean discardBorderAfter;
+    private boolean discardPaddingBefore;
+    private boolean discardPaddingAfter;
+    private MinOptMax effSpaceBefore;
+    private MinOptMax effSpaceAfter;
 
     /** The list of child BreakPoss instances. */
     protected List childBreaks = new java.util.ArrayList();
@@ -87,6 +95,21 @@
         }
     }
 
+    /** @see org.apache.fop.layoutmgr.BlockStackingLayoutManager */
+    public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+        resetSpaces(); 
+        return super.getNextKnuthElements(context, alignment);
+    }
+   
+    private void resetSpaces() {
+        this.discardBorderBefore = false;        
+        this.discardBorderAfter = false;        
+        this.discardPaddingBefore = false;        
+        this.discardPaddingAfter = false;
+        this.effSpaceBefore = foSpaceBefore;
+        this.effSpaceAfter = foSpaceAfter;
+    }
+    
     /**
      * Proxy iterator for Block LM.
      * This iterator creates and holds the complete list
@@ -277,12 +300,6 @@
         }
 
         getPSLM().addIDToPage(getBlockFO().getId());
-        /* TODO remove when markers are really ok
-        log.debug("Checking on " + this);
-        log.debug("Checking first=" + firstPos);
-        log.debug("Checking last=" + lastPos);
-        log.debug("->" + isFirst(firstPos) + "/" + isLast(lastPos));
-        */
         if (markers != null) {
             getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
         }
@@ -361,14 +378,6 @@
             //}
         }
 
-        // if adjusted space before
-        double adjust = layoutContext.getSpaceAdjust();
-        addBlockSpacing(adjust, foSpaceBefore);
-        foSpaceBefore = null;
-        //if (bSpaceBefore) {
-        //    addBlockSpacing(0, new MinOptMax(adjustedSpaceBefore));
-        //}
-
         while ((childLM = childPosIter.getNextChildLM()) != null) {
             // set last area flag
             lc.setFlags(LayoutContext.LAST_AREA,
@@ -378,22 +387,16 @@
             childLM.addAreas(childPosIter, lc);
         }
 
-        //int bIndents = getBlockFO().getCommonBorderPaddingBackground()
-        //                        .getBPPaddingAndBorder(false);
-
         if (markers != null) {
             getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
         }
 
+        TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), 
+                effSpaceBefore, effSpaceAfter);
         flush();
 
-        // if adjusted space after
-        addBlockSpacing(adjust, foSpaceAfter);
-        //if (bSpaceAfter) {
-        //    addBlockSpacing(0, new MinOptMax(adjustedSpaceAfter));
-        //}
-
         curBlockArea = null;
+        resetSpaces();
     }
 
     /**
@@ -426,30 +429,16 @@
             // set traits
             TraitSetter.setProducerID(curBlockArea, getBlockFO().getId());
             TraitSetter.addBorders(curBlockArea, 
-                    getBlockFO().getCommonBorderPaddingBackground(), this);
+                    getBlockFO().getCommonBorderPaddingBackground(), 
+                    discardBorderBefore, discardBorderAfter, false, false, this);
+            TraitSetter.addPadding(curBlockArea, 
+                    getBlockFO().getCommonBorderPaddingBackground(), 
+                    discardPaddingBefore, discardPaddingAfter, false, false, this);
             TraitSetter.addMargins(curBlockArea,
                     getBlockFO().getCommonBorderPaddingBackground(), 
                     getBlockFO().getCommonMarginBlock(),
                     this);
 
-            // Set up dimensions
-            // Get reference IPD from parentArea
-            //int referenceIPD = parentArea.getIPD();
-            //curBlockArea.setIPD(referenceIPD);
-
-            // Set the width of the block based on the parent block
-            // Need to be careful though, if parent is BC then width may not be set
-            /* TODO remove if really not used anymore
-            int parentwidth = 0;
-            if (parentArea instanceof BlockParent) {
-                parentwidth = ((BlockParent) parentArea).getIPD();
-            }
-            if (parentwidth == 0) {
-                parentwidth = referenceIPD;
-            }
-            parentwidth -= getIPIndents();
-            */
-
             setCurrentArea(curBlockArea); // ??? for generic operations
         }
         return curBlockArea;
@@ -533,6 +522,51 @@
     public boolean getGeneratesBlockArea() {
         return true;
     }
-   
+
+    /** @see org.apache.fop.layoutmgr.ConditionalElementListener */
+    public void notifySpace(RelSide side, MinOptMax effectiveLength) {
+        if (RelSide.BEFORE == side) {
+            if (log.isDebugEnabled()) {
+                log.debug(this + ": Space " + side + ", " 
+                        + this.effSpaceBefore + "-> " + effectiveLength);
+            }
+            this.effSpaceBefore = effectiveLength;
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug(this + ": Space " + side + ", " 
+                        + this.effSpaceAfter + "-> " + effectiveLength);
+            }
+            this.effSpaceAfter = effectiveLength;
+        }
+    }
+
+    /** @see org.apache.fop.layoutmgr.ConditionalElementListener */
+    public void notifyBorder(RelSide side, MinOptMax effectiveLength) {
+        if (effectiveLength == null) {
+            if (RelSide.BEFORE == side) {
+                this.discardBorderBefore = true;
+            } else {
+                this.discardBorderAfter = true;
+            }
+        }
+        if (log.isDebugEnabled()) {
+            log.debug(this + ": Border " + side + " -> " + effectiveLength);
+        }
+    }
+
+    /** @see org.apache.fop.layoutmgr.ConditionalElementListener */
+    public void notifyPadding(RelSide side, MinOptMax effectiveLength) {
+        if (effectiveLength == null) {
+            if (RelSide.BEFORE == side) {
+                this.discardPaddingBefore = true;
+            } else {
+                this.discardPaddingAfter = true;
+            }
+        }
+        if (log.isDebugEnabled()) {
+            log.debug(this + ": Padding " + side + " -> " + effectiveLength);
+        }
+    }
+
 }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=328010&r1=328009&r2=328010&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 Mon Oct 24 02:21:26 2005
@@ -53,12 +53,10 @@
     protected int adjustedSpaceAfter = 0;
     /** Only used to store the original list when createUnitElements is called */
     protected LinkedList storedList = null;
-    /** FO node */
-    protected FObj fobj;
     /** Indicates whether break before has been served or not */
     protected boolean bBreakBeforeServed = false;
-    /** Indicates whether space before has been served or not */
-    protected boolean bSpaceBeforeServed = false;
+    /** Indicates whether the first visible mark has been returned by this LM, yet */
+    protected boolean firstVisibleMarkServed = false;
     /** Reference IPD available */
     protected int referenceIPD = 0;
     /**
@@ -84,7 +82,6 @@
     public BlockStackingLayoutManager(FObj node) {
         super(node);
         setGeneratesBlockArea(true);
-        fobj = node;
     }
 
     /** 
@@ -103,16 +100,6 @@
         this.parentArea = parentArea;
     }
 
-    protected MinOptMax resolveSpaceSpecifier(Area nextArea) {
-        SpaceSpecifier spaceSpec = new SpaceSpecifier(false);
-        // Area prevArea = getCurrentArea().getLast();
-        // if (prevArea != null) {
-        //     spaceSpec.addSpace(prevArea.getSpaceAfter());
-        // }
-        // spaceSpec.addSpace(nextArea.getSpaceBefore());
-        return spaceSpec.resolve(false);
-    }
-
     /**
      * Add a block spacer for space before and space after a block.
      * This adds an empty Block area that acts as a block space.
@@ -121,15 +108,7 @@
      * @param minoptmax the min/opt/max value of the spacing
      */
     public void addBlockSpacing(double adjust, MinOptMax minoptmax) {
-        if (minoptmax == null) {
-            return;
-        }
-        int sp = minoptmax.opt;
-        if (adjust > 0) {
-            sp = sp + (int)(adjust * (minoptmax.max - minoptmax.opt));
-        } else {
-            sp = sp + (int)(adjust * (minoptmax.opt - minoptmax.min));
-        }
+        int sp = TraitSetter.getEffectiveSpace(adjust, minoptmax);
         if (sp != 0) {
             Block spacer = new Block();
             spacer.setBPD(sp);
@@ -153,7 +132,6 @@
             //log.error("Child not a Block in BlockStackingLM!");
         }
 
-        MinOptMax spaceBefore = resolveSpaceSpecifier(childArea);
         parentArea.addBlock((Block) childArea);
         flush(); // hand off current area to parent
     }
@@ -232,7 +210,7 @@
 
         if (!bBreakBeforeServed) {
             try {
-                if (addKnuthElementsForBreakBefore(returnList)) {
+                if (addKnuthElementsForBreakBefore(returnList, context)) {
                     return returnList;
                 }
             } finally {
@@ -240,15 +218,17 @@
             }
         }
 
-        if (!bSpaceBeforeServed) {
-            addKnuthElementsForSpaceBefore(returnList, alignment);
-            bSpaceBeforeServed = true;
-        }
+        addKnuthElementsForSpaceBefore(returnList, alignment);
         
-        addKnuthElementsForBorderPaddingBefore(returnList);
+        addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
+        firstVisibleMarkServed = true;
+
+        //Spaces, border and padding to be repeated at each break
+        addPendingMarks(context);
         
         while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
             LayoutContext childLC = new LayoutContext(0);
+            childLC.copyPendingMarksFrom(context);
             if (curLM instanceof LineLayoutManager) {
                 // curLM is a LineLayoutManager
                 // set stackLimit for lines
@@ -273,9 +253,9 @@
             }
             if (returnedList != null
                     && returnedList.size() == 1
-                    && ((KnuthElement) returnedList.getFirst()).isPenalty()
-                    && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
+                    && ((ListElement) returnedList.getFirst()).isForcedBreak()) {
                 // a descendant of this block has break-before
+                /*
                 if (returnList.size() == 0) {
                     // the first child (or its first child ...) has
                     // break-before;
@@ -283,7 +263,7 @@
                     // the
                     // following page
                     bSpaceBeforeServed = false;
-                }
+                }*/
                 contentList.addAll(returnedList);
 
                 /* extension: conversione di tutta la sequenza fin'ora ottenuta */
@@ -311,17 +291,27 @@
                         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 (!((KnuthElement) contentList.getLast()).isGlue()) {
+                        */
+                    } 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));
+                        /*
                         contentList.add(new KnuthPenalty(0, 0, false,
-                                new Position(this), false));
+                                new Position(this), false));*/
                     } 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
                     }
                 }
                 if (returnedList == null || returnedList.size() == 0) {
@@ -329,9 +319,7 @@
                     continue;
                 }
                 contentList.addAll(returnedList);
-                if (((KnuthElement) returnedList.getLast()).isPenalty()
-                        && ((KnuthPenalty) returnedList.getLast()).getP() 
-                                == -KnuthElement.INFINITE) {
+                if (((ListElement) returnedList.getLast()).isForcedBreak()) {
                     // a descendant of this block has break-after
                     if (curLM.isFinished()) {
                         // there is no other content in this block;
@@ -380,9 +368,9 @@
             returnList.add(new KnuthBox(0, notifyPos(new Position(this)), true));
         }
 
-        addKnuthElementsForBorderPaddingAfter(returnList);
+        addKnuthElementsForBorderPaddingAfter(returnList, true);
         addKnuthElementsForSpaceAfter(returnList, alignment);
-        addKnuthElementsForBreakAfter(returnList);
+        addKnuthElementsForBreakAfter(returnList, context);
 
         if (mustKeepWithNext()) {
             context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
@@ -741,27 +729,159 @@
     }
 
     /**
-     * Creates Knuth elements for before border padding and adds them to the return list.
-     * @param returnList return list to add the additional elements to
-     */
-    protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList/*, 
-            Position returnPosition*/) {
-        //Border and Padding (before)
-        CommonBorderPaddingBackground borderAndPadding = null;
+     * Adds the unresolved elements for border and padding to a layout context so break
+     * possibilities can be properly constructed.
+     * @param context the layout context
+     */
+    protected void addPendingMarks(LayoutContext context) {
+        SpaceProperty spaceBefore = getSpaceBeforeProperty();
+        if (spaceBefore != null
+                   && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 
+                        && spaceBefore.getMaximum(this).getLength().getValue(this) == 0)) {
+            context.addPendingBeforeMark(new SpaceElement(getAuxiliaryPosition(), spaceBefore,
+                    RelSide.BEFORE, 
+                    true, false, this));
+        }
+        SpaceProperty spaceAfter = getSpaceAfterProperty();
+        if (spaceAfter != null
+                && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 
+                     && spaceAfter.getMaximum(this).getLength().getValue(this) == 0)) {
+            context.addPendingAfterMark(new SpaceElement(getAuxiliaryPosition(), spaceAfter,
+                    RelSide.AFTER, 
+                    false, true, this));
+        }
+        CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground();
+        if (borderAndPadding != null) {
+            if (borderAndPadding.getBorderBeforeWidth(false) > 0) {
+                context.addPendingBeforeMark(new BorderElement(
+                        getAuxiliaryPosition(), 
+                        borderAndPadding.getBorderInfo(
+                                CommonBorderPaddingBackground.BEFORE).getWidth(),
+                                RelSide.BEFORE,
+                                false, false, this));
+            }
+            if (borderAndPadding.getPaddingBefore(false, this) > 0) {
+                context.addPendingBeforeMark(new PaddingElement(
+                        getAuxiliaryPosition(),
+                        borderAndPadding.getPaddingLengthProperty(
+                                CommonBorderPaddingBackground.BEFORE),
+                                RelSide.BEFORE, 
+                                false, false, this));
+            }
+            if (borderAndPadding.getBorderAfterWidth(false) > 0) {
+                context.addPendingAfterMark(new BorderElement(
+                        getAuxiliaryPosition(), 
+                        borderAndPadding.getBorderInfo(
+                                CommonBorderPaddingBackground.AFTER).getWidth(),
+                                RelSide.AFTER, 
+                                false, false, this));
+            }
+            if (borderAndPadding.getPaddingAfter(false, this) > 0) {
+                context.addPendingAfterMark(new PaddingElement(
+                        getAuxiliaryPosition(),
+                        borderAndPadding.getPaddingLengthProperty(
+                                CommonBorderPaddingBackground.AFTER),
+                                RelSide.AFTER, 
+                                false, false, this));
+            }
+        }
+    }
+    
+    /** @return the border, padding and background info structure */
+    private CommonBorderPaddingBackground getBorderPaddingBackground() {
         if (fobj instanceof org.apache.fop.fo.flow.Block) {
-            borderAndPadding = ((org.apache.fop.fo.flow.Block)fobj)
+            return ((org.apache.fop.fo.flow.Block)fobj)
                 .getCommonBorderPaddingBackground();
         } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
-            borderAndPadding = ((org.apache.fop.fo.flow.BlockContainer)fobj)
+            return ((org.apache.fop.fo.flow.BlockContainer)fobj)
+                .getCommonBorderPaddingBackground();
+        } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) {
+            return ((org.apache.fop.fo.flow.ListBlock)fobj)
+                .getCommonBorderPaddingBackground();
+        } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) {
+            return ((org.apache.fop.fo.flow.ListItem)fobj)
                 .getCommonBorderPaddingBackground();
+        } else if (fobj instanceof org.apache.fop.fo.flow.Table) {
+            return ((org.apache.fop.fo.flow.Table)fobj)
+                .getCommonBorderPaddingBackground();
+        } else {
+            return null;
         }
+    }
+    
+    /** @return the space-before property */
+    private SpaceProperty getSpaceBeforeProperty() {
+        if (fobj instanceof org.apache.fop.fo.flow.Block) {
+            return ((org.apache.fop.fo.flow.Block)fobj)
+                .getCommonMarginBlock().spaceBefore;
+        } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
+            return ((org.apache.fop.fo.flow.BlockContainer)fobj)
+                .getCommonMarginBlock().spaceBefore;
+        } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) {
+            return ((org.apache.fop.fo.flow.ListBlock)fobj)
+                .getCommonMarginBlock().spaceBefore;
+        } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) {
+            return ((org.apache.fop.fo.flow.ListItem)fobj)
+                .getCommonMarginBlock().spaceBefore;
+        } else if (fobj instanceof org.apache.fop.fo.flow.Table) {
+            return ((org.apache.fop.fo.flow.Table)fobj)
+                .getCommonMarginBlock().spaceBefore;
+        } else {
+            return null;
+        }
+    }
+    
+    /** @return the space-after property */
+    private SpaceProperty getSpaceAfterProperty() {
+        if (fobj instanceof org.apache.fop.fo.flow.Block) {
+            return ((org.apache.fop.fo.flow.Block)fobj)
+                .getCommonMarginBlock().spaceAfter;
+        } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
+            return ((org.apache.fop.fo.flow.BlockContainer)fobj)
+                .getCommonMarginBlock().spaceAfter;
+        } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) {
+            return ((org.apache.fop.fo.flow.ListBlock)fobj)
+                .getCommonMarginBlock().spaceAfter;
+        } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) {
+            return ((org.apache.fop.fo.flow.ListItem)fobj)
+                .getCommonMarginBlock().spaceAfter;
+        } else if (fobj instanceof org.apache.fop.fo.flow.Table) {
+            return ((org.apache.fop.fo.flow.Table)fobj)
+                .getCommonMarginBlock().spaceAfter;
+        } else {
+            return null;
+        }
+    }
+    
+    /**
+     * Creates Knuth elements for before border padding and adds them to the return list.
+     * @param returnList return list to add the additional elements to
+     */
+    protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList, boolean isFirst) {
+        //Border and Padding (before)
+        CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground();
         if (borderAndPadding != null) {
+            if (borderAndPadding.getBorderBeforeWidth(false) > 0) {
+                returnList.add(new BorderElement(
+                        getAuxiliaryPosition(), 
+                        borderAndPadding.getBorderInfo(CommonBorderPaddingBackground.BEFORE)
+                                .getWidth(),
+                        RelSide.BEFORE, isFirst, false, this));
+            }
+            if (borderAndPadding.getPaddingBefore(false, this) > 0) {
+                returnList.add(new PaddingElement(
+                        getAuxiliaryPosition(),
+                        borderAndPadding.getPaddingLengthProperty(
+                                CommonBorderPaddingBackground.BEFORE), 
+                        RelSide.BEFORE, isFirst, false, this));
+            }
             //TODO Handle conditionality
+            /*
             int bpBefore = borderAndPadding.getBorderBeforeWidth(false)
                          + borderAndPadding.getPaddingBefore(false, this);
             if (bpBefore > 0) {
                 returnList.add(new KnuthBox(bpBefore, getAuxiliaryPosition(), true));
-            }
+            }*/
         }
     }
 
@@ -769,24 +889,31 @@
      * Creates Knuth elements for after border padding and adds them to the return list.
      * @param returnList return list to add the additional elements to
      */
-    protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList/*, 
-            Position returnPosition*/) {
+    protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList, boolean isLast) {
         //Border and Padding (after)
-        CommonBorderPaddingBackground borderAndPadding = null;
-        if (fobj instanceof org.apache.fop.fo.flow.Block) {
-            borderAndPadding = ((org.apache.fop.fo.flow.Block)fobj)
-                .getCommonBorderPaddingBackground();
-        } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
-            borderAndPadding = ((org.apache.fop.fo.flow.BlockContainer)fobj)
-                .getCommonBorderPaddingBackground();
-        }
+        CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground();
         if (borderAndPadding != null) {
+            if (borderAndPadding.getPaddingAfter(false, this) > 0) {
+                returnList.add(new PaddingElement(
+                        getAuxiliaryPosition(),
+                        borderAndPadding.getPaddingLengthProperty(
+                                CommonBorderPaddingBackground.AFTER),
+                        RelSide.AFTER, false, isLast, this));
+            }
+            if (borderAndPadding.getBorderAfterWidth(false) > 0) {
+                returnList.add(new BorderElement(
+                        getAuxiliaryPosition(), 
+                        borderAndPadding.getBorderInfo(CommonBorderPaddingBackground.AFTER)
+                                .getWidth(),
+                        RelSide.AFTER, false, isLast, this));
+            }
             //TODO Handle conditionality
+            /*
             int bpAfter = borderAndPadding.getBorderAfterWidth(false)
                         + borderAndPadding.getPaddingAfter(false, this);
             if (bpAfter > 0) {
                 returnList.add(new KnuthBox(bpAfter, getAuxiliaryPosition(), true));
-            }
+            }*/
         }
     }
 
@@ -795,8 +922,8 @@
      * @param returnList return list to add the additional elements to
      * @return true if an element has been added due to a break-before.
      */
-    protected boolean addKnuthElementsForBreakBefore(LinkedList returnList/*, 
-            Position returnPosition*/) {
+    protected boolean addKnuthElementsForBreakBefore(LinkedList returnList, 
+            LayoutContext context) {
         int breakBefore = -1;
         if (fobj instanceof org.apache.fop.fo.flow.Block) {
             breakBefore = ((org.apache.fop.fo.flow.Block) fobj).getBreakBefore();
@@ -810,8 +937,10 @@
                 || breakBefore == EN_EVEN_PAGE 
                 || breakBefore == EN_ODD_PAGE) {
             // return a penalty element, representing a forced page break
-            returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false,
-                    breakBefore, getAuxiliaryPosition(), false));
+            returnList.add(new BreakElement(getAuxiliaryPosition(), 
+                    0, -KnuthElement.INFINITE, breakBefore, context));
+            //returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false,
+            //        breakBefore, getAuxiliaryPosition(), false));
             return true;
         } else {
             return false;
@@ -823,8 +952,8 @@
      * @param returnList return list to add the additional elements to
      * @return true if an element has been added due to a break-after.
      */
-    protected boolean addKnuthElementsForBreakAfter(LinkedList returnList/*, 
-            Position returnPosition*/) {
+    protected boolean addKnuthElementsForBreakAfter(LinkedList returnList, 
+            LayoutContext context) {
         int breakAfter = -1;
         if (fobj instanceof org.apache.fop.fo.flow.Block) {
             breakAfter = ((org.apache.fop.fo.flow.Block) fobj).getBreakAfter();
@@ -838,8 +967,10 @@
                 || breakAfter == EN_EVEN_PAGE
                 || breakAfter == EN_ODD_PAGE) {
             // add a penalty element, representing a forced page break
-            returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false,
-                    breakAfter, getAuxiliaryPosition(), false));
+            returnList.add(new BreakElement(getAuxiliaryPosition(), 
+                    0, -KnuthElement.INFINITE, breakAfter, context));
+            //returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false,
+            //        breakAfter, getAuxiliaryPosition(), false));
             return true;
         } else {
             return false;
@@ -853,21 +984,16 @@
      */
     protected void addKnuthElementsForSpaceBefore(LinkedList returnList/*, 
             Position returnPosition*/, int alignment) {
-        SpaceProperty spaceBefore = null;
-        if (fobj instanceof org.apache.fop.fo.flow.Block) {
-            spaceBefore = ((org.apache.fop.fo.flow.Block)fobj)
-                .getCommonMarginBlock().spaceBefore;
-        } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
-            spaceBefore = ((org.apache.fop.fo.flow.BlockContainer)fobj)
-                .getCommonMarginBlock().spaceBefore;
-        } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) {
-            spaceBefore = ((org.apache.fop.fo.flow.ListBlock)fobj)
-                .getCommonMarginBlock().spaceBefore;
-        } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) {
-            spaceBefore = ((org.apache.fop.fo.flow.ListItem)fobj)
-                .getCommonMarginBlock().spaceBefore;
-        }
+        SpaceProperty spaceBefore = getSpaceBeforeProperty();
         // append elements representing space-before
+        if (spaceBefore != null
+                   && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 
+                        && spaceBefore.getMaximum(this).getLength().getValue(this) == 0)) {
+            returnList.add(new SpaceElement(getAuxiliaryPosition(), spaceBefore,
+                    RelSide.BEFORE, 
+                    true, false, this));
+        }
+        /*
         if (bpUnit > 0
                 || spaceBefore != null
                    && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 
@@ -882,7 +1008,7 @@
                 returnList.add(new KnuthGlue(0, 0, 0,
                         BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, 
                         getAuxiliaryPosition(), true));
-            } else /*if (alignment == EN_JUSTIFY)*/ {
+            } else { //if (alignment == EN_JUSTIFY) {
                 returnList.add(new KnuthGlue(
                         spaceBefore.getOptimum(this).getLength().getValue(this),
                         spaceBefore.getMaximum(this).getLength().getValue(this)
@@ -891,13 +1017,13 @@
                                 - spaceBefore.getMinimum(this).getLength().getValue(this),
                         BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, 
                         getAuxiliaryPosition(), true));
-            } /*else {
-                returnList.add(new KnuthGlue(
-                        spaceBefore.getOptimum().getLength().getValue(this), 
-                        0, 0, BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT,
-                        returnPosition, true));
-            }*/
-        }
+//            } else {
+//                returnList.add(new KnuthGlue(
+//                        spaceBefore.getOptimum().getLength().getValue(this), 
+//                        0, 0, BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT,
+//                        returnPosition, true));
+            }
+        }*/
     }
 
     /**
@@ -907,21 +1033,16 @@
      */
     protected void addKnuthElementsForSpaceAfter(LinkedList returnList/*, Position returnPosition*/, 
                 int alignment) {
-        SpaceProperty spaceAfter = null;
-        if (fobj instanceof org.apache.fop.fo.flow.Block) {
-            spaceAfter = ((org.apache.fop.fo.flow.Block)fobj)
-                .getCommonMarginBlock().spaceAfter;
-        } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
-            spaceAfter = ((org.apache.fop.fo.flow.BlockContainer)fobj)
-                .getCommonMarginBlock().spaceAfter;
-        } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) {
-            spaceAfter = ((org.apache.fop.fo.flow.ListBlock)fobj)
-                .getCommonMarginBlock().spaceAfter;
-        } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) {
-            spaceAfter = ((org.apache.fop.fo.flow.ListItem)fobj)
-                .getCommonMarginBlock().spaceAfter;
-        }
+        SpaceProperty spaceAfter = getSpaceAfterProperty();
         // append elements representing space-after
+        if (spaceAfter != null
+                && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 
+                     && spaceAfter.getMaximum(this).getLength().getValue(this) == 0)) {
+            returnList.add(new SpaceElement(getAuxiliaryPosition(), spaceAfter,
+                    RelSide.AFTER, 
+                    false, true, this));
+        }
+        /*
         if (bpUnit > 0
                 || spaceAfter != null
                    && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 
@@ -934,7 +1055,7 @@
                 returnList.add(new KnuthGlue(0, 0, 0, 
                         BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT,
                         getAuxiliaryPosition(), true));
-            } else /*if (alignment == EN_JUSTIFY)*/ {
+            } else { //if (alignment == EN_JUSTIFY) {
                 returnList.add(new KnuthGlue(
                         spaceAfter.getOptimum(this).getLength().getValue(this),
                         spaceAfter.getMaximum(this).getLength().getValue(this)
@@ -943,16 +1064,16 @@
                                 - spaceAfter.getMinimum(this).getLength().getValue(this),
                         BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, getAuxiliaryPosition(),
                         (!spaceAfter.getSpace().isDiscard()) ? false : true));
-            } /*else {
-                returnList.add(new KnuthGlue(
-                        spaceAfter.getOptimum().getLength().getValue(this), 0, 0,
-                        BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, returnPosition,
-                        (!spaceAfter.getSpace().isDiscard()) ? false : true));
-            }*/
+//            } else {
+//                returnList.add(new KnuthGlue(
+//                        spaceAfter.getOptimum().getLength().getValue(this), 0, 0,
+//                        BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, returnPosition,
+//                        (!spaceAfter.getSpace().isDiscard()) ? false : true));
+            }
             if (spaceAfter != null && !spaceAfter.getSpace().isDiscard()) {
                 returnList.add(new KnuthBox(0, getAuxiliaryPosition(), true));
             }
-        }
+        }*/
     }
 
     protected LinkedList createUnitElements(LinkedList oldList) {
@@ -1330,8 +1451,8 @@
           
         ListIterator listIter = sourceList.listIterator();
         while (listIter.hasNext()) {
-            KnuthElement tempElement;
-            tempElement = (KnuthElement) listIter.next();
+            ListElement tempElement;
+            tempElement = (ListElement) listIter.next();
             if (force || tempElement.getLayoutManager() != this) {
                 tempElement.setPosition(notifyPos(new NonLeafPosition(this,
                         tempElement.getPosition())));

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java?rev=328010&r1=328009&r2=328010&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java Mon Oct 24 02:21:26 2005
@@ -36,13 +36,16 @@
     public static void removeLegalBreaks(LinkedList elements) {
         ListIterator i = elements.listIterator();
         while (i.hasNext()) {
-            KnuthElement el = (KnuthElement)i.next();
+            ListElement el = (ListElement)i.next();
             if (el.isPenalty()) {
-                KnuthPenalty penalty = (KnuthPenalty)el;
+                BreakElement breakPoss = (BreakElement)el;
                 //Convert all penalties no break inhibitors
-                if (penalty.getP() < KnuthPenalty.INFINITE) {
+                if (breakPoss.getPenaltyValue() < KnuthPenalty.INFINITE) {
+                    breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
+                    /*
                     i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE, 
                             penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary()));
+                    */
                 }
             } else if (el.isGlue()) {
                 i.previous();
@@ -106,11 +109,11 @@
         int count = end - start + 1;
         int len = 0;
         while (iter.hasNext()) {
-            KnuthElement el = (KnuthElement)iter.next();
+            ListElement el = (ListElement)iter.next();
             if (el.isBox()) {
-                len += el.getW();
+                len += ((KnuthElement)el).getW();
             } else if (el.isGlue()) {
-                len += el.getW();
+                len += ((KnuthElement)el).getW();
             } else {
                 //log.debug("Ignoring penalty: " + el);
                 //ignore penalties
@@ -131,6 +134,16 @@
      */
     public static int calcContentLength(List elems) {
         return calcContentLength(elems, 0, elems.size() - 1);
+    }
+    
+    /**
+     * Indicates whether the given element list ends with a forced break.
+     * @param elems the element list
+     * @return true if the list ends with a forced break
+     */
+    public static boolean endsWithForcedBreak(LinkedList elems) {
+        ListElement last = (ListElement)elems.getLast();
+        return last.isForcedBreak();
     }
     
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=328010&r1=328009&r2=328010&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 Mon Oct 24 02:21:26 2005
@@ -36,7 +36,6 @@
  */
 public class FlowLayoutManager extends BlockStackingLayoutManager
                                implements BlockLevelLayoutManager {
-    private Flow fobj;
     
     /** Array of areas currently being filled stored by area class */
     private BlockParent[] currentAreas = new BlockParent[Area.CLASS_MAX];
@@ -51,7 +50,6 @@
      */
     public FlowLayoutManager(PageSequenceLayoutManager pslm, Flow node) {
         super(node);
-        fobj = node;
         setParent(pslm);
     }
 
@@ -84,6 +82,7 @@
                 log.debug("span change from " + currentSpan + " to " + span);
                 context.signalSpanChange(span);
                 currentSpan = span;
+                SpaceResolver.resolveElementList(returnList);
                 return returnList;
             }
             
@@ -109,10 +108,10 @@
             wrapPositionElements(tempList, returnedList);
 
             if (returnedList.size() == 1
-                && ((KnuthElement)returnedList.getFirst()).isPenalty()
-                && ((KnuthPenalty)returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
+                && ElementListUtils.endsWithForcedBreak(returnedList)) {
                 // a descendant of this flow has break-before
                 returnList.addAll(returnedList);
+                SpaceResolver.resolveElementList(returnList);
                 return returnList;
             } else {
                 if (returnList.size() > 0) {
@@ -123,20 +122,19 @@
                         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
-                        returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, 
-                                new Position(this), false));
-                    } else if (!((KnuthElement) returnList.getLast()).isGlue()) {
+                        returnList.add(new BreakElement(
+                                new Position(this), KnuthElement.INFINITE, context));
+                    } else if (!((ListElement) returnList.getLast()).isGlue()) {
                         // add a null penalty to allow a break between blocks
-                        returnList.add(new KnuthPenalty(0, 0, false, 
-                                new Position(this), false));
+                        returnList.add(new BreakElement(
+                                new Position(this), 0, context));
                     }
                 }
-                if (returnedList.size() > 0) { // controllare!
+                if (returnedList.size() > 0) {
                     returnList.addAll(returnedList);
-                    if (((KnuthElement)returnedList.getLast()).isPenalty()
-                        && ((KnuthPenalty)returnedList.getLast()).getP() 
-                                == -KnuthElement.INFINITE) {
+                    if (ElementListUtils.endsWithForcedBreak(returnList)) {
                         // a descendant of this flow has break-after
+                        SpaceResolver.resolveElementList(returnList);
                         return returnList;
                     }
                 }
@@ -148,6 +146,7 @@
             }
         }
 
+        SpaceResolver.resolveElementList(returnList);
         setFinished(true);
 
         if (returnList.size() > 0) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java?rev=328010&r1=328009&r2=328010&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java Mon Oct 24 02:21:26 2005
@@ -23,12 +23,20 @@
 
 import java.util.LinkedList;
 
+/**
+ * Layout manager for footnote bodies.
+ */
 public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager {
 
+    /**
+     * Creates a new FootnoteBodyLayoutManager.
+     * @param body the footnote-body element
+     */
     public FootnoteBodyLayoutManager(FootnoteBody body) {
         super(body);
     }
 
+    /** @see org.apache.fop.layoutmgr.LayoutManager */
     public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
         LayoutManager childLM = null;
         LayoutManager lastLM = null;
@@ -38,8 +46,6 @@
         // and put them in a new list;
         LinkedList positionList = new LinkedList();
         Position pos;
-        boolean bSpaceBefore = false;
-        boolean bSpaceAfter = false;
         while (parentIter.hasNext()) {
             pos = (Position) parentIter.next();
             //log.trace("pos = " + pos.getClass().getName() + "; " + pos);
@@ -73,14 +79,13 @@
         }
     }
 
+    /** @see org.apache.fop.layoutmgr.LayoutManager#addChildArea(org.apache.fop.area.Area) */
     public void addChildArea(Area childArea) {
         childArea.setAreaClass(Area.CLASS_FOOTNOTE);
         parentLM.addChildArea(childArea);
     }
 
-    /**
-     * convenience method that returns the FootnoteBody node
-     */
+    /** @return the FootnoteBody node */
     protected FootnoteBody getFootnodeBodyFO() {
         return (FootnoteBody) fobj;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message