]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added convenience methods performing the cast between FObj and Block, FObj and BlockC...
authorLuca Furini <lfurini@apache.org>
Thu, 14 Apr 2005 16:15:29 +0000 (16:15 +0000)
committerLuca Furini <lfurini@apache.org>
Thu, 14 Apr 2005 16:15:29 +0000 (16:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_KnuthStylePageBreaking@198583 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java

index 2a8c668b775cdd3af704aef6fc8d5d9e78e1eb00..423fae12ce46698c57f01cd7983b5c3430db0ec3 100644 (file)
@@ -41,7 +41,6 @@ import org.apache.fop.traits.SpaceVal;
  * LayoutManager for a block-container FO.
  */
 public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
-/*LF*/  //    private BlockContainer fobj;
     
     private BlockViewport viewportBlockArea;
     private Block referenceArea;
@@ -90,41 +89,40 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
      */
     public BlockContainerLayoutManager(BlockContainer node) {
         super(node);
-/*LF*/  //        fobj = node;
     }
     
     /**
      * @see org.apache.fop.layoutmgr.AbstractLayoutManager#initProperties()
      */
     protected void initProperties() {
-        abProps = ((BlockContainer) fobj).getCommonAbsolutePosition();
-        foBlockSpaceBefore = new SpaceVal(((BlockContainer) fobj).getCommonMarginBlock().spaceBefore).getSpace();
-        foBlockSpaceAfter = new SpaceVal(((BlockContainer) fobj).getCommonMarginBlock().spaceAfter).getSpace();
+        abProps = getBlockContainerFO().getCommonAbsolutePosition();
+        foBlockSpaceBefore = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceBefore).getSpace();
+        foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceAfter).getSpace();
 
-        boolean rotated = (((BlockContainer) fobj).getReferenceOrientation() % 180 != 0);
+        boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
         if (rotated) {
-            height = ((BlockContainer) fobj).getInlineProgressionDimension().getOptimum().getLength();
-            width = ((BlockContainer) fobj).getBlockProgressionDimension().getOptimum().getLength();
+            height = getBlockContainerFO().getInlineProgressionDimension().getOptimum().getLength();
+            width = getBlockContainerFO().getBlockProgressionDimension().getOptimum().getLength();
         } else {
-            height = ((BlockContainer) fobj).getBlockProgressionDimension().getOptimum().getLength();
-            width = ((BlockContainer) fobj).getInlineProgressionDimension().getOptimum().getLength();
+            height = getBlockContainerFO().getBlockProgressionDimension().getOptimum().getLength();
+            width = getBlockContainerFO().getInlineProgressionDimension().getOptimum().getLength();
         }
         
 /*LF*/  bpUnit = 0; //layoutProps.blockProgressionUnit;
 /*LF*/  if (bpUnit == 0) {
 /*LF*/      // use optimum space values
-/*LF*/      adjustedSpaceBefore = ((BlockContainer) fobj).getCommonMarginBlock().spaceBefore.getSpace().getOptimum().getLength().getValue();
-/*LF*/      adjustedSpaceAfter = ((BlockContainer) fobj).getCommonMarginBlock().spaceAfter.getSpace().getOptimum().getLength().getValue();
+/*LF*/      adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock().spaceBefore.getSpace().getOptimum().getLength().getValue();
+/*LF*/      adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock().spaceAfter.getSpace().getOptimum().getLength().getValue();
 /*LF*/  } else {
 /*LF*/      // use minimum space values
-/*LF*/      adjustedSpaceBefore = ((BlockContainer) fobj).getCommonMarginBlock().spaceBefore.getSpace().getMinimum().getLength().getValue();
-/*LF*/      adjustedSpaceAfter = ((BlockContainer) fobj).getCommonMarginBlock().spaceAfter.getSpace().getMinimum().getLength().getValue();
+/*LF*/      adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock().spaceBefore.getSpace().getMinimum().getLength().getValue();
+/*LF*/      adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock().spaceAfter.getSpace().getMinimum().getLength().getValue();
 /*LF*/  }
     }
 
     /** @return the content IPD */
     protected int getRotatedIPD() {
-        return ((BlockContainer) fobj).getInlineProgressionDimension().getOptimum().getLength().getValue();
+        return getBlockContainerFO().getInlineProgressionDimension().getOptimum().getLength().getValue();
     }
 
     private int getSpaceBefore() {
@@ -133,16 +131,16 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
     
     private int getBPIndents() {
         int indents = 0;
-        indents += ((BlockContainer) fobj).getCommonMarginBlock().spaceBefore.getOptimum().getLength().getValue();
-        indents += ((BlockContainer) fobj).getCommonMarginBlock().spaceAfter.getOptimum().getLength().getValue();
-        indents += ((BlockContainer) fobj).getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
+        indents += getBlockContainerFO().getCommonMarginBlock().spaceBefore.getOptimum().getLength().getValue();
+        indents += getBlockContainerFO().getCommonMarginBlock().spaceAfter.getOptimum().getLength().getValue();
+        indents += getBlockContainerFO().getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
         return indents;
     }
     
     private int getIPIndents() {
         int iIndents = 0;
-        iIndents += ((BlockContainer) fobj).getCommonMarginBlock().startIndent.getValue();
-        iIndents += ((BlockContainer) fobj).getCommonMarginBlock().endIndent.getValue();
+        iIndents += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
+        iIndents += getBlockContainerFO().getCommonMarginBlock().endIndent.getValue();
         return iIndents;
     }
     
@@ -164,7 +162,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         }
         
         autoHeight = false;
