You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2012/04/05 18:20:17 UTC

svn commit: r1309921 [26/42] - in /xmlgraphics/fop/branches/Temp_TrueTypeInPostScript: ./ examples/embedding/ examples/embedding/java/embedding/ examples/embedding/java/embedding/atxml/ examples/embedding/java/embedding/tools/ examples/plan/src/org/apa...

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -19,9 +19,7 @@
 
 package org.apache.fop.layoutmgr.list;
 
-import java.util.Iterator;
 import java.util.LinkedList;
-import java.util.List;
 
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
@@ -36,8 +34,8 @@ import org.apache.fop.layoutmgr.LayoutMa
 import org.apache.fop.layoutmgr.NonLeafPosition;
 import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition;
+import org.apache.fop.layoutmgr.TraitSetter;
 
 /**
  * LayoutManager for a list-item-label or list-item-body FO.
@@ -46,23 +44,9 @@ public class ListItemContentLayoutManage
 
     private Block curBlockArea;
 
-    private int xoffset;
+    private int xOffset;
     private int itemIPD;
 
-    private static class StackingIter extends PositionIterator {
-        StackingIter(Iterator parentIter) {
-            super(parentIter);
-        }
-
-        protected LayoutManager getLM(Object nextObj) {
-            return ((Position) nextObj).getLM();
-        }
-
-        protected Position getPos(Object nextObj) {
-            return ((Position) nextObj);
-        }
-    }
-
     /**
      * Create a new Cell layout manager.
      * @param node list-item-label node
@@ -95,13 +79,7 @@ public class ListItemContentLayoutManage
      * @param off the x offset
      */
     public void setXOffset(int off) {
-        xoffset = off;
-    }
-
-    /** {@inheritDoc} */
-    public List getChangedKnuthElements(List oldList, int alignment) {
-        //log.debug("  ListItemContentLayoutManager.getChanged>");
-        return super.getChangedKnuthElements(oldList, alignment);
+        xOffset = off;
     }
 
     /**
@@ -112,6 +90,7 @@ public class ListItemContentLayoutManage
      * @param parentIter the iterator of the break positions
      * @param layoutContext the layout context for adding the areas
      */
