From eb38f7030da62d3c307199547c5620f9b2839375 Mon Sep 17 00:00:00 2001 From: Oleg Tkachenko Date: Sun, 24 Nov 2002 07:23:51 +0000 Subject: [PATCH] Support for page-width and page-height "auto" values (fallback to 8 and 11in). Fixes infinite loop when page-height is "auto". git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@195621 13f79535-47bb-0310-9956-ffa450edef68 --- src/codegen/foproperties.xml | 6 +++--- .../apache/fop/fo/pagination/SimplePageMaster.java | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/codegen/foproperties.xml b/src/codegen/foproperties.xml index bc8f18f64..465e23571 100644 --- a/src/codegen/foproperties.xml +++ b/src/codegen/foproperties.xml @@ -1592,7 +1592,7 @@ Length 1.0pt - + @@ -1849,7 +1849,7 @@ false Length - 11in + auto page-position @@ -1868,7 +1868,7 @@ false Length - 8in + auto precedence diff --git a/src/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/org/apache/fop/fo/pagination/SimplePageMaster.java index e792df673..543eff03d 100644 --- a/src/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -9,12 +9,11 @@ package org.apache.fop.fo.pagination; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; import org.apache.fop.layout.PageMaster; -import org.apache.fop.layout.RegionArea; import org.apache.fop.layout.BodyRegionArea; import org.apache.fop.layout.MarginProps; import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.Length; import java.util.HashMap; import java.util.Iterator; @@ -27,6 +26,9 @@ import java.util.Iterator; * ¶6.4.12 */ public class SimplePageMaster extends FObj { + // Fallback values for "auto" page size: 8x11in + private final static int FALLBACK_PAGE_HEIGHT = 792000; + private final static int FALLBACK_PAGE_WIDTH = 576000; public static class Maker extends FObj.Maker { public FObj make(FObj parent, @@ -82,10 +84,10 @@ public class SimplePageMaster extends FObj { } protected void end() { - int pageWidth = - this.properties.get("page-width").getLength().mvalue(); - int pageHeight = - this.properties.get("page-height").getLength().mvalue(); + Length pageWidthLen = this.properties.get("page-width").getLength(); + int pageWidth = pageWidthLen.isAuto() ? FALLBACK_PAGE_WIDTH : pageWidthLen.mvalue(); + Length pageHeightLen = this.properties.get("page-height").getLength(); + int pageHeight = pageHeightLen.isAuto() ? FALLBACK_PAGE_HEIGHT : pageHeightLen.mvalue(); // this.properties.get("reference-orientation"); // this.properties.get("writing-mode"); -- 2.39.5