aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/pagination
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2011-01-18 08:54:08 +0000
committerJeremias Maerki <jeremias@apache.org>2011-01-18 08:54:08 +0000
commit992d7e9d1d3a71209ae689eb60b5e3c15295fe2d (patch)
tree7fc8445564597ae49eb9b1a082d7f8498409a4bf /src/java/org/apache/fop/fo/pagination
parentce6d9e1eeef5f7b17fada9f07145e7e430586bf1 (diff)
parent5a367c3b12e19af7a66fc923d7149bf22cdfb596 (diff)
downloadxmlgraphics-fop-992d7e9d1d3a71209ae689eb60b5e3c15295fe2d.tar.gz
xmlgraphics-fop-992d7e9d1d3a71209ae689eb60b5e3c15295fe2d.zip
Merge from Trunk, revisions 965390 to 1060234.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Color@1060241 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/pagination')
-rw-r--r--src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java3
-rw-r--r--src/java/org/apache/fop/fo/pagination/Declarations.java6
-rw-r--r--src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java34
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageProductionException.java2
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequence.java17
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java13
-rw-r--r--src/java/org/apache/fop/fo/pagination/Region.java8
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionAfter.java7
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionBefore.java31
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionBody.java10
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionEnd.java7
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionStart.java7
-rw-r--r--src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java8
-rw-r--r--src/java/org/apache/fop/fo/pagination/Root.java20
-rw-r--r--src/java/org/apache/fop/fo/pagination/SimplePageMaster.java17
-rw-r--r--src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java1
16 files changed, 88 insertions, 103 deletions
diff --git a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
index dce36f95c..51b24b314 100644
--- a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
@@ -34,7 +34,9 @@ import org.apache.fop.fo.PropertyList;
public abstract class AbstractPageSequence extends FObj {
// The value of properties relevant for fo:page-sequence.
+ /** initial page number */
protected Numeric initialPageNumber;
+ /** forced page count */
protected int forcePageCount;
private String format;
private int letterValue;
@@ -45,6 +47,7 @@ public abstract class AbstractPageSequence extends FObj {
private PageNumberGenerator pageNumberGenerator;
+ /** starting page number */
protected int startingPageNumber = 0;
/**
diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java
index 1385bccc9..9c68043ff 100644
--- a/src/java/org/apache/fop/fo/pagination/Declarations.java
+++ b/src/java/org/apache/fop/fo/pagination/Declarations.java
@@ -41,7 +41,7 @@ import org.apache.fop.fo.ValidationException;
*/
public class Declarations extends FObj {
- private Map colorProfiles = null;
+ private Map<String, ColorProfile> colorProfiles = null;
/**
* @param parent FONode that is the parent of this object
@@ -98,7 +98,7 @@ public class Declarations extends FObj {
private void addColorProfile(ColorProfile cp) {
if (colorProfiles == null) {
- colorProfiles = new java.util.HashMap();
+ colorProfiles = new java.util.HashMap<String, ColorProfile>();
}
if (colorProfiles.get(cp.getColorProfileName()) != null) {
// duplicate names
@@ -132,7 +132,7 @@ public class Declarations extends FObj {
public ColorProfile getColorProfile(String cpName) {
ColorProfile profile = null;
if (this.colorProfiles != null) {
- profile = (ColorProfile)this.colorProfiles.get(cpName);
+ profile = this.colorProfiles.get(cpName);
}
return profile;
}
diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
index 482ec83c4..c4189d0c4 100644
--- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
+++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
@@ -44,8 +44,8 @@ import org.apache.fop.fo.ValidationException;
*/
public class LayoutMasterSet extends FObj {
- private Map simplePageMasters;
- private Map pageSequenceMasters;
+ private Map<String, SimplePageMaster> simplePageMasters;
+ private Map<String, PageSequenceMaster> pageSequenceMasters;
/**
* Create a LayoutMasterSet instance that is a child of the given
@@ -65,8 +65,8 @@ public class LayoutMasterSet extends FObj {
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
getRoot().setLayoutMasterSet(this);
- simplePageMasters = new java.util.HashMap();
- pageSequenceMasters = new java.util.HashMap();
+ simplePageMasters = new java.util.HashMap<String, SimplePageMaster>();
+ pageSequenceMasters = new java.util.HashMap<String, PageSequenceMaster>();
}
/** {@inheritDoc} */
@@ -98,18 +98,13 @@ public class LayoutMasterSet extends FObj {
*/
private void checkRegionNames() throws ValidationException {
// (user-entered) region-name to default region map.
- Map allRegions = new java.util.HashMap();
- for (Iterator spm = simplePageMasters.values().iterator();
- spm.hasNext();) {
- SimplePageMaster simplePageMaster
- = (SimplePageMaster)spm.next();
- Map spmRegions = simplePageMaster.getRegions();
- for (Iterator e = spmRegions.values().iterator();
- e.hasNext();) {
- Region region = (Region) e.next();
+ Map<String, String> allRegions = new java.util.HashMap<String, String>();
+ for (SimplePageMaster simplePageMaster : simplePageMasters.values()) {
+ Map<String, Region> spmRegions = simplePageMaster.getRegions();
+ for (Region region : spmRegions.values()) {
if (allRegions.containsKey(region.getRegionName())) {
String defaultRegionName
- = (String) allRegions.get(region.getRegionName());
+ = allRegions.get(region.getRegionName());
if (!defaultRegionName.equals(region.getDefaultRegionName())) {
getFOValidationEventProducer().regionNameMappedToMultipleRegionClasses(this,
region.getRegionName(),
@@ -118,7 +113,7 @@ public class LayoutMasterSet extends FObj {
}
}
allRegions.put(region.getRegionName(),
- region.getDefaultRegionName());
+ region.getDefaultRegionName());
}
}
}
@@ -155,7 +150,7 @@ public class LayoutMasterSet extends FObj {
* @return the requested simple-page-master
*/
public SimplePageMaster getSimplePageMaster(String masterName) {
- return (SimplePageMaster)this.simplePageMasters.get(masterName);
+ return this.simplePageMasters.get(masterName);
}
/**
@@ -185,7 +180,7 @@ public class LayoutMasterSet extends FObj {
* @return the requested PageSequenceMaster instance
*/
public PageSequenceMaster getPageSequenceMaster(String masterName) {
- return (PageSequenceMaster)this.pageSequenceMasters.get(masterName);
+ return this.pageSequenceMasters.get(masterName);
}
/**
@@ -194,9 +189,8 @@ public class LayoutMasterSet extends FObj {
* @return true when the region name specified has a region in this LayoutMasterSet
*/
public boolean regionNameExists(String regionName) {
- for (Iterator e = simplePageMasters.values().iterator();
- e.hasNext();) {
- if (((SimplePageMaster)e.next()).regionNameExists(regionName)) {
+ for (SimplePageMaster spm : simplePageMasters.values()) {
+ if (spm.regionNameExists(regionName)) {
return true;
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageProductionException.java b/src/java/org/apache/fop/fo/pagination/PageProductionException.java
index bb09db6f4..39060f3d4 100644
--- a/src/java/org/apache/fop/fo/pagination/PageProductionException.java
+++ b/src/java/org/apache/fop/fo/pagination/PageProductionException.java
@@ -98,7 +98,7 @@ public class PageProductionException extends RuntimeException {
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<PageProductionException> getExceptionClass() {
return PageProductionException.class;
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java
index 26812166d..ee78bb8ba 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java
@@ -48,7 +48,7 @@ public class PageSequence extends AbstractPageSequence {
// the set of flows includes StaticContent flows also
/** Map of flows to their flow name (flow-name, Flow) */
- private Map/*<String, Flow>*/ flowMap;
+ private Map<String, Flow> flowMap;
/**
* The currentSimplePageMaster is either the page master for the
@@ -96,7 +96,7 @@ public class PageSequence extends AbstractPageSequence {
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
super.startOfNode();
- flowMap = new java.util.HashMap/*<String, Flow>*/();
+ flowMap = new java.util.HashMap<String, Flow>();
this.simplePageMaster
= getRoot().getLayoutMasterSet().getSimplePageMaster(masterReference);
@@ -151,7 +151,7 @@ public class PageSequence extends AbstractPageSequence {
/**
* {@inheritDoc}
- * @todo see if addChildNode() should also be called for fo's other than
+ * TODO see if addChildNode() should also be called for fo's other than
* fo:flow.
*/
public void addChildNode(FONode child) throws FOPException {
@@ -167,7 +167,7 @@ public class PageSequence extends AbstractPageSequence {
break;
case FO_STATIC_CONTENT:
addFlow((StaticContent)child);
- flowMap.put(((StaticContent)child).getFlowName(), child);
+ flowMap.put(((Flow)child).getFlowName(), (Flow)child);
break;
default:
super.addChildNode(child);
@@ -239,7 +239,7 @@ public class PageSequence extends AbstractPageSequence {
}
/** @return the flow map for this page-sequence */
- public Map getFlowMap() {
+ public Map<String, Flow> getFlowMap() {
return this.flowMap;
}
@@ -254,10 +254,9 @@ public class PageSequence extends AbstractPageSequence {
* @return the SimplePageMaster to use for this page
* @throws PageProductionException if there's a problem determining the page master
*/
- public SimplePageMaster getNextSimplePageMaster(int page,
- boolean isFirstPage,
- boolean isLastPage,
- boolean isBlank) throws PageProductionException {
+ public SimplePageMaster getNextSimplePageMaster
+ (int page, boolean isFirstPage, boolean isLastPage, boolean isBlank)
+ throws PageProductionException {
if (pageSequenceMaster == null) {
return simplePageMaster;
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
index 705b955e9..5b71525d3 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
@@ -44,7 +44,7 @@ public class PageSequenceMaster extends FObj {
// End of property values
private LayoutMasterSet layoutMasterSet;
- private List subSequenceSpecifiers;
+ private List<SubSequenceSpecifier> subSequenceSpecifiers;
private SubSequenceSpecifier currentSubSequence;
private int currentSubSequenceNumber = -1;
@@ -76,7 +76,7 @@ public class PageSequenceMaster extends FObj {
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
- subSequenceSpecifiers = new java.util.ArrayList();
+ subSequenceSpecifiers = new java.util.ArrayList<SubSequenceSpecifier>();
layoutMasterSet = parent.getRoot().getLayoutMasterSet();
layoutMasterSet.addPageSequenceMaster(masterName, this);
}
@@ -121,8 +121,7 @@ public class PageSequenceMaster extends FObj {
currentSubSequenceNumber++;
if (currentSubSequenceNumber >= 0
&& currentSubSequenceNumber < subSequenceSpecifiers.size()) {
- return (SubSequenceSpecifier)subSequenceSpecifiers
- .get(currentSubSequenceNumber);
+ return subSequenceSpecifiers.get(currentSubSequenceNumber);
}
return null;
}
@@ -134,8 +133,8 @@ public class PageSequenceMaster extends FObj {
currentSubSequenceNumber = -1;
currentSubSequence = null;
if (subSequenceSpecifiers != null) {
- for (int i = 0; i < subSequenceSpecifiers.size(); i++) {
- ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset();
+ for (SubSequenceSpecifier subSequenceSpecifier : subSequenceSpecifiers) {
+ subSequenceSpecifier.reset();
}
}
}
@@ -150,7 +149,7 @@ public class PageSequenceMaster extends FObj {
if (!success) {
if (currentSubSequenceNumber > 0) {
currentSubSequenceNumber--;
- currentSubSequence = (SubSequenceSpecifier)subSequenceSpecifiers
+ currentSubSequence = subSequenceSpecifiers
.get(currentSubSequenceNumber);
} else {
currentSubSequence = null;
diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java
index 6f94418be..a3c259aa7 100644
--- a/src/java/org/apache/fop/fo/pagination/Region.java
+++ b/src/java/org/apache/fop/fo/pagination/Region.java
@@ -31,7 +31,6 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
/**
@@ -48,7 +47,8 @@ public abstract class Region extends FObj {
private int writingMode;
// End of property values
- private SimplePageMaster layoutMaster;
+ /** the parent {@link SimplePageMaster} */
+ protected final SimplePageMaster layoutMaster;
/**
* Base constructor
@@ -103,11 +103,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 71ea26818..4aa29ec90 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java
@@ -25,7 +25,7 @@ import java.awt.Rectangle;
// FOP
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.LengthBase;
-import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FONode;
/**
@@ -49,31 +49,16 @@ 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.
*/
- 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) {
+ if (layoutMaster.getWritingMode() == EN_LR_TB
+ || layoutMaster.getWritingMode() == EN_RL_TB) {
neighbourContext = pageWidthContext;
vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue(pageHeightContext));
} else {
@@ -81,7 +66,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 165bb4734..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
@@ -106,12 +106,14 @@ public class RegionBody extends Region {
* Also the values are resolved relative to the page size
* and reference orientation.
*/
- PercentBaseContext pageWidthContext = getPageWidthContext(LengthBase.CONTAINING_BLOCK_WIDTH);
- PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CONTAINING_BLOCK_WIDTH);
+ PercentBaseContext pageWidthContext
+ = getPageWidthContext(LengthBase.CONTAINING_BLOCK_WIDTH);
+ PercentBaseContext pageHeightContext
+ = getPageHeightContext(LengthBase.CONTAINING_BLOCK_WIDTH);
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..2533763a5 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,8 @@ 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 +63,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..fdb423c51 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,15 @@ 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;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
index 9b4c6544f..629d7d59d 100644
--- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
+++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
@@ -48,7 +48,7 @@ public class RepeatablePageMasterAlternatives extends FObj
private int numberConsumed = 0;
- private List conditionalPageMasterRefs;
+ private List<ConditionalPageMasterReference> conditionalPageMasterRefs;
private boolean hasPagePositionLast = false;
private boolean hasPagePositionOnly = false;
@@ -68,7 +68,7 @@ public class RepeatablePageMasterAlternatives extends FObj
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
- conditionalPageMasterRefs = new java.util.ArrayList();
+ conditionalPageMasterRefs = new java.util.ArrayList<ConditionalPageMasterReference>();
assert parent.getName().equals("fo:page-sequence-master"); //Validation by the parent
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent;
@@ -128,9 +128,7 @@ public class RepeatablePageMasterAlternatives extends FObj
numberConsumed++;
}
- for (int i = 0; i < conditionalPageMasterRefs.size(); i++) {
- ConditionalPageMasterReference cpmr
- = (ConditionalPageMasterReference)conditionalPageMasterRefs.get(i);
+ for (ConditionalPageMasterReference cpmr : conditionalPageMasterRefs) {
if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isBlankPage)) {
return cpmr.getMasterReference();
}
diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java
index fcbb54abd..fb69dc2f1 100644
--- a/src/java/org/apache/fop/fo/pagination/Root.java
+++ b/src/java/org/apache/fop/fo/pagination/Root.java
@@ -47,8 +47,8 @@ public class Root extends FObj {
private LayoutMasterSet layoutMasterSet;
private Declarations declarations;
private BookmarkTree bookmarkTree = null;
- private List destinationList;
- private List pageSequences;
+ private List<Destination> destinationList;
+ private List<PageSequence> pageSequences;
// temporary until above list populated
private boolean pageSequenceFound = false;
@@ -77,11 +77,12 @@ public class Root extends FObj {
*/
public Root(FONode parent) {
super(parent);
- pageSequences = new java.util.ArrayList();
+ pageSequences = new java.util.ArrayList<PageSequence>();
}
/** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
+ super.bind(pList);
mediaUsage = pList.get(PR_MEDIA_USAGE).getEnum();
}
@@ -144,7 +145,11 @@ public class Root extends FObj {
}
- /** @inheritDoc */
+ /**
+ * @param loc location in the source file
+ * @param child the {@link FONode} to validate against
+ * @throws ValidationException if the incoming node is not a valid child for the given FO
+ */
protected void validateChildNode(Locator loc, FONode child) throws ValidationException {
if (child instanceof AbstractPageSequence) {
pageSequenceFound = true;
@@ -207,7 +212,8 @@ public class Root extends FObj {
* @param additionalPages the total pages generated by the sequence (for statistics)
* @throws IllegalArgumentException for negative additional page counts
*/
- public void notifyPageSequenceFinished(int lastPageNumber, int additionalPages) {
+ public void notifyPageSequenceFinished(int lastPageNumber, int additionalPages)
+ throws IllegalArgumentException {
if (additionalPages >= 0) {
totalPagesGenerated += additionalPages;
@@ -238,7 +244,7 @@ public class Root extends FObj {
return null;
}
if (currentIndex < (pageSequences.size() - 1)) {
- return (PageSequence)pageSequences.get(currentIndex + 1);
+ return pageSequences.get(currentIndex + 1);
} else {
return null;
}
@@ -290,7 +296,7 @@ public class Root extends FObj {
*/
public void addDestination(Destination destination) {
if (destinationList == null) {
- destinationList = new java.util.ArrayList();
+ destinationList = new java.util.ArrayList<Destination>();
}
destinationList.add(destination);
}
diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
index 8c95e1b8a..bd186db78 100644
--- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
@@ -56,7 +56,7 @@ public class SimplePageMaster extends FObj {
/**
* Page regions (regionClass, Region)
*/
- private Map regions;
+ private Map<String, Region> regions;
// used for node validation
private boolean hasRegionBody = false;
@@ -99,7 +99,7 @@ public class SimplePageMaster extends FObj {
}
//Well, there are only 5 regions so we can save a bit of memory here
- regions = new HashMap(5);
+ regions = new HashMap<String, Region>(5);
}
/** {@inheritDoc} */
@@ -135,7 +135,7 @@ public class SimplePageMaster extends FObj {
} else if (hasRegionEnd) {
nodesOutOfOrderError(loc, "fo:region-before", "fo:region-end");
} else {
- hasRegionBody = true;
+ hasRegionBefore = true;
}
} else if (localName.equals("region-after")) {
if (!hasRegionBody) {
@@ -192,8 +192,7 @@ public class SimplePageMaster extends FObj {
* @param region region to add
*/
protected void addRegion(Region region) {
- String key = String.valueOf(region.getNameId());
- regions.put(key, region);
+ regions.put(String.valueOf(region.getNameId()), region);
}
/**
@@ -240,14 +239,14 @@ public class SimplePageMaster extends FObj {
* @return the region, null if it doesn't exist
*/
public Region getRegion(int regionId) {
- return (Region) regions.get(String.valueOf(regionId));
+ return regions.get(String.valueOf(regionId));
}
/**
* Returns a Map of regions associated with this simple-page-master
* @return the regions
*/
- public Map getRegions() {
+ public Map<String, Region> getRegions() {
return regions;
}
@@ -258,9 +257,7 @@ public class SimplePageMaster extends FObj {
* @return True if a region with this name exists
*/
protected boolean regionNameExists(String regionName) {
- for (Iterator regenum = regions.values().iterator();
- regenum.hasNext();) {
- Region r = (Region) regenum.next();
+ for (Region r : regions.values()) {
if (r.getRegionName().equals(regionName)) {
return true;
}
diff --git a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
index aa2c2bb8b..2bb891cd9 100644
--- a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
+++ b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
@@ -28,6 +28,7 @@ public interface SubSequenceSpecifier {
/**
* Returns the name of the next page master.
+ *
* @param isOddPage True if the next page number is odd
* @param isFirstPage True if the next page is the first
* @param isLastPage True if the next page is the last