You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ad...@apache.org on 2009/03/22 22:08:48 UTC

svn commit: r757256 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination: Region.java RegionAfter.java RegionBody.java RegionEnd.java RegionStart.java SimplePageMaster.java

Author: adelmelle
Date: Sun Mar 22 21:08:48 2009
New Revision: 757256

URL: http://svn.apache.org/viewvc?rev=757256&view=rev
Log:
Minor refactoring: extract code-blocks from the Region implementations into protected final method on SimplePageMaster.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java?rev=757256&r1=757255&r2=757256&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/Region.java Sun Mar 22 21:08:48 2009
@@ -26,6 +26,7 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
@@ -130,6 +131,24 @@
                 || name.equals("xsl-footnote-separator"));
     }
 
+    /**
+     * Get the page-width context
+     * @param lengthBase    the lengthBase to use for resolving percentages
+     * @return  context for the width of the page-reference-area
+     */
+    protected PercentBaseContext getPageWidthContext(int lengthBase) {
+        return layoutMaster.getPageWidthContext(lengthBase);
+    }
+
+    /**
+     * Get the page-width context
+     * @param lengthBase    the lengthBase to use for resolving percentages
+     * @return  context for the width of the page-reference-area
+     */
+    protected PercentBaseContext getPageHeightContext(int lengthBase) {
+        return layoutMaster.getPageHeightContext(lengthBase);
+    }
+
     /** {@inheritDoc} */
     public boolean generatesReferenceAreas() {
         return true;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java?rev=757256&r1=757255&r2=757256&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionAfter.java Sun Mar 22 21:08:48 2009
@@ -26,7 +26,7 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.LengthBase;
-import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.datatypes.PercentBaseContext;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_region-after">
@@ -48,25 +48,9 @@
         /* Special rules apply to resolving extent as values are resolved relative
          * to the page size and reference orientation.
          */
-        SimplePercentBaseContext pageWidthContext;
-        SimplePercentBaseContext pageHeightContext;
-        if (spm.getReferenceOrientation() % 180 == 0) {
-            pageWidthContext = new SimplePercentBaseContext(null,
-                                                            LengthBase.CUSTOM_BASE,
-                                                            spm.getPageWidth().getValue());
-            pageHeightContext = new SimplePercentBaseContext(null,
-                                                             LengthBase.CUSTOM_BASE,
-                                                             spm.getPageHeight().getValue());
-        } else {
-            // invert width and height since top left are rotated by 90 (cl or ccl)
-            pageWidthContext = new SimplePercentBaseContext(null,
-                                                            LengthBase.CUSTOM_BASE,
-                                                            spm.getPageHeight().getValue());
-            pageHeightContext = new SimplePercentBaseContext(null,
-                                                             LengthBase.CUSTOM_BASE,
-                                                             spm.getPageWidth().getValue());
-        }
-        SimplePercentBaseContext neighbourContext;
+        PercentBaseContext pageWidthContext = getPageWidthContext(LengthBase.CUSTOM_BASE);
+        PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
+        PercentBaseContext neighbourContext;
         Rectangle vpRect;
         if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
             neighbourContext = pageWidthContext;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java?rev=757256&r1=757255&r2=757256&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionBody.java Sun Mar 22 21:08:48 2009
@@ -27,7 +27,7 @@
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.datatypes.Numeric;
-import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.properties.CommonMarginBlock;
@@ -106,24 +106,8 @@
          * Also the values are resolved relative to the page size
          * and reference orientation.
          */
-        SimplePercentBaseContext pageWidthContext;
-        SimplePercentBaseContext pageHeightContext;
-        if (spm.getReferenceOrientation() % 180 == 0) {
-            pageWidthContext = new SimplePercentBaseContext(null,
-                                                            LengthBase.CONTAINING_BLOCK_WIDTH,
-                                                            spm.getPageWidth().getValue());
-            pageHeightContext = new SimplePercentBaseContext(null,
-                                                             LengthBase.CONTAINING_BLOCK_WIDTH,
-                                                             spm.getPageHeight().getValue());
-        } else {
-            // invert width and height since top left are rotated by 90 (cl or ccl)
-            pageWidthContext = new SimplePercentBaseContext(null,
-                                                            LengthBase.CONTAINING_BLOCK_WIDTH,
-                                                            spm.getPageHeight().getValue());
-            pageHeightContext = new SimplePercentBaseContext(null,
-                                                             LengthBase.CONTAINING_BLOCK_WIDTH,
-                                                             spm.getPageWidth().getValue());
-        }
+        PercentBaseContext pageWidthContext = getPageWidthContext(LengthBase.CONTAINING_BLOCK_WIDTH);
+        PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CONTAINING_BLOCK_WIDTH);
 
         int start;
         int end;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java?rev=757256&r1=757255&r2=757256&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionEnd.java Sun Mar 22 21:08:48 2009
