]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
PR:
authorGlen Mazza <gmazza@apache.org>
Sun, 29 Aug 2004 20:17:35 +0000 (20:17 +0000)
committerGlen Mazza <gmazza@apache.org>
Sun, 29 Aug 2004 20:17:35 +0000 (20:17 +0000)
Obtained from:
Submitted by:
Reviewed by:
Convenience method fobj.getPropLength() added to simplify some of the code.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197895 13f79535-47bb-0310-9956-ffa450edef68

14 files changed:
src/java/org/apache/fop/fo/FObj.java
src/java/org/apache/fop/fo/flow/Block.java
src/java/org/apache/fop/fo/flow/BlockContainer.java
src/java/org/apache/fop/fo/flow/Leader.java
src/java/org/apache/fop/fo/flow/Table.java
src/java/org/apache/fop/fo/flow/TableBody.java
src/java/org/apache/fop/fo/flow/TableCell.java
src/java/org/apache/fop/fo/flow/TableRow.java
src/java/org/apache/fop/fo/pagination/RegionBA.java
src/java/org/apache/fop/fo/pagination/RegionSE.java
src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
src/java/org/apache/fop/layoutmgr/InstreamForeignObjectLM.java
src/java/org/apache/fop/layoutmgr/PageLayoutManager.java
src/java/org/apache/fop/render/rtf/TextAttributesConverter.java

index 27e91c126b8744866257e7682f212a9ed107fb4b..b7c865d9b021e81099d4ba3996ad3d84e1dd595b 100644 (file)
@@ -188,7 +188,7 @@ public class FObj extends FONode implements Constants {
     }
 
     /**
-     * Helper method to quickly obtain the String value of a property
+     * Convenience method to quickly obtain the String value of a property
      * for this FO, without querying for the propertyList first.
      * Meaningful only for properties having a string representation
      * @param propId - the Constants ID of the desired property to obtain
@@ -198,6 +198,17 @@ public class FObj extends FONode implements Constants {
         return propertyList.get(propId).getString();
     }
 
+    /**
+     * Convenience method to quickly obtain the length value of a property
+     * for this FO, without querying for the propertyList first.
+     * Meaningful only for properties having a length representation
+     * @param propId - the Constants ID of the desired property to obtain
+     * @return the length value of the property value
+     */
+    public int getPropLength(int propId) {
+        return propertyList.get(propId).getLength().getValue();
+    }
+
     /**
      * @see org.apache.fop.fo.FONode#addChildNode(FONode)
      */