-        boolean rotated = (((BlockContainer) fobj).getReferenceOrientation() % 180 != 0); //vals[0] == 0.0;
+        boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); //vals[0] == 0.0;
         referenceIPD = context.getRefIPD();
         int maxbpd = context.getStackLimit().opt;
         int allocBPD, allocIPD;
@@ -186,19 +184,19 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         vpContentIPD = allocIPD - getIPIndents();
         
         double contentRectOffsetX = 0;
-        contentRectOffsetX += ((BlockContainer) fobj).getCommonMarginBlock().startIndent.getValue();
+        contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
         double contentRectOffsetY = 0;
-        //contentRectOffsetY += ((BlockContainer) fobj).getCommonMarginBlock().startIndent.getValue();
+        //contentRectOffsetY += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
         //contentRectOffsetY += getSpaceBefore();
-        contentRectOffsetY += ((BlockContainer) fobj).getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
-        contentRectOffsetY += ((BlockContainer) fobj).getCommonBorderPaddingBackground().getPaddingBefore(false);
+        contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
+        contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getPaddingBefore(false);
         
         Rectangle2D rect = new Rectangle2D.Double(
                 contentRectOffsetX, contentRectOffsetY, 
                 vpContentIPD, vpContentBPD);
         relDims = new FODimension(0, 0);
-        absoluteCTM = CTM.getCTMandRelDims(((BlockContainer) fobj).getReferenceOrientation(),
-                ((BlockContainer) fobj).getWritingMode(), rect, relDims);
+        absoluteCTM = CTM.getCTMandRelDims(getBlockContainerFO().getReferenceOrientation(),
+                getBlockContainerFO().getWritingMode(), rect, relDims);
 
         MinOptMax stackLimit = new MinOptMax(relDims.bpd);
 
