From 95578ece33bc4875131447a7e678012559a7248b Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 6 Mar 2003 13:42:42 +0000 Subject: [PATCH] Switched to long licence Some general checkstyle fixing git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196028 13f79535-47bb-0310-9956-ffa450edef68 --- .../ConditionalPageMasterReference.java | 108 ++++++++++++--- .../fop/fo/pagination/LayoutMasterSet.java | 120 +++++++++++++---- .../fo/pagination/PageMasterReference.java | 79 +++++++++-- .../fo/pagination/PageNumberGenerator.java | 82 ++++++++++-- .../fop/fo/pagination/PageSequence.java | 53 +++++++- .../fop/fo/pagination/PageSequenceMaster.java | 126 ++++++++++++++---- src/org/apache/fop/fo/pagination/Region.java | 126 +++++++++++++++--- .../apache/fop/fo/pagination/RegionAfter.java | 84 ++++++++++-- .../apache/fop/fo/pagination/RegionBA.java | 90 ++++++++++--- .../apache/fop/fo/pagination/RegionBASE.java | 9 ++ .../fop/fo/pagination/RegionBefore.java | 76 ++++++++++- .../apache/fop/fo/pagination/RegionBody.java | 19 +++ .../apache/fop/fo/pagination/RegionEnd.java | 81 +++++++++-- .../apache/fop/fo/pagination/RegionSE.java | 78 +++++++++-- .../apache/fop/fo/pagination/RegionStart.java | 80 +++++++++-- .../RepeatablePageMasterAlternatives.java | 82 ++++++++++-- .../RepeatablePageMasterReference.java | 75 +++++++++-- src/org/apache/fop/fo/pagination/Root.java | 85 ++++++++++-- .../fop/fo/pagination/SimplePageMaster.java | 53 +++++++- .../pagination/SinglePageMasterReference.java | 63 ++++++++- .../fo/pagination/SubSequenceSpecifier.java | 73 ++++++++-- 21 files changed, 1400 insertions(+), 242 deletions(-) diff --git a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java index a85ddd43a..598965dde 100644 --- a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java @@ -1,18 +1,66 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.apps.FOPException; - +// XML import org.xml.sax.Attributes; +// FOP +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.properties.BlankOrNotBlank; +import org.apache.fop.fo.properties.OddOrEven; +import org.apache.fop.fo.properties.PagePosition; +import org.apache.fop.apps.FOPException; + /** * A conditional-page-master-reference formatting object. * This is a reference to a page master with a set of conditions. @@ -31,10 +79,16 @@ public class ConditionalPageMasterReference extends FObj { private int oddOrEven; private int blankOrNotBlank; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public ConditionalPageMasterReference(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); if (getProperty("master-reference") != null) { @@ -48,12 +102,17 @@ public class ConditionalPageMasterReference extends FObj { this.blankOrNotBlank = this.properties.get("blank-or-not-blank").getEnum(); } + /** + * Sets the master name. + * @param masterName name for the master + */ protected void setMasterName(String masterName) { this.masterName = masterName; } /** * Returns the "master-name" attribute of this page master reference + * @return the master name */ public String getMasterName() { return masterName; @@ -63,22 +122,27 @@ public class ConditionalPageMasterReference extends FObj { * Check if the conditions for this reference are met. * checks the page number and emptyness to determine if this * matches. + * @param isOddPage True if page number odd + * @param isFirstPage True if page is first page + * @param isBlankPage True if page is blank + * @return True if the conditions for this reference are met */ - protected boolean isValid(boolean isOddPage, boolean isFirstPage, - boolean isEmptyPage) { + protected boolean isValid(boolean isOddPage, + boolean isFirstPage, + boolean isBlankPage) { // page-position - if( isFirstPage ) { - if (pagePosition==PagePosition.REST) { + if (isFirstPage) { + if (pagePosition == PagePosition.REST) { return false; - } else if (pagePosition==PagePosition.LAST) { + } else if (pagePosition == PagePosition.LAST) { // how the hell do you know at this point? getLogger().debug("LAST PagePosition NYI"); return false; } } else { - if (pagePosition==PagePosition.FIRST) { + if (pagePosition == PagePosition.FIRST) { return false; - } else if (pagePosition==PagePosition.LAST) { + } else if (pagePosition == PagePosition.LAST) { // how the hell do you know at this point? getLogger().debug("LAST PagePosition NYI"); // potentially valid, don't return @@ -87,22 +151,22 @@ public class ConditionalPageMasterReference extends FObj { // odd-or-even if (isOddPage) { - if (oddOrEven==OddOrEven.EVEN) { + if (oddOrEven == OddOrEven.EVEN) { return false; } } else { - if (oddOrEven==OddOrEven.ODD) { + if (oddOrEven == OddOrEven.ODD) { return false; } } // blank-or-not-blank - if (isEmptyPage) { - if (blankOrNotBlank==BlankOrNotBlank.NOT_BLANK) { + if (isBlankPage) { + if (blankOrNotBlank == BlankOrNotBlank.NOT_BLANK) { return false; } } else { - if (blankOrNotBlank==BlankOrNotBlank.BLANK) { + if (blankOrNotBlank == BlankOrNotBlank.BLANK) { return false; } } @@ -112,6 +176,8 @@ public class ConditionalPageMasterReference extends FObj { /** * Check that the parent is the right type of formatting object * repeatable-page-master-alternatives. + * @param parent parent node + * @throws FOPException If the parent is invalid */ protected void validateParent(FONode parent) throws FOPException { if (parent.getName().equals("fo:repeatable-page-master-alternatives")) { diff --git a/src/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/org/apache/fop/fo/pagination/LayoutMasterSet.java index 87f6e9331..9e60dff9f 100644 --- a/src/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -1,23 +1,67 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.apps.FOPException; - // Java -import java.util.HashMap; import java.util.Iterator; import java.util.Map; +// XML import org.xml.sax.Attributes; +// FOP +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; +import org.apache.fop.apps.FOPException; + /** * The layout-master-set formatting object. * This class maintains the set of simple page master and @@ -28,13 +72,20 @@ import org.xml.sax.Attributes; * information for a page sequence. */ public class LayoutMasterSet extends FObj { + private Map simplePageMasters; private Map pageSequenceMasters; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public LayoutMasterSet(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); @@ -46,22 +97,25 @@ public class LayoutMasterSet extends FObj { + parent.getName()); } - this.simplePageMasters = new HashMap(); - this.pageSequenceMasters = new HashMap(); + this.simplePageMasters = new java.util.HashMap(); + this.pageSequenceMasters = new java.util.HashMap(); } /** * Add a simple page master. * The name is checked to throw an error if already added. + * @param simplePageMaster simple-page-master to add + * @throws FOPException if there's a problem with name uniqueness */ protected void addSimplePageMaster(SimplePageMaster simplePageMaster) - throws FOPException { + throws FOPException { // check against duplication of master-name - if (existsName(simplePageMaster.getMasterName())) + if (existsName(simplePageMaster.getMasterName())) { throw new FOPException("'master-name' (" + simplePageMaster.getMasterName() + ") must be unique " + "across page-masters and page-sequence-masters"); + } this.simplePageMasters.put(simplePageMaster.getMasterName(), simplePageMaster); } @@ -70,6 +124,8 @@ public class LayoutMasterSet extends FObj { * Get a simple page master by name. * This is used by the page sequence to get a page master for * creating pages. + * @param masterName the name of the page master + * @return the requested simple-page-master */ public SimplePageMaster getSimplePageMaster(String masterName) { return (SimplePageMaster)this.simplePageMasters.get(masterName); @@ -78,14 +134,19 @@ public class LayoutMasterSet extends FObj { /** * Add a page sequence master. * The name is checked to throw an error if already added. + * @param masterName name for the master + * @param pageSequenceMaster PageSequenceMaster instance + * @throws FOPException if there's a problem with name uniqueness */ - protected void addPageSequenceMaster(String masterName, PageSequenceMaster pageSequenceMaster) - throws FOPException { + protected void addPageSequenceMaster(String masterName, + PageSequenceMaster pageSequenceMaster) + throws FOPException { // check against duplication of master-name - if (existsName(masterName)) + if (existsName(masterName)) { throw new FOPException("'master-name' (" + masterName + ") must be unique " + "across page-masters and page-sequence-masters"); + } this.pageSequenceMasters.put(masterName, pageSequenceMaster); } @@ -93,6 +154,8 @@ public class LayoutMasterSet extends FObj { * Get a page sequence master by name. * This is used by the page sequence to get a page master for * creating pages. + * @param masterName name of the master + * @return the requested PageSequenceMaster instance */ public PageSequenceMaster getPageSequenceMaster(String masterName) { return (PageSequenceMaster)this.pageSequenceMasters.get(masterName); @@ -100,23 +163,27 @@ public class LayoutMasterSet extends FObj { private boolean existsName(String masterName) { if (simplePageMasters.containsKey(masterName) - || pageSequenceMasters.containsKey(masterName)) + || pageSequenceMasters.containsKey(masterName)) { return true; - else + } else { return false; + } } + /** + * Section 7.33.15: check to see that if a region-name is a + * duplicate, that it maps to the same region-class. + * @throws FOPException if there's a name duplication + */ protected void checkRegionNames() throws FOPException { - // Section 7.33.15 check to see that if a region-name is a - // duplicate, that it maps to the same region-class. - Map allRegions = new HashMap(); + Map allRegions = new java.util.HashMap(); for (Iterator spm = simplePageMasters.values().iterator(); - spm.hasNext(); ) { + spm.hasNext();) { SimplePageMaster simplePageMaster = (SimplePageMaster)spm.next(); Map spmRegions = simplePageMaster.getRegions(); for (Iterator e = spmRegions.values().iterator(); - e.hasNext(); ) { + e.hasNext();) { Region region = (Region)e.next(); if (allRegions.containsKey(region.getRegionName())) { String localClass = @@ -138,12 +205,13 @@ public class LayoutMasterSet extends FObj { } /** - * Checks whether or not a region name exists in this master set + * Checks whether or not a region name exists in this master set. + * @param regionName name of the region * @return true when the region name specified has a region in this LayoutMasterSet */ protected boolean regionNameExists(String regionName) { for (Iterator e = simplePageMasters.values().iterator(); - e.hasNext(); ) { + e.hasNext();) { if (((SimplePageMaster)e.next()).regionNameExists(regionName)) { return true; } diff --git a/src/org/apache/fop/fo/pagination/PageMasterReference.java b/src/org/apache/fop/fo/pagination/PageMasterReference.java index 400b27d0c..bc87aced8 100644 --- a/src/org/apache/fop/fo/pagination/PageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/PageMasterReference.java @@ -1,32 +1,82 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.apps.FOPException; - // SAX import org.xml.sax.Attributes; +// FOP +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; +import org.apache.fop.apps.FOPException; + /** * Base PageMasterReference class. Provides implementation for handling the * master-reference attribute and containment within a PageSequenceMaster */ public abstract class PageMasterReference extends FObj - implements SubSequenceSpecifier { + implements SubSequenceSpecifier { private String masterName; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public PageMasterReference(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); if (getProperty("master-reference") != null) { @@ -38,6 +88,7 @@ public abstract class PageMasterReference extends FObj /** * Returns the "master-reference" attribute of this page master reference + * @return the name of the page master */ public String getMasterName() { return masterName; @@ -45,15 +96,17 @@ public abstract class PageMasterReference extends FObj /** * Checks that the parent is the right element. The default implementation - * checks for fo:page-sequence-master + * checks for fo:page-sequence-master. + * @param parent parent node + * @throws FOPException If the parent is invalid. */ protected void validateParent(FONode parent) throws FOPException { if (parent.getName().equals("fo:page-sequence-master")) { PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent; if (getMasterName() == null) { - getLogger().warn("" + getName() - + " does not have a master-reference and so is being ignored"); + getLogger().warn(getName() + + " does not have a master-reference and so is being ignored"); } else { pageSequenceMaster.addSubsequenceSpecifier(this); } diff --git a/src/org/apache/fop/fo/pagination/PageNumberGenerator.java b/src/org/apache/fop/fo/pagination/PageNumberGenerator.java index aea06f125..25d5d6927 100644 --- a/src/org/apache/fop/fo/pagination/PageNumberGenerator.java +++ b/src/org/apache/fop/fo/pagination/PageNumberGenerator.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; // Avalon @@ -23,11 +66,11 @@ public class PageNumberGenerator extends AbstractLogEnabled { private int letterValue; // constants - private int DECIMAL = 1; // '0*1' - private int LOWERALPHA = 2; // 'a' - private int UPPERALPHA = 3; // 'A' - private int LOWERROMAN = 4; // 'i' - private int UPPERROMAN = 5; // 'I' + private static final int DECIMAL = 1; // '0*1' + private static final int LOWERALPHA = 2; // 'a' + private static final int UPPERALPHA = 3; // 'A' + private static final int LOWERROMAN = 4; // 'i' + private static final int UPPERROMAN = 5; // 'I' // flags private int formatType = DECIMAL; @@ -38,6 +81,14 @@ public class PageNumberGenerator extends AbstractLogEnabled { "", "0", "00", "000", "0000", "00000" }; + /** + * Main constructor. For further information on the parameters see the XSLT + * specs (Number to String Conversion Attributes). + * @param format format for the page number + * @param groupingSeparator grouping separator + * @param groupingSize grouping size + * @param letterValue letter value + */ public PageNumberGenerator(String format, char groupingSeparator, int groupingSize, int letterValue) { this.format = format; @@ -82,6 +133,11 @@ public class PageNumberGenerator extends AbstractLogEnabled { } } + /** + * Formats a page number. + * @param number page number to format + * @return the formatted page number as a String + */ public String makeFormattedPageNumber(int number) { String pn = null; if (formatType == DECIMAL) { @@ -92,13 +148,15 @@ public class PageNumberGenerator extends AbstractLogEnabled { } } else if ((formatType == LOWERROMAN) || (formatType == UPPERROMAN)) { pn = makeRoman(number); - if (formatType == UPPERROMAN) + if (formatType == UPPERROMAN) { pn = pn.toUpperCase(); + } } else { // alphabetic pn = makeAlpha(number); - if (formatType == UPPERALPHA) + if (formatType == UPPERALPHA) { pn = pn.toUpperCase(); + } } return pn; } diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index fc9498c37..91afc33a3 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; // FOP diff --git a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java index de11561dd..5b8c5e712 100644 --- a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -1,31 +1,75 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.apps.FOPException; - // Java -import java.util.ArrayList; import java.util.List; // SAX import org.xml.sax.Attributes; +// FOP +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; +import org.apache.fop.apps.FOPException; + /** * The page-sequence-master formatting object. * This class handles a list of subsequence specifiers * which are simple or complex references to page-masters. */ public class PageSequenceMaster extends FObj { - LayoutMasterSet layoutMasterSet; - List subSequenceSpecifiers; + + private LayoutMasterSet layoutMasterSet; + private List subSequenceSpecifiers; private SubSequenceSpecifier currentSubSequence; private int currentSubSequenceNumber; private String masterName; @@ -36,14 +80,21 @@ public class PageSequenceMaster extends FObj { // references to page-masters. So the methods use the former // terminology ('sub-sequence-specifiers', or SSS), // but the actual FO's are MasterReferences. + + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public PageSequenceMaster(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); - subSequenceSpecifiers = new ArrayList(); + subSequenceSpecifiers = new java.util.ArrayList(); if (parent.getName().equals("fo:layout-master-set")) { this.layoutMasterSet = (LayoutMasterSet)parent; @@ -61,10 +112,18 @@ public class PageSequenceMaster extends FObj { } } + /** + * Adds a new suqsequence specifier to the page sequence master. + * @param pageMasterReference the subsequence to add + */ protected void addSubsequenceSpecifier(SubSequenceSpecifier pageMasterReference) { subSequenceSpecifiers.add(pageMasterReference); } + /** + * Returns the next subsequence specifier + * @return a subsequence specifier + */ private SubSequenceSpecifier getNextSubSequence() { currentSubSequenceNumber++; if (currentSubSequenceNumber >= 0 @@ -75,31 +134,42 @@ public class PageSequenceMaster extends FObj { return null; } + /** + * Resets the subsequence specifiers subsystem. + */ public void reset() { currentSubSequenceNumber = -1; currentSubSequence = null; - for (int i = 0; i< subSequenceSpecifiers.size(); i++ ) { + for (int i = 0; i < subSequenceSpecifiers.size(); i++) { ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset(); } } - public SimplePageMaster getNextSimplePageMaster(boolean oddPage, - boolean firstPage, - boolean blankPage) - throws FOPException { - if (currentSubSequence==null) { + /** + * Returns the next simple-page-master. + * @param isOddPage True if the next page number is odd + * @param isFirstPage True if the next page is the first + * @param isBlankPage True if the next page is blank + * @return the requested page master + * @throws FOPException if there's a problem determining the next page master + */ + public SimplePageMaster getNextSimplePageMaster(boolean isOddPage, + boolean isFirstPage, + boolean isBlankPage) + throws FOPException { + if (currentSubSequence == null) { currentSubSequence = getNextSubSequence(); - if (currentSubSequence==null) { + if (currentSubSequence == null) { throw new FOPException("no subsequences in page-sequence-master '" + masterName + "'"); } } String pageMasterName = currentSubSequence - .getNextPageMasterName(oddPage, firstPage, blankPage); + .getNextPageMasterName(isOddPage, isFirstPage, isBlankPage); boolean canRecover = true; - while (pageMasterName==null) { + while (pageMasterName == null) { SubSequenceSpecifier nextSubSequence = getNextSubSequence(); - if (nextSubSequence==null) { + if (nextSubSequence == null) { if (!canRecover) { throw new FOPException("subsequences exhausted in page-sequence-master '" + masterName @@ -114,14 +184,14 @@ public class PageSequenceMaster extends FObj { currentSubSequence = nextSubSequence; } pageMasterName = currentSubSequence - .getNextPageMasterName(oddPage, firstPage, blankPage); + .getNextPageMasterName(isOddPage, isFirstPage, isBlankPage); } - SimplePageMaster pageMaster=this.layoutMasterSet - .getSimplePageMaster(pageMasterName); - if (pageMaster==null) { + SimplePageMaster pageMaster = this.layoutMasterSet + .getSimplePageMaster(pageMasterName); + if (pageMaster == null) { throw new FOPException("No simple-page-master matching '" + pageMasterName + "' in page-sequence-master '" - + masterName +"'"); + + masterName + "'"); } return pageMaster; } diff --git a/src/org/apache/fop/fo/pagination/Region.java b/src/org/apache/fop/fo/pagination/Region.java index 70ae1b1a5..2a4b6baef 100644 --- a/src/org/apache/fop/fo/pagination/Region.java +++ b/src/org/apache/fop/fo/pagination/Region.java @@ -1,10 +1,53 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; // Java @@ -30,24 +73,38 @@ import org.xml.sax.Attributes; * This is an abstract base class for pagination regions */ public abstract class Region extends FObj { + private static final String PROP_REGION_NAME = "region-name"; + /** Key for before regions */ public static final String BEFORE = "before"; + /** Key for start regions */ public static final String START = "start"; + /** Key for end regions */ public static final String END = "end"; + /** Key for after regions */ public static final String AFTER = "after"; + /** Key for body regions */ public static final String BODY = "body"; - private SimplePageMaster _layoutMaster; - private String _regionName; + private SimplePageMaster layoutMaster; + private String regionName; + /** Holds the overflow attribute */ protected int overflow; + /** Holds the writing mode */ protected int wm; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ protected Region(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); @@ -60,15 +117,15 @@ public abstract class Region extends FObj { 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 + && !getRegionName().equals(getDefaultRegionName())) { + throw new FOPException(PROP_REGION_NAME + " '" + regionName + "' for " + this.name + " not permitted."); } } if (parent instanceof SimplePageMaster) { - _layoutMaster = (SimplePageMaster)parent; + layoutMaster = (SimplePageMaster)parent; } else { throw new FOPException(this.name + " must be child " + "of simple-page-master, not " @@ -79,6 +136,9 @@ public abstract class Region extends FObj { /** * Creates a RegionViewport Area object for this pagination Region. + * @param reldims relative dimensions + * @param pageCTM page coordinate transformation matrix + * @return the new region viewport */ public RegionViewport makeRegionViewport(FODimension reldims, CTM pageCTM) { Rectangle2D relRegionRect = getViewportRectangle(reldims); @@ -116,6 +176,7 @@ public abstract class Region extends FObj { * @param absRegVPRect The region viewport rectangle is "absolute" coordinates * where x=distance from left, y=distance from bottom, width=right-left * height=top-bottom + * @return a new region reference area */ public RegionReference makeRegionReferenceArea(Rectangle2D absRegVPRect) { RegionReference r = new RegionReference(getRegionAreaClass()); @@ -132,39 +193,54 @@ public abstract class Region extends FObj { * @param absRegVPRect the rectangle to place the region contents */ protected void setRegionPosition(RegionReference r, Rectangle2D absRegVPRect) { - FODimension reldims = new FODimension(0,0); + FODimension reldims = new FODimension(0, 0); r.setCTM(propMgr.getCTMandRelDims(absRegVPRect, reldims)); } /** * Return the enumerated value designating this type of region in the * Area tree. + * @return the region area class */ protected abstract int getRegionAreaClass(); /** * Returns the default region name (xsl-region-before, xsl-region-start, * etc.) + * @return the default region name */ protected abstract String getDefaultRegionName(); + /** + * Returns the region class name. + * @return the region class name + */ public abstract String getRegionClass(); /** - * Returns the name of this region + * Returns the name of this region. + * @return the region name */ public String getRegionName() { - return _regionName; + return this.regionName; } + /** + * Sets the name of the region. + * @param name the name + */ private void setRegionName(String name) { - _regionName = name; + this.regionName = name; } + /** + * Returns the page master associated with this region. + * @return a simple-page-master + */ protected SimplePageMaster getPageMaster() { - return _layoutMaster; + return this.layoutMaster; } /** @@ -173,7 +249,7 @@ public abstract class Region extends FObj { * @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 { + protected boolean isReserved(String name) /*throws FOPException*/ { return (name.equals("xsl-region-before") || name.equals("xsl-region-start") || name.equals("xsl-region-end") @@ -182,20 +258,32 @@ public abstract class Region extends FObj { || name.equals("xsl-footnote-separator")); } + /** + * @see org.apache.fop.fo.FObj#generatesReferenceAreas() + */ public boolean generatesReferenceAreas() { return true; } + /** + * Returns a sibling region for this region. + * @param regionClass the class of the requested region + * @return the requested region + */ protected Region getSiblingRegion(String regionClass) { // Ask parent for region - return _layoutMaster.getRegion(regionClass); + return layoutMaster.getRegion(regionClass); } - boolean getPrecedence() { + /** + * Indicates if this region gets precedence. + * @return True if it gets precedence + */ + public boolean getPrecedence() { return false; } - int getExtent() { + public int getExtent() { return 0; } } diff --git a/src/org/apache/fop/fo/pagination/RegionAfter.java b/src/org/apache/fop/fo/pagination/RegionAfter.java index f6484a154..e8b3cae1b 100644 --- a/src/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/org/apache/fop/fo/pagination/RegionAfter.java @@ -1,48 +1,110 @@ /* * $Id$ - * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; +// Java +import java.awt.Rectangle; + // FOP -import org.apache.fop.fo.*; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.properties.WritingMode; import org.apache.fop.datatypes.FODimension; import org.apache.fop.area.RegionReference; -// Java -import java.awt.Rectangle; - +/** + * The fo:region-after element. + */ public class RegionAfter extends RegionBA { + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public RegionAfter(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) + */ protected Rectangle getViewportRectangle (FODimension reldims) { // Depends on extent, precedence ans writing mode Rectangle vpRect; - if (this.wm == WritingMode.LR_TB || this.wm == WritingMode.RL_TB) + if (this.wm == WritingMode.LR_TB || this.wm == WritingMode.RL_TB) { vpRect = new Rectangle(0, reldims.bpd - getExtent(), reldims.ipd, getExtent()); - else + } else { vpRect = new Rectangle(0, reldims.bpd - getExtent(), getExtent(), reldims.ipd); + } if (getPrecedence() == false) { adjustIPD(vpRect, this.wm); } return vpRect; } + /** + * @see org.apache.fop.fo.pagination.Region#getDefaultRegionName() + */ protected String getDefaultRegionName() { return "xsl-region-after"; } + /** + * @see org.apache.fop.fo.pagination.Region#getRegionAreaClass() + */ public int getRegionAreaClass() { return RegionReference.AFTER; } + /** + * @see org.apache.fop.fo.pagination.Region#getRegionClass() + */ public String getRegionClass() { return Region.AFTER; } diff --git a/src/org/apache/fop/fo/pagination/RegionBA.java b/src/org/apache/fop/fo/pagination/RegionBA.java index 88d88ec50..2f301ef08 100644 --- a/src/org/apache/fop/fo/pagination/RegionBA.java +++ b/src/org/apache/fop/fo/pagination/RegionBA.java @@ -1,36 +1,91 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; +// Java +import java.awt.Rectangle; + // FOP -import org.apache.fop.fo.*; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.properties.Precedence; import org.apache.fop.fo.properties.WritingMode; -// Java -import java.awt.Rectangle; - +/** + * Abstract base class for fo:region-before and fo:region-after. + */ public abstract class RegionBA extends RegionBASE { private boolean bPrecedence; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ protected RegionBA(FONode parent) { super(parent); } - boolean getPrecedence() { + /** + * @see org.apache.fop.fo.pagination.Region#getPrecedence() + */ + public boolean getPrecedence() { return bPrecedence; } + /** + * @see org.apache.fop.fo.FONode#end() + */ public void end() { super.end(); bPrecedence = - (this.properties.get("precedence").getEnum()==Precedence.TRUE); + (this.properties.get("precedence").getEnum() == Precedence.TRUE); } /** @@ -39,6 +94,8 @@ public abstract class RegionBA extends RegionBASE { * If precedence is false on a before or after region, its * inline-progression-dimension is limited by the extent of the start * and end regions if they are present. + * @param vpRect viewport rectangle + * @param wm writing mode */ protected void adjustIPD(Rectangle vpRect, int wm) { int offset = 0; @@ -47,15 +104,16 @@ public abstract class RegionBA extends RegionBASE { offset = start.getExtent(); vpRect.translate(offset, 0); } - Region end =getSiblingRegion(Region.END); + Region end = getSiblingRegion(Region.END); if (end != null) { offset += end.getExtent(); } if (offset > 0) { - if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) - vpRect.width-=offset; - else - vpRect.height-=offset; + if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) { + vpRect.width -= offset; + } else { + vpRect.height -= offset; + } } } } diff --git a/src/org/apache/fop/fo/pagination/RegionBASE.java b/src/org/apache/fop/fo/pagination/RegionBASE.java index 62cf8d037..8a5f3c975 100644 --- a/src/org/apache/fop/fo/pagination/RegionBASE.java +++ b/src/org/apache/fop/fo/pagination/RegionBASE.java @@ -60,16 +60,25 @@ public abstract class RegionBASE extends Region { private int extent; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ protected RegionBASE(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#end() + */ public void end() { // The problem with this is that it might not be known yet.... // Supposing extent is calculated in terms of percentage this.extent = this.properties.get("extent").getLength().getValue(); } + /** + * @see org.apache.fop.fo.pagination.Region#getExtent() + */ public int getExtent() { return this.extent; } diff --git a/src/org/apache/fop/fo/pagination/RegionBefore.java b/src/org/apache/fop/fo/pagination/RegionBefore.java index 5ec2a64d6..716848fea 100644 --- a/src/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/org/apache/fop/fo/pagination/RegionBefore.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; // FOP @@ -16,24 +59,42 @@ import org.apache.fop.area.RegionReference; // Java import java.awt.Rectangle; +/** + * The fo:region-before element. + */ public class RegionBefore extends RegionBA { + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public RegionBefore(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.pagination.Region#getDefaultRegionName() + */ protected String getDefaultRegionName() { return "xsl-region-before"; } + /** + * @see org.apache.fop.fo.pagination.Region#getRegionClass() + */ public String getRegionClass() { return Region.BEFORE; } + /** + * @see org.apache.fop.fo.pagination.Region#getRegionAreaClass() + */ public int getRegionAreaClass() { return RegionReference.BEFORE; } + /** + * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) + */ protected Rectangle getViewportRectangle (FODimension reldims) { // Depends on extent, precedence and writing mode // This should return rectangle in writing-mode coordinates relative @@ -42,10 +103,11 @@ public class RegionBefore extends RegionBA { // Before is always 0, start depends on extent // ipd depends on precedence, bpd=extent Rectangle vpRect; - if (this.wm == WritingMode.LR_TB || this.wm == WritingMode.RL_TB) + if (this.wm == WritingMode.LR_TB || this.wm == WritingMode.RL_TB) { vpRect = new Rectangle(0, 0, reldims.ipd, getExtent()); - else + } else { vpRect = new Rectangle(0, 0, getExtent(), reldims.ipd); + } if (getPrecedence() == false) { adjustIPD(vpRect, this.wm); } diff --git a/src/org/apache/fop/fo/pagination/RegionBody.java b/src/org/apache/fop/fo/pagination/RegionBody.java index 6d3903863..4480fc939 100644 --- a/src/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/org/apache/fop/fo/pagination/RegionBody.java @@ -67,14 +67,23 @@ import org.apache.fop.area.RegionReference; import org.apache.fop.area.BodyRegion; import org.apache.fop.layout.MarginProps; +/** + * The fo:region-body element. + */ public class RegionBody extends Region { private ColorType backgroundColor; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public RegionBody(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) + */ protected Rectangle getViewportRectangle (FODimension reldims) { /* * Use space-before and space-after which will use corresponding @@ -115,20 +124,30 @@ public class RegionBody extends Region { return ((prop != null) ? prop.getLength().getValue() : 0); } + /** + * @see org.apache.fop.fo.pagination.Region#getDefaultRegionName() + */ protected String getDefaultRegionName() { return "xsl-region-body"; } + /** + * @see org.apache.fop.fo.pagination.Region#getRegionClass() + */ public String getRegionClass() { return Region.BODY; } + /** + * @see org.apache.fop.fo.pagination.Region#getRegionAreaClass() + */ public int getRegionAreaClass() { return RegionReference.BODY; } /** * Override the inherited method. + * @see org.apache.fop.fo.pagination.Region#makeRegionReferenceArea(Rectangle2D) */ public RegionReference makeRegionReferenceArea(Rectangle2D absRegVPRect) { // Should set some column stuff here I think, or put it elsewhere diff --git a/src/org/apache/fop/fo/pagination/RegionEnd.java b/src/org/apache/fop/fo/pagination/RegionEnd.java index 7d13ebb7b..30d6dd9b1 100644 --- a/src/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/org/apache/fop/fo/pagination/RegionEnd.java @@ -1,52 +1,111 @@ /* * $Id$ - * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; // Java import java.awt.Rectangle; // FOP -import org.apache.fop.fo.*; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.properties.WritingMode; import org.apache.fop.datatypes.FODimension; import org.apache.fop.area.RegionReference; - +/** + * The fo:region-end element. + */ public class RegionEnd extends RegionSE { + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public RegionEnd(FONode parent) { super(parent); } - + /** + * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) + */ protected Rectangle getViewportRectangle (FODimension reldims) { // Depends on extent, precedence and writing mode Rectangle vpRect; - if (this.wm == WritingMode.LR_TB || this.wm == WritingMode.RL_TB) + if (this.wm == WritingMode.LR_TB || this.wm == WritingMode.RL_TB) { vpRect = new Rectangle(reldims.ipd - getExtent(), 0, getExtent(), reldims.bpd); - else + } else { vpRect = new Rectangle(reldims.ipd - getExtent(), 0, reldims.bpd, getExtent()); + } adjustIPD(vpRect, this.wm); return vpRect; } + /** + * @see org.apache.fop.fo.pagination.Region#getDefaultRegionName() + */ protected String getDefaultRegionName() { return "xsl-region-end"; } - + /** + * @see org.apache.fop.fo.pagination.Region#getRegionClass() + */ public String getRegionClass() { return Region.END; } + /** + * @see org.apache.fop.fo.pagination.Region#getRegionAreaClass() + */ public int getRegionAreaClass() { return RegionReference.END; } diff --git a/src/org/apache/fop/fo/pagination/RegionSE.java b/src/org/apache/fop/fo/pagination/RegionSE.java index f4b4a3164..f62200014 100644 --- a/src/org/apache/fop/fo/pagination/RegionSE.java +++ b/src/org/apache/fop/fo/pagination/RegionSE.java @@ -1,21 +1,70 @@ /* * $Id$ - * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.WritingMode; - // Java import java.awt.Rectangle; +// FOP +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.properties.WritingMode; + +/** + * Abstract base class for fo:region-start and fo:region-end. + */ public abstract class RegionSE extends RegionBASE { + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ protected RegionSE(FONode parent) { super(parent); } @@ -27,6 +76,8 @@ public abstract class RegionSE extends RegionBASE { * regions only go to the limits of their extents, otherwise * they extend in the BPD to the page reference rectangle * diminish by extend of start and end if present. + * @param refRect reference rectangle + * @param wm writing mode */ protected void adjustIPD(Rectangle refRect, int wm) { int offset = 0; @@ -40,10 +91,11 @@ public abstract class RegionSE extends RegionBASE { offset += after.getExtent(); } if (offset > 0) { - if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) - refRect.height-=offset; - else - refRect.width-=offset; + if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) { + refRect.height -= offset; + } else { + refRect.width -= offset; + } } } } diff --git a/src/org/apache/fop/fo/pagination/RegionStart.java b/src/org/apache/fop/fo/pagination/RegionStart.java index d55096d20..c93ab79a4 100644 --- a/src/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/org/apache/fop/fo/pagination/RegionStart.java @@ -1,50 +1,110 @@ /* * $Id$ - * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources." - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; // Java import java.awt.Rectangle; // FOP -import org.apache.fop.fo.*; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.properties.WritingMode; import org.apache.fop.datatypes.FODimension; import org.apache.fop.area.RegionReference; +/** + * The fo:region-start element. + */ public class RegionStart extends RegionSE { - + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public RegionStart(FONode parent) { super(parent); } - + /** + * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) + */ protected Rectangle getViewportRectangle (FODimension reldims) { // Depends on extent, precedence anĂ¢ writing mode // This is the rectangle relative to the page-reference area in // writing-mode relative coordinates Rectangle vpRect; - if (this.wm == WritingMode.LR_TB || this.wm == WritingMode.RL_TB) + if (this.wm == WritingMode.LR_TB || this.wm == WritingMode.RL_TB) { vpRect = new Rectangle(0, 0, getExtent(), reldims.bpd); - else + } else { vpRect = new Rectangle(0, 0, reldims.bpd, getExtent()); + } adjustIPD(vpRect, this.wm); return vpRect; } + /** + * @see org.apache.fop.fo.pagination.Region#getDefaultRegionName() + */ protected String getDefaultRegionName() { return "xsl-region-start"; } + /** + * @see org.apache.fop.fo.pagination.Region#getRegionClass() + */ public String getRegionClass() { return Region.START; } + /** + * @see org.apache.fop.fo.pagination.Region#getRegionAreaClass() + */ public int getRegionAreaClass() { return RegionReference.START; } diff --git a/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index e9469b41e..0401b27e2 100644 --- a/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java @@ -1,20 +1,66 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; -import org.apache.fop.fo.*; -import org.apache.fop.apps.FOPException; - // Java import java.util.ArrayList; +// XML import org.xml.sax.Attributes; +// FOP +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; +import org.apache.fop.apps.FOPException; + /** * A repeatable-page-master-alternatives formatting object. * This contains a list of conditional-page-master-reference @@ -35,10 +81,16 @@ public class RepeatablePageMasterAlternatives extends FObj private ArrayList conditionalPageMasterRefs; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public RepeatablePageMasterAlternatives(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); @@ -55,7 +107,7 @@ public class RepeatablePageMasterAlternatives extends FObj String mr = getProperty("maximum-repeats").getString(); if (mr.equals("no-limit")) { - this.maximumRepeats=INFINITE; + this.maximumRepeats = INFINITE; } else { try { this.maximumRepeats = Integer.parseInt(mr); @@ -74,10 +126,11 @@ public class RepeatablePageMasterAlternatives extends FObj /** * Get the next matching page master from the conditional * page master references. + * @see org.apache.fop.fo.pagination.SubSequenceSpecifier */ public String getNextPageMasterName(boolean isOddPage, boolean isFirstPage, - boolean isEmptyPage) { + boolean isBlankPage) { if (maximumRepeats != INFINITE) { if (numberConsumed < maximumRepeats) { numberConsumed++; @@ -89,7 +142,7 @@ public class RepeatablePageMasterAlternatives extends FObj for (int i = 0; i < conditionalPageMasterRefs.size(); i++) { ConditionalPageMasterReference cpmr = (ConditionalPageMasterReference)conditionalPageMasterRefs.get(i); - if (cpmr.isValid(isOddPage, isFirstPage, isEmptyPage)) { + if (cpmr.isValid(isOddPage, isFirstPage, isBlankPage)) { return cpmr.getMasterName(); } } @@ -97,10 +150,17 @@ public class RepeatablePageMasterAlternatives extends FObj } + /** + * Adds a new conditional page master reference. + * @param cpmr the new conditional reference + */ public void addConditionalPageMasterReference(ConditionalPageMasterReference cpmr) { this.conditionalPageMasterRefs.add(cpmr); } + /** + * @see org.apache.fop.fo.pagination.SubSequenceSpecifier#reset() + */ public void reset() { this.numberConsumed = 0; } diff --git a/src/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java index 869babd8e..8707175a4 100644 --- a/src/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java @@ -1,24 +1,69 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; -import org.apache.fop.fo.*; -import org.apache.fop.apps.FOPException; - +// XML import org.xml.sax.Attributes; +// FOP +import org.apache.fop.fo.FONode; +import org.apache.fop.apps.FOPException; + /** * A repeatable-page-master-reference formatting object. * This handles a reference with a specified number of repeating * instances of the referenced page master (may have no limit). */ public class RepeatablePageMasterReference extends PageMasterReference - implements SubSequenceSpecifier { + implements SubSequenceSpecifier { private static final int INFINITE = -1; @@ -27,10 +72,16 @@ public class RepeatablePageMasterReference extends PageMasterReference private int maximumRepeats; private int numberConsumed = 0; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public RepeatablePageMasterReference(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); @@ -52,6 +103,9 @@ public class RepeatablePageMasterReference extends PageMasterReference } } + /** + * @see org.apache.fop.fo.pagination.SubSequenceSpecifier + */ public String getNextPageMasterName(boolean isOddPage, boolean isFirstPage, boolean isEmptyPage) { @@ -65,6 +119,9 @@ public class RepeatablePageMasterReference extends PageMasterReference return getMasterName(); } + /** + * @see org.apache.fop.fo.pagination.SubSequenceSpecifier#reset() + */ public void reset() { this.numberConsumed = 0; } diff --git a/src/org/apache/fop/fo/pagination/Root.java b/src/org/apache/fop/fo/pagination/Root.java index a76832f23..0e4e7b864 100644 --- a/src/org/apache/fop/fo/pagination/Root.java +++ b/src/org/apache/fop/fo/pagination/Root.java @@ -1,10 +1,53 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; // FOP @@ -12,7 +55,6 @@ import org.apache.fop.fo.FObj; import org.apache.fop.fo.FONode; // Java -import java.util.ArrayList; import java.util.List; /** @@ -23,27 +65,42 @@ public class Root extends FObj { private List pageSequences; /** - * keeps count of page number from over PageSequence instances + * Keeps count of page number from over PageSequence instances */ private int runningPageNumberCounter = 0; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public Root(FONode parent) { super(parent); // this.properties.get("media-usage"); - pageSequences = new ArrayList(); + pageSequences = new java.util.ArrayList(); if (parent != null) { //throw new FOPException("root must be root element"); } } + /** + * Returns the number of pages generated (over all PageSequence instances). + * @return the number of pages + */ protected int getRunningPageNumberCounter() { return this.runningPageNumberCounter; } + /** + * Sets the overall page number counter. + * @param count the new page count + */ protected void setRunningPageNumberCounter(int count) { this.runningPageNumberCounter = count; } + /** + * Returns the number of PageSequence instances. + * @return the number of PageSequence instances + */ public int getPageSequenceCount() { return pageSequences.size(); } @@ -51,12 +108,14 @@ public class Root extends FObj { /** * Some properties, such as 'force-page-count', require a * page-sequence to know about some properties of the next. + * @param current the current PageSequence * @return succeeding PageSequence; null if none */ public PageSequence getSucceedingPageSequence(PageSequence current) { int currentIndex = pageSequences.indexOf(current); - if (currentIndex == -1) + if (currentIndex == -1) { return null; + } if (currentIndex < (pageSequences.size() - 1)) { return (PageSequence)pageSequences.get(currentIndex + 1); } else { @@ -64,10 +123,18 @@ public class Root extends FObj { } } + /** + * Returns the associated LayoutMasterSet. + * @return the LayoutMasterSet instance + */ public LayoutMasterSet getLayoutMasterSet() { return this.layoutMasterSet; } + /** + * Sets the associated LayoutMasterSet. + * @param layoutMasterSet the LayoutMasterSet to use + */ public void setLayoutMasterSet(LayoutMasterSet layoutMasterSet) { this.layoutMasterSet = layoutMasterSet; } diff --git a/src/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/org/apache/fop/fo/pagination/SimplePageMaster.java index 11479e8d0..3c705e7d7 100644 --- a/src/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -86,10 +86,16 @@ public class SimplePageMaster extends FObj { private PageMaster pageMaster; private String masterName; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public SimplePageMaster(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); @@ -171,22 +177,41 @@ public class SimplePageMaster extends FObj { properties = null; } + /** + * @see org.apache.fop.fo.FObj#generatesReferenceAreas() + */ public boolean generatesReferenceAreas() { return true; } + /** + * Returns the page master. + * @return the page master + */ public PageMaster getPageMaster() { return this.pageMaster; } + /** + * Returns the next page master. For simple-page-master this is always the + * same as the previous. + * @return the page master + */ public PageMaster getNextPageMaster() { return this.pageMaster; } + /** + * Returns the name of the simple-page-master. + * @return the page master name + */ public String getMasterName() { return masterName; } + /** + * @see org.apache.fop.fo.FONode#addChild(FONode) + */ protected void addChild(FONode child) { if (child instanceof Region) { addRegion((Region)child); @@ -196,28 +221,44 @@ public class SimplePageMaster extends FObj { } } + /** + * Adds a region to this simple-page-master. + * @param region region to add + */ protected void addRegion(Region region) { String key = region.getRegionClass(); if (regions.containsKey(key)) { - getLogger().error("Only one region of class " - + key - + " allowed within a simple-page-master."); - // throw new FOPException("Only one region of class " -// + key -// + " allowed within a simple-page-master."); + getLogger().error("Only one region of class " + key + + " allowed within a simple-page-master. The duplicate" + + " region (" + region.getName() + ") is ignored."); } else { regions.put(key, region); } } + /** + * Returns the region for a given region class. + * @param regionClass region class to lookup + * @return the region, null if it doesn't exist + */ public Region getRegion(String regionClass) { return (Region)regions.get(regionClass); } + /** + * Returns a Map of regions associated with this simple-page-master + * @return the regions + */ protected Map getRegions() { return regions; } + /** + * Indicates if a region with a given name exists in this + * simple-page-master. + * @param regionName name of the region to lookup + * @return True if a region with this name exists + */ protected boolean regionNameExists(String regionName) { for (Iterator regenum = regions.values().iterator(); regenum.hasNext();) { diff --git a/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java index 6ed306b8d..8ed60ea04 100644 --- a/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java @@ -1,9 +1,53 @@ /* * $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. - */ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; import org.apache.fop.fo.FONode; @@ -14,18 +58,24 @@ import org.apache.fop.fo.FONode; * master name only once until reset. */ public class SinglePageMasterReference extends PageMasterReference - implements SubSequenceSpecifier { + implements SubSequenceSpecifier { private static final int FIRST = 0; private static final int DONE = 1; private int state; + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public SinglePageMasterReference(FONode parent) { super(parent); this.state = FIRST; } + /** + * @see org.apache.fop.fo.pagination.SubSequenceSpecifier + */ public String getNextPageMasterName(boolean isOddPage, boolean isFirstPage, boolean isEmptyPage) { @@ -37,6 +87,9 @@ public class SinglePageMasterReference extends PageMasterReference } } + /** + * @see org.apache.fop.fo.pagination.SubSequenceSpecifier#reset() + */ public void reset() { this.state = FIRST; } diff --git a/src/org/apache/fop/fo/pagination/SubSequenceSpecifier.java b/src/org/apache/fop/fo/pagination/SubSequenceSpecifier.java index 4a4c8bdb9..73b46bebe 100644 --- a/src/org/apache/fop/fo/pagination/SubSequenceSpecifier.java +++ b/src/org/apache/fop/fo/pagination/SubSequenceSpecifier.java @@ -1,28 +1,81 @@ /* * $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. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ package org.apache.fop.fo.pagination; import org.apache.fop.apps.FOPException; + /** * Classes that implement this interface can be added to a PageSequenceMaster, * and are capable of looking up an appropriate PageMaster. */ public interface SubSequenceSpecifier { - public String getNextPageMasterName(boolean isOddPage, - boolean isFirstPage, - boolean isEmptyPage) - throws FOPException; + + /** + * Returns the name of the next page master. + * @param isOddPage True if the next page number is odd + * @param isFirstPage True if the next page is the first + * @param isBlankPage True if the next page is blank + * @return the page master name + * @throws FOPException if there's a problem determining the next page master + */ + String getNextPageMasterName(boolean isOddPage, + boolean isFirstPage, + boolean isBlankPage) + throws FOPException; /** * Called before a new page sequence is rendered so subsequences can reset * any state they keep during the formatting process. */ - public void reset(); + void reset(); } -- 2.39.5