xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phanc...@apache.org
Subject svn commit: r1394098 [3/4] - in /xmlgraphics/fop/branches/Temp_RoundedCorners: ./ examples/plan/src/org/apache/fop/plan/ lib/ src/documentation/content/xdocs/ src/documentation/content/xdocs/dev/ src/documentation/content/xdocs/trunk/ src/java/org/apac...
Date Thu, 04 Oct 2012 14:46:06 GMT
Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -312,7 +312,7 @@ public class BlockLayoutManager extends 
 
         addId();
 
-        addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
+        registerMarkers(true, isFirst(firstPos), isLast(lastPos));
 
         // the Positions in positionList were inside the elements
         // created by the LineLM
@@ -327,7 +327,7 @@ public class BlockLayoutManager extends 
             childLM.addAreas(childPosIter, lc);
         }
 
-        addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
+        registerMarkers(false, isFirst(firstPos), isLast(lastPos));
 
         TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(),
                 effSpaceBefore, effSpaceAfter);

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/BreakElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/BreakElement.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/BreakElement.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/BreakElement.java Thu Oct  4 14:46:01 2012
@@ -21,6 +21,8 @@ package org.apache.fop.layoutmgr;
 
 import java.util.List;
 
+import org.apache.fop.fo.Constants;
+
 /**
  * This class represents an unresolved break possibility.
  */
@@ -28,7 +30,7 @@ public class BreakElement extends Unreso
 
     private int penaltyWidth;
     private int penaltyValue;
-    private int breakClass = -1;
+    private int breakClass;
     private List pendingBeforeMarks;
     private List pendingAfterMarks;
 
@@ -39,7 +41,7 @@ public class BreakElement extends Unreso
      * @param context the layout context which contains the pending conditional elements
      */
     public BreakElement(Position position, int penaltyValue, LayoutContext context) {
-        this(position, penaltyValue, -1, context);
+        this(position, penaltyValue, Constants.EN_AUTO, context);
     }
 
     /**
@@ -80,7 +82,7 @@ public class BreakElement extends Unreso
         super(position);
         this.penaltyWidth = penaltyWidth;
         this.penaltyValue = penaltyValue;
-        this.breakClass = breakClass;
+        setBreakClass(breakClass);
         this.pendingBeforeMarks = context.getPendingBeforeMarks();
         this.pendingAfterMarks = context.getPendingAfterMarks();
     }
@@ -142,13 +144,24 @@ public class BreakElement extends Unreso
      *
      * @param breakClass one of
      *   {@link org.apache.fop.fo.Constants#EN_AUTO},
+     *   {@link org.apache.fop.fo.Constants#EN_LINE},
      *   {@link org.apache.fop.fo.Constants#EN_COLUMN},
      *   {@link org.apache.fop.fo.Constants#EN_PAGE},
      *   {@link org.apache.fop.fo.Constants#EN_EVEN_PAGE},
      *   {@link org.apache.fop.fo.Constants#EN_ODD_PAGE}.
      */
     public void setBreakClass(int breakClass) {
-        this.breakClass = breakClass;
+        switch (breakClass) {
+        case Constants.EN_AUTO:
+        case Constants.EN_LINE:
+        case Constants.EN_COLUMN:
+        case Constants.EN_PAGE:
+        case Constants.EN_EVEN_PAGE:
+        case Constants.EN_ODD_PAGE:
+            this.breakClass = breakClass;
+            break;
+        default: throw new IllegalArgumentException("Illegal value for break class: " + breakClass);
+        }
     }
 
     /** @return the pending border and padding elements at the before edge */

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java Thu Oct  4 14:46:01 2012
@@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.fo.FOElementMapping;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FONode.FONodeIterator;
 import org.apache.fop.fo.FOText;
 import org.apache.fop.fo.FObjMixed;
 import org.apache.fop.fo.extensions.ExternalDocument;
@@ -117,7 +118,7 @@ public class LayoutManagerMapping implem
         registerMaker(Block.class, new BlockLayoutManagerMaker());
         registerMaker(Leader.class, new LeaderLayoutManagerMaker());
         registerMaker(RetrieveMarker.class, new RetrieveMarkerLayoutManagerMaker());
-        registerMaker(RetrieveTableMarker.class, new Maker());
+        registerMaker(RetrieveTableMarker.class, new RetrieveTableMarkerLayoutManagerMaker());
         registerMaker(Character.class, new CharacterLayoutManagerMaker());
         registerMaker(ExternalGraphic.class,
                    new ExternalGraphicLayoutManagerMaker());
@@ -407,6 +408,24 @@ public class LayoutManagerMapping implem
         }
     }
 
+    public class RetrieveTableMarkerLayoutManagerMaker extends Maker {
+        public void make(FONode node, List lms) {
+            FONodeIterator baseIter = node.getChildNodes();
+            if (baseIter == null) {
+                // this happens when the retrieve-table-marker cannot be resolved yet
+                RetrieveTableMarker rtm = (RetrieveTableMarker) node;
+                RetrieveTableMarkerLayoutManager rtmlm = new RetrieveTableMarkerLayoutManager(rtm);
+                lms.add(rtmlm);
+                return;
+            }
+            while (baseIter.hasNext()) {
+                // this happens when the retrieve-table-marker has been resolved
+                FONode child = (FONode) baseIter.next();
+                makeLayoutManagers(child, lms);
+            }
+        }
+    }
+
     /** a layout manager maker */
     public class WrapperLayoutManagerMaker extends Maker {
         /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -167,125 +167,22 @@ public class StaticContentLayoutManager 
         return (StaticContent) fobj;
     }
 
-    private class StaticContentBreaker extends AbstractBreaker {
-        private StaticContentLayoutManager lm;
-        private int displayAlign;
-        private int ipd;
-        private int overflow = 0;
-
-        public StaticContentBreaker(StaticContentLayoutManager lm, int ipd,
-                int displayAlign) {
-            this.lm = lm;
-            this.ipd = ipd;
-            this.displayAlign = displayAlign;
+    private class StaticContentBreaker extends LocalBreaker {
+
+        public StaticContentBreaker(StaticContentLayoutManager lm, int ipd, int displayAlign) {
+            super(lm, ipd, displayAlign);
         }
 
         /** {@inheritDoc} */
         protected void observeElementList(List elementList) {
             String elementListID = getStaticContentFO().getFlowName();
-            String pageSequenceID = ((PageSequence)lm.getParent().getFObj()).getId();
+            String pageSequenceID = ((PageSequence) lm.getParent().getFObj()).getId();
             if (pageSequenceID != null && pageSequenceID.length() > 0) {
                 elementListID += "-" + pageSequenceID;
             }
             ElementListObserver.observe(elementList, "static-content", elementListID);
         }
 
-        /** {@inheritDoc} */
-        protected boolean isPartOverflowRecoveryActivated() {
-            //For side regions, this must be disabled because of wanted overflow.
-            return false;
-        }
-
-        public boolean isOverflow() {
-            return (this.overflow != 0);
-        }
-
-        public int getOverflowAmount() {
-            return this.overflow;
-        }
-
-        /** {@inheritDoc} */
-        protected PageBreakingLayoutListener createLayoutListener() {
-            return new PageBreakingLayoutListener() {
-
-                public void notifyOverflow(int part, int amount, FObj obj) {
-                    if (StaticContentBreaker.this.overflow == 0) {
-                        StaticContentBreaker.this.overflow = amount;
-                    }
-                }
-
-            };
-        }
-
-        protected LayoutManager getTopLevelLM() {
-            return lm;
-        }
-
-        protected LayoutContext createLayoutContext() {
-            LayoutContext lc = super.createLayoutContext();
-            lc.setRefIPD(ipd);
-            return lc;
-        }
-
-        protected List getNextKnuthElements(LayoutContext context, int alignment) {
-            LayoutManager curLM; // currently active LM
-            List returnList = new LinkedList();
-
-            while ((curLM = getChildLM()) != null) {
-                LayoutContext childLC = LayoutContext.newInstance();
-                childLC.setStackLimitBP(context.getStackLimitBP());
-                childLC.setRefIPD(context.getRefIPD());
-                childLC.setWritingMode(context.getWritingMode());
-
-                List returnedList = null;
-                //The following is a HACK! Ignore leading and trailing white space
-                boolean ignore = curLM instanceof TextLayoutManager;
-                if (!curLM.isFinished()) {
-                    returnedList = curLM.getNextKnuthElements(childLC, alignment);
-                }
-                if (returnedList != null && !ignore) {
-                    lm.wrapPositionElements(returnedList, returnList);
-                }
-            }
-            SpaceResolver.resolveElementList(returnList);
-            setFinished(true);
-            return returnList;
-        }
-
-        protected int getCurrentDisplayAlign() {
-            return displayAlign;
-        }
-
-        protected boolean hasMoreContent() {
-            return !lm.isFinished();
-        }
-
-        protected void addAreas(PositionIterator posIter, LayoutContext context) {
-            AreaAdditionUtil.addAreas(lm, posIter, context);
-        }
-
-        protected void doPhase3(PageBreakingAlgorithm alg, int partCount,
-                BlockSequence originalList, BlockSequence effectiveList) {
-            if (partCount > 1) {
-                PageBreakPosition pos = (PageBreakPosition)alg.getPageBreaks().getFirst();
-                int firstPartLength = ElementListUtils.calcContentLength(effectiveList,
-                        effectiveList.ignoreAtStart, pos.getLeafPos());
-                overflow += alg.totalWidth - firstPartLength;
-            }
-            //Rendering all parts (not just the first) at once for the case where the parts that
-            //overflow should be visible.
-            alg.removeAllPageBreaks();
-            //Directly add areas after finding the breaks
-            this.addAreas(alg, 1, originalList, effectiveList);
-        }
-
-        protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) {
-            //nop for static content
-        }
-
-        protected LayoutManager getCurrentChildLM() {
-            return null; //TODO NYI
-        }
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -480,7 +480,7 @@ public class InlineLayoutManager extends
             context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this));
         }
 