@@ -324,9 +322,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
 
             if (contentOverflows) {
                 log.warn("Contents overflow block-container viewport: clipping");
-                if (((BlockContainer) fobj).getOverflow() == EN_HIDDEN) {
+                if (getBlockContainerFO().getOverflow() == EN_HIDDEN) {
                     clip = true;
-                } else if (((BlockContainer) fobj).getOverflow() == EN_ERROR_IF_OVERFLOW) {
+                } else if (getBlockContainerFO().getOverflow() == EN_ERROR_IF_OVERFLOW) {
                     //TODO Throw layout exception
                     clip = true;
                 }
@@ -386,19 +384,19 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         vpContentIPD = allocIPD - getIPIndents();
         
         double contentRectOffsetX = offset.getX();
-        contentRectOffsetX += ((BlockContainer) fobj).getCommonMarginBlock().startIndent.getValue();
+        contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
         double contentRectOffsetY = offset.getY();
         contentRectOffsetY += getSpaceBefore();
-        contentRectOffsetY += ((BlockContainer) fobj).getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
-        contentRectOffsetY += ((BlockContainer) fobj).getCommonBorderPaddingBackground().getPaddingBefore(false);
+        contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
+        contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getPaddingBefore(false);
         
         Rectangle2D rect = new Rectangle2D.Double(
                 contentRectOffsetX, contentRectOffsetY, 
                 vpContentIPD, vpContentBPD);
         relDims = new FODimension(0, 0);
         absoluteCTM = CTM.getCTMandRelDims(
-                ((BlockContainer) fobj).getReferenceOrientation(),
-                ((BlockContainer) fobj).getWritingMode(), 
+                getBlockContainerFO().getReferenceOrientation(),
+                getBlockContainerFO().getWritingMode(), 
                 rect, relDims);
 
         MinOptMax range = new MinOptMax(relDims.ipd);
@@ -415,9 +413,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
             //TODO Maybe check for page overflow when autoHeight=true
             if (!autoHeight & (contentOverflows/*usedBPD > relDims.bpd*/)) {
                 log.warn("Contents overflow block-container viewport: clipping");
-                if (((BlockContainer) fobj).getOverflow() == EN_HIDDEN) {
+                if (getBlockContainerFO().getOverflow() == EN_HIDDEN) {
                     clip = true;
-                } else if (((BlockContainer) fobj).getOverflow() == EN_ERROR_IF_OVERFLOW) {
+                } else if (getBlockContainerFO().getOverflow() == EN_ERROR_IF_OVERFLOW) {
                     //TODO Throw layout exception
                     clip = true;
                 }
@@ -504,7 +502,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         }
 
         protected int getCurrentDisplayAlign() {
-            return ((BlockContainer) fobj).getDisplayAlign();
+            return getBlockContainerFO().getDisplayAlign();
         }
         
         protected boolean hasMoreContent() {
@@ -555,7 +553,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         }
 
         autoHeight = false;
-        boolean rotated = (((BlockContainer) fobj).getReferenceOrientation() % 180 != 0); //vals[0] == 0.0;
+        boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); //vals[0] == 0.0;
         referenceIPD = context.getRefIPD();
         int maxbpd = context.getStackLimit().opt;
         int allocBPD, allocIPD;
@@ -577,19 +575,19 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         vpContentIPD = allocIPD - getIPIndents();
         
         double contentRectOffsetX = 0;
-        contentRectOffsetX += ((BlockContainer) fobj).getCommonMarginBlock().startIndent.getValue();
+        contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
         double contentRectOffsetY = 0;
-        //contentRectOffsetY += ((BlockContainer) fobj).getCommonMarginBlock().startIndent.getValue();
+        //contentRectOffsetY += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
         //contentRectOffsetY += getSpaceBefore();
-        contentRectOffsetY += ((BlockContainer) fobj).getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
-        contentRectOffsetY += ((BlockContainer) fobj).getCommonBorderPaddingBackground().getPaddingBefore(false);
+        contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
+        contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getPaddingBefore(false);
         
         Rectangle2D rect = new Rectangle2D.Double(
                 contentRectOffsetX, contentRectOffsetY, 
                 vpContentIPD, vpContentBPD);
         relDims = new FODimension(0, 0);
-        absoluteCTM = CTM.getCTMandRelDims(((BlockContainer) fobj).getReferenceOrientation(),
-                ((BlockContainer) fobj).getWritingMode(), rect, relDims);
+        absoluteCTM = CTM.getCTMandRelDims(getBlockContainerFO().getReferenceOrientation(),
+                getBlockContainerFO().getWritingMode(), rect, relDims);
         //double[] vals = absoluteCTM.toArray();
 
         MinOptMax stackLimit;
@@ -624,10 +622,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         BreakPoss lastPos = null;
 
         //TODO fix layout dimensions!
-        ((BlockContainer) fobj).setLayoutDimension(PercentBase.BLOCK_IPD, allocIPD);
-        ((BlockContainer) fobj).setLayoutDimension(PercentBase.BLOCK_BPD, allocBPD);
-        ((BlockContainer) fobj).setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, relDims.ipd);
-        ((BlockContainer) fobj).setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, relDims.bpd);
+        getBlockContainerFO().setLayoutDimension(PercentBase.BLOCK_IPD, allocIPD);
+        getBlockContainerFO().setLayoutDimension(PercentBase.BLOCK_BPD, allocBPD);
+        getBlockContainerFO().setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, relDims.ipd);
+        getBlockContainerFO().setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, relDims.bpd);
 
         while ((curLM = getChildLM()) != null) {
             //Treat bc with fixed BPD as non-breakable
@@ -777,19 +775,19 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         vpContentIPD = allocIPD - getIPIndents();
         
         double contentRectOffsetX = offset.getX();
-        contentRectOffsetX += ((BlockContainer) fobj).getCommonMarginBlock().startIndent.getValue();
+        contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue();
         double contentRectOffsetY = offset.getY();
         contentRectOffsetY += getSpaceBefore();
-        contentRectOffsetY += ((BlockContainer) fobj).getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
-        contentRectOffsetY += ((BlockContainer) fobj).getCommonBorderPaddingBackground().getPaddingBefore(false);
+        contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
+        contentRectOffsetY += getBlockContainerFO().getCommonBorderPaddingBackground().getPaddingBefore(false);
         
         Rectangle2D rect = new Rectangle2D.Double(
                 contentRectOffsetX, contentRectOffsetY, 
                 vpContentIPD, vpContentBPD);
         relDims = new FODimension(0, 0);
         absoluteCTM = CTM.getCTMandRelDims(
-                ((BlockContainer) fobj).getReferenceOrientation(),
-                ((BlockContainer) fobj).getWritingMode(), 
+                getBlockContainerFO().getReferenceOrientation(),
+                getBlockContainerFO().getWritingMode(), 
                 rect, relDims);
         
         while ((curLM = getChildLM()) != null) {
@@ -819,9 +817,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         //TODO Maybe check for page overflow when autoHeight=true
         if (!autoHeight & (usedBPD > relDims.bpd)) {
             log.warn("Contents overflow block-container viewport: clipping");
-            if (((BlockContainer) fobj).getOverflow() == EN_HIDDEN) {
+            if (getBlockContainerFO().getOverflow() == EN_HIDDEN) {
                 clip = true;
-            } else if (((BlockContainer) fobj).getOverflow() == EN_ERROR_IF_OVERFLOW) {
+            } else if (getBlockContainerFO().getOverflow() == EN_ERROR_IF_OVERFLOW) {
                 //TODO Throw layout exception
                 clip = true;
             }
@@ -843,7 +841,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
             addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
         }
 
-        addID(((BlockContainer) fobj).getId());
+        addID(getBlockContainerFO().getId());
         //addMarkers(true, bp1.isFirstArea(), bp1.isLastArea());
         addMarkers(true, true, false);
 
@@ -949,8 +947,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
             // add space before and / or after the paragraph
             // to reach a multiple of bpUnit
             if (bSpaceBefore && bSpaceAfter) {
-                foBlockSpaceBefore = new SpaceVal(((BlockContainer) fobj).getCommonMarginBlock().spaceBefore).getSpace();
-                foBlockSpaceAfter = new SpaceVal(((BlockContainer) fobj).getCommonMarginBlock().spaceAfter).getSpace();
+                foBlockSpaceBefore = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceBefore).getSpace();
+                foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceAfter).getSpace();
                 adjustedSpaceBefore = (neededUnits(splitLength
                         + foBlockSpaceBefore.min
                         + foBlockSpaceAfter.min)
@@ -998,7 +996,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
             bcpos.getBreaker().addContainedAreas();
         }
 
-        int bIndents = ((BlockContainer) fobj).getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
+        int bIndents = getBlockContainerFO().getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
 
         addMarkers(false, false, true);
 
@@ -1026,7 +1024,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         }*/
 
         BreakPoss bp1 = (BreakPoss)parentIter.peekNext();
-        addID(((BlockContainer) fobj).getId());
+        addID(getBlockContainerFO().getId());
         addMarkers(true, bp1.isFirstArea(), bp1.isLastArea());
 
         LayoutManager childLM;
@@ -1050,7 +1048,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         /*
         if (!isAbsoluteOrFixed()) {
             // if adjusted space after
-            foBlockSpaceAfter = new SpaceVal(((BlockContainer) fobj).getCommonMarginBlock().spaceAfter).getSpace();
+            foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock().spaceAfter).getSpace();
             addBlockSpacing(adjust, foBlockSpaceAfter);
         }*/
         
@@ -1077,11 +1075,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
                 viewportBlockArea.setBPD(vpContentBPD);
             }
 