+    @Override
     public void addAreas(PositionIterator parentIter,
                          LayoutContext layoutContext) {
         getParentArea(null);
@@ -127,10 +106,10 @@ public class ListItemContentLayoutManage
 
         // "unwrap" the NonLeafPositions stored in parentIter
         // and put them in a new list;
-        LinkedList positionList = new LinkedList();
+        LinkedList<Position> positionList = new LinkedList<Position>();
         Position pos;
         while (parentIter.hasNext()) {
-            pos = (Position)parentIter.next();
+            pos = parentIter.next();
             if (pos == null) {
                 continue;
             }
@@ -156,7 +135,7 @@ public class ListItemContentLayoutManage
 
         addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
 
-        StackingIter childPosIter = new StackingIter(positionList.listIterator());
+        PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
         while ((childLM = childPosIter.getNextChildLM()) != null) {
             // Add the block areas to Area
             lc.setFlags(LayoutContext.FIRST_AREA, childLM == firstLM);
@@ -189,12 +168,14 @@ public class ListItemContentLayoutManage
      * @param childArea the child area to get the parent for
      * @return the parent area
      */
+    @Override
     public Area getParentArea(Area childArea) {
         if (curBlockArea == null) {
             curBlockArea = new Block();
             curBlockArea.setPositioning(Block.ABSOLUTE);
             // set position
-            curBlockArea.setXOffset(xoffset);
+            curBlockArea.setXOffset(xOffset);
+            //TODO: Check - itemIPD never set?
             curBlockArea.setIPD(itemIPD);
             //curBlockArea.setHeight();
 
@@ -215,6 +196,7 @@ public class ListItemContentLayoutManage
      *
      * @param childArea the child to add to the cell
      */
+    @Override
     public void addChildArea(Area childArea) {
         if (curBlockArea != null) {
             curBlockArea.addBlock((Block) childArea);
@@ -222,19 +204,21 @@ public class ListItemContentLayoutManage
     }
 
     /** {@inheritDoc} */
+    @Override
     public KeepProperty getKeepTogetherProperty() {
         return getPartFO().getKeepTogether();
     }
 
     /** {@inheritDoc} */
+    @Override
     public Keep getKeepWithNext() {
         return Keep.KEEP_AUTO;
     }
 
     /** {@inheritDoc} */
+    @Override
     public Keep getKeepWithPrevious() {
         return Keep.KEEP_AUTO;
     }
-
 }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -38,6 +38,7 @@ import org.apache.fop.layoutmgr.BreakEle
 import org.apache.fop.layoutmgr.ConditionalElementListener;
 import org.apache.fop.layoutmgr.ElementListObserver;
 import org.apache.fop.layoutmgr.ElementListUtils;
+import org.apache.fop.layoutmgr.FootnoteBodyLayoutManager;
 import org.apache.fop.layoutmgr.Keep;
 import org.apache.fop.layoutmgr.KnuthBlockBox;
 import org.apache.fop.layoutmgr.KnuthBox;
@@ -63,9 +64,7 @@ import org.apache.fop.traits.SpaceVal;
 public class ListItemLayoutManager extends BlockStackingLayoutManager
                     implements ConditionalElementListener {
 
-    /**
-     * logging instance
-     */
+    /** logging instance */
     private static Log log = LogFactory.getLog(ListItemLayoutManager.class);
 
     private ListItemContentLayoutManager label;
@@ -73,8 +72,8 @@ public class ListItemLayoutManager exten
 
     private Block curBlockArea = null;
 
-    private List labelList = null;
-    private List bodyList = null;
+    private List<ListElement> labelList = null;
+    private List<ListElement> bodyList = null;
 
     private boolean discardBorderBefore;
     private boolean discardBorderAfter;
@@ -86,37 +85,35 @@ public class ListItemLayoutManager exten
     private Keep keepWithNextPendingOnLabel;
     private Keep keepWithNextPendingOnBody;
 
-    private int listItemHeight;
-
     private class ListItemPosition extends Position {
-        private int iLabelFirstIndex;
-        private int iLabelLastIndex;
-        private int iBodyFirstIndex;
-        private int iBodyLastIndex;
+        private int labelFirstIndex;
+        private int labelLastIndex;
+        private int bodyFirstIndex;
+        private int bodyLastIndex;
 
         public ListItemPosition(LayoutManager lm, int labelFirst, int labelLast,
                 int bodyFirst, int bodyLast) {
             super(lm);
-            iLabelFirstIndex = labelFirst;
-            iLabelLastIndex = labelLast;
-            iBodyFirstIndex = bodyFirst;
-            iBodyLastIndex = bodyLast;
+            labelFirstIndex = labelFirst;
+            labelLastIndex = labelLast;
+            bodyFirstIndex = bodyFirst;
+            bodyLastIndex = bodyLast;
         }
 
         public int getLabelFirstIndex() {
-            return iLabelFirstIndex;
+            return labelFirstIndex;
         }
 
         public int getLabelLastIndex() {
-            return iLabelLastIndex;
+            return labelLastIndex;
         }
 
         public int getBodyFirstIndex() {
-            return iBodyFirstIndex;
+            return bodyFirstIndex;
         }
 
         public int getBodyLastIndex() {
-            return iBodyLastIndex;
+            return bodyLastIndex;
         }
 
         /** {@inheritDoc} */
@@ -128,8 +125,8 @@ public class ListItemLayoutManager exten
         public String toString() {
             StringBuffer sb = new StringBuffer("ListItemPosition:");
             sb.append(getIndex()).append("(");
-            sb.append("label:").append(iLabelFirstIndex).append("-").append(iLabelLastIndex);
-            sb.append(" body:").append(iBodyFirstIndex).append("-").append(iBodyLastIndex);
+            sb.append("label:").append(labelFirstIndex).append("-").append(labelLastIndex);
+            sb.append(" body:").append(bodyFirstIndex).append("-").append(bodyLastIndex);
             sb.append(")");
             return sb.toString();
         }
@@ -172,6 +169,7 @@ public class ListItemLayoutManager exten
     }
 
     /** {@inheritDoc} */
+    @Override
     public void initialize() {
         foSpaceBefore = new SpaceVal(
                 getListItemFO().getCommonMarginBlock().spaceBefore, this).getSpace();
@@ -191,32 +189,21 @@ public class ListItemLayoutManager exten
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getNextKnuthElements(LayoutContext context, int alignment) {
         referenceIPD = context.getRefIPD();
         LayoutContext childLC;
 
-        List returnList = new LinkedList();
+        List<ListElement> returnList = new LinkedList<ListElement>();
 
-        if (!breakBeforeServed) {
-            breakBeforeServed = true;
-            if (!context.suppressBreakBefore()) {
-                if (addKnuthElementsForBreakBefore(returnList, context)) {
-                    return returnList;
-                }
-            }
+        if (!breakBeforeServed(context, returnList)) {
+            return returnList;
         }
 
-        addKnuthElementsForSpaceBefore(returnList, alignment);
-
-        addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
-        firstVisibleMarkServed = true;
-
-        //Spaces, border and padding to be repeated at each break
-        addPendingMarks(context);
+        addFirstVisibleMarks(returnList, context, alignment);
 
         // label
-        childLC = new LayoutContext(0);
-        childLC.setRefIPD(context.getRefIPD());
+        childLC = makeChildLayoutContext(context);
         label.initialize();
         labelList = label.getNextKnuthElements(childLC, alignment);
 
@@ -229,8 +216,7 @@ public class ListItemLayoutManager exten
         this.keepWithNextPendingOnLabel = childLC.getKeepWithNextPending();
 
         // body
-        childLC = new LayoutContext(0);
-        childLC.setRefIPD(context.getRefIPD());
+        childLC = makeChildLayoutContext(context);
         body.initialize();
         bodyList = body.getNextKnuthElements(childLC, alignment);
 
@@ -248,8 +234,8 @@ public class ListItemLayoutManager exten
         // "wrap" the Position inside each element
         wrapPositionElements(returnedList, returnList, true);
 
-        addKnuthElementsForBorderPaddingAfter(returnList, true);
-        addKnuthElementsForSpaceAfter(returnList, alignment);
+        addLastVisibleMarks(returnList, context, alignment);
+
         addKnuthElementsForBreakAfter(returnList, context);
 
         context.updateKeepWithNextPending(this.keepWithNextPendingOnLabel);
@@ -262,11 +248,25 @@ public class ListItemLayoutManager exten
         return returnList;
     }
 
-    private List getCombinedKnuthElementsForListItem(List labelElements,
-            List bodyElements, LayoutContext context) {
+    /**
+     * Overridden to unconditionally add elements for space-before.
+     * {@inheritDoc}
+     */
+    @Override
+    protected void addFirstVisibleMarks(List<ListElement> elements,
+                                        LayoutContext context, int alignment) {
+        addKnuthElementsForSpaceBefore(elements, alignment);
+        addKnuthElementsForBorderPaddingBefore(elements, !firstVisibleMarkServed);
+        firstVisibleMarkServed = true;
+        //Spaces, border and padding to be repeated at each break
+        addPendingMarks(context);
+    }
+
+    private List getCombinedKnuthElementsForListItem(List<ListElement> labelElements,
+            List<ListElement> bodyElements, LayoutContext context) {
         // Copy elements to array lists to improve element access performance
-        List[] elementLists = {new ArrayList(labelElements),
-                               new ArrayList(bodyElements)};
+        List[] elementLists = {new ArrayList<ListElement>(labelElements),
+                               new ArrayList<ListElement>(bodyElements)};
         int[] fullHeights = {ElementListUtils.calcContentLength(elementLists[0]),
                 ElementListUtils.calcContentLength(elementLists[1])};
         int[] partialHeights = {0, 0};
@@ -278,7 +278,7 @@ public class ListItemLayoutManager exten
         int addedBoxHeight = 0;
         Keep keepWithNextActive = Keep.KEEP_AUTO;
 
-        LinkedList returnList = new LinkedList();
+        LinkedList<ListElement> returnList = new LinkedList<ListElement>();
         while ((step = getNextStep(elementLists, start, end, partialHeights)) > 0) {
 
             if (end[0] + 1 == elementLists[0].size()) {
@@ -314,14 +314,14 @@ public class ListItemLayoutManager exten
             // collect footnote information
             // TODO this should really not be done like this. ListItemLM should remain as
             // footnote-agnostic as possible
-            LinkedList footnoteList = null;
+            LinkedList<FootnoteBodyLayoutManager> 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 = new LinkedList<FootnoteBodyLayoutManager>();
                         }
                         footnoteList.addAll(((KnuthBlockBox) el).getFootnoteBodyLMs());
                     }
@@ -424,15 +424,12 @@ public class ListItemLayoutManager exten
                         fullHeights[1] - partialHeights[1]);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
+    @Override
     public List getChangedKnuthElements(List oldList, int alignment) {
-        //log.debug(" LILM.getChanged> label");
         // label
         labelList = label.getChangedKnuthElements(labelList, alignment);
 
-        //log.debug(" LILM.getChanged> body");
         // body
         // "unwrap" the Positions stored in the elements
         ListIterator oldListIterator = oldList.listIterator();
@@ -440,11 +437,6 @@ public class ListItemLayoutManager exten
         while (oldListIterator.hasNext()) {
             oldElement = (KnuthElement)oldListIterator.next();
             Position innerPosition = oldElement.getPosition().getPosition();
-            //log.debug(" BLM> unwrapping: " + (oldElement.isBox()
-            //  ? "box    " : (oldElement.isGlue() ? "glue   " : "penalty"))
-            //  + " creato da " + oldElement.getLayoutManager().getClass().getName());
-            //log.debug(" BLM> unwrapping:         "
-            //  + oldElement.getPosition().getClass().getName());
             if (innerPosition != null) {
                 // oldElement was created by a descendant of this BlockLM
                 oldElement.setPosition(innerPosition);
@@ -473,11 +465,11 @@ public class ListItemLayoutManager exten
 
     /**
      * Add the areas for the break points.
-     * This sets the offset of each cell as it is added.
      *
      * @param parentIter the position iterator
      * @param layoutContext the layout context for adding areas
      */
+    @Override
     public void addAreas(PositionIterator parentIter,
                          LayoutContext layoutContext) {
         getParentArea(null);
@@ -489,10 +481,10 @@ public class ListItemLayoutManager exten
         Position lastPos = null;
 
         // "unwrap" the NonLeafPositions stored in parentIter
-        LinkedList positionList = new LinkedList();
+        LinkedList<Position> positionList = new LinkedList<Position>();
         Position pos;
         while (parentIter.hasNext()) {
-            pos = (Position) parentIter.next();
+            pos = parentIter.next();
             if (pos.getIndex() >= 0) {
                 if (firstPos == null) {
                     firstPos = pos;
@@ -514,12 +506,12 @@ public class ListItemLayoutManager exten
         int bodyFirstIndex = ((ListItemPosition) positionList.getFirst()).getBodyFirstIndex();
         int bodyLastIndex = ((ListItemPosition) positionList.getLast()).getBodyLastIndex();
 
-        //Determine previous break if any
+        //Determine previous break if any (in item label list)
         int previousBreak = ElementListUtils.determinePreviousBreak(labelList, labelFirstIndex);
         SpaceResolver.performConditionalsNotification(labelList,
                 labelFirstIndex, labelLastIndex, previousBreak);
 
-        //Determine previous break if any
+        //Determine previous break if any (in item body list)
         previousBreak = ElementListUtils.determinePreviousBreak(bodyList, bodyFirstIndex);
         SpaceResolver.performConditionalsNotification(bodyList,
                 bodyFirstIndex, bodyLastIndex, previousBreak);
@@ -577,16 +569,6 @@ public class ListItemLayoutManager exten
     }
 
     /**
-     * Get the height of the list item after adjusting.
-     * Should only be called after adding the list item areas.
-     *
-     * @return the height of this list item after adjustment
-     */
-    public int getListItemHeight() {
-        return listItemHeight;
-    }
-
-    /**
      * Return an Area which can contain the passed childArea. The childArea
      * may not yet have any content, but it has essential traits set.
      * In general, if the LayoutManager already has an Area it simply returns
@@ -599,6 +581,7 @@ public class ListItemLayoutManager exten
      * @param childArea the child area
      * @return the parent are for the child
      */
+    @Override
     public Area getParentArea(Area childArea) {
         if (curBlockArea == null) {
             curBlockArea = new Block();
@@ -607,19 +590,15 @@ public class ListItemLayoutManager exten
             /*Area parentArea =*/ parentLayoutManager.getParentArea(curBlockArea);
 
             // set traits
-            TraitSetter.setProducerID(curBlockArea, getListItemFO().getId());
-            TraitSetter.addBorders(curBlockArea,
-                    getListItemFO().getCommonBorderPaddingBackground(),
+            ListItem fo = getListItemFO();
+            TraitSetter.setProducerID(curBlockArea, fo.getId());
+            TraitSetter.addBorders(curBlockArea, fo.getCommonBorderPaddingBackground(),
                     discardBorderBefore, discardBorderAfter, false, false, this);
-            TraitSetter.addPadding(curBlockArea,
-                    getListItemFO().getCommonBorderPaddingBackground(),
+            TraitSetter.addPadding(curBlockArea, fo.getCommonBorderPaddingBackground(),
                     discardPaddingBefore, discardPaddingAfter, false, false, this);
-            TraitSetter.addMargins(curBlockArea,
-                    getListItemFO().getCommonBorderPaddingBackground(),
-                    getListItemFO().getCommonMarginBlock(), this);
-            TraitSetter.addBreaks(curBlockArea,
-                    getListItemFO().getBreakBefore(),
-                    getListItemFO().getBreakAfter());
+            TraitSetter.addMargins(curBlockArea, fo.getCommonBorderPaddingBackground(),
+                    fo.getCommonMarginBlock(), this);
+            TraitSetter.addBreaks(curBlockArea, fo.getBreakBefore(), fo.getBreakAfter());
 
             int contentIPD = referenceIPD - getIPIndents();
             curBlockArea.setIPD(contentIPD);
@@ -636,6 +615,7 @@ public class ListItemLayoutManager exten
      *
      * @param childArea the child area
      */
+    @Override
     public void addChildArea(Area childArea) {
         if (curBlockArea != null) {
             curBlockArea.addBlock((Block) childArea);
@@ -643,16 +623,19 @@ public class ListItemLayoutManager exten
     }
 
     /** {@inheritDoc} */
+    @Override
     public KeepProperty getKeepTogetherProperty() {
         return getListItemFO().getKeepTogether();
     }
 
     /** {@inheritDoc} */
+    @Override
     public KeepProperty getKeepWithPreviousProperty() {
         return getListItemFO().getKeepWithPrevious();
     }
 
     /** {@inheritDoc} */
+    @Override
     public KeepProperty getKeepWithNextProperty() {
         return getListItemFO().getKeepWithNext();
     }
@@ -703,6 +686,7 @@ public class ListItemLayoutManager exten
     }
 
     /** {@inheritDoc} */
+    @Override
     public void reset() {
         super.reset();
         label.reset();

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java Thu Apr  5 16:19:19 2012
@@ -33,6 +33,9 @@ import org.apache.fop.fo.expr.RelativeNu
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableColumn;
 import org.apache.fop.fo.properties.TableColLength;
+import org.apache.fop.traits.Direction;
+import org.apache.fop.traits.WritingModeTraits;
+import org.apache.fop.traits.WritingModeTraitsGetter;
 
 /**
  * Class holding a number of columns making up the column setup of a row.
@@ -43,6 +46,7 @@ public class ColumnSetup {
     private static Log log = LogFactory.getLog(ColumnSetup.class);
 
     private Table table;
+    private WritingModeTraitsGetter wmTraits;
     private List columns = new java.util.ArrayList();
     private List colWidths = new java.util.ArrayList();
 
@@ -53,7 +57,9 @@ public class ColumnSetup {
      * @param table the table to construct this column setup for
      */
     public ColumnSetup(Table table) {
+        assert table != null;
         this.table = table;
+        this.wmTraits = WritingModeTraits.getWritingModeTraitsGetter ( table );
         prepareColumns();
         initializeColumnWidths();
     }
@@ -232,11 +238,47 @@ public class ColumnSetup {
     }
 
     /**
+     * Determine the X offset of the indicated column, where this
+     * offset denotes the left edge of the column irrespective of writing
+     * mode. If writing mode's column progression direction is right-to-left,
+     * then the first column is the right-most column and the last column is
+     * the left-most column; otherwise, the first column is the left-most
+     * column.
      * @param col column index (1 is first column)
      * @param context the context for percentage based calculations
      * @return the X offset of the requested column
      */
     public int getXOffset(int col, PercentBaseContext context) {
+        // TODO handle vertical WMs [GA]
+        if ( (wmTraits != null) && (wmTraits.getColumnProgressionDirection() == Direction.RL) ) {
+            return getXOffsetRTL(col, context);
+        } else {
+            return getXOffsetLTR(col, context);
+        }
+    }
+
+    /*
+     * Determine x offset by summing widths of columns to left of specified
+     * column; i.e., those columns whose column numbers are greater than the
+     * specified column number.
+     */
+    private int getXOffsetRTL(int col, PercentBaseContext context) {
+        int xoffset = 0;
+        for (int i = col, nc = colWidths.size(); ++i < nc;) {
+            int effCol = i;
+            if (colWidths.get(effCol) != null) {
+                xoffset += ((Length) colWidths.get(effCol)).getValue(context);
+            }
+        }
+        return xoffset;
+    }
+
+    /*
+     * Determine x offset by summing widths of columns to left of specified
+     * column; i.e., those columns whose column numbers are less than the
+     * specified column number.
+     */
+    private int getXOffsetLTR(int col, PercentBaseContext context) {
         int xoffset = 0;
         for (int i = col; --i >= 0;) {
             int effCol;

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -25,6 +25,7 @@ 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;

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/RowPainter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/RowPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/RowPainter.java Thu Apr  5 16:19:19 2012
@@ -46,7 +46,6 @@ import org.apache.fop.layoutmgr.KnuthPos
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.SpaceResolver;
 import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.traits.BorderProps;
 
 class RowPainter {
     private static Log log = LogFactory.getLog(RowPainter.class);

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -553,12 +553,8 @@ public class TableCellLayoutManager exte
 
     /** {@inheritDoc} */
     public Keep getKeepTogether() {
-        Keep keep = Keep.KEEP_AUTO;
-        if (primaryGridUnit.getRow() != null) {
-            keep = Keep.getKeep(primaryGridUnit.getRow().getKeepTogether());
-        }
-        keep = keep.compare(getParentKeepTogether());
-        return keep;
+        // keep-together does not apply to fo:table-cell
+        return Keep.KEEP_AUTO;
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableStepper.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableStepper.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/table/TableStepper.java Thu Apr  5 16:19:19 2012
@@ -239,7 +239,7 @@ public class TableStepper {
                 }
             }
 
-            Keep keep = Keep.KEEP_AUTO;
+            Keep keep = getTableLM().getKeepTogether();
             int stepPenalty = 0;
             for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
                 ActiveCell activeCell = (ActiveCell) iter.next();
@@ -248,8 +248,6 @@ public class TableStepper {
             }
             if (!rowFinished) {
                 keep = keep.compare(rowGroup[activeRowIndex].getKeepTogether());
-                //The above call doesn't take the penalty from the table into account, so...
-                keep = keep.compare(getTableLM().getKeepTogether());
             } else if (activeRowIndex < rowGroup.length - 1) {
                 keep = keep.compare(rowGroup[activeRowIndex].getKeepWithNext());
                 keep = keep.compare(rowGroup[activeRowIndex + 1].getKeepWithPrevious());

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/ASCII85Filter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/ASCII85Filter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/ASCII85Filter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/ASCII85Filter.java Thu Apr  5 16:19:19 2012
@@ -19,8 +19,8 @@
 
 package org.apache.fop.pdf;
 
-import java.io.OutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 
 import org.apache.xmlgraphics.util.io.ASCII85OutputStream;
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/ASCIIHexFilter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/ASCIIHexFilter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/ASCIIHexFilter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/ASCIIHexFilter.java Thu Apr  5 16:19:19 2012
@@ -19,8 +19,8 @@
 
 package org.apache.fop.pdf;
 
-import java.io.OutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 
 import org.apache.xmlgraphics.util.io.ASCIIHexOutputStream;
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/AbstractPDFStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/AbstractPDFStream.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/AbstractPDFStream.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/AbstractPDFStream.java Thu Apr  5 16:19:19 2012
@@ -21,7 +21,6 @@ package org.apache.fop.pdf;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.Writer;
 
 import org.apache.commons.io.output.CountingOutputStream;
 
@@ -30,16 +29,48 @@ import org.apache.fop.util.CloseBlockerO
 /**
  * This is an abstract base class for PDF streams.
  */
-public abstract class AbstractPDFStream extends PDFDictionary {
+public abstract class AbstractPDFStream extends PDFObject {
+
+    private final PDFDictionary dictionary;
 
     /** The filters that should be applied */
     private PDFFilterList filters;
 
+    private final boolean encodeOnTheFly;
+
+    protected AbstractPDFStream() {
+        this(true);
+    }
+
+    protected AbstractPDFStream(PDFDictionary dictionary) {
+        this(dictionary, true);
+    }
+
+    protected AbstractPDFStream(boolean encodeOnTheFly) {
+        this(new PDFDictionary(), encodeOnTheFly);
+    }
+
+    protected AbstractPDFStream(PDFDictionary dictionary, boolean encodeOnTheFly) {
+        this.dictionary = dictionary;
+        this.encodeOnTheFly = encodeOnTheFly;
+    }
+
+    protected final PDFDictionary getDictionary() {
+        return dictionary;
+    }
+
+    protected Object get(String key) {
+        return dictionary.get(key);
+    }
+
     /**
-     * Constructor for AbstractPDFStream.
+     * Puts the given object in the dictionary associated to this stream.
+     *
+     * @param key the key in the dictionary
+     * @param value the value to store
      */
-    public AbstractPDFStream() {
-        super();
+    public void put(String key, Object value) {
+        dictionary.put(key, value);
     }
 
     /**
@@ -131,8 +162,8 @@ public abstract class AbstractPDFStream 
      */
     protected StreamCache encodeStream() throws IOException {
         //Allocate a temporary buffer to find out the size of the encoded stream
-        final StreamCache encodedStream = StreamCacheFactory.getInstance().
-                createStreamCache(getSizeHint());
+        final StreamCache encodedStream = StreamCacheFactory.getInstance()
+                .createStreamCache(getSizeHint());
         OutputStream filteredOutput
                 = getFilterList().applyFilters(encodedStream.getOutputStream());
         outputRawStreamData(filteredOutput);
@@ -164,7 +195,7 @@ public abstract class AbstractPDFStream 
         OutputStream filteredOutput = getFilterList().applyFilters(cout);
         outputRawStreamData(filteredOutput);
         filteredOutput.close();
-        refLength.setNumber(new Integer(cout.getCount()));
+        refLength.setNumber(Integer.valueOf(cout.getCount()));
         bytesWritten += cout.getCount();
 
         //Stream trailer
@@ -180,31 +211,30 @@ public abstract class AbstractPDFStream 
      * byte arrays around so much
      * {@inheritDoc}
      */
-    protected int output(OutputStream stream) throws IOException {
+    @Override
+    public int output(OutputStream stream) throws IOException {
         setupFilterList();
 
         CountingOutputStream cout = new CountingOutputStream(stream);
-        Writer writer = PDFDocument.getWriterFor(cout);
-        writer.write(getObjectID());
-        //int length = 0;
+        StringBuilder textBuffer = new StringBuilder(64);
 
         StreamCache encodedStream = null;
         PDFNumber refLength = null;
         final Object lengthEntry;
-        if (isEncodingOnTheFly()) {
+        if (encodeOnTheFly) {
             refLength = new PDFNumber();
             getDocumentSafely().registerObject(refLength);
             lengthEntry = refLength;
         } else {
             encodedStream = encodeStream();
-            lengthEntry = new Integer(encodedStream.getSize() + 1);
+            lengthEntry = Integer.valueOf(encodedStream.getSize() + 1);
         }
 
         populateStreamDict(lengthEntry);
-        writeDictionary(cout, writer);
+        dictionary.writeDictionary(cout, textBuffer);
 
         //Send encoded stream to target OutputStream
-        writer.flush();
+        PDFDocument.flushTextBuffer(textBuffer, cout);
         if (encodedStream == null) {
             encodeAndWriteStream(cout, refLength);
         } else {
@@ -212,18 +242,14 @@ public abstract class AbstractPDFStream 
             encodedStream.clear(); //Encoded stream can now be discarded
         }
 
-        writer.write("\nendobj\n");
-        writer.flush();
+        PDFDocument.flushTextBuffer(textBuffer, cout);
         return cout.getCount();
     }
 
-    /**
-     * Indicates whether encoding may happen without buffering the encoded data. If this method
-     * returns true, the /Length entry will be an indirect object, a direct object otherwise.
-     * @return true if encoding should happen "on the fly"
-     */
-    protected boolean isEncodingOnTheFly() {
-        return getDocument().isEncodingOnTheFly();
+    @Override
+    public void setDocument(PDFDocument doc) {
+        dictionary.setDocument(doc);
+        super.setDocument(doc);
     }
 
     /**
@@ -234,7 +260,7 @@ public abstract class AbstractPDFStream 
     protected void populateStreamDict(Object lengthEntry) {
         put("Length", lengthEntry);
         if (!getFilterList().isDisableAllFilters()) {
-            getFilterList().putFilterDictEntries(this);
+            getFilterList().putFilterDictEntries(dictionary);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/CMapBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/CMapBuilder.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/CMapBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/CMapBuilder.java Thu Apr  5 16:19:19 2012
@@ -202,4 +202,4 @@ public class CMapBuilder {
          * }
          */
     }
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/DCTFilter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/DCTFilter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/DCTFilter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/DCTFilter.java Thu Apr  5 16:19:19 2012
@@ -20,12 +20,12 @@
 package org.apache.fop.pdf;
 
 /**
- * DCT Filter class. Right now it is just used as a dummy filter flag so
+ * <p>DCT Filter class. Right now it is just used as a dummy filter flag so
  * we can write JPG images to the PDF. The encode method just returns the
  * data passed to it. In the future an actual JPEG compression should be
- * added to the encode method so other images can be compressed.
+ * added to the encode method so other images can be compressed.</p>
  *
- * @author Eric Dalquist
+ * <p>This work was authored by Eric Dalquist.</p>
  */
 public class DCTFilter extends NullFilter {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/DestinationComparator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/DestinationComparator.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/DestinationComparator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/DestinationComparator.java Thu Apr  5 16:19:19 2012
@@ -19,8 +19,6 @@
 
 package org.apache.fop.pdf;
 
-import org.apache.fop.pdf.PDFDestination;
-
 /**
  * Comparator class to enable comparing (and
  * hence sorting) of PDFDestination objects.

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/InMemoryStreamCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/InMemoryStreamCache.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/InMemoryStreamCache.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/InMemoryStreamCache.java Thu Apr  5 16:19:19 2012
@@ -20,8 +20,8 @@
 package org.apache.fop.pdf;
 
 import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 
 /**
  * StreamCache implementation that uses temporary files rather than heap.

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFAnnotList.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFAnnotList.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFAnnotList.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFAnnotList.java Thu Apr  5 16:19:19 2012
@@ -58,22 +58,19 @@ public class PDFAnnotList extends PDFObj
      */
     public String toPDFString() {
         StringBuffer p = new StringBuffer(128);
-        p.append(getObjectID());
         p.append("[\n");
         for (int i = 0; i < getCount(); i++) {
             p.append(((PDFObject)links.get(i)).referencePDF());
             p.append("\n");
         }
-        p.append("]\nendobj\n");
+        p.append("]");
         return p.toString();
     }
 
     /*
      * example
-     * 20 0 obj
      * [
      * 19 0 R
      * ]
-     * endobj
      */
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFArray.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFArray.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFArray.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFArray.java Thu Apr  5 16:19:19 2012
@@ -21,8 +21,6 @@ package org.apache.fop.pdf;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Collection;
 import java.util.List;
 
 import org.apache.commons.io.output.CountingOutputStream;
@@ -34,7 +32,7 @@ public class PDFArray extends PDFObject 
     /**
      * List holding the values of this array
      */
-    protected List values = new java.util.ArrayList();
+    protected List<Object> values = new java.util.ArrayList<Object>();
 
     /**
      * Create a new, empty array object
@@ -49,7 +47,7 @@ public class PDFArray extends PDFObject 
      * Create a new, empty array object with no parent.
      */
     public PDFArray() {
-        this(null);
+        this((PDFObject) null);
     }
 
     /**
@@ -62,7 +60,7 @@ public class PDFArray extends PDFObject 
         super(parent);
 
         for (int i = 0, c = values.length; i < c; i++) {
-            this.values.add(new Integer(values[i]));
+            this.values.add(Integer.valueOf(values[i]));
         }
     }
 
@@ -85,7 +83,7 @@ public class PDFArray extends PDFObject 
      * @param parent the array's parent if any
      * @param values the actual values wrapped by this object
      */
-    public PDFArray(PDFObject parent, Collection values) {
+    public PDFArray(PDFObject parent, List<?> values) {
         /* generic creation of PDF object */
         super(parent);
 
@@ -93,6 +91,15 @@ public class PDFArray extends PDFObject 
     }
 
     /**
+     * Creates an array object made of the given elements.
+     *
+     * @param elements the array content
+     */
+    public PDFArray(Object... elements) {
+        this(null, elements);
+    }
+
+    /**
      * Create the array object
      * @param parent the array's parent if any
      * @param values the actual array wrapped by this object
@@ -180,28 +187,20 @@ public class PDFArray extends PDFObject 
     }
 
     /** {@inheritDoc} */
-    protected int output(OutputStream stream) throws IOException {
+    @Override
+    public int output(OutputStream stream) throws IOException {
         CountingOutputStream cout = new CountingOutputStream(stream);
-        Writer writer = PDFDocument.getWriterFor(cout);
-        if (hasObjectNumber()) {
-            writer.write(getObjectID());
-        }
-
-        writer.write('[');
+        StringBuilder textBuffer = new StringBuilder(64);
+        textBuffer.append('[');
         for (int i = 0; i < values.size(); i++) {
             if (i > 0) {
-                writer.write(' ');
+                textBuffer.append(' ');
             }
             Object obj = this.values.get(i);
-            formatObject(obj, cout, writer);
-        }
-        writer.write(']');
-
-        if (hasObjectNumber()) {
-            writer.write("\nendobj\n");
+            formatObject(obj, cout, textBuffer);
         }
-
-        writer.flush();
+        textBuffer.append(']');
+        PDFDocument.flushTextBuffer(textBuffer, cout);
         return cout.getCount();
     }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCIDFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCIDFont.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCIDFont.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCIDFont.java Thu Apr  5 16:19:19 2012
@@ -200,7 +200,6 @@ public class PDFCIDFont extends PDFObjec
      */
     public String toPDFString() {
         StringBuffer p = new StringBuffer(128);
-        p.append(getObjectID());
         p.append("<< /Type /Font");
         p.append("\n/BaseFont /");
         p.append(this.basefont);
@@ -234,14 +233,13 @@ public class PDFCIDFont extends PDFObjec
             p.append("\n/DW2 [");    // always two values, see p 211
             p.append(this.dw2[0]);
             p.append(this.dw2[1]);
-            p.append("] \n>>\nendobj\n");
+            p.append("]");
         }
         if (w2 != null) {
             p.append("\n/W2 ");
             p.append(w2.toPDFString());
-            p.append(" \n>>\nendobj\n");
         }
-        p.append(" \n>>\nendobj\n");
+        p.append("\n>>");
         return p.toString();
     }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCMap.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCMap.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCMap.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCMap.java Thu Apr  5 16:19:19 2012
@@ -423,7 +423,7 @@ public class PDFCMap extends PDFStream {
     }
 
     /** {@inheritDoc} */
-    protected int output(OutputStream stream) throws IOException {
+    public int output(OutputStream stream) throws IOException {
         CMapBuilder builder = createCMapBuilder(getBufferWriter());
         builder.writeCMap();
         return super.output(stream);

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCharProcs.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCharProcs.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCharProcs.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFCharProcs.java Thu Apr  5 16:19:19 2012
@@ -19,8 +19,8 @@
 
 package org.apache.fop.pdf;
 
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
 
 /**
  * class representing a /CharProcs dictionary for Type3 fonts.

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFColor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFColor.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFColor.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFColor.java Thu Apr  5 16:19:19 2012
@@ -19,20 +19,18 @@
 
 package org.apache.fop.pdf;
 
-import java.awt.Color;
 import java.awt.color.ColorSpace;
-import java.awt.color.ICC_ColorSpace;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace;
 
-import org.apache.fop.util.ColorExt;
-
 /**
- * PDF Color object.
- * This is used to output color to a PDF content stream.
+ * PDF Color object. It is currently only used to hold the transparent color of a masked bitmap
+ * image. And in this context, only RGB and Gray values are used.
+ * <p>
+ * Use of this class is discouraged. {@link PDFColorHandler} is now used for in-content color
+ * selection. For masked bitmaps, it may be wiser to switch to {@link Color} in the long run.
  */
 public class PDFColor extends PDFPathPaint {
     // could be 3.0 as well.
@@ -46,14 +44,8 @@ public class PDFColor extends PDFPathPai
     private double yellow = -1.0;
     private double black = -1.0;
 
-    // TODO - It would probably be better to reorganize PDFPathPaint/PDFColor/PDFColorSpace
-    //        class hierarchy. However, at this early stages of my FOP understanding, I can
-    //        not really oversee the consequences of such a switch (nor whether it would be
-    //        appropriate).
-    private ColorExt colorExt = null;
-
     /**
-     * Create a PDF color with double values ranging from 0 to 1
+     * Create a PDF color with double values ranging from 0 to 1.
      *
      * @param theRed the red double value
      * @param theGreen the green double value
@@ -69,81 +61,27 @@ public class PDFColor extends PDFPathPai
     }
 
     /**
-     * Create PDFColor for the given document and based on the java.awt.Color object
-     *
-     * In case the java.awt.Color is an instance of the ColorExt class a PDFICCStream is added to
-     * the PDFDocument that is being created
-     *
-     * @param pdfDoc PDFDocument that is being created
-     * @param col Color object from which to create this PDFColor
-     */
-    public PDFColor(PDFDocument pdfDoc, Color col) {
-        this(col);
-        // TODO - 1) There is a potential conflict when FOP and Batik elements use the same color
-        //           profile name for different profiles.
-        //        2) In case the same color profile is used with different names it will be
-        //           included multiple times in the PDF
-        //
-        if (colorExt != null
-                && pdfDoc.getResources().getColorSpace(colorExt.getIccProfileName()) == null) {
-            PDFICCStream pdfIccStream = new PDFICCStream();
-            ColorSpace ceCs = colorExt.getOrigColorSpace();
-            try {
-                pdfIccStream.setColorSpace(((ICC_ColorSpace)ceCs).getProfile(), null);
-                pdfIccStream.setData(
-                        ((ICC_ColorSpace)colorExt.getColorSpace()).getProfile().getData());
-            } catch (IOException ioe) {
-                log.error("Failed to set profile data for " + colorExt.getIccProfileName());
-            }
-            pdfDoc.registerObject(pdfIccStream);
-            pdfDoc.getFactory().makeICCBasedColorSpace(
-                    null, colorExt.getIccProfileName(), pdfIccStream);
-            if (log.isInfoEnabled()) {
-                log.info("Adding PDFICCStream " + colorExt.getIccProfileName()
-                        + " for " + colorExt.getIccProfileSrc());
-            }
-        }
-    }
-
-    /**
      * Create a PDF color from a java.awt.Color object.
      *
      * Different Color objects are handled differently. Cases recognized are.
      *
      * 1. CMYK color
-     * 2. ColorExt color
-     * 3. 'Normal' java.awt.Color (RGB case assumed)
+     * 3. 'Normal' java.awt.Color (RGB case assumed or implicit conversion to sRGB)
      *
      * @param col the java.awt.Color object for which to create a PDFColor object
      */
     public PDFColor(java.awt.Color col) {
         ColorSpace cs = col.getColorSpace();
-        ColorExt ce = null;
-        if (col instanceof ColorExt) {
-            ce = (ColorExt)col;
-            cs = ce.getOrigColorSpace();
-        }
         if (cs != null && cs instanceof DeviceCMYKColorSpace) {
             // CMYK case
             this.colorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_CMYK);
-            float[] cmyk = (ce == null
-                    ? col.getColorComponents(null)
-                    : ce.getOriginalColorComponents());
+            float[] cmyk = col.getColorComponents(null);
             this.cyan = cmyk[0];
             this.magenta = cmyk[1];
             this.yellow = cmyk[2];
             this.black = cmyk[3];
-        } else if (ce != null) {
-            // ColorExt (ICC) case
-            this.colorExt = ce;
-            float[] rgb = col.getRGBColorComponents(null);
-            this.red = rgb[0];
-            this.green = rgb[1];
-            this.blue = rgb[2];
-            // TODO - See earlier todo
-            this.colorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
         } else {
-            // Default (RGB) Color
+            // Default (RGB) Color (ICC Colors are converted to sRGB, too)
             this.colorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
             float[] comps = new float[3];
             comps = col.getColorComponents(comps);
@@ -163,7 +101,6 @@ public class PDFColor extends PDFPathPai
     public PDFColor(int theRed, int theGreen, int theBlue) {
         this(((double)theRed) / 255d, ((double)theGreen) / 255d,
              ((double)theBlue) / 255d);
-
     }
 
     /**
@@ -176,8 +113,6 @@ public class PDFColor extends PDFPathPai
      */
     public PDFColor(double theCyan, double theMagenta, double theYellow,
                     double theBlack) {
-        // super(theNumber);//?
-
         this.colorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_CMYK);
 
         this.cyan = theCyan;
@@ -351,26 +286,7 @@ public class PDFColor extends PDFPathPai
     public String getColorSpaceOut(boolean fillNotStroke) {
         StringBuffer p = new StringBuffer("");
 
-        if (this.colorExt != null) {
-            if (fillNotStroke)  {
-                p.append("/" + this.colorExt.getIccProfileName() + " cs ");
-            } else {
-                p.append("/" + this.colorExt.getIccProfileName() + " CS ");
-            }
-            float[] colorArgs;
-            colorArgs = this.colorExt.getOriginalColorComponents();
-            if (colorArgs == null) {
-                colorArgs = this.colorExt.getColorComponents(null);
-            }
-            for (int ix = 0; ix < colorArgs.length; ix++) {
-                p.append(colorArgs[ix] + " ");
-            }
-            if (fillNotStroke)  {
-                p.append("sc\n");
-            } else {
-                p.append("SC\n");
-            }
-        } else if (this.colorSpace.getColorSpace()
+        if (this.colorSpace.getColorSpace()
                 == PDFDeviceColorSpace.DEVICE_RGB) {       // colorspace is RGB
             // according to pdfspec 12.1 p.399
             // if the colors are the same then just use the g or G operator

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDestination.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDestination.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDestination.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDestination.java Thu Apr  5 16:19:19 2012
@@ -21,7 +21,6 @@ package org.apache.fop.pdf;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.Writer;
 
 import org.apache.commons.io.output.CountingOutputStream;
 
@@ -51,16 +50,16 @@ public class PDFDestination extends PDFO
         this.idRef = idRef;
     }
 
-    /** {@inheritDoc} */
-    protected int output(OutputStream stream) throws IOException {
+    @Override
+    public int output(OutputStream stream) throws IOException {
         CountingOutputStream cout = new CountingOutputStream(stream);
-        Writer writer = PDFDocument.getWriterFor(cout);
+        StringBuilder textBuffer = new StringBuilder(64);
 
-        formatObject(getIDRef(), cout, writer);
-        writer.write(' ');
-        formatObject(goToReference, cout, writer);
+        formatObject(getIDRef(), cout, textBuffer);
+        textBuffer.append(' ');
+        formatObject(goToReference, cout, textBuffer);
 
-        writer.flush();
+        PDFDocument.flushTextBuffer(textBuffer, cout);
         return cout.getCount();
     }
 
@@ -70,6 +69,7 @@ public class PDFDestination extends PDFO
      * @param goToReference the reference to set in the associated DestinationData object.
      * @deprecated use setGoToReference(Object) instead
      */
+    @Deprecated
     public void setGoToReference(String goToReference) {
         this.goToReference = goToReference;
     }
@@ -107,6 +107,7 @@ public class PDFDestination extends PDFO
      * @param obj the object to compare
      * @return true if this equals other object
      */
+    @Override
     public boolean equals(Object obj) {
         if (this == obj) {
             return true;
@@ -125,6 +126,7 @@ public class PDFDestination extends PDFO
     }
 
     /** {@inheritDoc} */
+    @Override
     public int hashCode() {
         return getIDRef().hashCode();
     }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDeviceColorSpace.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDeviceColorSpace.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDeviceColorSpace.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDeviceColorSpace.java Thu Apr  5 16:19:19 2012
@@ -19,6 +19,8 @@
 
 package org.apache.fop.pdf;
 
+import java.awt.color.ColorSpace;
+
 /**
  * Represents a device-specific color space. Used for mapping DeviceRGB, DeviceCMYK and DeviceGray.
  */
@@ -137,4 +139,28 @@ public class PDFDeviceColorSpace impleme
         return getColorSpace() == DEVICE_GRAY;
     }
 
+    /**
+     * Returns a suitable {@link PDFDeviceColorSpace} object given a {@link ColorSpace} object.
+     * @param cs ColorSpace instance
+     * @return a PDF-based color space
+     */
+    public static PDFDeviceColorSpace toPDFColorSpace(ColorSpace cs) {
+        if (cs == null) {
+            return null;
+        }
+
+        PDFDeviceColorSpace pdfCS = new PDFDeviceColorSpace(0);
+        switch (cs.getType()) {
+            case ColorSpace.TYPE_CMYK:
+                pdfCS.setColorSpace(PDFDeviceColorSpace.DEVICE_CMYK);
+            break;
+            case ColorSpace.TYPE_GRAY:
+                pdfCS.setColorSpace(PDFDeviceColorSpace.DEVICE_GRAY);
+                break;
+            default:
+                pdfCS.setColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
+        }
+        return pdfCS;
+    }
+
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDictionary.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDictionary.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDictionary.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFDictionary.java Thu Apr  5 16:19:19 2012
@@ -21,8 +21,6 @@ package org.apache.fop.pdf;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -36,13 +34,13 @@ public class PDFDictionary extends PDFOb
     /**
      * the entry map
      */
-    protected Map entries = new java.util.HashMap();
+    protected Map<String, Object> entries = new java.util.HashMap<String, Object>();
 
     /**
      * maintains the order of the entries added to the entry map. Whenever you modify
      * "entries", always make sure you adjust this list accordingly.
      */
-    protected List order = new java.util.ArrayList();
+    protected List<String> order = new java.util.ArrayList<String>();
 
     /**
      * Create a new dictionary object.
@@ -86,7 +84,7 @@ public class PDFDictionary extends PDFOb
         if (!entries.containsKey(name)) {
             this.order.add(name);
         }
-        this.entries.put(name, new Integer(value));
+        this.entries.put(name, Integer.valueOf(value));
     }
 
     /**
@@ -99,51 +97,41 @@ public class PDFDictionary extends PDFOb
     }
 
     /** {@inheritDoc} */
-    protected int output(OutputStream stream) throws IOException {
+    @Override
+    public int output(OutputStream stream) throws IOException {
         CountingOutputStream cout = new CountingOutputStream(stream);
-        Writer writer = PDFDocument.getWriterFor(cout);
-        if (hasObjectNumber()) {
-            writer.write(getObjectID());
-        }
-
-        writeDictionary(cout, writer);
-
-        if (hasObjectNumber()) {
-            writer.write("\nendobj\n");
-        }
-
-        writer.flush();
+        StringBuilder textBuffer = new StringBuilder(64);
+        writeDictionary(cout, textBuffer);
+        PDFDocument.flushTextBuffer(textBuffer, cout);
         return cout.getCount();
     }
 
     /**
      * Writes the contents of the dictionary to a StringBuffer.
      * @param out the OutputStream (for binary content)
-     * @param writer the Writer (for text content, wraps the above OutputStream)
+     * @param textBuffer the text buffer for text output
      * @throws IOException if an I/O error occurs
      */
-    protected void writeDictionary(OutputStream out, Writer writer) throws IOException {
-        writer.write("<<");
+    protected void writeDictionary(OutputStream out, StringBuilder textBuffer) throws IOException {
+        textBuffer.append("<<");
         boolean compact = (this.order.size() <= 2);
-        Iterator iter = this.order.iterator();
-        while (iter.hasNext()) {
-            String key = (String)iter.next();
+        for (String key : this.order) {
             if (compact) {
-                writer.write(' ');
+                textBuffer.append(' ');
             } else {
-                writer.write("\n  ");
+                textBuffer.append("\n  ");
             }
-            writer.write(PDFName.escapeName(key));
-            writer.write(' ');
+            textBuffer.append(PDFName.escapeName(key));
+            textBuffer.append(' ');
             Object obj = this.entries.get(key);
-            formatObject(obj, out, writer);
+            formatObject(obj, out, textBuffer);
         }
         if (compact) {
-            writer.write(' ');
+            textBuffer.append(' ');
         } else {
-            writer.write('\n');
+            textBuffer.append('\n');
         }
-        writer.write(">>\n");
+        textBuffer.append(">>\n");
     }
 
 }



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