From 63c97af3ea8809db549483c2df3976e7d2a8576b Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Thu, 21 Nov 2002 08:14:42 +0000 Subject: [PATCH] Add constructor to generate PageSequenceMaster from FoSimplePageMaster. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195589 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/fo/pagination/PageSequenceMaster.java | 64 ++++++++++++------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java index d854671c9..7bee0e5e8 100644 --- a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -38,8 +38,13 @@ import org.apache.fop.fo.pagination.FoPageSequenceMaster .FoRepeatablePageMasterAlternatives.FoConditionalPageMasterReference; /** - * Encodes an fo:page-sequence-master and associated - * conditions. + * Encodes an fo:page-sequence-master and associated + * conditions. All page-sequence-master specifications are converted + * into repeatable-page-master-alternatives. + * For a simple-page-master, a PageSequenceMaster object is + * created which shares a name with its target simple-page-master. + * This procedure results in a single common structure and manner of access + * for all page masters. */ public class PageSequenceMaster { @@ -55,15 +60,36 @@ public class PageSequenceMaster { private ArrayList masters = new ArrayList(1); /** - * @param masterName - the name of this master. + * Create a PageSequenceMaster from an + * FoSimplePageMaster. + * @param simplePM - the FoSimplePageMaster from which this + * PageSequenceMaster is derived. + */ + public PageSequenceMaster(FoSimplePageMaster simplePM) + throws PropertyException, FOPException + { + PageMasterAlternatives masterAlt; + masterName = simplePM.getMasterName(); + masterAlt = new PageMasterAlternatives(1, NO_LIMIT); + // Create and add a single default PageCondition + masterAlt.addCondition + (masterAlt.new PageCondition(simplePM, + BlankOrNotBlank.ANY, + OddOrEven.ANY, + PagePosition.ANY)); + masters.add(masterAlt); + } + + /** + * Create a PageSequenceMaster from an + * FoPageSequenceMaster. * @param pageSeq - the FoPageSequenceMaster from which this * PageSequenceMaster is derived. * @param simplePageMasters - a HashMap of * FoSimplePageMasters indexed by master-name. */ public PageSequenceMaster - (String masterName, FoPageSequenceMaster pageSeq, - HashMap simplePageMasters) + (FoPageSequenceMaster pageSeq, HashMap simplePageMasters) throws PropertyException, FOPException { String masterRef; @@ -73,23 +99,7 @@ public class PageSequenceMaster { int enumValue; PropertyValue pv; Numeric npv; - this.masterName = masterName; - // Convert the simple-page-masters into page-sequence-masters - Iterator names = simplePageMasters.keySet().iterator(); - while (names.hasNext()) { - String master = (String)(names.next()); - simplePM = - (FoSimplePageMaster)(simplePageMasters.get(master)); - // Create a PageMasterAlternatives - masterAlt = new PageMasterAlternatives(1, NO_LIMIT); - // Create and add a single default PageCondition - masterAlt.addCondition - (masterAlt.new PageCondition(simplePM, - BlankOrNotBlank.ANY, - OddOrEven.ANY, - PagePosition.ANY)); - masters.add(masterAlt); - } + masterName = pageSeq.getMasterName(); // Process the sequence of masters. int numChildren = pageSeq.numChildren(); for (int child = 0; child < numChildren; child++) { @@ -215,6 +225,16 @@ public class PageSequenceMaster { } } + /** + * Get the master-name of this PageSequenceMaster. This is the + * name by which fo:page-sequences will reference the master + * through their master-reference property. + * @return the name. + */ + public String getMasterName() { + return masterName; + } + /** * Get the FoSimplePageMaster referred to by the * master-reference property in the argument FONode. -- 2.39.5