@@ -26,7 +26,7 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.LengthBase;
-import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.datatypes.PercentBaseContext;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_region-end">
@@ -48,25 +48,9 @@
         /* Special rules apply to resolving extent as values are resolved relative
          * to the page size and reference orientation.
          */
-        SimplePercentBaseContext pageWidthContext;
-        SimplePercentBaseContext pageHeightContext;
-        if (spm.getReferenceOrientation() % 180 == 0) {
-            pageWidthContext = new SimplePercentBaseContext(null,
-                                                            LengthBase.CUSTOM_BASE,
-                                                            spm.getPageWidth().getValue());
-            pageHeightContext = new SimplePercentBaseContext(null,
-                                                             LengthBase.CUSTOM_BASE,
-                                                             spm.getPageHeight().getValue());
-        } else {
-            // invert width and height since top left are rotated by 90 (cl or ccl)
-            pageWidthContext = new SimplePercentBaseContext(null,
-                                                            LengthBase.CUSTOM_BASE,
-                                                            spm.getPageHeight().getValue());
-            pageHeightContext = new SimplePercentBaseContext(null,
-                                                             LengthBase.CUSTOM_BASE,
-                                                             spm.getPageWidth().getValue());
-        }
-        SimplePercentBaseContext neighbourContext;
+        PercentBaseContext pageWidthContext = getPageWidthContext(LengthBase.CUSTOM_BASE);
+        PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
+        PercentBaseContext neighbourContext;
         Rectangle vpRect;
         if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
             neighbourContext = pageHeightContext;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java?rev=757256&r1=757255&r2=757256&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RegionStart.java Sun Mar 22 21:08:48 2009
@@ -26,7 +26,7 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.LengthBase;
-import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.datatypes.PercentBaseContext;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_region-start">
@@ -48,25 +48,9 @@
         /* Special rules apply to resolving extent as values are resolved relative
          * to the page size and reference orientation.
          */
-        SimplePercentBaseContext pageWidthContext;
-        SimplePercentBaseContext pageHeightContext;
-        if (spm.getReferenceOrientation() % 180 == 0) {
-            pageWidthContext = new SimplePercentBaseContext(null,
-                                                            LengthBase.CUSTOM_BASE,
-                                                            spm.getPageWidth().getValue());
-            pageHeightContext = new SimplePercentBaseContext(null,
-                                                             LengthBase.CUSTOM_BASE,
-                                                             spm.getPageHeight().getValue());
-        } else {
-            // invert width and height since top left are rotated by 90 (cl or ccl)
-            pageWidthContext = new SimplePercentBaseContext(null,
-                                                            LengthBase.CUSTOM_BASE,
-                                                            spm.getPageHeight().getValue());
-            pageHeightContext = new SimplePercentBaseContext(null,
-                                                             LengthBase.CUSTOM_BASE,
-                                                             spm.getPageWidth().getValue());
-        }
-        SimplePercentBaseContext neighbourContext;
+        PercentBaseContext pageWidthContext = getPageWidthContext(LengthBase.CUSTOM_BASE);
+        PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
+        PercentBaseContext neighbourContext;
         Rectangle vpRect;
         if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
             neighbourContext = pageHeightContext;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java?rev=757256&r1=757255&r2=757256&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java Sun Mar 22 21:08:48 2009
@@ -29,6 +29,8 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
@@ -195,6 +197,44 @@
     }
 
     /**
+     * Gets the context for the width of the page-reference-area,
+     * taking into account the reference-orientation.
+     *
+     * @param lengthBase    the lengthBase to use to resolve percentages
+     * @return context for the width of the page-reference-area
+     */
+    protected final PercentBaseContext getPageWidthContext(int lengthBase) {
+        return (this.referenceOrientation.getValue() % 180 == 0)
+                ? new SimplePercentBaseContext(
+                        null,
+                        lengthBase,
+                        this.getPageWidth().getValue())
+                : new SimplePercentBaseContext(
+                        null,
+                        lengthBase,
+                        this.getPageHeight().getValue());
+    }
+
+    /**
+     * Gets the context for the height of the page-reference-area,
+     * taking into account the reference-orientation.
+     *
+     * @param lengthBase    the lengthBase to use to resolve percentages
+     * @return the context for the height of the page-reference-area
+     */
+    protected final PercentBaseContext getPageHeightContext(int lengthBase) {
+        return (this.referenceOrientation.getValue() % 180 == 0)
+                ? new SimplePercentBaseContext(
+                        null,
+                        lengthBase,
+                        this.getPageHeight().getValue())
+                : new SimplePercentBaseContext(
+                        null,
+                        lengthBase,
+                        this.getPageWidth().getValue());
+    }
+
+    /**
      * Returns the region for a given region class.
      * @param regionId Constants ID of the FO representing the region
      * @return the region, null if it doesn't exist



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