aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorPeter Herweg <pherweg@apache.org>2004-01-28 19:00:09 +0000
committerPeter Herweg <pherweg@apache.org>2004-01-28 19:00:09 +0000
commit76cbbf7f7c91955f3c441b29a4fac2b9b235f0c9 (patch)
tree4571bb50da889c1431361444311a7c8822886100 /src/java/org/apache
parent5bcd5f1f2f587405256da3ffb4f645f6e83d070a (diff)
downloadxmlgraphics-fop-76cbbf7f7c91955f3c441b29a4fac2b9b235f0c9.tar.gz
xmlgraphics-fop-76cbbf7f7c91955f3c441b29a4fac2b9b235f0c9.zip
improved support for margin-top and margin-bottom in fo:region-XXX
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197283 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/render/rtf/PageAttributesConverter.java114
-rw-r--r--src/java/org/apache/fop/render/rtf/RTFHandler.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java7
3 files changed, 96 insertions, 27 deletions
diff --git a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
index f3030911b..994aacfaa 100644
--- a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
@@ -56,6 +56,8 @@ import org.apache.avalon.framework.logger.ConsoleLogger;
//FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.pagination.Region;
+import org.apache.fop.fo.pagination.SimplePageMaster;
import org.apache.fop.fo.Property;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
@@ -72,48 +74,110 @@ class PageAttributesConverter {
private static Logger log = new ConsoleLogger();
/** convert xsl:fo attributes to RTF text attributes */
- static RtfAttributes convertPageAttributes(PropertyList props, PropertyList defProps) {
- RtfAttributes attrib = null;
-
+ static RtfAttributes convertPageAttributes(SimplePageMaster pagemaster) {
+ RtfAttributes attrib = new RtfAttributes();
+
try {
- Property p;
-
- if (defProps != null) {
- attrib = convertPageAttributes(defProps, null);
- } else {
- attrib = new RtfAttributes();
- }
-
+ FoUnitsConverter converter = FoUnitsConverter.getInstance();
+
+ float fPageTop = 0;
+ float fPageBottom = 0;
+ PropertyList props = null;
+ Property p = null;
+ Float f = null;
+
+ Region before = pagemaster.getRegion("before");
+ Region body = pagemaster.getRegion("body");
+ Region after = pagemaster.getRegion("after");
+
+ //page attributes
+ props = pagemaster.propertyList;
+
if ((p = props.get(Constants.PR_PAGE_WIDTH)) != null) {
- Float f = new Float(p.getLength().getValue() / 1000f);
+ f = new Float(p.getLength().getValue() / 1000f);
attrib.set(RtfPage.PAGE_WIDTH,
- (int)FoUnitsConverter.getInstance().convertToTwips(f.toString() + "pt"));
+ (int)converter.convertToTwips(f.toString() + "pt"));
}
+
if ((p = props.get(Constants.PR_PAGE_HEIGHT)) != null) {
- Float f = new Float(p.getLength().getValue() / 1000f);
+ f = new Float(p.getLength().getValue() / 1000f);
attrib.set(RtfPage.PAGE_HEIGHT,
- (int)FoUnitsConverter.getInstance().convertToTwips(f.toString() + "pt"));
+ (int)converter.convertToTwips(f.toString() + "pt"));
}
+
if ((p = props.get(Constants.PR_MARGIN_TOP)) != null) {
- Float f = new Float(p.getLength().getValue() / 1000f);
- attrib.set(RtfPage.MARGIN_TOP,
- (int)FoUnitsConverter.getInstance().convertToTwips(f.toString() + "pt"));
+ fPageTop = p.getLength().getValue() / 1000f;
}
+
if ((p = props.get(Constants.PR_MARGIN_BOTTOM)) != null) {
- Float f = new Float(p.getLength().getValue() / 1000f);
- attrib.set(RtfPage.MARGIN_BOTTOM,
- (int)FoUnitsConverter.getInstance().convertToTwips(f.toString() + "pt"));
+ fPageBottom = p.getLength().getValue() / 1000f;
}
+
if ((p = props.get(Constants.PR_MARGIN_LEFT)) != null) {
- Float f = new Float(p.getLength().getValue() / 1000f);
+ f = new Float(p.getLength().getValue() / 1000f);
attrib.set(RtfPage.MARGIN_LEFT,
- (int)FoUnitsConverter.getInstance().convertToTwips(f.toString() + "pt"));
+ (int)converter.convertToTwips(f.toString() + "pt"));
}
if ((p = props.get(Constants.PR_MARGIN_RIGHT)) != null) {
- Float f = new Float(p.getLength().getValue() / 1000f);
+ f = new Float(p.getLength().getValue() / 1000f);
attrib.set(RtfPage.MARGIN_RIGHT,
- (int)FoUnitsConverter.getInstance().convertToTwips(f.toString() + "pt"));
+ (int)converter.convertToTwips(f.toString() + "pt"));
+ }
+
+ //region-body attributes
+ float fBodyTop = fPageTop;
+ float fBodyBottom = fPageBottom;
+
+ if (body != null) {
+ props = body.propertyList;
+
+ if ((p = props.get(Constants.PR_MARGIN_TOP)) != null) {
+ fBodyTop += p.getLength().getValue() / 1000f;
+ }
+
+ if ((p = props.get(Constants.PR_MARGIN_BOTTOM)) != null) {
+ fBodyBottom += p.getLength().getValue() / 1000f;
+ }
}
+
+ f = new Float(fBodyTop);
+ attrib.set(RtfPage.MARGIN_TOP,
+ (int)converter.convertToTwips(f.toString() + "pt"));
+
+ f = new Float(fBodyBottom);
+ attrib.set(RtfPage.MARGIN_BOTTOM,
+ (int)converter.convertToTwips(f.toString() + "pt"));
+
+ //region-before attributes
+ float fBeforeTop = fPageTop;
+
+ if (before != null) {
+ props = before.propertyList;
+
+ if ((p = props.get(Constants.PR_MARGIN_TOP)) != null) {
+ fBeforeTop += p.getLength().getValue() / 1000f;
+ }
+ }
+
+ f = new Float(fBeforeTop);
+ attrib.set(RtfPage.HEADERY,
+ (int)converter.convertToTwips(f.toString() + "pt"));
+
+ //region-after attributes
+ float fAfterBottom = fPageBottom;
+
+ if (after != null) {
+ props = after.propertyList;
+
+ if ((p = props.get(Constants.PR_MARGIN_BOTTOM)) != null) {
+ fAfterBottom += p.getLength().getValue() / 1000f;
+ }
+ }
+
+ f = new Float(fAfterBottom);
+ attrib.set(RtfPage.FOOTERY,
+ (int)converter.convertToTwips(f.toString() + "pt"));
+
} catch (FOPException e) {
log.error("Exception in convertPageAttributes: "
+ e.getMessage() + "- page attributes ignored");
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index 5f2f73114..72250b650 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -216,7 +216,7 @@ public class RTFHandler extends FOInputHandler {
if (pagemaster != null) {
sect.getRtfAttributes().set(
PageAttributesConverter.convertPageAttributes(
- pagemaster.propertyList, null));
+ pagemaster));
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
index 1d2a3a325..55f5a042a 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
@@ -84,11 +84,16 @@ extends RtfContainer {
public static final String MARGIN_LEFT = "margl";
/** constant for right margin */
public static final String MARGIN_RIGHT = "margr";
+
+ /** constant for header position */
+ public static final String HEADERY = "headery";
+ /** constant for footer position */
+ public static final String FOOTERY = "footery";
/** String array of RtfPage attributes */
public static final String[] PAGE_ATTR = new String[]{
PAGE_WIDTH, PAGE_HEIGHT, MARGIN_TOP, MARGIN_BOTTOM,
- MARGIN_LEFT, MARGIN_RIGHT
+ MARGIN_LEFT, MARGIN_RIGHT, HEADERY, FOOTERY
};
/** RtfPage creates new page attributes with the parent container, the writer