-        addMarkersToPage(
+        registerMarkers(
                 true,
                 !areaCreated,
                 lastPos == null || isLast(lastPos));
@@ -542,7 +542,7 @@ public class InlineLayoutManager extends
         setTraits(areaCreated, lastPos == null || !isLast(lastPos));
         parentLayoutManager.addChildArea(getCurrentArea());
 
-        addMarkersToPage(
+        registerMarkers(
                 false,
                 !areaCreated,
                 lastPos == null || isLast(lastPos));

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -649,6 +649,10 @@ public class LineLayoutManager extends I
         log.trace("Restarting line breaking from index " + restartPosition.getIndex());
         int parIndex = restartPosition.getLeafPos();
         KnuthSequence paragraph = knuthParagraphs.get(parIndex);
+        if (paragraph instanceof Paragraph) {
+            ((Paragraph) paragraph).ignoreAtStart = 0;
+            isFirstInBlock = false;
+        }
         paragraph.subList(0, restartPosition.getIndex() + 1).clear();
         Iterator<KnuthElement> iter = paragraph.iterator();
         while (iter.hasNext() && !iter.next().isBox()) {

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -171,7 +171,7 @@ public class ListBlockLayoutManager exte
             }
         }
 
-        addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
+        registerMarkers(true, isFirst(firstPos), isLast(lastPos));
 
         PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
         while ((childLM = childPosIter.getNextChildLM()) != null) {
@@ -184,7 +184,7 @@ public class ListBlockLayoutManager exte
             childLM.addAreas(childPosIter, lc);
         }
 
-        addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
+        registerMarkers(false, isFirst(firstPos), isLast(lastPos));
 
         // We are done with this area add the background
         TraitSetter.addBackground(curBlockArea,

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -136,7 +136,7 @@ public class ListItemContentLayoutManage
             }
         }
 
-        addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
+        registerMarkers(true, isFirst(firstPos), isLast(lastPos));
 
         PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
         while ((childLM = childPosIter.getNextChildLM()) != null) {
@@ -149,7 +149,7 @@ public class ListItemContentLayoutManage
             childLM.addAreas(childPosIter, lc);
         }
 
-        addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
+        registerMarkers(false, isFirst(firstPos), isLast(lastPos));
 
         flush();
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -509,7 +509,7 @@ public class ListItemLayoutManager exten
             }
         }
 
-        addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
+        registerMarkers(true, isFirst(firstPos), isLast(lastPos));
 
         // use the first and the last ListItemPosition to determine the
         // corresponding indexes in the original labelList and bodyList
@@ -563,7 +563,7 @@ public class ListItemLayoutManager exten
         }
         curBlockArea.setBPD(itemBPD);
 
-        addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
+        registerMarkers(false, isFirst(firstPos), isLast(lastPos));
 
         // We are done with this area add the background
         TraitSetter.addBackground(curBlockArea,

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/RowPainter.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/RowPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/RowPainter.java Thu Oct  4 14:46:01 2012
@@ -303,11 +303,16 @@ class RowPainter {
                     borderAfterWhich = ConditionalBorder.REST;
                 }
 
+                // when adding the areas for the TableCellLayoutManager this helps with the isLast trait
+                // if, say, the first cell of a row has content that fits in the page, but the content of
+                // the second cell does not fit this will assure that the isLast trait for the first cell
+                // will also be false
+                lastCellParts[i].pgu.getCellLM().setLastTrait(lastCellParts[i].isLastPart());
                 addAreasForCell(firstCellParts[i].pgu,
                         firstCellParts[i].start, lastCellParts[i].end,
                         actualRowHeight, borderBeforeWhich, borderAfterWhich,
                         lastOnPage);
-                firstCellParts[i] = null;
+                firstCellParts[i] = null; // why? what about the lastCellParts[i]?
                 Arrays.fill(firstCellOnPage, i, i + currentGU.getCell().getNumberColumnsSpanned(),
                         false);
             }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -21,6 +21,7 @@ package org.apache.fop.layoutmgr.table;
 
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -28,19 +29,24 @@ import org.apache.commons.logging.LogFac
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.Trait;
+import org.apache.fop.fo.flow.Marker;
 import org.apache.fop.fo.flow.table.ConditionalBorder;
 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.TableCell;
 import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.fo.flow.table.TableFooter;
+import org.apache.fop.fo.flow.table.TableHeader;
 import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.fo.flow.table.TableRow;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
+import org.apache.fop.layoutmgr.AbstractLayoutManager;
 import org.apache.fop.layoutmgr.AreaAdditionUtil;
 import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
+import org.apache.fop.layoutmgr.ElementListObserver;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.Keep;
 import org.apache.fop.layoutmgr.KnuthBox;
@@ -49,8 +55,10 @@ import org.apache.fop.layoutmgr.KnuthGlu
 import org.apache.fop.layoutmgr.KnuthPenalty;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.LocalBreaker;
 import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.layoutmgr.PositionIterator;
+import org.apache.fop.layoutmgr.RetrieveTableMarkerLayoutManager;
 import org.apache.fop.layoutmgr.SpaceResolver;
 import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.traits.BorderProps;
@@ -79,6 +87,28 @@ public class TableCellLayoutManager exte
     private int totalHeight;
     private int usedBPD;
     private boolean emptyCell = true;
+    private boolean isDescendantOfTableFooter;
+    private boolean isDescendantOfTableHeader;
+    private boolean hasRetrieveTableMarker;
+
+    // place holder for the addAreas arguments
+    private boolean savedAddAreasArguments;
+    private PositionIterator savedParentIter;
+    private LayoutContext savedLayoutContext;
+    private int[] savedSpannedGridRowHeights;
+    private int savedStartRow;
+    private int savedEndRow;
+    private int savedBorderBeforeWhich;
+    private int savedBorderAfterWhich;
+    private boolean savedFirstOnPage;
+    private boolean savedLastOnPage;
+    private RowPainter savedPainter;
+    private int savedFirstRowHeight;
+    // this is set to false when the table-cell has a retrieve-table-marker and is in the table-header
+    private boolean flushArea = true;
+
+    // this information is set by the RowPainter
+    private boolean isLastTrait;
 
     /**
      * Create a new Cell layout manager.
@@ -88,6 +118,11 @@ public class TableCellLayoutManager exte
     public TableCellLayoutManager(TableCell node, PrimaryGridUnit pgu) {
         super(node);
         this.primaryGridUnit = pgu;
+        this.isDescendantOfTableHeader = node.getParent().getParent() instanceof TableHeader
+                || node.getParent() instanceof TableHeader;
+        this.isDescendantOfTableFooter = node.getParent().getParent() instanceof TableFooter
+                || node.getParent() instanceof TableFooter;
+        this.hasRetrieveTableMarker = node.hasRetrieveTableMarker();
     }
 
     /** @return the table-cell FO */
