diff options
author | Andreas L. Delmelle <adelmelle@apache.org> | 2005-09-24 22:00:02 +0000 |
---|---|---|
committer | Andreas L. Delmelle <adelmelle@apache.org> | 2005-09-24 22:00:02 +0000 |
commit | 78a328cba576a8857eb4a299741b7568736f075d (patch) | |
tree | 29bb195bc5f4e60a2bea8889d48edfe46179e982 /src/java/org/apache/fop/fo/properties/PageDimensionMaker.java | |
parent | 3bbd46a754991021b4ab2a1e644dad54c865dcbe (diff) | |
download | xmlgraphics-fop-78a328cba576a8857eb4a299741b7568736f075d.tar.gz xmlgraphics-fop-78a328cba576a8857eb4a299741b7568736f075d.zip |
Added custom Maker for page-height and page-width; use fallback values in case value is auto
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@291338 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/properties/PageDimensionMaker.java')
-rw-r--r-- | src/java/org/apache/fop/fo/properties/PageDimensionMaker.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java b/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java new file mode 100644 index 000000000..cf50fc41f --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java @@ -0,0 +1,70 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.fo.properties; + +import org.apache.fop.fo.Constants; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.fo.properties.LengthProperty; + +/** + * Custom Maker for page-height / page-width + * + */ +public class PageDimensionMaker extends LengthProperty.Maker { + + /** + * Constructor + * + * @param propId the property Id + */ + public PageDimensionMaker(int propId) { + super(propId); + } + + /** + * Check the value of the page-width / page-height property. + * Return the default or user-defined fallback in case the value + * was specified as "auto" + * + * @see org.apache.fop.fo.properties.PropertyMaker#get(int, PropertyList, boolean, boolean) + */ + public Property get(int subpropId, PropertyList propertyList, + boolean tryInherit, boolean tryDefault) + throws PropertyException { + + Property p = super.get(0, propertyList, tryInherit, tryDefault); + + //TODO: add check for both height and width being specified as indefinite + // and use the fallback value (= set to "auto") + + if (p.isAuto()) { + FObj fo = propertyList.getFObj(); + + String fallbackValue = (propId == Constants.PR_PAGE_HEIGHT) + ? fo.getFOEventHandler().getUserAgent().getPageHeight() + : fo.getFOEventHandler().getUserAgent().getPageWidth(); + return make(propertyList, fallbackValue, fo); + } + + return p; + } + +} |