index d46651e8bacfa8fbee9f2b95129afd1d9764c9f1..f1fe8a3452ac81ed69b068043fd4a674a1376291 100644 (file)
@@ -116,18 +116,12 @@ public class Block extends FObjMixed {
         this.alignLast =
           this.propertyList.get(PR_TEXT_ALIGN_LAST).getEnum();
         this.breakAfter = this.propertyList.get(PR_BREAK_AFTER).getEnum();
-        this.lineHeight = this.propertyList.get(
-                            PR_LINE_HEIGHT).getLength().getValue();
-        this.startIndent = this.propertyList.get(
-                             PR_START_INDENT).getLength().getValue();
-        this.endIndent = this.propertyList.get(
-                           PR_END_INDENT).getLength().getValue();
-        this.spaceBefore = this.propertyList.get(
-                             PR_SPACE_BEFORE | CP_OPTIMUM).getLength().getValue();
-        this.spaceAfter = this.propertyList.get(
-                            PR_SPACE_AFTER | CP_OPTIMUM).getLength().getValue();
-        this.textIndent = this.propertyList.get(
-                            PR_TEXT_INDENT).getLength().getValue();
+        this.lineHeight = getPropLength(PR_LINE_HEIGHT);
+        this.startIndent = getPropLength(PR_START_INDENT);
+        this.endIndent = getPropLength(PR_END_INDENT);
+        this.spaceBefore = getPropLength(PR_SPACE_BEFORE | CP_OPTIMUM);
+        this.spaceAfter = getPropLength(PR_SPACE_AFTER | CP_OPTIMUM);
+        this.textIndent = getPropLength(PR_TEXT_INDENT);
         this.keepWithNext =
           this.propertyList.get(PR_KEEP_WITH_NEXT).getEnum();
 
index a27a0f24f10bfd7f9be65cc5f833c00783db1bce..2d277fecef696ec020fd09a6b68ca176f7438edb 100644 (file)
@@ -64,8 +64,8 @@ public class BlockContainer extends FObj {
         this.backgroundColor =
             this.propertyList.get(PR_BACKGROUND_COLOR).getColorType();
 
-        this.width = this.propertyList.get(PR_WIDTH).getLength().getValue();
-        this.height = this.propertyList.get(PR_HEIGHT).getLength().getValue();
+        this.width = getPropLength(PR_WIDTH);
+        this.height = getPropLength(PR_HEIGHT);
     }
 
     /**
index a417777b43b6efc7aa0911574589e949124714cc..ca92fcb6ff20871d30cb8a6a1c66d6020eb00213 100644 (file)
@@ -75,8 +75,7 @@ public class Leader extends FObjMixed {
             case LeaderPattern.RULE:
                 // the following properties only apply
                 // for leader-pattern = "rule"
-                ruleThickness =
-                         propertyList.get(PR_RULE_THICKNESS).getLength().getValue();
+                ruleThickness = getPropLength(PR_RULE_THICKNESS);
                 ruleStyle = propertyList.get(PR_RULE_STYLE).getEnum();
             break;
             case LeaderPattern.DOTS:
@@ -88,9 +87,7 @@ public class Leader extends FObjMixed {
         }
 
         // if leaderPatternWidth = 0 = default = use-font-metric
-        patternWidth =
-            this.propertyList.get(PR_LEADER_PATTERN_WIDTH).getLength().getValue();
-
+        patternWidth = getPropLength(PR_LEADER_PATTERN_WIDTH);
     }
 
     /**
index 570372944a9ea8fc735a1114c85a6ee4d35ab54b..4c532f67fd29b9e25e96649d7523fa080b5c64c0 100644 (file)
@@ -86,15 +86,13 @@ public class Table extends FObj {
         super.addProperties(attlist);
         this.breakBefore = this.propertyList.get(PR_BREAK_BEFORE).getEnum();
         this.breakAfter = this.propertyList.get(PR_BREAK_AFTER).getEnum();
-        this.spaceBefore = this.propertyList.get(
-                             PR_SPACE_BEFORE | CP_OPTIMUM).getLength().getValue();
-        this.spaceAfter = this.propertyList.get(
-                            PR_SPACE_AFTER | CP_OPTIMUM).getLength().getValue();
+        this.spaceBefore = getPropLength(PR_SPACE_BEFORE | CP_OPTIMUM);
+        this.spaceAfter = getPropLength(PR_SPACE_AFTER | CP_OPTIMUM);
         this.backgroundColor =
           this.propertyList.get(PR_BACKGROUND_COLOR).getColorType();
         this.ipd = this.propertyList.get(
                      PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
-        this.height = this.propertyList.get(PR_HEIGHT).getLength().getValue();
+        this.height = getPropLength(PR_HEIGHT);
         this.bAutoLayout = (this.propertyList.get(
                 PR_TABLE_LAYOUT).getEnum() == TableLayout.AUTO);
 
index 2b0ad8dfc58f70e6ca3f9a2f1e5ba4497896bb29..342684c50051ceb94057af9be64e0597efe8e30e 100644 (file)
@@ -54,10 +54,8 @@ public class TableBody extends FObj {
      */
     protected void addProperties(Attributes attlist) throws SAXParseException {
         super.addProperties(attlist);
-        this.spaceBefore = this.propertyList.get(
-                             PR_SPACE_BEFORE | CP_OPTIMUM).getLength().getValue();
-        this.spaceAfter = this.propertyList.get(
-                            PR_SPACE_AFTER | CP_OPTIMUM).getLength().getValue();
+        this.spaceBefore = getPropLength(PR_SPACE_BEFORE | CP_OPTIMUM);
+        this.spaceAfter = getPropLength(PR_SPACE_AFTER | CP_OPTIMUM);
         this.backgroundColor =
           this.propertyList.get(PR_BACKGROUND_COLOR).getColorType();
         getFOInputHandler().startBody(this);
index cb6928d87bf4d6406c6d189c2546b5e6f1fc93ba..1f8d46a713b8a5e731e1a797c1a21d6c8768be1e 100644 (file)
@@ -202,8 +202,7 @@ public class TableCell extends FObj {
             bRelativeAlign = false;    // Align on a per-cell basis
         }
 
-        this.minCellHeight =
-            this.propertyList.get(PR_HEIGHT).getLength().getValue();
+        this.minCellHeight = getPropLength(PR_HEIGHT);
     }
 
     /**
@@ -220,8 +219,8 @@ public class TableCell extends FObj {
              * border-separate should only be specified on the table object,
              * but it inherits.
              */
-            int iSep = propertyList.get(
-                    PR_BORDER_SEPARATION | CP_INLINE_PROGRESSION_DIRECTION).getLength().getValue();
+            int iSep = getPropLength(PR_BORDER_SEPARATION | 
+                CP_INLINE_PROGRESSION_DIRECTION);
             this.startAdjust = iSep / 2 + bp.getBorderStartWidth(false)
                                + bp.getPaddingStart(false);
 
@@ -230,8 +229,8 @@ public class TableCell extends FObj {
                                + bp.getPaddingEnd(false);
 
             // Offset of content rectangle in the block-progression direction
-            borderSeparation = propertyList.get(
-                    PR_BORDER_SEPARATION | CP_BLOCK_PROGRESSION_DIRECTION).getLength().getValue();
+            borderSeparation = getPropLength(PR_BORDER_SEPARATION | 
+                CP_BLOCK_PROGRESSION_DIRECTION);
             this.beforeOffset = borderSeparation / 2
                                 + bp.getBorderBeforeWidth(false)
                                 + bp.getPaddingBefore(false);
index 21d5057d7dde29c97f506afe4d060ba6d77e4fd4..f4e3b448e0b77561e25ce0a5ab640f576e9feb87 100644 (file)
@@ -89,7 +89,7 @@ public class TableRow extends FObj {
         this.keepWithPrevious =
             getKeepValue(PR_KEEP_WITH_PREVIOUS | CP_WITHIN_COLUMN);
 
-        this.minHeight = this.propertyList.get(PR_HEIGHT).getLength().getValue();
+        this.minHeight = getPropLength(PR_HEIGHT);
         setup = true;
     }
 
index 53d1b07452932de995cdbdbf0686c25a0b51575a..80705b4294b2e37aaed54afd9bb707a6c75f2b21 100644 (file)
@@ -48,7 +48,7 @@ public abstract class RegionBA extends Region {
         bPrecedence =
             (this.propertyList.get(PR_PRECEDENCE).getEnum() == Precedence.TRUE);
 
-        this.extent = this.propertyList.get(PR_EXTENT).getLength().getValue();
+        this.extent = getPropLength(PR_EXTENT);
     }
 
     /**
index 5965602375e970d4d1848f667e768c325b55ce25..1f97acdafdd9f2d5dc2733dec3f6e19643107de7 100644 (file)
@@ -43,7 +43,7 @@ public abstract class RegionSE extends Region {
     protected void addProperties(Attributes attlist) throws SAXParseException {
         super.addProperties(attlist);
         
-        this.extent = this.propertyList.get(PR_EXTENT).getLength().getValue();
+        this.extent = getPropLength(PR_EXTENT);
     }
 
     /**
index d3d42ac0195ea442b9c283c6d42101a39e7737c3..f8e46ed70631f12be7252a14d07d670e76489714 100644 (file)
@@ -96,11 +96,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
     }
 
     protected int getRotatedIPD() {
-        PropertyList props = fobj.getPropertyList();
-        int height = props.get(PR_HEIGHT).getLength().getValue();
-        height = props.get(PR_INLINE_PROGRESSION_DIMENSION | CP_OPTIMUM).getLength().getValue();
-
-        return height;
+        return fobj.getPropLength(PR_INLINE_PROGRESSION_DIMENSION 
+            | CP_OPTIMUM);
     }
 
     public BreakPoss getNextBreakPoss(LayoutContext context) {
index eb582e313292f2cf86e50f3d28e3f31dc498db61..6abc1a60ebc5f20265c5659f9859575ad7a6f1fb 100644 (file)
@@ -73,7 +73,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
         int ipd = -1;
         boolean bpdauto = false;
         if (hasLH) {
-            bpd = ifoNode.getProperty(PR_LINE_HEIGHT).getLength().getValue();
+            bpd = ifoNode.getPropLength(PR_LINE_HEIGHT);
         } else {
             // this property does not apply when the line-height applies
             // isn't the block-progression-dimension always in the same
index 5397b57dd3c579a1666e5b29074b71f50a4d8a5f..82dd3077fb3c45bbe869c1bd2c30b4d80f47e38a 100644 (file)
@@ -739,10 +739,9 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
     }
 
     private PageViewport createPageAreas(SimplePageMaster spm) {
-        int pageWidth =
-                spm.getProperty(PR_PAGE_WIDTH).getLength().getValue();
-        int pageHeight =
-                spm.getProperty(PR_PAGE_HEIGHT).getLength().getValue();
+        int pageWidth = spm.getPropLength(PR_PAGE_WIDTH);
+        int pageHeight = spm.getPropLength(PR_PAGE_HEIGHT);
+
         // Set the page dimension as the toplevel containing block for margin.
         ((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_IPD, pageWidth);
         ((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_BPD, pageHeight);
@@ -844,8 +843,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
         }
         body.setColumnCount(columnCount);
 
-        int columnGap =
-                r.getProperty(PR_COLUMN_GAP).getLength().getValue();
+        int columnGap = r.getPropLength(PR_COLUMN_GAP);
         body.setColumnGap(columnGap);
         return body;
     }
index 0fc3902df170bd2fd669a14b29744c0248ac6b66..a33e4bb9d39ab2d4209332fcaa87a5c1b252d57a 100644 (file)
@@ -103,7 +103,7 @@ class TextAttributesConverter {
     }
 
     private static void attrBlockFontSize(FObj fobj, RtfAttributes rtfAttr) {
-        int fopValue = fobj.getProperty(Constants.PR_FONT_SIZE).getLength().getValue() / 500;
+        int fopValue = fobj.getPropLength(Constants.PR_FONT_SIZE) / 500;
         rtfAttr.set("fs", fopValue);
     }