aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/pagination
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-09-05 08:09:42 +0000
committerJeremias Maerki <jeremias@apache.org>2005-09-05 08:09:42 +0000
commit299c6b1393cf9d5194929ac8c756171b2ff2ce4f (patch)
treea03a028f1ef7f339b938f6af08a2a51391e3216a /src/java/org/apache/fop/fo/pagination
parent2daa1220f0331d560481ed48d5531ee1b6555793 (diff)
downloadxmlgraphics-fop-299c6b1393cf9d5194929ac8c756171b2ff2ce4f.tar.gz
xmlgraphics-fop-299c6b1393cf9d5194929ac8c756171b2ff2ce4f.zip
Bugzilla #36487:
Background images were incorrectly positioned in some absolute positioned blocks. Some additional attributes output by the XMLRenderer. Refactored the layout for e-g and i-f-o. Introduced common base classes for the corresponding flow objects as well as the e-g and i-f-o LMs. Fixed incorrectly applied margins on region-body when writing mode is not lr. Fixed application of correct percent base for margins and extents on regions when the reference orientation is 90 degrees. Fixed incorrectly positioned regions when writing mode is different between the simple-page-master setting and the setting on the region. Several updates to the layout engine test cases. Submitted by: Manuel Mall <mm.at.arcus.com.au> git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@278690 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/Region.java4
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionAfter.java46
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionBefore.java45
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionBody.java59
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionEnd.java40
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionStart.java42
6 files changed, 149 insertions, 87 deletions
diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java
index 4980d057e..756b2be03 100644
--- a/src/java/org/apache/fop/fo/pagination/Region.java
+++ b/src/java/org/apache/fop/fo/pagination/Region.java
@@ -99,11 +99,11 @@ public abstract class Region extends FObj {
/**
* @param pageRefRect reference dimension of the page area.
- * @param pageViewRectRect page view port dimensions.
+ * @param spm the simple page master this region belongs to.
* @return the rectangle for the viewport area
*/
public abstract Rectangle getViewportRectangle(FODimension pageRefRect
- , FODimension pageViewPortRect);
+ , SimplePageMaster spm);
/**
* 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 68d6d066d..776f9d764 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java
@@ -40,31 +40,43 @@ public class RegionAfter extends RegionBA {
}
/**
- * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+ * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
*/
- public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
- // Depends on extent, precedence ans writing mode
- /* Special rules apply to resolving extent.
- * In the property subsystem the extent property is configured to
- * using BLOCK_WIDTH as its percent base.
- * However, depending on the writing mode extent import resolved either
- * against the page width or the page height.
+ public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+ /* Special rules apply to resolving extent as values are resolved relative
+ * to the page size and reference orientation.
*/
- Rectangle vpRect;
- SimplePercentBaseContext pageWidthContext
- = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
- SimplePercentBaseContext pageHeightContext
- = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+ 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;
- if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
+ Rectangle vpRect;
+ if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
neighbourContext = pageWidthContext;
- vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext), reldims.ipd, getExtent().getValue(pageHeightContext));
+ vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext)
+ , reldims.ipd, getExtent().getValue(pageHeightContext));
} else {
neighbourContext = pageHeightContext;
- vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageWidthContext), getExtent().getValue(pageWidthContext), reldims.ipd);
+ vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageWidthContext)
+ , getExtent().getValue(pageWidthContext), reldims.ipd);
}
if (getPrecedence() == EN_FALSE) {
- adjustIPD(vpRect, getWritingMode(), neighbourContext);
+ adjustIPD(vpRect, spm.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 c1f683c05..53279e4da 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java
@@ -46,28 +46,33 @@ public class RegionBefore extends RegionBA {
}
/**
- * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+ * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
*/
- public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
- // Depends on extent, precedence and writing mode
- // This should return rectangle in writing-mode coordinates relative
- // to the page-reference area rectangle
- // This means the origin is (start, before) and the dimensions are (ipd,bpd)
- // Before is always 0, start depends on extent
- // ipd depends on precedence, bpd=extent
- /* Special rules apply to resolving extent.
- * In the property subsystem the extent property is configured to
- * using BLOCK_WIDTH as its percent base.
- * However, depending on the writing mode extent import resolved either
- * against the page width or the page height.
+ public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+ /* Special rules apply to resolving extent as values are resolved relative
+ * to the page size and reference orientation.
*/
- Rectangle vpRect;
- SimplePercentBaseContext pageWidthContext
- = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
- SimplePercentBaseContext pageHeightContext
- = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+ 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;
- if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
+ Rectangle vpRect;
+ if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
neighbourContext = pageWidthContext;
vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue(pageHeightContext));
} else {
@@ -75,7 +80,7 @@ public class RegionBefore extends RegionBA {
vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.ipd);
}
if (getPrecedence() == EN_FALSE) {
- adjustIPD(vpRect, getWritingMode(), neighbourContext);
+ adjustIPD(vpRect, spm.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 835802469..855b2747f 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionBody.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java
@@ -63,13 +63,14 @@ public class RegionBody extends Region {
* these cases, but we will need to be able to change Numeric
* values in order to do this.
*/
- attributeError("If overflow property is set to \"scroll\"," +
- " a column-count other than \"1\" may not be specified.");
+ attributeError("If overflow property is set to \"scroll\","
+ + " a column-count other than \"1\" may not be specified.");
}
}
/**
* Return the Common Margin Properties-Block.
+ * @return the Common Margin Properties-Block.
*/
public CommonMarginBlock getCommonMarginBlock() {
return commonMarginBlock;
@@ -77,6 +78,7 @@ public class RegionBody extends Region {
/**
* Return the "column-count" property.
+ * @return the "column-count" property.
*/
public int getColumnCount() {
return columnCount.getValue();
@@ -84,35 +86,60 @@ public class RegionBody extends Region {
/**
* Return the "column-gap" property.
+ * @return the "column-gap" property.
*/
public int getColumnGap() {
return columnGap.getValue();
}
/**
- * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+ * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
*/
- public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
+ public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
/* 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
* all margin properties are configured to using BLOCK_WIDTH.
* That's why we 'cheat' here and setup a context for the height but
* use the LengthBase.BLOCK_WIDTH.
- * Also the values are resolved relative to the page size.
+ * Also the values are resolved relative to the page size
+ * and reference orientation.
*/
- SimplePercentBaseContext pageWidthContext
- = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortRect.ipd);
- SimplePercentBaseContext pageHeightContext
- = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortRect.bpd);
+ 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());
+ }
- int left = commonMarginBlock.marginLeft.getValue(pageWidthContext);
- int right = commonMarginBlock.marginRight.getValue(pageWidthContext);
- int top = commonMarginBlock.marginTop.getValue(pageHeightContext);
- int bottom = commonMarginBlock.marginBottom.getValue(pageHeightContext);
- return new Rectangle(left, top,
- reldims.ipd - left - right,
- reldims.bpd - top - bottom);
+ int start;
+ int end;
+ if (spm.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
+ start = commonMarginBlock.marginRight.getValue(pageWidthContext);
+ end = commonMarginBlock.marginLeft.getValue(pageWidthContext);
+ }
+ int before = commonMarginBlock.spaceBefore.getOptimum(pageHeightContext)
+ .getLength().getValue(pageHeightContext);
+ int after = commonMarginBlock.spaceAfter.getOptimum(pageHeightContext)
+ .getLength().getValue(pageHeightContext);
+ return new Rectangle(start, before,
+ reldims.ipd - start - end,
+ reldims.bpd - before - after);
}
/**
diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java
index a097ec375..eadc08992 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java
@@ -39,23 +39,33 @@ public class RegionEnd extends RegionSE {
}
/**
- * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+ * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
*/
- public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
- // Depends on extent, precedence and writing mode
- /* Special rules apply to resolving extent.
- * In the property subsystem the extent property is configured to
- * using BLOCK_WIDTH as its percent base.
- * However, depending on the writing mode extent import resolved either
- * against the page width or the page height.
+ public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+ /* Special rules apply to resolving extent as values are resolved relative
+ * to the page size and reference orientation.
*/
- Rectangle vpRect;
- SimplePercentBaseContext pageWidthContext
- = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
- SimplePercentBaseContext pageHeightContext
- = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+ 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;
- if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
+ Rectangle vpRect;
+ if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
neighbourContext = pageHeightContext;
vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0,
getExtent().getValue(pageWidthContext), reldims.bpd);
@@ -65,7 +75,7 @@ public class RegionEnd extends RegionSE {
vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageHeightContext), 0,
reldims.bpd, getExtent().getValue(pageHeightContext));
}
- adjustIPD(vpRect, getWritingMode(), neighbourContext);
+ adjustIPD(vpRect, spm.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 2de7cc68f..2d74069bc 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionStart.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java
@@ -39,32 +39,40 @@ public class RegionStart extends RegionSE {
}
/**
- * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension)
+ * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension, SimplePageMaster)
*/
- public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) {
- // Depends on extent, precedence and writing mode
- // This is the rectangle relative to the page-reference area in
- // writing-mode relative coordinates
- /* Special rules apply to resolving extent.
- * In the property subsystem the extent property is configured to
- * using BLOCK_WIDTH as its percent base.
- * However, depending on the writing mode extent import resolved either
- * against the page width or the page height.
+ public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+ /* Special rules apply to resolving extent as values are resolved relative
+ * to the page size and reference orientation.
*/
- Rectangle vpRect;
- SimplePercentBaseContext pageWidthContext
- = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd);
- SimplePercentBaseContext pageHeightContext
- = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd);
+ 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;
- if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) {
+ Rectangle vpRect;
+ if (spm.getWritingMode() == EN_LR_TB || spm.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, getWritingMode(), neighbourContext);
+ adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
return vpRect;
}