@@ -248,6 +283,84 @@ public class TableCellLayoutManager exte
         totalHeight = h;
     }
 
+    private void clearRetrieveTableMarkerChildNodes(List<LayoutManager> childrenLMs) {
+        if (childrenLMs == null) {
+            return;
+        }
+        int n = childrenLMs.size();
+        for (int j = 0; j < n; j++) {
+            LayoutManager lm = (LayoutManager) childrenLMs.get(j);
+            if (lm == null) {
+                return;
+            } else if (lm instanceof RetrieveTableMarkerLayoutManager) {
+                ((AbstractLayoutManager) lm).getFObj().clearChildNodes();
+            } else {
+                List<LayoutManager> lms = lm.getChildLMs();
+                clearRetrieveTableMarkerChildNodes(lms);
+            }
+        }
+    }
+
+    /**
+     * Checks whether the associated table cell of this LM is in a table header or footer.
+     * @return true if descendant of table header or footer
+     */
+    private boolean isDescendantOfTableHeaderOrFooter() {
+        return (isDescendantOfTableFooter || isDescendantOfTableHeader);
+    }
+
+    private void saveAddAreasArguments(PositionIterator parentIter, LayoutContext layoutContext,
+            int[] spannedGridRowHeights, int startRow, int endRow, int borderBeforeWhich,
+            int borderAfterWhich, boolean firstOnPage, boolean lastOnPage, RowPainter painter,
+            int firstRowHeight) {
+        // checks for savedAddAreasArguments and isDescendantOfTableHeader were already made but repeat them
+        if (savedAddAreasArguments) {
+            return;
+        }
+        if (isDescendantOfTableHeader) {
+            savedAddAreasArguments = true;
+            savedParentIter = null /* parentIter */;
+            savedLayoutContext = null /* layoutContext */;
+            savedSpannedGridRowHeights = spannedGridRowHeights;
+            savedStartRow = startRow;
+            savedEndRow = endRow;
+            savedBorderBeforeWhich = borderBeforeWhich;
+            savedBorderAfterWhich = borderAfterWhich;
+            savedFirstOnPage = firstOnPage;
+            savedLastOnPage = lastOnPage;
+            savedPainter = painter;
+            savedFirstRowHeight = firstRowHeight;
+            TableLayoutManager parentTableLayoutManager = getTableLayoutManager();
+            parentTableLayoutManager.saveTableHeaderTableCellLayoutManagers(this);
+            // this saving is done the first time the addArea() is called; since the retrieve-table-markers
+            // cannot be resolved at this time we do not want to flush the area; the area needs nevertheless
+            // be built so that space is allocated for it.
+            flushArea = false;
+        }
+    }
+
+    private TableLayoutManager getTableLayoutManager() {
+        LayoutManager parentLM = getParent();
+        while (!(parentLM instanceof TableLayoutManager)) {
+            parentLM = parentLM.getParent();
+        }
+        TableLayoutManager tlm = (TableLayoutManager) parentLM;
+        return tlm;
+    }
+
+    /**
+     * Calls the addAreas() using the original arguments.
+     */
+    protected void repeatAddAreas() {
+        if (savedAddAreasArguments) {
+            addAreas(savedParentIter, savedLayoutContext, savedSpannedGridRowHeights, savedStartRow,
+                    savedEndRow, savedBorderBeforeWhich, savedBorderAfterWhich, savedFirstOnPage,
+                    savedLastOnPage, savedPainter, savedFirstRowHeight);
+            // so that the arguments of the next table fragment header can be saved
+            savedAddAreasArguments = false;
+        }
+    }
+
     /**
      * Add the areas for the break points. The cell contains block stacking layout
      * managers that add block areas.
@@ -407,7 +520,28 @@ public class TableCellLayoutManager exte
             }
         }
 
-        AreaAdditionUtil.addAreas(this, parentIter, layoutContext);
+        if (isDescendantOfTableHeaderOrFooter()) {
+            if (hasRetrieveTableMarker) {
+                if (isDescendantOfTableHeader && !savedAddAreasArguments) {
+                    saveAddAreasArguments(parentIter, layoutContext, spannedGridRowHeights, startRow, endRow,
+                            borderBeforeWhich, borderAfterWhich, firstOnPage, lastOnPage, painter,
+                            firstRowHeight);
+                }
+                recreateChildrenLMs();
+                int displayAlign = ((TableCell) this.getFObj()).getDisplayAlign();
+                TableCellBreaker breaker = new TableCellBreaker(this, cellIPD, displayAlign);
+                breaker.doLayout(usedBPD, false);
+                // this is needed so the next time the LMs are recreated they look like the originals; this
+                // is due to the fact that during the doLayout() above the FO tree changes when the
+                // retrieve-table-markers are resolved
+                clearRetrieveTableMarkerChildNodes(getChildLMs());
+            }
+        }
+
+        // if hasRetrieveTableMarker == true the areas were already added when the re-layout was done above
+        if (!hasRetrieveTableMarker) {
+            AreaAdditionUtil.addAreas(this, parentIter, layoutContext);
+        }
         // Re-adjust the cell's bpd as it may have been modified by the previous call
         // for some reason (?)
         curBlockArea.setBPD(cellBPD);
@@ -418,7 +552,11 @@ public class TableCellLayoutManager exte
                     getTableCell().getCommonBorderPaddingBackground(), this);
         }
 
-        flush();
+        if (flushArea) {
+            flush();
+        } else {
+            flushArea = true;
+        }
 
         curBlockArea = null;
 
@@ -604,4 +742,49 @@ public class TableCellLayoutManager exte
         return true;
     }
 
+    private class TableCellBreaker extends LocalBreaker {
+
+        public TableCellBreaker(TableCellLayoutManager lm, int ipd, int displayAlign) {
+            super(lm, ipd, displayAlign);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        protected void observeElementList(List elementList) {
+            String elementListID = lm.getParent().getFObj().getId() + "-" + lm.getFObj().getId();
+            ElementListObserver.observe(elementList, "table-cell", elementListID);
+        }
+
+    }
+
+    /**
+     * Registers the FO's markers on the current PageViewport and parent Table.
+     *
+     * @param isStarting    boolean indicating whether the markers qualify as 'starting'
+     * @param isFirst   boolean indicating whether the markers qualify as 'first'
+     * @param isLast    boolean indicating whether the markers qualify as 'last'
+     */
+    protected void registerMarkers(boolean isStarting, boolean isFirst, boolean isLast) {
+        Map<String, Marker> markers = getTableCell().getMarkers();
+        if (markers != null) {
+            getCurrentPV().registerMarkers(markers, isStarting, isFirst, isLast && isLastTrait);
+            if (!isDescendantOfTableHeaderOrFooter()) {
+                getTableLayoutManager().registerMarkers(markers, isStarting, isFirst, isLast && isLastTrait);
+            }
+        }
+    }
+
+    void setLastTrait(boolean isLast) {
+        isLastTrait = isLast;
+    }
+
+    /** {@inheritDoc} */
+    public void setParent(LayoutManager lm) {
+        this.parentLayoutManager = lm;
+        if (this.hasRetrieveTableMarker) {
+            this.getTableLayoutManager().flagAsHavingRetrieveTableMarker();
+        }
+    }
+
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -31,9 +31,11 @@ import org.apache.commons.logging.LogFac
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.flow.Marker;
 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.BreakElement;
 import org.apache.fop.layoutmgr.ElementListUtils;
@@ -400,9 +402,13 @@ public class TableContentLayoutManager i
             }
         }
 
-        Map markers = getTableLM().getTable().getMarkers();
+        // there may be table fragment markers stored; clear them since we are starting a new fragment
+        tableLM.clearTableFragmentMarkers();
+
+        // note: markers at table level are to be retrieved by the page, not by the table itself
+        Map<String, Marker> markers = getTableLM().getTable().getMarkers();
         if (markers != null) {
-            getTableLM().getCurrentPV().addMarkers(markers,
+            getTableLM().getCurrentPV().registerMarkers(markers,
                     true, getTableLM().isFirst(firstPos), getTableLM().isLast(lastCheckPos));
         }
 
@@ -430,6 +436,10 @@ public class TableContentLayoutManager i
             addBodyAreas(tablePositions.iterator(), painter, footerElements == null);
         }
 
