From cbf2374388014a02bf3ffe87455476b639f03d32 Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Sun, 1 Aug 2004 15:26:53 +0000 Subject: [PATCH] PR: Obtained from: Submitted by: Reviewed by: Consolidated RegionBASE into Region and RegionBA/RegionSE (RegionBASE was supporting only one unique property.) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197848 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/fo/pagination/Region.java | 14 +--- .../apache/fop/fo/pagination/RegionBA.java | 26 ++++---- .../apache/fop/fo/pagination/RegionBASE.java | 65 ------------------- .../fop/fo/pagination/RegionBefore.java | 6 +- .../apache/fop/fo/pagination/RegionSE.java | 17 +++-- .../apache/fop/layoutmgr/AddLMVisitor.java | 12 +--- 6 files changed, 30 insertions(+), 110 deletions(-) delete mode 100644 src/java/org/apache/fop/fo/pagination/RegionBASE.java diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index b04c51a29..b6838bd76 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -57,6 +57,8 @@ public abstract class Region extends FObj { /** Holds the writing mode */ protected int wm; + protected int extent = 0; + /** * @see org.apache.fop.fo.FONode#FONode(FONode) */ @@ -190,16 +192,6 @@ public abstract class Region extends FObj { } public int getExtent() { - return 0; - } - - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveRegion(this); + return extent; } - } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBA.java b/src/java/org/apache/fop/fo/pagination/RegionBA.java index de1866b38..b0da0abe4 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBA.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBA.java @@ -22,6 +22,7 @@ package org.apache.fop.fo.pagination; import java.awt.Rectangle; // XML +import org.xml.sax.Attributes; import org.xml.sax.SAXParseException; // FOP @@ -32,7 +33,7 @@ import org.apache.fop.layoutmgr.AddLMVisitor; /** * Abstract base class for fo:region-before and fo:region-after. */ -public abstract class RegionBA extends RegionBASE { +public abstract class RegionBA extends Region { private boolean bPrecedence; @@ -43,6 +44,15 @@ public abstract class RegionBA extends RegionBASE { super(parent, regionId); } + protected void addProperties(Attributes attlist) throws SAXParseException { + super.addProperties(attlist); + + bPrecedence = + (this.propertyList.get(PR_PRECEDENCE).getEnum() == Precedence.TRUE); + + this.extent = this.propertyList.get(PR_EXTENT).getLength().getValue(); + } + /** * @see org.apache.fop.fo.pagination.Region#getPrecedence() */ @@ -50,15 +60,6 @@ public abstract class RegionBA extends RegionBASE { return bPrecedence; } - /** - * @see org.apache.fop.fo.FONode#endOfNode() - */ - protected void endOfNode() throws SAXParseException { - super.endOfNode(); - bPrecedence = - (this.propertyList.get(PR_PRECEDENCE).getEnum() == Precedence.TRUE); - } - /** * Adjust the viewport reference rectangle for a region as a function * of precedence. @@ -87,10 +88,5 @@ public abstract class RegionBA extends RegionBASE { } } } - - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveRegionBA(this); - } - } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBASE.java b/src/java/org/apache/fop/fo/pagination/RegionBASE.java deleted file mode 100644 index 8bc8c8f20..000000000 --- a/src/java/org/apache/fop/fo/pagination/RegionBASE.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 1999-2004 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.pagination; - -// XML -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -// FOP -import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; - - -/** - * Base class for Before, After, Start and End regions (BASE). - */ -public abstract class RegionBASE extends Region { - - private int extent; - - /** - * @see org.apache.fop.fo.FONode#FONode(FONode) - */ - protected RegionBASE(FONode parent, int regionId) { - super(parent, regionId); - } - - /** - * @see org.apache.fop.fo.FONode#endOfNode() - */ - protected void endOfNode() throws SAXParseException { - // The problem with this is that it might not be known yet.... - // Supposing extent is calculated in terms of percentage - this.extent = this.propertyList.get(PR_EXTENT).getLength().getValue(); - } - - /** - * @see org.apache.fop.fo.pagination.Region#getExtent() - */ - public int getExtent() { - return this.extent; - } - - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveRegionBASE(this); - } - -} - diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java index b87eff4c9..e9e59201a 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java @@ -18,14 +18,14 @@ package org.apache.fop.fo.pagination; +// Java +import java.awt.Rectangle; + // FOP import org.apache.fop.datatypes.FODimension; import org.apache.fop.fo.FONode; import org.apache.fop.layoutmgr.AddLMVisitor; -// Java -import java.awt.Rectangle; - /** * The fo:region-before element. */ diff --git a/src/java/org/apache/fop/fo/pagination/RegionSE.java b/src/java/org/apache/fop/fo/pagination/RegionSE.java index 4981cdae0..53976210c 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionSE.java +++ b/src/java/org/apache/fop/fo/pagination/RegionSE.java @@ -21,6 +21,10 @@ package org.apache.fop.fo.pagination; // Java import java.awt.Rectangle; +// XML +import org.xml.sax.Attributes; +import org.xml.sax.SAXParseException; + // FOP import org.apache.fop.fo.FONode; import org.apache.fop.layoutmgr.AddLMVisitor; @@ -28,7 +32,7 @@ import org.apache.fop.layoutmgr.AddLMVisitor; /** * Abstract base class for fo:region-start and fo:region-end. */ -public abstract class RegionSE extends RegionBASE { +public abstract class RegionSE extends Region { /** * @see org.apache.fop.fo.FONode#FONode(FONode) @@ -37,6 +41,12 @@ public abstract class RegionSE extends RegionBASE { super(parent, regionId); } + protected void addProperties(Attributes attlist) throws SAXParseException { + super.addProperties(attlist); + + this.extent = this.propertyList.get(PR_EXTENT).getLength().getValue(); + } + /** * Adjust the viewport reference rectangle for a region as a function * of precedence. @@ -66,10 +76,5 @@ public abstract class RegionSE extends RegionBASE { } } } - - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveRegionSE(this); - } - } diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index fbd13e027..3b30e81c6 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -105,7 +105,6 @@ import org.apache.fop.fo.pagination.PageSequenceMaster; import org.apache.fop.fo.pagination.Region; import org.apache.fop.fo.pagination.RegionAfter; import org.apache.fop.fo.pagination.RegionBA; -import org.apache.fop.fo.pagination.RegionBASE; import org.apache.fop.fo.pagination.RegionBefore; import org.apache.fop.fo.pagination.RegionBody; import org.apache.fop.fo.pagination.RegionEnd; @@ -964,18 +963,11 @@ public class AddLMVisitor { serveFObj((FObj)node); } - /** - * @param node RegionBASE object to process - */ - public void serveRegionBASE(RegionBASE node) { - serveRegion((Region)node); - } - /** * @param node RegionBA object to process */ public void serveRegionBA(RegionBA node) { - serveRegionBASE((RegionBASE)node); + serveRegion((Region)node); } /** @@ -996,7 +988,7 @@ public class AddLMVisitor { * @param node RegionSE object to process */ public void serveRegionSE(RegionSE node) { - serveRegionBASE((RegionBASE)node); + serveRegion((Region)node); } /** -- 2.39.5