-            TraitSetter.addBorders(viewportBlockArea, ((BlockContainer) fobj).getCommonBorderPaddingBackground());
-            TraitSetter.addBackground(viewportBlockArea, ((BlockContainer) fobj).getCommonBorderPaddingBackground());
+            TraitSetter.addBorders(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground());
+            TraitSetter.addBackground(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground());
             TraitSetter.addMargins(viewportBlockArea, 
-                    ((BlockContainer) fobj).getCommonBorderPaddingBackground(),
-                    ((BlockContainer) fobj).getCommonMarginBlock());
+                    getBlockContainerFO().getCommonBorderPaddingBackground(),
+                    getBlockContainerFO().getCommonMarginBlock());
             
             viewportBlockArea.setCTM(absoluteCTM);
             viewportBlockArea.setClip(clip);
@@ -1152,10 +1150,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         usedBPD = referenceArea.getAllocBPD();
         /* done by the breaker now by inserting additional boxes
         if (!autoHeight & (usedBPD > 0)) {
-            if (((BlockContainer) fobj).getDisplayAlign() == EN_CENTER) {
+            if (getBlockContainerFO().getDisplayAlign() == EN_CENTER) {
                 viewportBlockArea.setCTM(viewportBlockArea.getCTM().multiply(
                         new CTM().translate(0, (relDims.bpd - usedBPD) / 2)));
-            } else if (((BlockContainer) fobj).getDisplayAlign() == EN_AFTER) {
+            } else if (getBlockContainerFO().getDisplayAlign() == EN_AFTER) {
                 viewportBlockArea.setCTM(viewportBlockArea.getCTM().multiply(
                         new CTM().translate(0, (relDims.bpd - usedBPD))));
             }
@@ -1195,25 +1193,31 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
     public boolean mustKeepTogether() {
         //TODO Keeps will have to be more sophisticated sooner or later
         return ((BlockLevelLayoutManager)getParent()).mustKeepTogether() 
-                || !((BlockContainer) fobj).getKeepTogether().getWithinPage().isAuto()
-                || !((BlockContainer) fobj).getKeepTogether().getWithinColumn().isAuto();
+                || !getBlockContainerFO().getKeepTogether().getWithinPage().isAuto()
+                || !getBlockContainerFO().getKeepTogether().getWithinColumn().isAuto();
     }
 
     /**
      * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious()
      */
     public boolean mustKeepWithPrevious() {
-        return !((BlockContainer) fobj).getKeepWithPrevious().getWithinPage().isAuto()
-                || !((BlockContainer) fobj).getKeepWithPrevious().getWithinColumn().isAuto();
+        return !getBlockContainerFO().getKeepWithPrevious().getWithinPage().isAuto()
+                || !getBlockContainerFO().getKeepWithPrevious().getWithinColumn().isAuto();
     }
 
     /**
      * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext()
      */
     public boolean mustKeepWithNext() {
-        return !((BlockContainer) fobj).getKeepWithNext().getWithinPage().isAuto()
-                || !((BlockContainer) fobj).getKeepWithNext().getWithinColumn().isAuto();
+        return !getBlockContainerFO().getKeepWithNext().getWithinPage().isAuto()
+                || !getBlockContainerFO().getKeepWithNext().getWithinColumn().isAuto();
     }