+        // if there are TCLMs saved because they have a RetrieveTableMarker, we repeat the header areas now;
+        // this can also be done after the areas for the footer are added but should be the same as here
+        tableLM.repeatAddAreasForSavedTableHeaderTableCellLayoutManagers();
+
         if (footerElements != null) {
             boolean ancestorTreatAsArtifact = layoutContext.treatAsArtifact();
             layoutContext.setTreatAsArtifact(treatFooterAsArtifact);
@@ -442,7 +452,7 @@ public class TableContentLayoutManager i
         this.usedBPD += painter.getAccumulatedBPD();
 
         if (markers != null) {
-            getTableLM().getCurrentPV().addMarkers(markers,
+            getTableLM().getCurrentPV().registerMarkers(markers,
                     false, getTableLM().isFirst(firstPos), getTableLM().isLast(lastCheckPos));
         }
     }
@@ -503,14 +513,20 @@ public class TableContentLayoutManager i
      */
     private void addTablePartAreas(List positions, RowPainter painter, TablePart body,
             boolean isFirstPos, boolean isLastPos, boolean lastInBody, boolean lastOnPage) {
-        getTableLM().getCurrentPV().addMarkers(body.getMarkers(),
+        getTableLM().getCurrentPV().registerMarkers(body.getMarkers(),
                 true, isFirstPos, isLastPos);
+        if (body instanceof TableBody) {
+            getTableLM().registerMarkers(body.getMarkers(), true, isFirstPos, isLastPos);
+        }
         painter.startTablePart(body);
         for (Iterator iter = positions.iterator(); iter.hasNext();) {
             painter.handleTableContentPosition((TableContentPosition) iter.next());
         }
-        getTableLM().getCurrentPV().addMarkers(body.getMarkers(),
+        getTableLM().getCurrentPV().registerMarkers(body.getMarkers(),
                 false, isFirstPos, isLastPos);
+        if (body instanceof TableBody) {
+            getTableLM().registerMarkers(body.getMarkers(), false, isFirstPos, isLastPos);
+        }
         painter.endTablePart(lastInBody, lastOnPage);
     }
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java Thu Oct  4 14:46:01 2012
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -33,12 +34,16 @@ import org.apache.fop.datatypes.LengthBa
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.flow.Marker;
+import org.apache.fop.fo.flow.Markers;
+import org.apache.fop.fo.flow.RetrieveTableMarker;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableColumn;
 import org.apache.fop.fo.properties.KeepProperty;
 import org.apache.fop.layoutmgr.BlockLevelEventProducer;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
 import org.apache.fop.layoutmgr.BreakElement;
+import org.apache.fop.layoutmgr.BreakOpportunity;
 import org.apache.fop.layoutmgr.ConditionalElementListener;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthGlue;
@@ -62,7 +67,7 @@ import org.apache.fop.util.BreakUtil;
  * the render background.
  */
 public class TableLayoutManager extends BlockStackingLayoutManager
-                implements ConditionalElementListener {
+                implements ConditionalElementListener, BreakOpportunity {
 
     /**
      * logging instance
@@ -92,6 +97,15 @@ public class TableLayoutManager extends 
 
     private Position auxiliaryPosition;
 
+    // this holds a possible list of TCLMs that needed to have their addAreas() repeated
+    private List<TableCellLayoutManager> savedTCLMs;
+    private boolean areAllTCLMsSaved;
+
+    private Markers tableMarkers;
+    private Markers tableFragmentMarkers;
+
+    private boolean hasRetrieveTableMarker;
+
     /**
      * Temporary holder of column background informations for a table-cell's area.
      *
@@ -559,4 +573,112 @@ public class TableLayoutManager extends 
         tableUnit = 0.0;
     }
 
+    /**
+     * Saves a TableCellLayoutManager for later use.
+     * 
+     * @param tclm a TableCellLayoutManager that has a RetrieveTableMarker
+     */
+    protected void saveTableHeaderTableCellLayoutManagers(TableCellLayoutManager tclm) {
+        if (savedTCLMs == null) {
+            savedTCLMs = new ArrayList<TableCellLayoutManager>();
+        }
+        if (!areAllTCLMsSaved) {
+            savedTCLMs.add(tclm);
+        }
+    }
+
+    /**
+     * Calls addAreas() for each of the saved TableCellLayoutManagers.
+     */
+    protected void repeatAddAreasForSavedTableHeaderTableCellLayoutManagers() {
+        if (savedTCLMs == null) {
+            return;
+        }
+        // if we get to this stage then we are at the footer of the table fragment; this means that no more
+        // different TCLM need to be saved (we already have all); we flag the list as being complete then
+        areAllTCLMsSaved = true;
+        for (int i = 0; i < savedTCLMs.size(); i++) {
+            TableCellLayoutManager tclm = savedTCLMs.get(i);
+            tclm.repeatAddAreas();
+        }
+    }
+
+    /**
+     * Resolves a RetrieveTableMarker by finding a qualifying Marker to which it is bound to.
+     * @param rtm the RetrieveTableMarker to be resolved
+     * @return a bound RetrieveTableMarker instance or null if no qualifying Marker found
+     */
+    public RetrieveTableMarker resolveRetrieveTableMarker(RetrieveTableMarker rtm) {
+        String name = rtm.getRetrieveClassName();
+        int originalPosition = rtm.getPosition();
+        boolean changedPosition = false;
+
+        Marker mark = null;
+        // try the primary retrieve scope area, which is the same as table-fragment
+        mark = (tableFragmentMarkers == null) ? null : tableFragmentMarkers.resolve(rtm);
+        if (mark == null && rtm.getBoundary() != Constants.EN_TABLE_FRAGMENT) {
+            rtm.changePositionTo(Constants.EN_LAST_ENDING);
+            changedPosition = true;
+            // try the page scope area
+            mark = getCurrentPV().resolveMarker(rtm);
+            if (mark == null && rtm.getBoundary() != Constants.EN_PAGE) {
+                // try the table scope area
+                mark = (tableMarkers == null) ? null : tableMarkers.resolve(rtm);
+            }
+        }
+        if (changedPosition) {
+            // so that the next time it is called looks unchanged
+            rtm.changePositionTo(originalPosition);
+        }
+        if (mark == null) {
+            log.debug("found no marker with name: " + name);
+            return null;
+        } else {
+            rtm.bindMarker(mark);
+            return rtm;
+        }
+    }
+
+    /**
+     * Register the markers for this table.
+     *
+     * @param marks the map of markers to add
+     * @param starting if the area being added is starting or ending
+     * @param isfirst if the area being added has is-first trait
+     * @param islast if the area being added has is-last trait
+     */
+    public void registerMarkers(Map<String, Marker> marks, boolean starting, boolean isfirst,
+            boolean islast) {
+        if (tableMarkers == null) {
+            tableMarkers = new Markers();
+        }
+        tableMarkers.register(marks, starting, isfirst, islast);
+        if (tableFragmentMarkers == null) {
+            tableFragmentMarkers = new Markers();
+        }
+        tableFragmentMarkers.register(marks, starting, isfirst, islast);
+    }
+
+    /**
+     * Clears the list of markers in the current table fragment. Should be called just before starting a new
+     * header (that belongs to the next table fragment).
+     */
+    protected void clearTableFragmentMarkers() {
+        tableFragmentMarkers = null;
+    }
+
+    public void flagAsHavingRetrieveTableMarker() {
+        hasRetrieveTableMarker = true;
+    }
+
+    protected void possiblyRegisterMarkersForTables(Map<String, Marker> markers, boolean isStarting,
+            boolean isFirst, boolean isLast) {
+        // note: if we allow table-footer after a table-body this check should not be made and the markers
+        // should be registered regardless because the retrieval may be done only in the footer
+        if (hasRetrieveTableMarker) {
+            registerMarkers(markers, isStarting, isFirst, isLast);
+        }
+        super.possiblyRegisterMarkersForTables(markers, isStarting, isFirst, isLast);
+    }
+
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFDocument.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFDocument.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFDocument.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFDocument.java Thu Oct  4 14:46:01 2012
@@ -355,36 +355,20 @@ public class PDFDocument {
     }
 
     /**
-     * Creates and returns a structure element.
-     *
-     * @param structureType the structure type of the new element (value for the
-     * S entry)
-     * @param parent the parent of the new structure element in the structure
-     * hierarchy
-     * @return a dictionary of type StructElem
+     * Adds the given element to the structure tree.
      */
-    public PDFStructElem makeStructureElement(StructureType structureType, PDFObject parent) {
-        PDFStructElem structElem = new PDFStructElem(parent, structureType);
+    public void registerStructureElement(PDFStructElem structElem) {
         assignObjectNumber(structElem);
         structureTreeElements.add(structElem);
-        return structElem;
     }
 
     /**
-     * Creates and returns a structure element.
-     *
-     * @param structureType the structure type of the new element (value for the
-     * S entry)
-     * @param parent the parent of the new structure element in the structure
-     * hierarchy
-     * @param scope the scope of the given table header element
-     * @return a dictionary of type StructElem
+     * Assigns the given scope to the given element and adds it to the structure tree. The
+     * scope may not be added if it's not compatible with this document's PDF version.
      */
-    public PDFStructElem makeStructureElement(StructureType structureType, PDFObject parent,
-            Scope scope) {
-        PDFStructElem structElem = makeStructureElement(structureType, parent);
+    public void registerStructureElement(PDFStructElem structElem, Scope scope) {
+        registerStructureElement(structElem);
         versionController.addTableHeaderScopeAttribute(structElem, scope);
-        return structElem;
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFEncoding.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFEncoding.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFEncoding.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFEncoding.java Thu Oct  4 14:46:01 2012
@@ -23,6 +23,9 @@ package org.apache.fop.pdf;
 import java.util.Collections;
 import java.util.Set;
 
+import org.apache.fop.fonts.CodePointMapping;
+import org.apache.fop.fonts.SingleByteEncoding;
+
 /**
  * Class representing an /Encoding object.
  *
@@ -74,6 +77,38 @@ public class PDFEncoding extends PDFDict
     }
 
     /**
+     * Creates a PDFEncoding instance from a CodePointMapping instance.
+     * @param encoding the code point mapping (encoding)
+     * @param fontName ...
+     * @return the PDF Encoding dictionary (or a String with the predefined encoding)
+     */
+    static Object createPDFEncoding(SingleByteEncoding encoding, String fontName) {
+        //If encoding type is null, return null which causes /Encoding to be omitted.
+        if (encoding == null) {
+            return null;
+        }
+        String encodingName = null;
+        SingleByteEncoding baseEncoding;
+        if (fontName.indexOf("Symbol") >= 0) {
+            baseEncoding = CodePointMapping.getMapping(CodePointMapping.SYMBOL_ENCODING);
+            encodingName = baseEncoding.getName();
+        } else {
+            baseEncoding = CodePointMapping.getMapping(CodePointMapping.STANDARD_ENCODING);
+        }
+        PDFEncoding pdfEncoding = new PDFEncoding(encodingName);
+        PDFEncoding.DifferencesBuilder builder = pdfEncoding.createDifferencesBuilder();
+        PDFArray differences = builder.buildDifferencesArray(baseEncoding, encoding);
+        // TODO This method should not be returning an Object with two different outcomes
+        // resulting in subsequent `if (X instanceof Y)` statements.
+        if (differences.length() > 0) {
+            pdfEncoding.setDifferences(differences);
+            return pdfEncoding;
+        } else {
+            return encodingName;
+        }
+    }
+
+    /**
      * Indicates whether a given encoding is one of the predefined encodings.
      * @param name the encoding name (ex. "StandardEncoding")
      * @return true if it is a predefined encoding
@@ -83,6 +118,15 @@ public class PDFEncoding extends PDFDict
     }
 
     /**
+     * Indicates whether the given encoding type is that of standard encoding
+     * @param name The encoding name
+     * @return Returns true if it is of type standard encoding
+     */
+    static boolean hasStandardEncoding(String encodingName) {
+        return encodingName.equals(STANDARD_ENCODING);
+    }
+
+    /**
      * Creates and returns a new DifferencesBuilder instance for constructing the Differences
      * array.
      * @return the DifferencesBuilder
@@ -104,18 +148,44 @@ public class PDFEncoding extends PDFDict
      */
     public class DifferencesBuilder {
 
-        private PDFArray differences = new PDFArray();
         private int currentCode = -1;
 
         /**
+         * Creates an array containing the differences between two single-byte.
+         * font encodings.
+         * @param encodingA The first single-byte encoding
+         * @param encodingB The second single-byte encoding
+         * @return The PDFArray of differences between encodings
+         */
+        public PDFArray buildDifferencesArray(SingleByteEncoding encodingA,
+                SingleByteEncoding encodingB) {
+            PDFArray differences = new PDFArray();
+            int start = -1;
+            String[] baseNames = encodingA.getCharNameMap();
+            String[] charNameMap = encodingB.getCharNameMap();
+            for (int i = 0, ci = charNameMap.length; i < ci; i++) {
+                String basec = baseNames[i];
+                String c = charNameMap[i];
+                if (!basec.equals(c)) {
+                    if (start != i) {
+                        addDifference(i, differences);
+                        start = i;
+                    }
+                    addName(c, differences);
+                    start++;
+                }
+            }
+            return differences;
+        }
+
+        /**
          * Start a new difference.
          * @param code the starting code index inside the encoding
          * @return this builder instance
          */
-        public DifferencesBuilder addDifference(int code) {
+        private void addDifference(int code, PDFArray differences) {
             this.currentCode = code;
-            this.differences.add(new Integer(code));
-            return this;
+            differences.add(Integer.valueOf(code));
         }
 
         /**
@@ -123,28 +193,11 @@ public class PDFEncoding extends PDFDict
          * @param name the character name
          * @return this builder instance
          */
-        public DifferencesBuilder addName(String name) {
+        private void addName(String name, PDFArray differences) {
             if (this.currentCode < 0) {
                 throw new IllegalStateException("addDifference(int) must be called first");
             }
-            this.differences.add(new PDFName(name));
-            return this;
-        }
-
-        /**
-         * Indicates whether any differences have been recorded.
-         * @return true if there are differences.
-         */
-        public boolean hasDifferences() {
-            return (this.differences.length() > 0);
-        }
-
-        /**
-         * Creates and returns the PDFArray representing the Differences entry.
-         * @return the Differences entry
-         */
-        public PDFArray toPDFArray() {
-            return this.differences;
+            differences.add(new PDFName(name));
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFFactory.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFFactory.java Thu Oct  4 14:46:01 2012
@@ -44,9 +44,9 @@ import org.apache.xmlgraphics.java2d.col
 import org.apache.xmlgraphics.xmp.Metadata;
 
 import org.apache.fop.fonts.CIDFont;
-import org.apache.fop.fonts.CIDSubset;
 import org.apache.fop.fonts.CodePointMapping;
 import org.apache.fop.fonts.CustomFont;
+import org.apache.fop.fonts.EmbeddingMode;
 import org.apache.fop.fonts.FontDescriptor;
 import org.apache.fop.fonts.FontMetrics;
 import org.apache.fop.fonts.FontType;
@@ -1369,23 +1369,14 @@ public class PDFFactory {
                 } else {
                     cidMetrics = (CIDFont)metrics;
                 }
-                PDFCIDSystemInfo sysInfo
-                    = new PDFCIDSystemInfo(cidMetrics.getRegistry(),
-                                         cidMetrics.getOrdering(),
-                                         cidMetrics.getSupplement());
-                PDFCIDFont cidFont = new PDFCIDFont(subsetFontName,
-                                   cidMetrics.getCIDType(),
-                                   cidMetrics.getDefaultWidth(),
-                                   getSubsetWidths(cidMetrics), sysInfo,
-                                   (PDFCIDFontDescriptor)pdfdesc);
+                PDFCIDSystemInfo sysInfo = new PDFCIDSystemInfo(cidMetrics.getRegistry(),
+                        cidMetrics.getOrdering(), cidMetrics.getSupplement());
+                PDFCIDFont cidFont = new PDFCIDFont(subsetFontName, cidMetrics.getCIDType(),
+                        cidMetrics.getDefaultWidth(), getFontWidths(cidMetrics), sysInfo,
+                        (PDFCIDFontDescriptor) pdfdesc);
                 getDocument().registerObject(cidFont);
-
-                PDFCMap cmap = new PDFToUnicodeCMap(
-                        cidMetrics.getCIDSubset().getSubsetChars(),
-                        "fop-ucs-H",
-                        new PDFCIDSystemInfo("Adobe",
-                            "Identity",
-                            0), false);
+                PDFCMap cmap = new PDFToUnicodeCMap(cidMetrics.getCIDSet().getChars(), "fop-ucs-H",
+                        new PDFCIDSystemInfo("Adobe", "Identity", 0), false);
                 getDocument().registerObject(cmap);
                 ((PDFFontType0)font).setCMAP(cmap);
                 ((PDFFontType0)font).setDescendantFonts(cidFont);
@@ -1469,61 +1460,18 @@ public class PDFFactory {
     /**
      * Creates a PDFEncoding instance from a CodePointMapping instance.
      * @param encoding the code point mapping (encoding)
-     * @param fontNameHint ...
+     * @param fontName ...
      * @return the PDF Encoding dictionary (or a String with the predefined encoding)
      */
-    public Object createPDFEncoding(SingleByteEncoding encoding, String fontNameHint) {
-        SingleByteEncoding baseEncoding;
-        if (fontNameHint.indexOf("Symbol") >= 0) {
-            baseEncoding = CodePointMapping.getMapping(
-                    CodePointMapping.SYMBOL_ENCODING);
-        } else {
-            baseEncoding = CodePointMapping.getMapping(
-                    CodePointMapping.STANDARD_ENCODING);
-        }
-        PDFEncoding pdfEncoding = new PDFEncoding(baseEncoding.getName());
-        PDFEncoding.DifferencesBuilder builder
-                = pdfEncoding.createDifferencesBuilder();
-        int start = -1;
-        String[] baseNames = baseEncoding.getCharNameMap();
-        String[] charNameMap = encoding.getCharNameMap();
-        for (int i = 0, ci = charNameMap.length; i < ci; i++) {
-            String basec = baseNames[i];
-            String c = charNameMap[i];
-            if (!basec.equals(c)) {
-                if (start != i) {
-                    builder.addDifference(i);
-                    start = i;
-                }
-                builder.addName(c);
-                start++;
-            }
-        }
-        if (builder.hasDifferences()) {
-            pdfEncoding.setDifferences(builder.toPDFArray());
-            return pdfEncoding;
-        } else {
-            return baseEncoding.getName();
-        }
+    public Object createPDFEncoding(SingleByteEncoding encoding, String fontName) {
+        return PDFEncoding.createPDFEncoding(encoding, fontName);
     }
 
-    /**
-     * Creates and returns a width array with the widths of all the characters in the subset.
-     * @param cidFont the font
-     * @return the width array
-     */
-    public PDFWArray getSubsetWidths(CIDFont cidFont) {
+    private PDFWArray getFontWidths(CIDFont cidFont) {
         // Create widths for reencoded chars
         PDFWArray warray = new PDFWArray();
-        int[] widths = cidFont.getWidths();
-        CIDSubset subset = cidFont.getCIDSubset();
-        int[] tmpWidth = new int[subset.getSubsetSize()];
-
-        for (int i = 0, c = subset.getSubsetSize(); i < c; i++) {
-            int nwx = Math.max(0, subset.getGlyphIndexForSubsetIndex(i));
-            tmpWidth[i] = widths[nwx];
-        }
-        warray.addEntry(0, tmpWidth);
+        int[] widths = cidFont.getCIDSet().getWidths();
+        warray.addEntry(0, widths);
         return warray;
     }
 
@@ -1591,13 +1539,13 @@ public class PDFFactory {
     }
 
     private void buildCIDSet(PDFFontDescriptor descriptor, CIDFont cidFont) {
-        BitSet cidSubset = cidFont.getCIDSubset().getGlyphIndexBitSet();
-        PDFStream cidSet = makeStream(null, true);
-        ByteArrayOutputStream baout = new ByteArrayOutputStream(cidSubset.length() / 8 + 1);
+        BitSet cidSet = cidFont.getCIDSet().getGlyphIndices();
+        PDFStream pdfStream = makeStream(null, true);
+        ByteArrayOutputStream baout = new ByteArrayOutputStream(cidSet.length() / 8 + 1);
         int value = 0;
-        for (int i = 0, c = cidSubset.length(); i < c; i++) {
+        for (int i = 0, c = cidSet.length(); i < c; i++) {
             int shift = i % 8;
-            boolean b = cidSubset.get(i);
+            boolean b = cidSet.get(i);
             if (b) {
                 value |= 1 << 7 - shift;
             }
@@ -1608,8 +1556,8 @@ public class PDFFactory {
         }
         baout.write(value);
         try {
-            cidSet.setData(baout.toByteArray());
-            descriptor.setCIDSet(cidSet);
+            pdfStream.setData(baout.toByteArray());
+            descriptor.setCIDSet(pdfStream);
         } catch (IOException ioe) {
             log.error(
                     "Failed to write CIDSet [" + cidFont + "] "
@@ -1640,14 +1588,16 @@ public class PDFFactory {
                 if (desc.getFontType() == FontType.TYPE0) {
                     MultiByteFont mbfont = (MultiByteFont) font;
                     FontFileReader reader = new FontFileReader(in);
-
-                    TTFSubSetFile subset = new TTFSubSetFile();
-                    subset.readFont(reader, mbfont.getTTCName(), mbfont.getUsedGlyphs());
-                    byte[] subsetFont = subset.getFontSubset();
-                    // Only TrueType CID fonts are supported now
-
-                    embeddedFont = new PDFTTFStream(subsetFont.length);
-                    ((PDFTTFStream) embeddedFont).setData(subsetFont, subsetFont.length);
+                    byte[] fontBytes;
+                    if (font.getEmbeddingMode() == EmbeddingMode.FULL) {
+                        fontBytes = reader.getAllBytes();
+                    } else {
+                        TTFSubSetFile ttfFile = new TTFSubSetFile();
+                        ttfFile.readFont(reader, mbfont.getTTCName(), mbfont.getUsedGlyphs());
+                        fontBytes = ttfFile.getFontSubset();
+                    }
+                    embeddedFont = new PDFTTFStream(fontBytes.length);
+                    ((PDFTTFStream) embeddedFont).setData(fontBytes, fontBytes.length);
                 } else if (desc.getFontType() == FontType.TYPE1) {
                     PFBParser parser = new PFBParser();
                     PFBData pfb = parser.parsePFB(in);

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFFont.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFFont.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFFont.java Thu Oct  4 14:46:01 2012
@@ -70,7 +70,7 @@ public class PDFFont extends PDFDictiona
      * @param encoding the encoding
      */
     public void setEncoding(String encoding) {
-        if (encoding != null) {
+        if (encoding != null && !PDFEncoding.hasStandardEncoding(encoding)) {
             put("Encoding", new PDFName(encoding));
         }
     }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFStructElem.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFStructElem.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFStructElem.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFStructElem.java Thu Oct  4 14:46:01 2012
@@ -32,7 +32,8 @@ import org.apache.fop.util.LanguageTags;
 /**
  * Class representing a PDF Structure Element.
  */
-public class PDFStructElem extends PDFDictionary implements StructureTreeElement, CompressedObject {
+public class PDFStructElem extends StructureHierarchyMember
+        implements StructureTreeElement, CompressedObject {
 
     private StructureType structureType;
 
@@ -51,7 +52,7 @@ public class PDFStructElem extends PDFDi
      * @param parent parent of this element
      * @param structureType the structure type of this element
      */
-    PDFStructElem(PDFObject parent, StructureType structureType) {
+    public PDFStructElem(PDFObject parent, StructureType structureType) {
         this(parent);
         this.structureType = structureType;
         put("S", structureType.getName());
@@ -86,6 +87,7 @@ public class PDFStructElem extends PDFDi
      *
      * @param kid element to be added
      */
+    @Override
     public void addKid(PDFObject kid) {
         if (kids == null) {
             kids = new ArrayList<PDFObject>();

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFStructTreeRoot.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFStructTreeRoot.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFStructTreeRoot.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/PDFStructTreeRoot.java Thu Oct  4 14:46:01 2012
@@ -22,7 +22,7 @@ package org.apache.fop.pdf;
 /**
  * Class representing a PDF /StructTreeRoot dictionary.
  */
-public class PDFStructTreeRoot extends PDFDictionary {
+public class PDFStructTreeRoot extends StructureHierarchyMember {
 
     /**
      * Creates a new /StructTreeRoot dictionary.
@@ -49,6 +49,7 @@ public class PDFStructTreeRoot extends P
      *
      * @param kid an object to be added to the K entry
      */
+    @Override
     public void addKid(PDFObject kid) {
         getKids().add(kid);
     }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/StandardStructureTypes.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/StandardStructureTypes.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/StandardStructureTypes.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/pdf/StandardStructureTypes.java Thu Oct  4 14:46:01 2012
@@ -111,6 +111,11 @@ public final class StandardStructureType
             return name;
         }
 
+        @Override
+        public String toString() {
+            return name.toString().substring(1);
+        }
+
     }
 
     private static final Map<String, StructureType> STRUCTURE_TYPES = new HashMap<String, StructureType>();

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java Thu Oct  4 14:46:01 2012
@@ -328,7 +328,8 @@ public class AFPDocumentHandler extends 
                 case IN_PAGE_HEADER:
                     String name = aps.getName();
                     String value = aps.getValue();
-                    dataStream.createTagLogicalElement(name, value);
+                    int encoding = aps.getEncoding();
+                    dataStream.createTagLogicalElement(name, value, encoding);
                     break;
                 default:
                     throw new IFException(

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java Thu Oct  4 14:46:01 2012
@@ -144,6 +144,12 @@ public class AFPExtensionHandler extends
                 if (placement != null && placement.length() > 0) {
                     pageSetupExtn.setPlacement(ExtensionPlacement.fromXMLValue(placement));
                 }
+
+                String encoding =  lastAttributes.getValue("encoding");
+                if (encoding != null && pageSetupExtn != null) {
+                    pageSetupExtn.setEncoding(Integer.parseInt(encoding));
+                }
+
                 if (content.length() > 0 && pageSetupExtn != null) {
                     pageSetupExtn.setContent(content.toString());
                     content.setLength(0); //Reset text buffer (see characters())

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java Thu Oct  4 14:46:01 2012
@@ -23,6 +23,8 @@ import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
 
+import org.apache.fop.afp.modca.TagLogicalElement;
+
 /**
  * This is the pass-through value object for the AFP extension.
  */
@@ -48,6 +50,27 @@ public class AFPPageSetup extends AFPExt
     protected ExtensionPlacement placement = ExtensionPlacement.DEFAULT;
 
     /**
+     * the CCSID character set encoding
+     */
+    protected int encoding = TagLogicalElement.State.ENCODING_NONE;
+
+    /**
+     *
+     * @return CCSID character set encoding
+     */
+    public int getEncoding() {
+        return encoding;
+    }
+
+    /**
+     *
+     * @param encoding CCSID character set encoding
+     */
+    public void setEncoding(int encoding) {
+        this.encoding = encoding;
+    }
+
+    /**
      * Default constructor.
      *
      * @param elementName the name of the setup code object, may be null

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java Thu Oct  4 14:46:01 2012
@@ -35,6 +35,7 @@ import org.apache.fop.fo.extensions.Exte
  */
 public class AFPPageSetupElement extends AbstractAFPExtensionObject {
 
+    private static final String ATT_ENCODING = "encoding";
     private static final String ATT_SRC = "src";
 
     /**
@@ -105,6 +106,16 @@ public class AFPPageSetupElement extends
             } else {
                 missingPropertyError(AFPPageSetup.ATT_VALUE);
             }
+            attr = attlist.getValue(ATT_ENCODING);
+            if (attr != null) {
+                try {
+                    pageSetup.setEncoding(Integer.parseInt(attr));
+                } catch (NumberFormatException nfe) {
+                    invalidPropertyValueError(ATT_ENCODING, attr, nfe);
+                }
+
+            }
+
         }
         String placement = attlist.getValue(AFPPageSetup.ATT_PLACEMENT);
         if (placement != null && placement.length() > 0) {

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java Thu Oct  4 14:46:01 2012
@@ -84,7 +84,7 @@ public abstract class AbstractBitmapDocu
         super(context);
         //Set target resolution
         int dpi = Math.round(context.getUserAgent().getTargetResolution());
-        getSettings().getWriterParams().setResolution(dpi);
+        getSettings().setResolution(dpi);
 
         Map renderingOptions = getUserAgent().getRendererOptions();
         setTargetBitmapSize((Dimension)renderingOptions.get(TARGET_BITMAP_SIZE));

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java Thu Oct  4 14:46:01 2012
@@ -107,4 +107,27 @@ public class BitmapRenderingSettings ext
         return this.qualityRendering;
     }
 
+    /**
+     * Sets the compression method for the image writer.
+     * @param compressionMethod the compression method name
+     */
+    public void setCompressionMethod(String compressionMethod) {
+        writerParams.setCompressionMethod(compressionMethod);
+    }
+
+    /**
+     * Returns the compression method being used by the image writer.
+     * @return the compression method in use
+     */
+    public String getCompressionMethod() {
+        return writerParams.getCompressionMethod();
+    }
+
+    /**
+     * Sets the resolution of the output image.
+     * @param dpi the dots-per-inch of the image
+     */
+    public void setResolution(int dpi) {
+        writerParams.setResolution(dpi);
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java Thu Oct  4 14:46:01 2012
@@ -19,6 +19,8 @@
 
 package org.apache.fop.render.bitmap;
 
+import org.apache.xmlgraphics.image.writer.ResolutionUnit;
+
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser;
 import org.apache.fop.render.intermediate.IFContext;
@@ -32,6 +34,7 @@ public class TIFFDocumentHandler extends
 
     TIFFDocumentHandler(IFContext context) {
         super(context);
+        getSettings().getWriterParams().setResolutionUnit(ResolutionUnit.CENTIMETER);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java Thu Oct  4 14:46:01 2012
@@ -38,7 +38,6 @@ import org.apache.commons.logging.Log;
 import org.apache.xmlgraphics.image.GraphicsUtil;
 import org.apache.xmlgraphics.image.rendered.FormatRed;
 import org.apache.xmlgraphics.image.writer.ImageWriter;
-import org.apache.xmlgraphics.image.writer.ImageWriterParams;
 import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
 import org.apache.xmlgraphics.image.writer.MultiImageWriter;
 
@@ -47,9 +46,9 @@ import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.java2d.Java2DRenderer;
 
-import static org.apache.fop.render.bitmap.TIFFCompressionValues.CCITT_T4;
-import static org.apache.fop.render.bitmap.TIFFCompressionValues.CCITT_T6;
-import static org.apache.fop.render.bitmap.TIFFCompressionValues.PACKBITS;
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T4;
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T6;
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.PACKBITS;
 
 /**
  * <p>
@@ -74,11 +73,7 @@ import static org.apache.fop.render.bitm
  */
 public class TIFFRenderer extends Java2DRenderer {
 
-    /** ImageWriter parameters */
-    private ImageWriterParams writerParams;
-
-    /** Image Type as parameter for the BufferedImage constructor (see BufferedImage.TYPE_*) */
-    private int bufferedImageType = BufferedImage.TYPE_INT_ARGB;
+    private BitmapRenderingSettings imageSettings;
 
     private OutputStream outputStream;
 
@@ -94,11 +89,11 @@ public class TIFFRenderer extends Java2D
      */
     public TIFFRenderer(FOUserAgent userAgent) {
         super(userAgent);
-        writerParams = new ImageWriterParams();
-        writerParams.setCompressionMethod(PACKBITS.getName());
-
+        imageSettings = new BitmapRenderingSettings();
+        imageSettings.setCompressionMethod(PACKBITS.getName());
+        imageSettings.setBufferedImageType(BufferedImage.TYPE_INT_ARGB);
         int dpi = Math.round(userAgent.getTargetResolution());
-        writerParams.setResolution(dpi);
+        imageSettings.setResolution(dpi);
     }
 
     /** {@inheritDoc} */
@@ -129,7 +124,7 @@ public class TIFFRenderer extends Java2D
                 // Write all pages/images
                 while (pageImagesItr.hasNext()) {
                     RenderedImage img = (RenderedImage) pageImagesItr.next();
-                    multiWriter.writeImage(img, writerParams);
+                    multiWriter.writeImage(img, imageSettings.getWriterParams());
                 }
             } finally {
                 multiWriter.close();
@@ -139,7 +134,7 @@ public class TIFFRenderer extends Java2D
             if (pageImagesItr.hasNext()) {
                 renderedImage = (RenderedImage) pageImagesItr.next();
             }
-            writer.writeImage(renderedImage, outputStream, writerParams);
+            writer.writeImage(renderedImage, outputStream, imageSettings.getWriterParams());
             if (pageImagesItr.hasNext()) {
                 BitmapRendererEventProducer eventProducer
                     = BitmapRendererEventProducer.Provider.get(
@@ -156,7 +151,7 @@ public class TIFFRenderer extends Java2D
 
     /** {@inheritDoc} */
     protected BufferedImage getBufferedImage(int bitmapWidth, int bitmapHeight) {
-        return new BufferedImage(bitmapWidth, bitmapHeight, bufferedImageType);
+        return new BufferedImage(bitmapWidth, bitmapHeight, imageSettings.getBufferedImageType());
     }
 
     /** Private inner class to lazy page rendering. */
@@ -195,7 +190,7 @@ public class TIFFRenderer extends Java2D
                 throw new NoSuchElementException(e.getMessage());
             }
 
-            TIFFCompressionValues compression = TIFFCompressionValues.getValue(writerParams.getCompressionMethod());
+            TIFFCompressionValue compression = TIFFCompressionValue.getType(imageSettings.getCompressionMethod());
             if (compression == CCITT_T4 || compression == CCITT_T6) {
                 return pageImage;
             } else {
@@ -226,11 +221,14 @@ public class TIFFRenderer extends Java2D
 
     /** @param bufferedImageType an image type */
     public void setBufferedImageType(int bufferedImageType) {
-        this.bufferedImageType = bufferedImageType;
+        imageSettings.setBufferedImageType(bufferedImageType);
     }
 
-    /** @return image writer parameters */
-    public ImageWriterParams getWriterParams() {
-        return writerParams;
+    /**
+     * Returns the settings for the image rendering.
+     * @return the image rendering settings
+     */
+    public BitmapRenderingSettings getRenderingSettings() {
+        return imageSettings;
     }
 }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java Thu Oct  4 14:46:01 2012
@@ -23,21 +23,24 @@ import java.util.EnumMap;
 
 import org.apache.avalon.framework.configuration.Configuration;
 
-import org.apache.xmlgraphics.util.MimeConstants;
-
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.fonts.DefaultFontConfig;
 import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser;
 import org.apache.fop.render.RendererConfigOption;
 
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.PACKBITS;
+
 /**
  * The renderer configuration object for the TIFF renderer.
  */
 public final class TIFFRendererConfig extends BitmapRendererConfig {
 
     public enum TIFFRendererOption implements RendererConfigOption {
-        COMPRESSION("compression", TIFFCompressionValues.PACKBITS);
+        COMPRESSION("compression", PACKBITS),
+        /** option to encode one row per strip or a all rows in a single strip*/
+        SINGLE_STRIP("single-strip", Boolean.FALSE);
 
         private final String name;
         private final Object defaultValue;
@@ -63,8 +66,16 @@ public final class TIFFRendererConfig ex
         super(fontConfig);
     }
 
-    public TIFFCompressionValues getCompressionType() {
-        return (TIFFCompressionValues) params.get(TIFFRendererOption.COMPRESSION);
+    public TIFFCompressionValue getCompressionType() {
+        return (TIFFCompressionValue) params.get(TIFFRendererOption.COMPRESSION);
+    }
+
+    /**
+     * @return True if all rows are contained in a single strip, False each strip contains one row or null
+     * if not set.
+     */
+    public Boolean isSingleStrip() {
+        return (Boolean) params.get(TIFFRendererOption.SINGLE_STRIP);
     }
 
     /**
@@ -92,9 +103,10 @@ public final class TIFFRendererConfig ex
                     .parse(cfg, userAgent.validateStrictly()));
             super.build(config, userAgent, cfg);
             if (cfg != null) {
-            setParam(TIFFRendererOption.COMPRESSION,
-                        TIFFCompressionValues.getValue(getValue(cfg,
-                                TIFFRendererOption.COMPRESSION)));
+                setParam(TIFFRendererOption.COMPRESSION,
+                        TIFFCompressionValue.getType(getValue(cfg, TIFFRendererOption.COMPRESSION)));
+                setParam(TIFFRendererOption.SINGLE_STRIP, Boolean.valueOf(getValue(cfg,
+                                TIFFRendererOption.SINGLE_STRIP)));
             }
             return config;
         }

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java Thu Oct  4 14:46:01 2012
@@ -19,13 +19,9 @@
 
 package org.apache.fop.render.bitmap;
 
-import java.awt.image.BufferedImage;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import org.apache.xmlgraphics.image.writer.ImageWriterParams;
-
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.render.Renderer;
@@ -33,9 +29,7 @@ import org.apache.fop.render.RendererCon
 import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser;
 import org.apache.fop.render.intermediate.IFDocumentHandler;
 
-import static org.apache.fop.render.bitmap.TIFFCompressionValues.CCITT_T4;
-import static org.apache.fop.render.bitmap.TIFFCompressionValues.CCITT_T6;
-import static org.apache.fop.render.bitmap.TIFFCompressionValues.NONE;
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.NONE;
 
 /**
  * TIFF Renderer configurator
@@ -62,43 +56,40 @@ public class TIFFRendererConfigurator ex
         final TIFFRendererConfig config = (TIFFRendererConfig) getRendererConfig(renderer);
         if (config != null) {
             TIFFRenderer tiffRenderer = (TIFFRenderer) renderer;
-            //set compression
-            tiffRenderer.setBufferedImageType(getCompressionType(config, tiffRenderer.getWriterParams()));
+            setCompressionMethod(config.getCompressionType(), tiffRenderer.getRenderingSettings());
         }
         super.configure(renderer);
     }
 
-    private int getCompressionType(TIFFRendererConfig config, ImageWriterParams writerParms)
-            throws FOPException {
-        //Some compression formats need a special image format:
-        TIFFCompressionValues compression = config.getCompressionType();
+    private void setCompressionMethod(TIFFCompressionValue compression,
+            BitmapRenderingSettings settings) throws FOPException {
         if (compression != null) {
             if (compression != NONE) {
-                writerParms.setCompressionMethod(compression.getName());
+                settings.setCompressionMethod(compression.getName());
             }
             if (LOG.isInfoEnabled()) {
                 LOG.info("TIFF compression set to " + compression.getName());
             }
+            if (compression.hasCCITTCompression()) {
+                settings.setBufferedImageType(compression.getImageType());
+            }
         }
-        return getBufferedImageTypeFor(compression);
     }
 
-    private int getBufferedImageTypeFor(TIFFCompressionValues compressionType) {
-        if (compressionType == CCITT_T6 || compressionType == CCITT_T4) {
-            return BufferedImage.TYPE_BYTE_BINARY;
-        } else {
-            return BufferedImage.TYPE_INT_ARGB;
-        }
+    private boolean isSingleStrip(TIFFRendererConfig config) {
+        Boolean singleRowPerStrip = config.isSingleStrip();
+        return singleRowPerStrip == null ? false : singleRowPerStrip;
     }
 
-    /** {@inheritDoc} */
+    @Override
     public void configure(IFDocumentHandler documentHandler) throws FOPException {
-        final TIFFRendererConfig tiffConfig = (TIFFRendererConfig) getRendererConfig(documentHandler);
-        if (tiffConfig != null) {
+        final TIFFRendererConfig config = (TIFFRendererConfig) getRendererConfig(documentHandler);
+        if (config != null) {
             TIFFDocumentHandler tiffHandler = (TIFFDocumentHandler) documentHandler;
             BitmapRenderingSettings settings = tiffHandler.getSettings();
             configure(documentHandler, settings, new TIFFRendererConfigParser());
-            settings.setBufferedImageType(getCompressionType(tiffConfig, settings.getWriterParams()));
+            setCompressionMethod(config.getCompressionType(), settings);
+            settings.getWriterParams().setSingleStrip(isSingleStrip(config));
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFEventProducer.java?rev=1394098&r1=1394097&r2=1394098&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFEventProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFEventProducer.java Thu Oct  4 14:46:01 2012
@@ -59,12 +59,11 @@ public interface PDFEventProducer extend
      * Custom structure type is not standard as per the PDF reference.
      *
      * @param source the event source
-     * @param fo the local name of the formatting object having the custom type
      * @param type custom structure type
      * @param fallback default structure type used as a fallback
      * @event.severity WARN
      */
-    void nonStandardStructureType(Object source, String fo, String type, String fallback);
+    void nonStandardStructureType(Object source, String type, String fallback);
 
     /**
      * The encryption length must be a multiple of 8 between 40 and 128.



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