From 2fb9c63eea373b6ec707b116286e97cfc72a594b Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Sun, 9 Jan 2011 12:11:07 +0000 Subject: [PATCH] Simplify Region.getViewportRectangle(): no reason to pass the SinglePageMaster as a parameter, as Regions have access to it git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1056923 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/Page.java | 10 ++++------ src/java/org/apache/fop/fo/pagination/Region.java | 6 ++---- src/java/org/apache/fop/fo/pagination/RegionAfter.java | 7 ++++--- .../org/apache/fop/fo/pagination/RegionBefore.java | 6 +++--- src/java/org/apache/fop/fo/pagination/RegionBody.java | 4 ++-- src/java/org/apache/fop/fo/pagination/RegionEnd.java | 6 +++--- src/java/org/apache/fop/fo/pagination/RegionStart.java | 6 +++--- 7 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index 242123baa..715bcfe85 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -123,7 +123,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { for (Iterator regenum = spm.getRegions().values().iterator(); regenum.hasNext();) { Region r = (Region)regenum.next(); - RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM, spm); + RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM); if (r.getNameId() == Constants.FO_REGION_BODY) { rr = new BodyRegion((RegionBody) r, rvp); } else { @@ -138,7 +138,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { setRegionReferencePosition(rr, r, rvp.getViewArea()); rvp.setRegionReference(rr); setRegionViewport(r.getNameId(), rvp); - } + } } /** @@ -153,12 +153,10 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { * @param r the region the viewport is to be created for * @param reldims relative dimensions * @param pageCTM page coordinate transformation matrix - * @param spm the simple-page-master for this page * @return the new region viewport */ - private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM, - SimplePageMaster spm) { - Rectangle2D relRegionRect = r.getViewportRectangle(reldims, spm); + private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM) { + Rectangle2D relRegionRect = r.getViewportRectangle(reldims); Rectangle2D absRegionRect = pageCTM.transform(relRegionRect); // Get the region viewport rectangle in absolute coords by // transforming it using the page CTM diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index ea449cdff..fe5a95749 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -47,7 +47,7 @@ public abstract class Region extends FObj { private int writingMode; // End of property values - private SimplePageMaster layoutMaster; + protected final SimplePageMaster layoutMaster; /** * Base constructor @@ -102,11 +102,9 @@ public abstract class Region extends FObj { /** * @param pageRefRect reference dimension of the page area. - * @param spm the simple page master this region belongs to. * @return the rectangle for the viewport area */ - public abstract Rectangle getViewportRectangle(FODimension pageRefRect - , SimplePageMaster spm); + public abstract Rectangle getViewportRectangle(FODimension pageRefRect); /** * Returns the default region name (xsl-region-before, xsl-region-start, diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java index 841bff0d6..bab5d46b8 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java @@ -44,7 +44,7 @@ public class RegionAfter extends RegionBA { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ @@ -52,7 +52,8 @@ public class RegionAfter extends RegionBA { PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE); PercentBaseContext neighbourContext; Rectangle vpRect; - if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) { + if (layoutMaster.getWritingMode() == EN_LR_TB + || layoutMaster.getWritingMode() == EN_RL_TB) { neighbourContext = pageWidthContext; vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext) , reldims.ipd, getExtent().getValue(pageHeightContext)); @@ -62,7 +63,7 @@ public class RegionAfter extends RegionBA { , getExtent().getValue(pageWidthContext), reldims.ipd); } if (getPrecedence() == EN_FALSE) { - adjustIPD(vpRect, spm.getWritingMode(), neighbourContext); + adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext); } return vpRect; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java index 728336c98..6d12e6e4e 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java @@ -49,7 +49,7 @@ public class RegionBefore extends RegionBA { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ @@ -57,7 +57,7 @@ public class RegionBefore extends RegionBA { PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE); PercentBaseContext neighbourContext; Rectangle vpRect; - if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) { + if (layoutMaster.getWritingMode() == EN_LR_TB || layoutMaster.getWritingMode() == EN_RL_TB) { neighbourContext = pageWidthContext; vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue(pageHeightContext)); } else { @@ -65,7 +65,7 @@ public class RegionBefore extends RegionBA { vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.ipd); } if (getPrecedence() == EN_FALSE) { - adjustIPD(vpRect, spm.getWritingMode(), neighbourContext); + adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext); } return vpRect; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index cb265706d..5eed36061 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -96,7 +96,7 @@ public class RegionBody extends Region { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving margins in the page context. * Contrary to normal margins in this case top and bottom margin * are resolved relative to the height. In the property subsystem @@ -113,7 +113,7 @@ public class RegionBody extends Region { int start; int end; - if (spm.getWritingMode() == EN_LR_TB) { // Left-to-right + if (layoutMaster.getWritingMode() == EN_LR_TB) { // Left-to-right start = commonMarginBlock.marginLeft.getValue(pageWidthContext); end = commonMarginBlock.marginRight.getValue(pageWidthContext); } else { // all other supported modes are right-to-left diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java index 8b348ed5d..4a054ad4e 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java @@ -44,7 +44,7 @@ public class RegionEnd extends RegionSE { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ @@ -52,7 +52,7 @@ public class RegionEnd extends RegionSE { PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE); PercentBaseContext neighbourContext; Rectangle vpRect; - if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) { + if (layoutMaster.getWritingMode() == EN_LR_TB || layoutMaster.getWritingMode() == EN_RL_TB) { neighbourContext = pageHeightContext; vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0, getExtent().getValue(pageWidthContext), reldims.bpd); @@ -62,7 +62,7 @@ public class RegionEnd extends RegionSE { vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageHeightContext), 0, reldims.bpd, getExtent().getValue(pageHeightContext)); } - adjustIPD(vpRect, spm.getWritingMode(), neighbourContext); + adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext); return vpRect; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java index afe9ddfe1..c0a57a0f7 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java @@ -44,7 +44,7 @@ public class RegionStart extends RegionSE { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ @@ -52,14 +52,14 @@ public class RegionStart extends RegionSE { PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE); PercentBaseContext neighbourContext; Rectangle vpRect; - if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) { + if (layoutMaster.getWritingMode() == EN_LR_TB || layoutMaster.getWritingMode() == EN_RL_TB) { neighbourContext = pageHeightContext; vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.bpd); } else { neighbourContext = pageWidthContext; vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue(pageHeightContext)); } - adjustIPD(vpRect, spm.getWritingMode(), neighbourContext); + adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext); return vpRect; } -- 2.39.5