aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2009-03-22 21:08:48 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2009-03-22 21:08:48 +0000
commit462737dc5e48cee597e7873829de4247ce481cde (patch)
treeec63cac64f6a2a906700212d67c7bd78da63e4f4 /src
parent3df2eea282cfff325ed544d514524bcccb1c3f2f (diff)
downloadxmlgraphics-fop-462737dc5e48cee597e7873829de4247ce481cde.tar.gz
xmlgraphics-fop-462737dc5e48cee597e7873829de4247ce481cde.zip
Minor refactoring: extract code-blocks from the Region implementations into protected final method on SimplePageMaster.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@757256 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/pagination/Region.java19
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionAfter.java24
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionBody.java22
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionEnd.java24
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionStart.java24
-rw-r--r--src/java/org/apache/fop/fo/pagination/SimplePageMaster.java40
6 files changed, 74 insertions, 79 deletions
diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java
index 87e9c4590..6f94418be 100644
--- a/src/java/org/apache/fop/fo/pagination/Region.java
+++ b/src/java/org/apache/fop/fo/pagination/Region.java
@@ -26,6 +26,7 @@ import org.xml.sax.Locator;
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 @@ public abstract class Region extends FObj {
|| 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;
diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java
index 2189fa67b..841bff0d6 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java
@@ -26,7 +26,7 @@ import java.awt.Rectangle;
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 @@ public class RegionAfter extends RegionBA {
/* 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;
diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java
index 43499678a..165bb4734 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionBody.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java
@@ -27,7 +27,7 @@ import org.apache.fop.datatypes.FODimension;
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 @@ public class RegionBody extends Region {
* 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;
diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java
index 611b1edf6..8b348ed5d 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java
@@ -26,7 +26,7 @@ import java.awt.Rectangle;
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 @@ public class RegionEnd extends RegionSE {
/* 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;
diff --git a/src/java/org/apache/fop/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java
index 12b578634..afe9ddfe1 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionStart.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java
@@ -26,7 +26,7 @@ import java.awt.Rectangle;
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 @@ public class RegionStart extends RegionSE {
/* 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;
diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
index b0ec96406..8c95e1b8a 100644
--- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
@@ -29,6 +29,8 @@ import org.xml.sax.Locator;
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 @@ public class SimplePageMaster extends FObj {
}
/**
+ * 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