-    
+
+    /**
+     * convenience method that returns the BlockContainer node
+     */
+    protected BlockContainer getBlockContainerFO() {
+        return (BlockContainer) fobj;
+    }    
 }
 
index c3d515f652f206516c779d0d27cb3c28b19fd1e6..05f9b7a8699ae11c4d5da1e8f2bca63fee30d689 100644 (file)
@@ -80,13 +80,13 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         super(inBlock);
         proxyLMiter = new ProxyLMiter();
 
-        Font fs = ((org.apache.fop.fo.flow.Block) fobj).getCommonFont().getFontState(
-                  ((org.apache.fop.fo.flow.Block) fobj).getFOEventHandler().getFontInfo());
+        Font fs = getBlockFO().getCommonFont().getFontState(
+                  getBlockFO().getFOEventHandler().getFontInfo());
         
         lead = fs.getAscender();
         follow = -fs.getDescender();
         middleShift = -fs.getXHeight() / 2;
-        lineHeight = ((org.apache.fop.fo.flow.Block) fobj).getLineHeight().getOptimum().getLength().getValue();
+        lineHeight = getBlockFO().getLineHeight().getOptimum().getLength().getValue();
     }
 
     /**
@@ -95,17 +95,17 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
      *      if defined for the block.
      */
     protected void initProperties() {
-        foBlockSpaceBefore = new SpaceVal(((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceBefore).getSpace();
+        foBlockSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore).getSpace();
         prevFoBlockSpaceAfter = foBlockSpaceAfter;
 /*LF*/  bpUnit = 0; //layoutProps.blockProgressionUnit;
 /*LF*/  if (bpUnit == 0) {
 /*LF*/      // use optimum space values
-/*LF*/      adjustedSpaceBefore = ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceBefore.getSpace().getOptimum().getLength().getValue();
-/*LF*/      adjustedSpaceAfter = ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceAfter.getSpace().getOptimum().getLength().getValue();
+/*LF*/      adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace().getOptimum().getLength().getValue();
+/*LF*/      adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace().getOptimum().getLength().getValue();
 /*LF*/  } else {
 /*LF*/      // use minimum space values
-/*LF*/      adjustedSpaceBefore = ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceBefore.getSpace().getMinimum().getLength().getValue();
-/*LF*/      adjustedSpaceAfter = ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceAfter.getSpace().getMinimum().getLength().getValue();
+/*LF*/      adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace().getMinimum().getLength().getValue();
+/*LF*/      adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace().getMinimum().getLength().getValue();
 /*LF*/  }
     }
 
@@ -165,7 +165,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
      */
     private LineLayoutManager createLineManager(LayoutManager firstlm) {
         LineLayoutManager llm;
-        llm = new LineLayoutManager(((org.apache.fop.fo.flow.Block) fobj), lineHeight, lead, follow, middleShift);
+        llm = new LineLayoutManager(getBlockFO(), lineHeight, lead, follow, middleShift);
         List inlines = new java.util.ArrayList();
         inlines.add(firstlm);
         while (proxyLMiter.hasNext()) {
@@ -183,8 +183,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
 
     private int getIPIndents() {
         int iIndents = 0;
-        iIndents += ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().startIndent.getValue();
-        iIndents += ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().endIndent.getValue();
+        iIndents += getBlockFO().getCommonMarginBlock().startIndent.getValue();
+        iIndents += getBlockFO().getCommonMarginBlock().endIndent.getValue();
         return iIndents;
     }
     
@@ -214,8 +214,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         BreakPoss lastPos = null;
 
         // Set context for percentage property values.
-        ((org.apache.fop.fo.flow.Block) fobj).setLayoutDimension(PercentBase.BLOCK_IPD, contentipd);
-        ((org.apache.fop.fo.flow.Block) fobj).setLayoutDimension(PercentBase.BLOCK_BPD, -1);
+        getBlockFO().setLayoutDimension(PercentBase.BLOCK_IPD, contentipd);
+        getBlockFO().setLayoutDimension(PercentBase.BLOCK_BPD, -1);
 
         while ((curLM = getChildLM()) != null) {
             // Make break positions and return blocks!
@@ -273,7 +273,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             if (getChildLM() == null || over) {
                 if (getChildLM() == null) {
                     setFinished(true);
-                    stackSize.add(new SpaceVal(((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceAfter).getSpace());
+                    stackSize.add(new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter).getSpace());
                 }
                 BreakPoss breakPoss = new BreakPoss(
                                     new LeafPosition(this, childBreaks.size() - 1));
@@ -305,24 +305,24 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
     public boolean mustKeepTogether() {
         //TODO Keeps will have to be more sophisticated sooner or later
         return ((BlockLevelLayoutManager)getParent()).mustKeepTogether() 
-                || !((org.apache.fop.fo.flow.Block) fobj).getKeepTogether().getWithinPage().isAuto()
-                || !((org.apache.fop.fo.flow.Block) fobj).getKeepTogether().getWithinColumn().isAuto();
+                || !getBlockFO().getKeepTogether().getWithinPage().isAuto()
+                || !getBlockFO().getKeepTogether().getWithinColumn().isAuto();
     }
 
     /**
      * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious()
      */
     public boolean mustKeepWithPrevious() {
-        return !((org.apache.fop.fo.flow.Block) fobj).getKeepWithPrevious().getWithinPage().isAuto()
-            || !((org.apache.fop.fo.flow.Block) fobj).getKeepWithPrevious().getWithinColumn().isAuto();
+        return !getBlockFO().getKeepWithPrevious().getWithinPage().isAuto()
+            || !getBlockFO().getKeepWithPrevious().getWithinColumn().isAuto();
     }
 
     /**
      * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext()
      */
     public boolean mustKeepWithNext() {
-        return !((org.apache.fop.fo.flow.Block) fobj).getKeepWithNext().getWithinPage().isAuto()
-                || !((org.apache.fop.fo.flow.Block) fobj).getKeepWithNext().getWithinColumn().isAuto();
+        return !getBlockFO().getKeepWithNext().getWithinPage().isAuto()
+                || !getBlockFO().getKeepWithNext().getWithinColumn().isAuto();
     }
 
     //TODO this method is no longer used
@@ -347,7 +347,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         foBlockSpaceBefore = null;
 
         if (!isBogus()) {
-            addID(((org.apache.fop.fo.flow.Block) fobj).getId());
+            addID(getBlockFO().getId());
             addMarkers(true, bp1.isFirstArea(), bp1.isLastArea());
         }
 
@@ -375,7 +375,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             flush();
 
             // if adjusted space after
-            foBlockSpaceAfter = new SpaceVal(((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceAfter).getSpace();
+            foBlockSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter).getSpace();
             addBlockSpacing(adjust, foBlockSpaceAfter);
             curBlockArea = null;
         }
@@ -392,7 +392,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
         }
 
-        addID(((org.apache.fop.fo.flow.Block) fobj).getId());
+        addID(getBlockFO().getId());
         //addMarkers(true, bp1.isFirstArea(), bp1.isLastArea());
         addMarkers(true, true, false);
 
@@ -491,8 +491,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             // add space before and / or after the paragraph
             // to reach a multiple of bpUnit
             if (bSpaceBefore && bSpaceAfter) {
-                foBlockSpaceBefore = new SpaceVal(((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceBefore).getSpace();
-                foBlockSpaceAfter = new SpaceVal(((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock().spaceAfter).getSpace();
+                foBlockSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore).getSpace();
+                foBlockSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter).getSpace();
                 adjustedSpaceBefore = (neededUnits(splitLength
                         + foBlockSpaceBefore.min
                         + foBlockSpaceAfter.min)
@@ -532,7 +532,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             childLM.addAreas(childPosIter, lc);
         }
 
-        int bIndents = ((org.apache.fop.fo.flow.Block) fobj).getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
+        int bIndents = getBlockFO().getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
 
         addMarkers(false, false, true);
 
@@ -562,7 +562,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             curBlockArea = new Block();
 
             TraitSetter.addBreaks(curBlockArea, 
-                    ((org.apache.fop.fo.flow.Block) fobj).getBreakBefore(), ((org.apache.fop.fo.flow.Block) fobj).getBreakAfter());
+                    getBlockFO().getBreakBefore(), getBlockFO().getBreakAfter());
 
             // Must get dimensions from parent area
             //Don't optimize this line away. It can have ugly side-effects.
@@ -570,12 +570,12 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
 
             // set traits
             TraitSetter.addBorders(curBlockArea, 
-                    ((org.apache.fop.fo.flow.Block) fobj).getCommonBorderPaddingBackground());
+                    getBlockFO().getCommonBorderPaddingBackground());
             TraitSetter.addBackground(curBlockArea, 
-                    ((org.apache.fop.fo.flow.Block) fobj).getCommonBorderPaddingBackground());
+                    getBlockFO().getCommonBorderPaddingBackground());
             TraitSetter.addMargins(curBlockArea,
-                    ((org.apache.fop.fo.flow.Block) fobj).getCommonBorderPaddingBackground(), 
-                    ((org.apache.fop.fo.flow.Block) fobj).getCommonMarginBlock());
+                    getBlockFO().getCommonBorderPaddingBackground(), 
+                    getBlockFO().getCommonMarginBlock());
 
             // Set up dimensions
             // Get reference IPD from parentArea
@@ -629,5 +629,12 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             LayoutManager lm = resetPos.getLM();
         }
     }
+
+    /**
+     * convenience method that returns the Block node
+     */
+    protected org.apache.fop.fo.flow.Block getBlockFO() {
+        return (org.apache.fop.fo.flow.Block) fobj;
+    }
 }