123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- /*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
- package org.apache.fop.fo.pagination;
-
- // FOP
- import org.apache.fop.fo.FObj;
- import org.apache.fop.fo.PropertyList;
- import org.apache.fop.apps.FOPException;
- import org.apache.fop.layout.RegionArea;
-
- /**
- * Abstract base class for pagination regions.
- */
- public abstract class Region extends FObj {
- public static final String PROP_REGION_NAME = "region-name";
-
- private SimplePageMaster _layoutMaster;
- private String _regionName;
-
- protected Region(FObj parent,
- PropertyList propertyList) throws FOPException {
- super(parent, propertyList);
-
- // regions may have name, or default
- if (null == this.properties.get(PROP_REGION_NAME)) {
- setRegionName(getDefaultRegionName());
- } else if (this.properties.get(PROP_REGION_NAME).getString().equals("")) {
- setRegionName(getDefaultRegionName());
- } else {
- setRegionName(this.properties.get(PROP_REGION_NAME).getString());
- // check that name is OK. Not very pretty.
- if (isReserved(getRegionName())
- &&!getRegionName().equals(getDefaultRegionName())) {
- throw new FOPException(PROP_REGION_NAME + " '" + _regionName
- + "' for " + this.getName()
- + " not permitted.");
- }
- }
-
- if (parent.getName().equals("fo:simple-page-master")) {
- _layoutMaster = (SimplePageMaster)parent;
- getPageMaster().addRegion(this);
- } else {
- throw new FOPException(getName() + " must be child "
- + "of simple-page-master, not "
- + parent.getName());
- }
- }
-
- /**
- * Creates a Region layout object for this pagination Region.
- */
- abstract RegionArea makeRegionArea(int allocationRectangleXPosition,
- int allocationRectangleYPosition,
- int allocationRectangleWidth,
- int allocationRectangleHeight);
-
- /**
- * Returns the default region name (xsl-region-before, xsl-region-start,
- * etc.)
- */
- protected abstract String getDefaultRegionName();
-
- public abstract String getRegionClass();
-
-
- /**
- * Returns the name of this region
- */
- public String getRegionName() {
- return _regionName;
- }
-
- private void setRegionName(String name) {
- _regionName = name;
- }
-
- protected SimplePageMaster getPageMaster() {
- return _layoutMaster;
- }
-
- /**
- * Checks to see if a given region name is one of the reserved names
- *
- * @param name a region name to check
- * @return true if the name parameter is a reserved region name
- */
- protected boolean isReserved(String name) throws FOPException {
- return (name.equals("xsl-region-before")
- || name.equals("xsl-region-start")
- || name.equals("xsl-region-end")
- || name.equals("xsl-region-after")
- || name.equals("xsl-before-float-separator")
- || name.equals("xsl-footnote-separator"));
- }
-
- public boolean generatesReferenceAreas() {
- return true;
- }
-
- }
|