diff options
Diffstat (limited to 'src/java/org/apache/fop/fo/pagination/PageSequence.java')
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/PageSequence.java | 113 |
1 files changed, 21 insertions, 92 deletions
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index f8f9f9277..91649fbc5 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -25,32 +25,22 @@ import java.util.Map; import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.Numeric; import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; /** - * Implementation of the fo:page-sequence formatting object. + * Abstract base implementation for page sequences. */ -public class PageSequence extends FObj { +public class PageSequence extends AbstractPageSequence { // The value of properties relevant for fo:page-sequence. private String country; - private String format; private String language; - private int letterValue; - private char groupingSeparator; - private int groupingSize; - private Numeric initialPageNumber; - private int forcePageCount; private String masterReference; + //private int writingMode; //XSL 1.1 // End of property values - /** The parent root object */ - private Root root; - // There doesn't seem to be anything in the spec requiring flows // to be in the order given, only that they map to the regions // defined in the page sequence, so all we need is this one hashmap @@ -59,9 +49,6 @@ public class PageSequence extends FObj { /** Map of flows to their flow name (flow-name, Flow) */ private Map flowMap; - private int startingPageNumber = 0; - private PageNumberGenerator pageNumberGenerator; - /** * The currentSimplePageMaster is either the page master for the * whole page sequence if master-reference refers to a simple-page-master, @@ -97,14 +84,9 @@ public class PageSequence extends FObj { public void bind(PropertyList pList) throws FOPException { super.bind(pList); country = pList.get(PR_COUNTRY).getString(); - format = pList.get(PR_FORMAT).getString(); language = pList.get(PR_LANGUAGE).getString(); - letterValue = pList.get(PR_LETTER_VALUE).getEnum(); - groupingSeparator = pList.get(PR_GROUPING_SEPARATOR).getCharacter(); - groupingSize = pList.get(PR_GROUPING_SIZE).getNumber().intValue(); - initialPageNumber = pList.get(PR_INITIAL_PAGE_NUMBER).getNumeric(); - forcePageCount = pList.get(PR_FORCE_PAGE_COUNT).getEnum(); masterReference = pList.get(PR_MASTER_REFERENCE).getString(); + //writingMode = pList.getWritingMode(); if (masterReference == null || masterReference.equals("")) { missingPropertyError("master-reference"); @@ -116,13 +98,12 @@ public class PageSequence extends FObj { */ protected void startOfNode() throws FOPException { super.startOfNode(); - this.root = (Root) parent; flowMap = new java.util.HashMap(); - this.simplePageMaster = root.getLayoutMasterSet().getSimplePageMaster(masterReference); + this.simplePageMaster = getRoot().getLayoutMasterSet().getSimplePageMaster(masterReference); if (this.simplePageMaster == null) { this.pageSequenceMaster - = root.getLayoutMasterSet().getPageSequenceMaster(masterReference); + = getRoot().getLayoutMasterSet().getPageSequenceMaster(masterReference); if (this.pageSequenceMaster == null) { throw new ValidationException("master-reference '" + masterReference + "' for fo:page-sequence matches no" @@ -130,9 +111,6 @@ public class PageSequence extends FObj { } } - this.pageNumberGenerator = new PageNumberGenerator( - format, groupingSeparator, groupingSize, letterValue); - getFOEventHandler().startPageSequence(this); } @@ -211,7 +189,7 @@ public class PageSequence extends FObj { + "\" found within fo:page-sequence", flow.getLocator()); } - if (!root.getLayoutMasterSet().regionNameExists(flowName) + if (!getRoot().getLayoutMasterSet().regionNameExists(flowName) && !flowName.equals("xsl-before-float-separator") && !flowName.equals("xsl-footnote-separator")) { throw new ValidationException("flow-name \"" @@ -221,31 +199,6 @@ public class PageSequence extends FObj { } } - /** - * Initialize the current page number for the start of the page sequence. - */ - public void initPageNumber() { - int pageNumberType = 0; - - if (initialPageNumber.getEnum() != 0) { - // auto | auto-odd | auto-even. - startingPageNumber = root.getEndingPageNumberOfPreviousSequence() + 1; - pageNumberType = initialPageNumber.getEnum(); - if (pageNumberType == EN_AUTO_ODD) { - if (startingPageNumber % 2 == 0) { - startingPageNumber++; - } - } else if (pageNumberType == EN_AUTO_EVEN) { - if (startingPageNumber % 2 == 1) { - startingPageNumber++; - } - } - } else { // <integer> for explicit page number - int pageStart = initialPageNumber.getValue(); - startingPageNumber = (pageStart > 0) ? pageStart : 1; // spec rule - } - } - // /** // * Returns true when there is more flow elements left to lay out. // */ @@ -306,15 +259,6 @@ public class PageSequence extends FObj { // return false; // } - /** - * Get the starting page number for this page sequence. - * - * @return the starting page number - */ - public int getStartingPageNumber() { - return startingPageNumber; - } - // private void forcePage(AreaTree areaTree, int firstAvailPageNumber) { // boolean makePage = false; // if (this.forcePageCount == ForcePageCount.AUTO) { @@ -433,6 +377,8 @@ public class PageSequence extends FObj { * page sequence * @param isLastPage indicator whether this page is the last page of the * page sequence + * @param isOnlyPage indicator whether this page is the only page of the + * page sequence * @param isBlank indicator whether the page will be blank * @return the SimplePageMaster to use for this page * @throws FOPException if there's a problem determining the page master @@ -440,6 +386,7 @@ public class PageSequence extends FObj { public SimplePageMaster getNextSimplePageMaster(int page, boolean isFirstPage, boolean isLastPage, + boolean isOnlyPage, boolean isBlank) throws FOPException { if (pageSequenceMaster == null) { @@ -450,11 +397,12 @@ public class PageSequence extends FObj { log.debug("getNextSimplePageMaster(page=" + page + " isOdd=" + isOddPage + " isFirst=" + isFirstPage - + " isLast=" + isLastPage + + " isLast=" + isLastPage + + " isOnly=" + isOnlyPage + " isBlank=" + isBlank + ")"); } return pageSequenceMaster.getNextSimplePageMaster(isOddPage, - isFirstPage, isLastPage, isBlank); + isFirstPage, isLastPage, isOnlyPage, isBlank); } /** @@ -478,24 +426,15 @@ public class PageSequence extends FObj { } } - /** - * Retrieves the string representation of a page number applicable - * for this page sequence - * @param pageNumber the page number - * @return string representation of the page number - */ - public String makeFormattedPageNumber(int pageNumber) { - return pageNumberGenerator.makeFormattedPageNumber(pageNumber); - } - - /** - * Public accessor for the ancestor Root. - * @return the ancestor Root - */ - public Root getRoot() { - return root; + /** @return true if the page-sequence has a page-master with page-position="only" */ + public boolean hasPagePositionOnly() { + if (pageSequenceMaster == null) { + return false; + } else { + return pageSequenceMaster.hasPagePositionOnly(); + } } - + /** @return the "master-reference" property. */ public String getMasterReference() { return masterReference; @@ -511,16 +450,6 @@ public class PageSequence extends FObj { return FO_PAGE_SEQUENCE; } - /** @return the force-page-count value */ - public int getForcePageCount() { - return forcePageCount; - } - - /** @return the initial-page-number property value */ - public Numeric getInitialPageNumber() { - return initialPageNumber; - } - /** @return the country property value */ public String getCountry() { return this.country; |