xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acumis...@apache.org
Subject svn commit: r674497 [8/11] - in /xmlgraphics/fop/branches/Temp_AreaTreeNewDesign: ./ lib/ lib/build/ src/codegen/unicode/data/ src/codegen/unicode/java/org/apache/fop/text/linebreak/ src/documentation/ src/documentation/content/xdocs/ src/documentation...
Date Mon, 07 Jul 2008 14:09:10 GMT
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java Mon Jul  7 07:09:01 2008
@@ -20,9 +20,7 @@
 package org.apache.fop.layoutmgr.inline;
 
 import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.InlineParent;
 import org.apache.fop.area.Block;
-import org.apache.fop.area.LineArea;
 import org.apache.fop.fo.flow.Wrapper;
 import org.apache.fop.layoutmgr.BlockLayoutManager;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
@@ -30,20 +28,19 @@
 import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.TraitSetter;
 
+import java.util.LinkedList;
+
 /**
  * This is the layout manager for the fo:wrapper formatting object.
  */
 public class WrapperLayoutManager extends LeafNodeLayoutManager {
     
-    private Wrapper fobj;
-
     /**
      * Creates a new LM for fo:wrapper.
      * @param node the fo:wrapper
      */
     public WrapperLayoutManager(Wrapper node) {
         super(node);
-        fobj = node;
     }
 
     /** {@inheritDoc} */
@@ -70,13 +67,13 @@
     public void addAreas(PositionIterator posIter, LayoutContext context) {
         if (fobj.hasId()) {
             addId();
-            InlineArea area = getEffectiveArea();
             if (parentLM instanceof BlockStackingLayoutManager
                     && !(parentLM instanceof BlockLayoutManager)) {
                 Block helperBlock = new Block();
                 TraitSetter.setProducerID(helperBlock, fobj.getId());
                 parentLM.addChildArea(helperBlock);
             } else {
+                InlineArea area = getEffectiveArea();
                 parentLM.addChildArea(area);
             }
         }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java Mon Jul  7 07:09:01 2008
@@ -115,9 +115,9 @@
     }
     
     /** {@inheritDoc} */
-    public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+    public List getNextKnuthElements(LayoutContext context, int alignment) {
         resetSpaces(); 
-        LinkedList returnList = super.getNextKnuthElements(context, alignment);
+        List returnList = super.getNextKnuthElements(context, alignment);
 
         //fox:widow-content-limit
         int widowRowLimit = getListBlockFO().getWidowContentLimit().getValue(); 
@@ -135,7 +135,7 @@
     }
    
     /** {@inheritDoc} */
-    public LinkedList getChangedKnuthElements(List oldList, int alignment) {
+    public List getChangedKnuthElements(List oldList, int alignment) {
         //log.debug("LBLM.getChangedKnuthElements>");
         return super.getChangedKnuthElements(oldList, alignment);
     }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java Mon Jul  7 07:09:01 2008
@@ -98,7 +98,7 @@
     }
 
     /** {@inheritDoc} */
-    public LinkedList getChangedKnuthElements(List oldList, int alignment) {
+    public List getChangedKnuthElements(List oldList, int alignment) {
         //log.debug("  ListItemContentLayoutManager.getChanged>");
         return super.getChangedKnuthElements(oldList, alignment);
     }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java Mon Jul  7 07:09:01 2008
@@ -26,7 +26,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.fo.flow.ListItem;
@@ -39,12 +38,14 @@
 import org.apache.fop.layoutmgr.ElementListObserver;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.KeepUtil;
+import org.apache.fop.layoutmgr.KnuthBlockBox;
 import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthPenalty;
 import org.apache.fop.layoutmgr.KnuthPossPosIter;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.ListElement;
 import org.apache.fop.layoutmgr.NonLeafPosition;
 import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.layoutmgr.PositionIterator;
@@ -71,8 +72,8 @@
 
     private Block curBlockArea = null;
 
-    private LinkedList labelList = null;
-    private LinkedList bodyList = null;
+    private List labelList = null;
+    private List bodyList = null;
 
     private boolean discardBorderBefore;
     private boolean discardBorderAfter;
@@ -189,11 +190,11 @@
     }
     
     /** {@inheritDoc} */
-    public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+    public List getNextKnuthElements(LayoutContext context, int alignment) {
         referenceIPD = context.getRefIPD();
         LayoutContext childLC;
         
-        LinkedList returnList = new LinkedList();
+        List returnList = new LinkedList();
         
         if (!breakBeforeServed) {
             try {
@@ -242,7 +243,7 @@
         this.keepWithNextPendingOnBody = childLC.getKeepWithNextPending();
 
         // create a combined list
-        LinkedList returnedList = getCombinedKnuthElementsForListItem(labelList, bodyList, context);
+        List returnedList = getCombinedKnuthElementsForListItem(labelList, bodyList, context);
 
         // "wrap" the Position inside each element
         wrapPositionElements(returnedList, returnList, true);
@@ -261,10 +262,9 @@
         return returnList;
     }
 
-    private LinkedList getCombinedKnuthElementsForListItem(LinkedList labelElements,
-                                                           LinkedList bodyElements,
-                                                           LayoutContext context) {
-        //Copy elements to array lists to improve element access performance
+    private List getCombinedKnuthElementsForListItem(List labelElements,
+            List bodyElements, LayoutContext context) {
+        // Copy elements to array lists to improve element access performance
         List[] elementLists = {new ArrayList(labelElements),
                                new ArrayList(bodyElements)};
         int[] fullHeights = {ElementListUtils.calcContentLength(elementLists[0]),
@@ -279,8 +279,7 @@
         int keepWithNextActive = BlockLevelLayoutManager.KEEP_AUTO;
 
         LinkedList returnList = new LinkedList();
-        while ((step = getNextStep(elementLists, start, end, partialHeights))
-               > 0) {
+        while ((step = getNextStep(elementLists, start, end, partialHeights)) > 0) {
             
             if (end[0] + 1 == elementLists[0].size()) {
                 keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnLabel);
@@ -312,11 +311,33 @@
             int boxHeight = step - addedBoxHeight - penaltyHeight;
             penaltyHeight += additionalPenaltyHeight; //Add AFTER calculating boxHeight!
 
+            // collect footnote information
+            // TODO this should really not be done like this. ListItemLM should remain as
+            // footnote-agnostic as possible
+            LinkedList footnoteList = null;
+            ListElement el;
+            for (int i = 0; i < elementLists.length; i++) {
+                for (int j = start[i]; j <= end[i]; j++) {
+                    el = (ListElement) elementLists[i].get(j);
+                    if (el instanceof KnuthBlockBox && ((KnuthBlockBox) el).hasAnchors()) {
+                        if (footnoteList == null) {
+                            footnoteList = new LinkedList();
+                        }
+                        footnoteList.addAll(((KnuthBlockBox) el).getFootnoteBodyLMs());
+                    }
+                }
+            }
+
             // add the new elements
             addedBoxHeight += boxHeight;
             ListItemPosition stepPosition = new ListItemPosition(this, 
                     start[0], end[0], start[1], end[1]);
-            returnList.add(new KnuthBox(boxHeight, stepPosition, false));
+            if (footnoteList == null) {
+                returnList.add(new KnuthBox(boxHeight, stepPosition, false));
+            } else {
+                returnList.add(new KnuthBlockBox(boxHeight, footnoteList, stepPosition, false));
+            }
+
             if (addedBoxHeight < totalHeight) {
                 int strength = BlockLevelLayoutManager.KEEP_AUTO;
                 strength = Math.max(strength, keepWithNextActive);
@@ -407,7 +428,7 @@
     /**
      * {@inheritDoc} 
      */
-    public LinkedList getChangedKnuthElements(List oldList, int alignment) {
+    public List getChangedKnuthElements(List oldList, int alignment) {
         //log.debug(" LILM.getChanged> label");
         // label
         labelList = label.getChangedKnuthElements(labelList, alignment);
@@ -436,9 +457,9 @@
             }
         }
 
-        LinkedList returnedList = body.getChangedKnuthElements(oldList, alignment);
+        List returnedList = body.getChangedKnuthElements(oldList, alignment);
         // "wrap" the Position inside each element
-        LinkedList tempList = returnedList;
+        List tempList = returnedList;
         KnuthElement tempElement;
         returnedList = new LinkedList();
         ListIterator listIter = tempList.listIterator();

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java Mon Jul  7 07:09:01 2008
@@ -19,12 +19,12 @@
 
 package org.apache.fop.layoutmgr.table;
 
+import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.table.ConditionalBorder;
 import org.apache.fop.fo.flow.table.EffRow;
@@ -32,6 +32,7 @@
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.ElementListUtils;
+import org.apache.fop.layoutmgr.KnuthBlockBox;
 import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthPenalty;
@@ -101,6 +102,8 @@
         private int penaltyLength;
         /** Value of the penalty ending this step, 0 if the step does not end on a penalty. */
         private int penaltyValue;
+        /** List of footnotes for this step. */
+        private List footnoteList;
         /**
          * One of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN},
          * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE},
@@ -130,6 +133,7 @@
             this.totalLength   = other.totalLength;
             this.penaltyLength = other.penaltyLength;
             this.penaltyValue  = other.penaltyValue;
+            this.footnoteList  = other.footnoteList;
             this.condBeforeContentLength = other.condBeforeContentLength;
             this.breakClass    = other.breakClass;
         }
@@ -293,6 +297,7 @@
         afterNextStep.penaltyValue = 0;
         afterNextStep.condBeforeContentLength = 0;
         afterNextStep.breakClass = Constants.EN_AUTO;
+        afterNextStep.footnoteList = null;
         boolean breakFound = false;
         boolean prevIsBox = false;
         boolean boxFound = false;
@@ -322,6 +327,12 @@
                 }
                 prevIsBox = false;
             } else {
+                if (el instanceof KnuthBlockBox && ((KnuthBlockBox) el).hasAnchors()) {
+                    if (afterNextStep.footnoteList == null) {
+                        afterNextStep.footnoteList = new LinkedList();
+                    }
+                    afterNextStep.footnoteList.addAll(((KnuthBlockBox) el).getFootnoteBodyLMs());
+                }
                 prevIsBox = true;
                 boxFound = true;
                 afterNextStep.contentLength += el.getW();
@@ -543,6 +554,18 @@
         }
     }
 
+    /**
+     * Adds the footnotes (if any) that are part of the next step, if this cell
+     * contributes content to the next step.
+     * 
+     * @param footnoteList the list to which this cell must add its footnotes
+     */
+    void addFootnotes(List footnoteList) {
+        if (includedInLastStep() && nextStep.footnoteList != null) {
+            footnoteList.addAll(nextStep.footnoteList);
+        }
+    }
+
     int getKeepWithNextStrength() {
         return keepWithNextStrength;
     }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Mon Jul  7 07:09:01 2008
@@ -21,10 +21,10 @@
 
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.GridUnit;
@@ -88,7 +88,6 @@
      * @param alignment alignment indicator
      * @param bodyType Indicates what kind of body is being processed (BODY, HEADER or FOOTER)
      * @param returnList List to received the generated elements
-     * @param rowGroup row group to process
      */
     private void createElementsForRowGroup(LayoutContext context, int alignment, 
             int bodyType, LinkedList returnList) {
@@ -116,7 +115,7 @@
                     childLC.setRefIPD(spanWidth);
                     
                     //Get the element list for the cell contents
-                    LinkedList elems = primary.getCellLM().getNextKnuthElements(
+                    List elems = primary.getCellLM().getNextKnuthElements(
                                             childLC, alignment);
                     ElementListObserver.observe(elems, "table-cell", primary.getCell().getId());
                     primary.setElements(elems);
@@ -124,7 +123,7 @@
             }
         }
         computeRowHeights();
-        LinkedList elements = tableStepper.getCombinedKnuthElementsForRowGroup(context,
+        List elements = tableStepper.getCombinedKnuthElementsForRowGroup(context,
                 rowGroup, bodyType);
         returnList.addAll(elements);
     }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/RowPainter.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/RowPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/RowPainter.java Mon Jul  7 07:09:01 2008
@@ -32,7 +32,7 @@
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.GridUnit;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
-import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.KnuthElement;
@@ -94,7 +94,7 @@
         this.firstRowOnPageIndex = -1;
     }
 
-    void startTablePart(TableBody tablePart) {
+    void startTablePart(TablePart tablePart) {
         CommonBorderPaddingBackground background = tablePart.getCommonBorderPaddingBackground();
         if (background.hasBackground()) {
             tablePartBackground = background;
@@ -229,8 +229,12 @@
 
         // Then add areas for cells finishing on the current row
         for (int i = 0; i < colCount; i++) {
-            GridUnit currentGU = currentRow.getGridUnit(i);            
-            if (!currentGU.isEmpty() && currentGU.getColSpanIndex() == 0
+            GridUnit currentGU = currentRow.getGridUnit(i);
+            if (currentGU.isEmpty()) {
+                // TODO remove once missing cells are properly implemented (i.e., replaced
+                // by an fo:table-cell element containing an empty fo:block)
+                firstCellOnPage[i] = false;
+            } else if (currentGU.getColSpanIndex() == 0
                     && (lastInPart || currentGU.isLastGridUnitRowSpan())
                     && firstCellParts[i] != null) {
                 assert firstCellParts[i].pgu == currentGU.getPrimary();
@@ -260,7 +264,8 @@
                         actualRowHeight, borderBeforeWhich, borderAfterWhich,
                         lastOnPage);
                 firstCellParts[i] = null;
-                firstCellOnPage[i] = false;
+                Arrays.fill(firstCellOnPage, i, i + currentGU.getCell().getNumberColumnsSpanned(),
+                        false);
             }
         }
         currentRowOffset += actualRowHeight;

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Mon Jul  7 07:09:01 2008
@@ -20,10 +20,10 @@
 package org.apache.fop.layoutmgr.table;
 
 import java.util.LinkedList;
+import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.Trait;
@@ -31,7 +31,7 @@
 import org.apache.fop.fo.flow.table.GridUnit;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.fo.flow.table.TableCell;
 import org.apache.fop.fo.flow.table.TableColumn;
 import org.apache.fop.fo.flow.table.TableRow;
@@ -52,6 +52,7 @@
 import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.util.ListUtil;
 
 /**
  * LayoutManager for a table-cell FO.
@@ -126,16 +127,16 @@
     /**
      * {@inheritDoc}
      */
-    public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+    public List getNextKnuthElements(LayoutContext context, int alignment) {
         MinOptMax stackLimit = new MinOptMax(context.getStackLimitBP());
 
         referenceIPD = context.getRefIPD();
         cellIPD = referenceIPD;
         cellIPD -= getIPIndents();
 
-        LinkedList returnedList;
-        LinkedList contentList = new LinkedList();
-        LinkedList returnList = new LinkedList();
+        List returnedList;
+        List contentList = new LinkedList();
+        List returnList = new LinkedList();
 
         BlockLevelLayoutManager curLM; // currently active LM
         BlockLevelLayoutManager prevLM = null; // previously active LM
@@ -151,7 +152,7 @@
             if (childLC.isKeepWithNextPending()) {
                 log.debug("child LM signals pending keep with next");
             }
-            if (contentList.size() == 0 && childLC.isKeepWithPreviousPending()) {
+            if (contentList.isEmpty() && childLC.isKeepWithPreviousPending()) {
                 primaryGridUnit.setKeepWithPreviousStrength(childLC.getKeepWithPreviousPending());
                 childLC.clearKeepWithPreviousPending();
             }
@@ -162,7 +163,7 @@
                 addInBetweenBreak(contentList, context, childLC);
             }
             contentList.addAll(returnedList);
-            if (returnedList.size() == 0) {
+            if (returnedList.isEmpty()) {
                 //Avoid NoSuchElementException below (happens with empty blocks)
                 continue;
             }
@@ -176,7 +177,7 @@
         primaryGridUnit.setKeepWithNextStrength(context.getKeepWithNextPending());
 
         returnedList = new LinkedList();
-        if (contentList.size() > 0) {
+        if (!contentList.isEmpty()) {
             wrapPositionElements(contentList, returnList);
         } else {
             // In relaxed validation mode, table-cells having no children are authorised.
@@ -187,13 +188,15 @@
         }
         //Space resolution
         SpaceResolver.resolveElementList(returnList);
-        if (((KnuthElement) returnList.getFirst()).isForcedBreak()) {
-            primaryGridUnit.setBreakBefore(((KnuthPenalty) returnList.getFirst()).getBreakClass());
-            returnList.removeFirst();
+        if (((KnuthElement) returnList.get(0)).isForcedBreak()) {
+            primaryGridUnit.setBreakBefore(((KnuthPenalty) returnList.get(0)).getBreakClass());
+            returnList.remove(0);
             assert !returnList.isEmpty();
         }
-        if (((KnuthElement) returnList.getLast()).isForcedBreak()) {
-            KnuthPenalty p = (KnuthPenalty) returnList.getLast();
+        final KnuthElement lastItem = (KnuthElement) ListUtil
+                .getLast(returnList);
+        if (((KnuthElement) lastItem).isForcedBreak()) {
+            KnuthPenalty p = (KnuthPenalty) lastItem;
             primaryGridUnit.setBreakAfter(p.getBreakClass());
             p.setP(0);
         }
@@ -436,7 +439,7 @@
                     -startIndent);
         }
 
-        TableBody body = primaryGridUnit.getTableBody();
+        TablePart body = primaryGridUnit.getTablePart();
         if (body.getCommonBorderPaddingBackground().hasBackground()) {
             painter.registerPartBackgroundArea(
                     getBackgroundArea(paddingRectBPD, borderBeforeWidth));

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java Mon Jul  7 07:09:01 2008
@@ -19,10 +19,10 @@
 
 package org.apache.fop.layoutmgr.table;
 
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.ListIterator;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
@@ -34,13 +34,14 @@
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BreakElement;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.KeepUtil;
 import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthGlue;
 import org.apache.fop.layoutmgr.KnuthPossPosIter;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.ListElement;
@@ -232,6 +233,17 @@
                 
                 //Get elements for next row group
                 nextRowGroupElems = rowGroupLM.getNextKnuthElements(context, alignment, bodyType);
+                /*
+                 * The last break element produced by TableStepper (for the previous row
+                 * group) may be used to represent the break between the two row groups.
+                 * Its penalty value and break class must just be overridden by the
+                 * characteristics of the keep or break between the two.
+                 * 
+                 * However, we mustn't forget that if the after border of the last row of
+                 * the row group is thicker in the normal case than in the trailing case,
+                 * an additional glue will be appended to the element list. So we may have
+                 * to go two steps backwards in the list.
+                 */
                 
                 //Determine keep constraints
                 int penaltyStrength = BlockLevelLayoutManager.KEEP_AUTO;
@@ -246,24 +258,35 @@
                 if (breakBetween != Constants.EN_AUTO) {
                     penaltyValue = -KnuthElement.INFINITE;
                 }
-                TableHFPenaltyPosition penaltyPos = new TableHFPenaltyPosition(getTableLM());
-                int penaltyLen = 0;
-                if (bodyType == TableRowIterator.BODY) {
-                    if (!getTableLM().getTable().omitHeaderAtBreak()) {
-                        penaltyLen += getHeaderNetHeight();
-                        penaltyPos.headerElements = getHeaderElements();
-                    }
-                    if (!getTableLM().getTable().omitFooterAtBreak()) {
-                        penaltyLen += getFooterNetHeight();
-                        penaltyPos.footerElements = getFooterElements();
-                    }
+                BreakElement breakElement;
+                ListIterator elemIter = returnList.listIterator(returnList.size());
+                ListElement elem = (ListElement) elemIter.previous();
+                if (elem instanceof KnuthGlue) {
+                    breakElement = (BreakElement) elemIter.previous();
+                } else {
+                    breakElement = (BreakElement) elem;
                 }
-                returnList.add(new BreakElement(penaltyPos, 
-                        penaltyLen, penaltyValue, breakBetween, context));
+                breakElement.setPenaltyValue(penaltyValue);
+                breakElement.setBreakClass(breakBetween);
                 returnList.addAll(nextRowGroupElems);
                 breakBetween = context.getBreakAfter();
             }
         }
+        /*
+         * The last break produced for the last row-group of this table part must be
+         * removed, because the breaking after the table will be handled by TableLM.
+         * Unless the element list ends with a glue, which must be kept to accurately
+         * represent the content. In such a case the break is simply disabled by setting
+         * its penalty to infinite.
+         */
+        ListIterator elemIter = returnList.listIterator(returnList.size());
+        ListElement elem = (ListElement) elemIter.previous();
+        if (elem instanceof KnuthGlue) {
+            BreakElement breakElement = (BreakElement) elemIter.previous();
+            breakElement.setPenaltyValue(KnuthElement.INFINITE);
+        } else {
+            elemIter.remove();
+        }
         context.updateKeepWithPreviousPending(keepWithPrevious);
         context.setBreakBefore(breakBefore);
 
@@ -300,7 +323,7 @@
         this.usedBPD = 0;
         RowPainter painter = new RowPainter(this, layoutContext);
 
-        List tablePositions = new ArrayList();
+        List tablePositions = new java.util.ArrayList();
         List headerElements = null;
         List footerElements = null;
         Position firstPos = null;
@@ -393,9 +416,9 @@
         }
     }
 
-    private void addHeaderFooterAreas(List elements, TableBody part, RowPainter painter,
+    private void addHeaderFooterAreas(List elements, TablePart part, RowPainter painter,
             boolean lastOnPage) {
-        List lst = new ArrayList(elements.size());
+        List lst = new java.util.ArrayList(elements.size());
         for (Iterator iter = new KnuthPossPosIter(elements); iter.hasNext();) {
             Position pos = (Position) iter.next();
             /*
@@ -422,32 +445,32 @@
     private void addBodyAreas(Iterator iterator, RowPainter painter,
             boolean lastOnPage) {
         painter.startBody();
-        List lst = new ArrayList();
+        List lst = new java.util.ArrayList();
         TableContentPosition pos = (TableContentPosition) iterator.next();
         boolean isFirstPos = pos.getFlag(TableContentPosition.FIRST_IN_ROWGROUP)
                 && pos.getRow().getFlag(EffRow.FIRST_IN_PART);
-        TableBody body = pos.getTableBody();
+        TablePart part = pos.getTablePart();
         lst.add(pos);
         while (iterator.hasNext()) {
             pos = (TableContentPosition) iterator.next();
-            if (pos.getTableBody() != body) {
-                addTablePartAreas(lst, painter, body, isFirstPos, true, false, false);
+            if (pos.getTablePart() != part) {
+                addTablePartAreas(lst, painter, part, isFirstPos, true, false, false);
                 isFirstPos = true;
                 lst.clear();
-                body = pos.getTableBody();
+                part = pos.getTablePart();
             }
             lst.add(pos);
         }
         boolean isLastPos = pos.getFlag(TableContentPosition.LAST_IN_ROWGROUP)
                 && pos.getRow().getFlag(EffRow.LAST_IN_PART);
-        addTablePartAreas(lst, painter, body, isFirstPos, isLastPos, true, lastOnPage);
+        addTablePartAreas(lst, painter, part, isFirstPos, isLastPos, true, lastOnPage);
         painter.endBody();
     }
 
     /**
      * Adds the areas corresponding to a single fo:table-header/footer/body element.
      */
-    private void addTablePartAreas(List positions, RowPainter painter, TableBody body,
+    private void addTablePartAreas(List positions, RowPainter painter, TablePart body,
             boolean isFirstPos, boolean isLastPos, boolean lastInBody, boolean lastOnPage) {
         getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
                 true, isFirstPos, isLastPos);

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java Mon Jul  7 07:09:01 2008
@@ -22,7 +22,7 @@
 import java.util.List;
 
 import org.apache.fop.fo.flow.table.EffRow;
-import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.Position;
 
@@ -80,8 +80,8 @@
         return row;
     }
 
-    TableBody getTableBody() {
-        return ((CellPart) cellParts.get(0)).pgu.getTableBody();
+    TablePart getTablePart() {
+        return ((CellPart) cellParts.get(0)).pgu.getTablePart();
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java Mon Jul  7 07:09:01 2008
@@ -178,9 +178,9 @@
     }
 
     /** {@inheritDoc} */
-    public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+    public List getNextKnuthElements(LayoutContext context, int alignment) {
         
-        LinkedList returnList = new LinkedList();
+        List returnList = new LinkedList();
 
         /*
          * Compute the IPD and adjust it if necessary (overconstrained)
@@ -271,8 +271,8 @@
         int breakBefore = BreakUtil.compareBreakClasses(getTable().getBreakBefore(),
                 childLC.getBreakBefore());
         if (breakBefore != Constants.EN_AUTO) {
-            returnList.addFirst(new BreakElement(getAuxiliaryPosition(), 
-                    0, -KnuthElement.INFINITE, breakBefore, context));
+            returnList.add(0, new BreakElement(getAuxiliaryPosition(), 0,
+                    -KnuthElement.INFINITE, breakBefore, context));
         }
 
         //addKnuthElementsForBreakAfter(returnList, context);

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java Mon Jul  7 07:09:01 2008
@@ -28,6 +28,7 @@
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 
 
 /**
@@ -69,7 +70,7 @@
             case FOOTER:
                 rowGroupsIter = table.getTableFooter().getRowGroups().iterator();
                 break;
-            default:
+            case BODY:
                 List rowGroupsList = new LinkedList();
                 // TODO this is ugly
                 for (FONodeIterator iter = table.getChildNodes(); iter.hasNext();) {
@@ -79,6 +80,9 @@
                     }
                 }
                 rowGroupsIter = rowGroupsList.iterator();
+                break;
+            default:
+                throw new IllegalArgumentException("Unrecognised TablePart: " + tablePart);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableStepper.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableStepper.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/layoutmgr/table/TableStepper.java Mon Jul  7 07:09:01 2008
@@ -33,6 +33,7 @@
 import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BreakElement;
 import org.apache.fop.layoutmgr.KeepUtil;
+import org.apache.fop.layoutmgr.KnuthBlockBox;
 import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthGlue;
@@ -199,12 +200,14 @@
                 }
             }
 
+            LinkedList footnoteList = new LinkedList();
             //Put all involved grid units into a list
             List cellParts = new java.util.ArrayList(columnCount);
             for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
                 ActiveCell activeCell = (ActiveCell) iter.next();
                 CellPart part = activeCell.createCellPart();
                 cellParts.add(part);
+                activeCell.addFootnotes(footnoteList);
             }
 
             //Create elements for step
@@ -217,7 +220,13 @@
                 tcpos.setFlag(TableContentPosition.FIRST_IN_ROWGROUP, true);
             }
             lastTCPos = tcpos;
-            returnList.add(new KnuthBox(boxLen, tcpos, false));
+
+            // TODO TableStepper should remain as footnote-agnostic as possible
+            if (footnoteList.isEmpty()) {
+                returnList.add(new KnuthBox(boxLen, tcpos, false));
+            } else {
+                returnList.add(new KnuthBlockBox(boxLen, footnoteList, tcpos, false));
+            }
 
             int effPenaltyLen = Math.max(0, penaltyOrGlueLen);
             TableHFPenaltyPosition penaltyPos = new TableHFPenaltyPosition(getTableLM());
@@ -273,13 +282,8 @@
             laststep = step;
             step = getNextStep();
         } while (step >= 0);
-        if (!returnList.isEmpty()) {
-            lastTCPos.setFlag(TableContentPosition.LAST_IN_ROWGROUP, true);
-            // It's not up to TableStepper to decide whether there can/must be a break
-            // after the row group or not, but to ancestor stacking elements
-            assert returnList.getLast() instanceof BreakElement;
-            returnList.removeLast();
-        }
+        assert !returnList.isEmpty();
+        lastTCPos.setFlag(TableContentPosition.LAST_IN_ROWGROUP, true);
         return returnList;
     }
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFDocument.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFDocument.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFDocument.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFDocument.java Mon Jul  7 07:09:01 2008
@@ -528,10 +528,10 @@
     public void setEncryption(PDFEncryptionParams params) {
         getProfile().verifyEncryptionAllowed();
         this.encryption = PDFEncryptionManager.newInstance(++this.objectcount, params);
-        ((PDFObject)this.encryption).setDocument(this);
         if (encryption != null) {
-            /**@todo this cast is ugly. PDFObject should be transformed to an interface. */
-            addTrailerObject((PDFObject)this.encryption);
+            PDFObject pdfObject = (PDFObject)encryption;
+            pdfObject.setDocument(this);
+            addTrailerObject(pdfObject);
         } else {
             log.warn(
                 "PDF encryption is unavailable. PDF will be "

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFFactory.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFFactory.java Mon Jul  7 07:09:01 2008
@@ -1203,10 +1203,11 @@
             PDFFontDescriptor pdfdesc = makeFontDescriptor(descriptor);
 
             PDFFont font = null;
-            font = PDFFont.createFont(fontname, fonttype, basefont, encoding);
+            font = PDFFont.createFont(fontname, fonttype, basefont, null);
             getDocument().registerObject(font);
 
             if (fonttype == FontType.TYPE0) {
+                font.setEncoding(encoding);
                 CIDFont cidMetrics;
                 if (metrics instanceof LazyFont) {
                     cidMetrics = (CIDFont)((LazyFont) metrics).getRealFont();
@@ -1252,7 +1253,9 @@
                 
                 //Handle encoding
                 SingleByteEncoding mapping = singleByteFont.getEncoding();
-                if (PDFEncoding.isPredefinedEncoding(mapping.getName())) {
+                if (singleByteFont.isSymbolicFont()) {
+                    //no encoding, use the font's encoding
+                } else if (PDFEncoding.isPredefinedEncoding(mapping.getName())) {
                     font.setEncoding(mapping.getName());
                 } else {
                     Object pdfEncoding = createPDFEncoding(mapping,

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFFont.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFFont.java Mon Jul  7 07:09:01 2008
@@ -62,8 +62,6 @@
             setEncoding((PDFEncoding)encoding);
         } else if (encoding instanceof String) {
             setEncoding((String)encoding);
-        } else {
-            throw new IllegalArgumentException("Illegal value for encoding");
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFResources.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFResources.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFResources.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/pdf/PDFResources.java Mon Jul  7 07:09:01 2008
@@ -28,6 +28,8 @@
 import org.apache.fop.fonts.FontDescriptor;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.Typeface;
+import org.apache.fop.fonts.base14.Symbol;
+import org.apache.fop.fonts.base14.ZapfDingbats;
 import org.apache.fop.util.ColorProfileUtil;
 
 /**
@@ -109,8 +111,12 @@
                 if (font instanceof FontDescriptor) {
                     desc = (FontDescriptor)font;
                 }
+                String encoding = font.getEncodingName();
+                if (font instanceof Symbol || font instanceof ZapfDingbats) {
+                    encoding = null; //Symbolic fonts shouldn't specify an encoding value in PDF
+                }
                 addFont(doc.getFactory().makeFont(
-                    f, font.getEmbedFontName(), font.getEncodingName(), font, desc));
+                    f, font.getEmbedFontName(), encoding, font, desc));
             }
         }
     }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java Mon Jul  7 07:09:01 2008
@@ -32,12 +32,13 @@
 import java.awt.image.DataBuffer;
 import java.awt.image.Raster;
 import java.awt.image.WritableRaster;
+import java.io.IOException;
 
 import org.apache.fop.render.RendererContext.RendererContextWrapper;
 import org.apache.fop.util.UnitConv;
 
 /**
- * Graphics2DAdapter implementation for PCL and HP GL/2.
+ * Abstract base class for Graphics2DAdapter implementations.
  */
 public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter {
 
@@ -135,4 +136,12 @@
             RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
     }
 
+    /** {@inheritDoc} */
+    public void paintImage(Graphics2DImagePainter painter, 
+            RendererContext context,
+            int x, int y, int width, int height) throws IOException {
+        paintImage((org.apache.xmlgraphics.java2d.Graphics2DImagePainter)painter,
+                context, x, y, width, height);
+    }
+    
 }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java Mon Jul  7 07:09:01 2008
@@ -37,6 +37,8 @@
 import org.apache.fop.area.Block;
 import org.apache.fop.area.BlockViewport;
 import org.apache.fop.area.CTM;
+import org.apache.fop.area.NormalFlow;
+import org.apache.fop.area.RegionReference;
 import org.apache.fop.area.RegionViewport;
 import org.apache.fop.area.Trait;
 import org.apache.fop.area.inline.ForeignObject;
@@ -95,19 +97,20 @@
      */
     protected void handleRegionTraits(RegionViewport region) {
         Rectangle2D viewArea = region.getViewArea();
+        RegionReference referenceArea = region.getRegionReference();
         float startx = (float)(viewArea.getX() / 1000f);
         float starty = (float)(viewArea.getY() / 1000f);
         float width = (float)(viewArea.getWidth() / 1000f);
         float height = (float)(viewArea.getHeight() / 1000f);
 
-        if (region.getRegionReference().getRegionClass() == FO_REGION_BODY) {
-            currentBPPosition = region.getBorderAndPaddingWidthBefore();
-            currentIPPosition = region.getBorderAndPaddingWidthStart();
-        }
-        drawBackAndBorders(region, startx, starty, width, height);
+        // adjust the current position according to region borders and padding
+        currentBPPosition = referenceArea.getBorderAndPaddingWidthBefore();
+        currentIPPosition = referenceArea.getBorderAndPaddingWidthStart();
+        // draw background (traits are in the RegionViewport)
+        // and borders (traits are in the RegionReference)
+        drawBackAndBorders(region, referenceArea, startx, starty, width, height);
     }
 
-    
     /**
      * Draw the background and borders.
      * This draws the background and border traits for an area given
@@ -122,15 +125,57 @@
     protected void drawBackAndBorders(Area area,
                     float startx, float starty,
                     float width, float height) {
+        drawBackAndBorders(area, area, startx, starty, width, height);
+    }
+
+    /**
+     * Draw the background and borders.
+     * This draws the background and border traits for an area given
+     * the position.
+     *
+     * @param backgroundArea the area to get the background traits from
+     * @param borderArea the area to get the border traits from
+     * @param startx the start x position
+     * @param starty the start y position
+     * @param width the width of the area
+     * @param height the height of the area
+     */
+    protected void drawBackAndBorders(Area backgroundArea, Area borderArea,
+                    float startx, float starty,
+                    float width, float height) {
         // draw background then border
 
-        BorderProps bpsBefore = (BorderProps)area.getTrait(Trait.BORDER_BEFORE);
-        BorderProps bpsAfter = (BorderProps)area.getTrait(Trait.BORDER_AFTER);
-        BorderProps bpsStart = (BorderProps)area.getTrait(Trait.BORDER_START);
-        BorderProps bpsEnd = (BorderProps)area.getTrait(Trait.BORDER_END);
+        BorderProps bpsBefore = (BorderProps)borderArea.getTrait(Trait.BORDER_BEFORE);
+        BorderProps bpsAfter = (BorderProps)borderArea.getTrait(Trait.BORDER_AFTER);
+        BorderProps bpsStart = (BorderProps)borderArea.getTrait(Trait.BORDER_START);
+        BorderProps bpsEnd = (BorderProps)borderArea.getTrait(Trait.BORDER_END);
+
+        drawBackground(startx, starty, width, height,
+                (Trait.Background) backgroundArea.getTrait(Trait.BACKGROUND), 
+                bpsBefore, bpsAfter, bpsStart, bpsEnd);
+        drawBorders(startx, starty, width, height,
+                bpsBefore, bpsAfter, bpsStart, bpsEnd);        
+    }
 
-        Trait.Background back;
-        back = (Trait.Background)area.getTrait(Trait.BACKGROUND);
+    /**
+     * Draw the background.
+     * This draws the background given the position and the traits.
+     *
+     * @param startx the start x position
+     * @param starty the start y position
+     * @param width the width of the area
+     * @param height the height of the area
+     * @param back the background traits
+     * @param bpsBefore the border-before traits
+     * @param bpsAfter the border-after traits
+     * @param bpsStart the border-start traits
+     * @param bpsEnd the border-end traits
+     */
+    protected void drawBackground(float startx, float starty,
+                    float width, float height,
+                    Trait.Background back,
+                    BorderProps bpsBefore, BorderProps bpsAfter,
+                    BorderProps bpsStart, BorderProps bpsEnd) {
         if (back != null) {
             endTextObject();
 
@@ -201,7 +246,25 @@
                 restoreGraphicsState();
             }
         }
+    }
 
+    /**
+     * Draw the borders.
+     * This draws the border traits given the position and the traits.
+     *
+     * @param startx the start x position
+     * @param starty the start y position
+     * @param width the width of the area
+     * @param height the height of the area
+     * @param bpsBefore the border-before traits
+     * @param bpsAfter the border-after traits
+     * @param bpsStart the border-start traits
+     * @param bpsEnd the border-end traits
+     */
+    protected void drawBorders(float startx, float starty,
+                    float width, float height,
+                    BorderProps bpsBefore, BorderProps bpsAfter,
+                    BorderProps bpsStart, BorderProps bpsEnd) {
         Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height);
         drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
     }
@@ -521,6 +584,69 @@
         }
     }
 
+    /** {@inheritDoc} */
+    protected void renderReferenceArea(Block block) {
+        // save position and offset
+        int saveIP = currentIPPosition;
+        int saveBP = currentBPPosition;
+
+        //Establish a new coordinate system
+        AffineTransform at = new AffineTransform();
+        at.translate(currentIPPosition, currentBPPosition);
+        at.translate(block.getXOffset(), block.getYOffset());
+        at.translate(0, block.getSpaceBefore());
+        
+        if (!at.isIdentity()) {
+            saveGraphicsState();
+            concatenateTransformationMatrix(mptToPt(at));
+        }
+
+        currentIPPosition = 0;
+        currentBPPosition = 0;
+        handleBlockTraits(block);
+
+        List children = block.getChildAreas();
+        if (children != null) {
+            renderBlocks(block, children);
+        }
+
+        if (!at.isIdentity()) {
+            restoreGraphicsState();
+        }
+        
+        // stacked and relative blocks effect stacking
+        currentIPPosition = saveIP;
+        currentBPPosition = saveBP;
+    }
+    
+    /** {@inheritDoc} */
+    protected void renderFlow(NormalFlow flow) {
+        // save position and offset
+        int saveIP = currentIPPosition;
+        int saveBP = currentBPPosition;
+
+        //Establish a new coordinate system
+        AffineTransform at = new AffineTransform();
+        at.translate(currentIPPosition, currentBPPosition);
+        
+        if (!at.isIdentity()) {
+            saveGraphicsState();
+            concatenateTransformationMatrix(mptToPt(at));
+        }
+
+        currentIPPosition = 0;
+        currentBPPosition = 0;
+        super.renderFlow(flow);
+        
+        if (!at.isIdentity()) {
+            restoreGraphicsState();
+        }
+        
+        // stacked and relative blocks effect stacking
+        currentIPPosition = saveIP;
+        currentBPPosition = saveBP;
+    }
+    
     /**
      * Concatenates the current transformation matrix with the given one, therefore establishing
      * a new coordinate system.

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractRenderer.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/AbstractRenderer.java Mon Jul  7 07:09:01 2008
@@ -54,7 +54,6 @@
 import org.apache.fop.area.RegionViewport;
 import org.apache.fop.area.Span;
 import org.apache.fop.area.Trait;
-import org.apache.fop.area.inline.Character;
 import org.apache.fop.area.inline.Container;
 import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.area.inline.Image;
@@ -246,15 +245,25 @@
         last here. */
         RegionViewport viewport;
         viewport = page.getRegionViewport(FO_REGION_BEFORE);
-        renderRegionViewport(viewport);
+        if (viewport != null) {
+            renderRegionViewport(viewport);
+        }
         viewport = page.getRegionViewport(FO_REGION_START);
-        renderRegionViewport(viewport);
+        if (viewport != null) {
+            renderRegionViewport(viewport);
+        }
         viewport = page.getRegionViewport(FO_REGION_END);
-        renderRegionViewport(viewport);
+        if (viewport != null) {
+            renderRegionViewport(viewport);
+        }
         viewport = page.getRegionViewport(FO_REGION_AFTER);
-        renderRegionViewport(viewport);
+        if (viewport != null) {
+            renderRegionViewport(viewport);
+        }
         viewport = page.getRegionViewport(FO_REGION_BODY);
-        renderRegionViewport(viewport);
+        if (viewport != null) {
+            renderRegionViewport(viewport);
+        }
     }
 
     /**
@@ -266,27 +275,25 @@
      * @param port  The region viewport to be rendered
      */
     protected void renderRegionViewport(RegionViewport port) {
-        if (port != null) {
-            Rectangle2D view = port.getViewArea();
-            // The CTM will transform coordinates relative to
-            // this region-reference area into page coords, so
-            // set origin for the region to 0,0.
-            currentBPPosition = 0;
-            currentIPPosition = 0;
-
-            RegionReference regionReference = port.getRegionReference();
-            handleRegionTraits(port);
-
-            //  shouldn't the viewport have the CTM
-            startVParea(regionReference.getCTM(), port.isClip() ? view : null);
-            // do after starting viewport area
-            if (regionReference.getRegionClass() == FO_REGION_BODY) {
-                renderBodyRegion((BodyRegion) regionReference);
-            } else {
-                renderRegion(regionReference);
-            }
-            endVParea();
+        Rectangle2D view = port.getViewArea();
+        // The CTM will transform coordinates relative to
+        // this region-reference area into page coords, so
+        // set origin for the region to 0,0.
+        currentBPPosition = 0;
+        currentIPPosition = 0;
+
+        RegionReference regionReference = port.getRegionReference();
+        handleRegionTraits(port);
+
+        //  shouldn't the viewport have the CTM
+        startVParea(regionReference.getCTM(), port.isClip() ? view : null);
+        // do after starting viewport area
+        if (regionReference.getRegionClass() == FO_REGION_BODY) {
+            renderBodyRegion((BodyRegion) regionReference);
+        } else {
+            renderRegion(regionReference);
         }
+        endVParea();
     }
 
     /**
@@ -320,8 +327,7 @@
      * @param region  The region reference area
      */
     protected void renderRegion(RegionReference region) {
-        List blocks = region.getBlocks();
-        renderBlocks(null, blocks);
+        renderBlocks(null, region.getBlocks());
     }
 
     /**
@@ -398,7 +404,7 @@
         for (int count = 0; count < spans.size(); count++) {
             span = (Span) spans.get(count);
             for (int c = 0; c < span.getColumnCount(); c++) {
-                NormalFlow flow = (NormalFlow) span.getNormalFlow(c);
+                NormalFlow flow = span.getNormalFlow(c);
 
                 if (flow != null) {
                     currentBPPosition = saveSpanBPPos;
@@ -484,6 +490,13 @@
     }
 
     /**
+     * Renders a block area that represents a reference area. The reference area establishes
+     * a new coordinate system.
+     * @param block the block area
+     */
+    protected abstract void renderReferenceArea(Block block);
+    
+    /**
      * Renders a list of block areas.
      *
      * @param parent  the parent block if the parent is a block, otherwise
@@ -495,7 +508,7 @@
         int saveBP = currentBPPosition;
 
         // Calculate the position of the content rectangle.
-        if (parent != null && !Boolean.TRUE.equals(parent.getTrait(Trait.IS_VIEWPORT_AREA))) {
+        if (parent != null && !parent.getTraitAsBoolean(Trait.IS_VIEWPORT_AREA)) {
             currentBPPosition += parent.getBorderAndPaddingWidthBefore();
             /* This is unnecessary now as we're going to use the *-indent traits
             currentIPPosition += parent.getBorderAndPaddingWidthStart();
@@ -551,6 +564,8 @@
                 // simply move position
                 currentBPPosition += block.getAllocBPD();
             }
+        } else if (block.getTraitAsBoolean(Trait.IS_REFERENCE_AREA)) {
+            renderReferenceArea(block);
         } else {
             // save position and offset
             int saveIP = currentIPPosition;
@@ -622,15 +637,6 @@
         }
     }
 
-    /**
-     * Render the given Character.
-     * @param ch the character to render
-     * @deprecated Only TextArea should be used. This method will be removed eventually.
-     */
-    protected void renderCharacter(Character ch) {
-        currentIPPosition += ch.getAllocIPD();
-    }
-
     /** 
      * Common method to render the background and borders for any inline area.
      * The all borders and padding are drawn outside the specified area.
@@ -738,6 +744,8 @@
             renderContainer((Container) content);
         } else if (content instanceof ForeignObject) {
             renderForeignObject((ForeignObject) content, contpos);
+        } else if (content instanceof InlineBlockParent) {
+            renderInlineBlockParent((InlineBlockParent) content);
         }
         currentIPPosition += viewport.getAllocIPD();
         currentBPPosition = saveBP;
@@ -776,7 +784,7 @@
      * @param pos  The target position of the foreign object
      * (todo) Make renderForeignObject() protected
      */
-    public void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
+    protected void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
         // Default: do nothing.
         // Some renderers (ex. Text) don't support foreign objects.
     }
@@ -801,8 +809,9 @@
                 handler.handleXML(ctx, doc, namespace);
             } catch (Exception e) {
                 // could not handle document
-                ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
-                        ctx.getUserAgent().getEventBroadcaster());
+                ResourceEventProducer eventProducer 
+                        = ResourceEventProducer.Provider.get(
+                            ctx.getUserAgent().getEventBroadcaster());
                 eventProducer.foreignXMLProcessingError(this, doc, namespace, e);
             }
         } else {

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/Graphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/Graphics2DAdapter.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/Graphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/Graphics2DAdapter.java Mon Jul  7 07:09:01 2008
@@ -47,4 +47,23 @@
             RendererContext context,
             int x, int y, int width, int height) throws IOException;
     
+    /**
+     * Paints an arbitrary images on a given Graphics2D instance. The renderer
+     * providing this functionality must set up a Graphics2D instance so that
+     * the image with the given extents (in mpt) can be painted by the painter
+     * passed to this method. The Graphics2DImagePainter is then passed this
+     * Graphics2D instance so the image can be painted.
+     * @param painter the painter which will paint the actual image
+     * @param context the renderer context for the current renderer
+     * @param x X position of the image
+     * @param y Y position of the image
+     * @param width width of the image
+     * @param height height of the image
+     * @throws IOException In case of an I/O error while writing the output format
+     * @deprecated Use the variant with the Graphics2DImagePainter from XML Graphics Commons instead
+     */
+    void paintImage(Graphics2DImagePainter painter, 
+            RendererContext context,
+            int x, int y, int width, int height) throws IOException;
+    
 }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/afp/AFPRenderer.java Mon Jul  7 07:09:01 2008
@@ -59,6 +59,7 @@
 import org.apache.fop.area.BlockViewport;
 import org.apache.fop.area.BodyRegion;
 import org.apache.fop.area.CTM;
+import org.apache.fop.area.NormalFlow;
 import org.apache.fop.area.OffDocumentItem;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.area.RegionReference;
@@ -467,9 +468,7 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void renderBlockViewport(BlockViewport bv, List children) {
         // clip and position viewport if necessary
 
@@ -591,6 +590,76 @@
     }
 
     /** {@inheritDoc} */
+    protected void renderReferenceArea(Block block) {
+        //TODO Remove this method once concatenateTransformationMatrix() is implemented 
+        
+        // save position and offset
+        int saveIP = currentIPPosition;
+        int saveBP = currentBPPosition;
+
+        //Establish a new coordinate system
+        AffineTransform at = new AffineTransform();
+        at.translate(currentIPPosition, currentBPPosition);
+        at.translate(block.getXOffset(), block.getYOffset());
+        at.translate(0, block.getSpaceBefore());
+        
+        if (!at.isIdentity()) {
+            Rectangle2D contentRect
+                = new Rectangle2D.Double(at.getTranslateX(), at.getTranslateY(),
+                        block.getAllocIPD(), block.getAllocBPD());
+            pushViewPortPos(new ViewPortPos(contentRect, new CTM(at)));
+        }
+
+        currentIPPosition = 0;
+        currentBPPosition = 0;
+        handleBlockTraits(block);
+
+        List children = block.getChildAreas();
+        if (children != null) {
+            renderBlocks(block, children);
+        }
+
+        if (!at.isIdentity()) {
+            popViewPortPos();
+        }
+        
+        // stacked and relative blocks effect stacking
+        currentIPPosition = saveIP;
+        currentBPPosition = saveBP;
+    }
+    
+    /** {@inheritDoc} */
+    protected void renderFlow(NormalFlow flow) {
+        // save position and offset
+        int saveIP = currentIPPosition;
+        int saveBP = currentBPPosition;
+
+        //Establish a new coordinate system
+        AffineTransform at = new AffineTransform();
+        at.translate(currentIPPosition, currentBPPosition);
+        
+        if (!at.isIdentity()) {
+            Rectangle2D contentRect
+                = new Rectangle2D.Double(at.getTranslateX(), at.getTranslateY(),
+                        flow.getAllocIPD(), flow.getAllocBPD());
+            pushViewPortPos(new ViewPortPos(contentRect, new CTM(at)));
+        }
+
+        currentIPPosition = 0;
+        currentBPPosition = 0;
+        super.renderFlow(flow);
+        
+        if (!at.isIdentity()) {
+            popViewPortPos();
+        }
+        
+        // stacked and relative blocks effect stacking
+        currentIPPosition = saveIP;
+        currentBPPosition = saveBP;
+    }
+    
+    
+    /** {@inheritDoc} */
     protected void concatenateTransformationMatrix(AffineTransform at) {
         //Not used here since AFPRenderer defines its own renderBlockViewport() method.
         throw new UnsupportedOperationException("NYI");
@@ -1218,20 +1287,24 @@
         }
     }
 
-    /**
-     * Restores the state stack after a break out.
-     * @param breakOutList the state stack to restore.
-     */
-    public void restoreStateStackAfterBreakOut(List breakOutList) {
-
+    /** {@inheritDoc} */
+    public List breakOutOfStateStack() {
+        log.debug("Block.FIXED --> break out");
+        List breakOutList = new java.util.ArrayList();
+        //Don't pop the last ViewPortPos (created by renderPage())
+        while (this.viewPortPositions.size() > 1) {
+            breakOutList.add(0, popViewPortPos());
+        }
+        return breakOutList;
     }
 
-    /**
-     * Breaks out of the state stack to handle fixed block-containers.
-     * @return the saved state stack to recreate later
-     */
-    public List breakOutOfStateStack() {
-        return null;
+    /** {@inheritDoc} */
+    public void restoreStateStackAfterBreakOut(List breakOutList) {
+        log.debug("Block.FIXED --> restoring context after break-out");
+        for (int i = 0, c = breakOutList.size(); i < c; i++) {
+            ViewPortPos vps = (ViewPortPos)breakOutList.get(i);
+            pushViewPortPos(vps);
+        }
     }
 
     /** Saves the graphics state of the rendering engine. */
@@ -1755,12 +1828,13 @@
         afpDataStream.setOffsets(vpp.x, vpp.y, vpp.rot);
     }
 
-    private void popViewPortPos() {
-        viewPortPositions.remove(viewPortPositions.size() - 1);
+    private ViewPortPos popViewPortPos() {
+        ViewPortPos current = (ViewPortPos)viewPortPositions.remove(viewPortPositions.size() - 1);
         if (viewPortPositions.size() > 0) {
             ViewPortPos vpp = (ViewPortPos)viewPortPositions.get(viewPortPositions.size() - 1);
             afpDataStream.setOffsets(vpp.x, vpp.y, vpp.rot);
         }
+        return current;
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java Mon Jul  7 07:09:01 2008
@@ -28,13 +28,13 @@
 
 import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
 
-import org.apache.fop.render.Graphics2DAdapter;
+import org.apache.fop.render.AbstractGraphics2DAdapter;
 import org.apache.fop.render.RendererContext;
 
 /**
  * Graphics2DAdapter implementation for Java2D.
  */
-public class Java2DGraphics2DAdapter implements Graphics2DAdapter {
+public class Java2DGraphics2DAdapter extends AbstractGraphics2DAdapter {
 
     /** {@inheritDoc} */
     public void paintImage(Graphics2DImagePainter painter,

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/java2d/Java2DRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/java2d/Java2DRenderer.java Mon Jul  7 07:09:01 2008
@@ -539,7 +539,9 @@
     protected void drawBorderLine(float x1, float y1, float x2, float y2,
             boolean horz, boolean startOrBefore, int style, Color col) {
         Graphics2D g2d = state.getGraph();
-        drawBorderLine(new Rectangle2D.Float(x1, y1, x2 - x1, y2 - y1),
+        float width = x2 - x1;
+        float height = y2 - y1;
+        drawBorderLine(new Rectangle2D.Float(x1, y1, width, height),
                 horz, startOrBefore, style, col, g2d);
     }
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl/PCLGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl/PCLGenerator.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl/PCLGenerator.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl/PCLGenerator.java Mon Jul  7 07:09:01 2008
@@ -230,6 +230,19 @@
     }
 
     /**
+     * Selects the duplexing mode for the page. 
+     * The parameter is usually printer-specific. 
+     * "0" means Simplex,
+     * "1" means Duplex, Long-Edge Binding,
+     * "2" means Duplex, Short-Edge Binding.
+     * @param selector the integer representing the duplexing mode of the page
+     * @throws IOException In case of an I/O error
+     */
+    public void selectDuplexMode(int selector) throws IOException {
+        writeCommand("&l" + selector + "S");
+    }
+
+    /**
      * Clears the horizontal margins.
      * @throws IOException In case of an I/O error
      */

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl/PCLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl/PCLRenderer.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl/PCLRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl/PCLRenderer.java Mon Jul  7 07:09:01 2008
@@ -66,6 +66,7 @@
 import org.apache.fop.area.Block;
 import org.apache.fop.area.BlockViewport;
 import org.apache.fop.area.CTM;
+import org.apache.fop.area.NormalFlow;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.area.RegionViewport;
 import org.apache.fop.area.Trait;
@@ -395,9 +396,7 @@
         return MIME_TYPE;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void renderPage(PageViewport page) throws IOException, FOPException {
         saveGraphicsState();
 
@@ -408,6 +407,13 @@
             gen.selectPaperSource(Integer.parseInt(paperSource));
         }
 
+        // Is Page duplex?
+        String pageDuplex = page.getForeignAttributeValue(
+                new QName(PCLElementMapping.NAMESPACE, null, "duplex-mode"));
+        if (pageDuplex != null) {
+            gen.selectDuplexMode(Integer.parseInt(pageDuplex));
+        }
+
         //Page size
         final long pagewidth = Math.round(page.getViewArea().getWidth());
         final long pageheight = Math.round(page.getViewArea().getHeight());
@@ -1023,6 +1029,79 @@
         //currentFontName = saveFontName;
     }
 
+    /** {@inheritDoc} */
+    protected void renderReferenceArea(Block block) {
+        //TODO This is the same code as in AbstractPathOrientedRenderer
+        //So there's some optimization potential but not otherwise PCLRenderer is a little
+        //difficult to derive from AbstractPathOrientedRenderer. Maybe an additional layer
+        //between PrintRenderer and AbstractPathOrientedRenderer is necessary.
+        
+        // save position and offset
+        int saveIP = currentIPPosition;
+        int saveBP = currentBPPosition;
+
+        //Establish a new coordinate system
+        AffineTransform at = new AffineTransform();
+        at.translate(currentIPPosition, currentBPPosition);
+        at.translate(block.getXOffset(), block.getYOffset());
+        at.translate(0, block.getSpaceBefore());
+        
+        if (!at.isIdentity()) {
+            saveGraphicsState();
+            concatenateTransformationMatrix(mptToPt(at));
+        }
+
+        currentIPPosition = 0;
+        currentBPPosition = 0;
+        handleBlockTraits(block);
+
+        List children = block.getChildAreas();
+        if (children != null) {
+            renderBlocks(block, children);
+        }
+
+        if (!at.isIdentity()) {
+            restoreGraphicsState();
+        }
+        
+        // stacked and relative blocks effect stacking
+        currentIPPosition = saveIP;
+        currentBPPosition = saveBP;
+    }
+    
+    /** {@inheritDoc} */
+    protected void renderFlow(NormalFlow flow) {
+        //TODO This is the same code as in AbstractPathOrientedRenderer
+        //So there's some optimization potential but not otherwise PCLRenderer is a little
+        //difficult to derive from AbstractPathOrientedRenderer. Maybe an additional layer
+        //between PrintRenderer and AbstractPathOrientedRenderer is necessary.
+
+        // save position and offset
+        int saveIP = currentIPPosition;
+        int saveBP = currentBPPosition;
+
+        //Establish a new coordinate system
+        AffineTransform at = new AffineTransform();
+        at.translate(currentIPPosition, currentBPPosition);
+        
+        if (!at.isIdentity()) {
+            saveGraphicsState();
+            concatenateTransformationMatrix(mptToPt(at));
+        }
+
+        currentIPPosition = 0;
+        currentBPPosition = 0;
+        super.renderFlow(flow);
+        
+        if (!at.isIdentity()) {
+            restoreGraphicsState();
+        }
+        
+        // stacked and relative blocks effect stacking
+        currentIPPosition = saveIP;
+        currentBPPosition = saveBP;
+    }
+    
     /**
      * Concatenates the current transformation matrix with the given one, therefore establishing
      * a new coordinate system.

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRenderer.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRenderer.java Mon Jul  7 07:09:01 2008
@@ -1415,7 +1415,6 @@
         updateColor(ct, true);
         
         beginTextObject();
-        StringBuffer pdf = new StringBuffer();
 
         String fontName = getInternalFontNameForArea(text);
         int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue();
@@ -1434,8 +1433,6 @@
 
         textutil.writeTextMatrix(new AffineTransform(1, 0, 0, -1, rx / 1000f, bl / 1000f));
 
-        currentStream.add(pdf.toString());
-
         super.renderText(text);
 
         textutil.writeTJ();
@@ -1844,5 +1841,13 @@
     public void setFilterMap(Map filterMap) {
         this.filterMap = filterMap;
     }
+
+    /**
+     * Sets the encryption parameters used by the PDF renderer.
+     * @param encryptionParams the encryption parameters 
+     */
+    public void setEncryptionParams(PDFEncryptionParams encryptionParams) {
+        this.encryptionParams = encryptionParams;
+    }
 }
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java Mon Jul  7 07:09:01 2008
@@ -28,6 +28,7 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.pdf.PDFAMode;
+import org.apache.fop.pdf.PDFEncryptionParams;
 import org.apache.fop.pdf.PDFFilterList;
 import org.apache.fop.pdf.PDFXMode;
 import org.apache.fop.render.PrintRendererConfigurator;
@@ -78,13 +79,54 @@
             if (s != null) {
                 pdfRenderer.setXMode(PDFXMode.valueOf(s));
             }
+            Configuration encryptionParamsConfig = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false);
+            if (encryptionParamsConfig != null) {
+                PDFEncryptionParams encryptionParams = new PDFEncryptionParams();
+                Configuration ownerPasswordConfig = encryptionParamsConfig.getChild(
+                        PDFRenderer.OWNER_PASSWORD, false);
+                if (ownerPasswordConfig != null) {
+                    String ownerPassword = ownerPasswordConfig.getValue(null);
+                    if (ownerPassword != null) {
+                        encryptionParams.setOwnerPassword(ownerPassword);
+                    }
+                }
+                Configuration userPasswordConfig = encryptionParamsConfig.getChild(
+                        PDFRenderer.USER_PASSWORD, false);
+                if (userPasswordConfig != null) {
+                    String userPassword = userPasswordConfig.getValue(null);
+                    if (userPassword != null) {
+                        encryptionParams.setUserPassword(userPassword);
+                    }
+                }
+                Configuration noPrintConfig = encryptionParamsConfig.getChild(
+                        PDFRenderer.NO_PRINT, false);
+                if (noPrintConfig != null) {
+                    encryptionParams.setAllowPrint(false);
+                }
+                Configuration noCopyContentConfig = encryptionParamsConfig.getChild(
+                        PDFRenderer.NO_COPY_CONTENT, false);
+                if (noCopyContentConfig != null) {
+                    encryptionParams.setAllowCopyContent(false);
+                }
+                Configuration noEditContentConfig = encryptionParamsConfig.getChild(
+                        PDFRenderer.NO_EDIT_CONTENT, false);
+                if (noEditContentConfig != null) {
+                    encryptionParams.setAllowEditContent(false);
+                }
+                Configuration noAnnotationsConfig = encryptionParamsConfig.getChild(
+                        PDFRenderer.NO_ANNOTATIONS, false);
+                if (noAnnotationsConfig != null) {
+                    encryptionParams.setAllowEditAnnotations(false);
+                }
+                pdfRenderer.setEncryptionParams(encryptionParams);
+            }
             s = cfg.getChild(PDFRenderer.KEY_OUTPUT_PROFILE, true).getValue(null);
             if (s != null) {
                 pdfRenderer.setOutputProfileURI(s);
             }
-            Configuration child = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false);
-            if (child != null) {
-                pdfRenderer.disableSRGBColorSpace = child.getValueAsBoolean(false);
+            Configuration disableColorSpaceConfig = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false);
+            if (disableColorSpaceConfig != null) {
+                pdfRenderer.disableSRGBColorSpace = disableColorSpaceConfig.getValueAsBoolean(false);
             }
         }
     }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/ImageEncoderCCITTFax.java Mon Jul  7 07:09:01 2008
@@ -25,6 +25,7 @@
 import org.apache.xmlgraphics.image.codec.tiff.TIFFImage;
 import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
 import org.apache.xmlgraphics.ps.ImageEncoder;
+import org.apache.xmlgraphics.ps.PSDictionary;
 
 /**
  * ImageEncoder implementation for CCITT encoded images.

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java Mon Jul  7 07:09:01 2008
@@ -28,13 +28,13 @@
 import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
 import org.apache.xmlgraphics.ps.PSGenerator;
 
-import org.apache.fop.render.Graphics2DAdapter;
+import org.apache.fop.render.AbstractGraphics2DAdapter;
 import org.apache.fop.render.RendererContext;
 
 /**
  * Graphics2DAdapter implementation for PostScript.
  */
-public class PSGraphics2DAdapter implements Graphics2DAdapter {
+public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter {
 
     private PSGenerator gen;
     private boolean clip = true;

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/PSRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/PSRenderer.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/PSRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/PSRenderer.java Mon Jul  7 07:09:01 2008
@@ -57,6 +57,9 @@
 import org.apache.xmlgraphics.image.loader.util.ImageUtil;
 import org.apache.xmlgraphics.ps.DSCConstants;
 import org.apache.xmlgraphics.ps.ImageEncoder;
+import org.apache.xmlgraphics.ps.PSDictionary;
+import org.apache.xmlgraphics.ps.PSPageDeviceDictionary;
+import org.apache.xmlgraphics.ps.PSDictionaryFormatException;
 import org.apache.xmlgraphics.ps.PSGenerator;
 import org.apache.xmlgraphics.ps.PSImageUtils;
 import org.apache.xmlgraphics.ps.PSProcSets;

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java?rev=674497&r1=674496&r2=674497&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java Mon Jul  7 07:09:01 2008
@@ -78,7 +78,7 @@
      * 
      * @param handler ContentHandler instance to send the SAX events to
      * @throws SAXException if there's a problem generating the SAX events
-     * @see org.apache.fop.util.XMLizable#toSAX(org.xml.sax.ContentHandler)
+     * @see org.apache.xmlgraphics.util.XMLizable#toSAX(org.xml.sax.ContentHandler)
      */
     public void toSAX(ContentHandler handler) throws SAXException {
         AttributesImpl atts = new AttributesImpl();



---------------------------------------------------------------------
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