cvs commit: xml-fop/src/org/apache/fop/fo/pagination FoPageSequenceMaster.java
pbwest 2002/10/30 05:09:11 Modified:src/org/apache/fop/fo/pagination Tag: FOP_0-20-0_Alt-Design FoPageSequenceMaster.java Log: Added sparsePropsSet support. Untabified. Revision ChangesPath No revision No revision 1.1.2.12 +228 -107 xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java Index: FoPageSequenceMaster.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -u -r1.1.2.11 -r1.1.2.12 --- FoPageSequenceMaster.java 28 Oct 2002 00:08:11 - 1.1.2.11 +++ FoPageSequenceMaster.java 30 Oct 2002 13:09:11 - 1.1.2.12 @@ -9,8 +9,8 @@ package org.apache.fop.fo.pagination; -import java.util.ArrayList; -import java.util.LinkedList; +import java.util.HashMap; +import java.util.BitSet; import java.util.NoSuchElementException; // FOP @@ -30,6 +30,7 @@ import org.apache.fop.datastructs.Tree; import org.apache.fop.datatypes.PropertyValue; import org.apache.fop.datatypes.NCName; +import org.apache.fop.datatypes.Ints; /** * Implements the fo:page-sequence-master flow object. These Fos are @@ -42,6 +43,138 @@ private static final String tag = "$Name$"; private static final String revision = "$Revision$"; +/** Map of Integer indices of sparsePropsSet array. +It is indexed by the FO index of the FO associated with a given +position in the sparsePropsSet array. See +{@link org.apache.fop.fo.FONode#sparsePropsSet FONode.sparsePropsSet}. + */ +private static final HashMap sparsePropsMap; + +/** An int array of of the applicable property indices, in +property index order. */ +private static final int[] sparseIndices; + +/** The number of applicable properties. This is the size of the +sparsePropsSet array. */ +private static final int numProps; + +static { +// applicableProps is a HashMap containing the indicies of the +// sparsePropsSet array, indexed by the FO index of the FO slot +// in sparsePropsSet. +sparsePropsMap = new HashMap(1); +numProps = 1; +sparseIndices = new int[] { PropNames.MASTER_NAME }; +sparsePropsMap.put +(Ints.consts.get(PropNames.MASTER_NAME), Ints.consts.get(0)); +} + +/** Constant values for FoSinglePageMasterReference. +See {@link #sparsePropsMap sparsePropsMap}. */ +private static final HashMap s_p_m_r_PropsMap; + +/** See {@link #sparseIndices sparseIndices}. */ +private static final int[] s_p_m_r_Indices; + +/** See {@link #numProps numProps}. */ +private static final int s_p_m_r_numProps; + +static { +// applicableProps is a HashMap containing the indicies of the +// sparsePropsSet array, indexed by the FO index of the FO slot +// in sparsePropsSet. +s_p_m_r_PropsMap = new HashMap(1); +s_p_m_r_numProps = 1; +s_p_m_r_Indices = new int[] { PropNames.MASTER_REFERENCE }; +s_p_m_r_PropsMap.put +(Ints.consts.get(PropNames.MASTER_REFERENCE), +Ints.consts.get(0)); +} + +/** See {@link #sparsePropsMap sparsePropsMap}. */ +private static final HashMap r_p_m_r_PropsMap; + +/** See {@link #sparseIndices sparseIndices}. */ +private static final int[] r_p_m_r_Indices; + +/** See {@link #numProps numProps}. */ +private static final int r_p_m_r_numProps; + +static { +// Collect the sets of properties that apply +BitSet propsets = new BitSet(); +propsets.set(PropNames.MASTER_REFERENCE); +propsets.set(PropNames.MAXIMUM_REPEATS); + +// Map these properties into sparsePropsSet +// sparsePropsSet is a HashMap containing the indicies of the +// sparsePropsSet array, indexed by the FO index of the FO slot +// in sparsePropsSet. +r_p_m_r_PropsMap = new HashMap(); +r_p_m_r_numProps = propsets.cardinality(); +r_p_m_r_Indices = new int[r_p_m_r_numProps]; +int propx = 0; +for (int next = propsets.nextSetBit(0); +next >= 0; +next = propsets.nextSetBit(next + 1)) { +r_p_m_r_Indices[propx] = next; +r_p_m_r_PropsMap.put +(Ints.consts.get(next), Ints.consts.get(propx++)); +} +} + +/** See {@link #sparsePropsMap sparsePropsMap}. */ +private static final HashMap r_p_m_a_PropsMap; + +/** See {@link #sparseIndices sparseIndices}. *
cvs commit: xml-fop/src/org/apache/fop/fo/pagination FoPageSequenceMaster.java
pbwest 2002/10/11 20:55:30 Modified:src/org/apache/fop/fo/pagination Tag: FOP_0-20-0_Alt-Design FoPageSequenceMaster.java Log: Removed subSequenceList. Handle SubSequences within FONode. Change getMasterName() to derive name directly from the PropertySet on the FONode. Revision ChangesPath No revision No revision 1.1.2.8 +25 -19 xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java Index: FoPageSequenceMaster.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- FoPageSequenceMaster.java 10 Oct 2002 17:05:02 - 1.1.2.7 +++ FoPageSequenceMaster.java 12 Oct 2002 03:55:30 - 1.1.2.8 @@ -63,21 +63,13 @@ private String masterName; -private ArrayList subSequenceList = new ArrayList(1); +//private ArrayList subSequenceList = new ArrayList(1); public FoPageSequenceMaster(FOTree foTree, FONode parent, XMLEvent event) throws Tree.TreeException, FOPException, PropertyException { super(foTree, FObjectNames.PAGE_SEQUENCE_MASTER, parent, event, FOPropertySets.SEQ_MASTER_SET); -// Check that the property has been set -PropertyValue name = propertySet[PropNames.MASTER_NAME]; -if (name == null) -throw new PropertyException("master-name property not set"); -if (name.getType() != PropertyValue.NCNAME) -throw new PropertyException -("master-name property not an NCName."); -masterName = ((NCName)name).getNCName(); // Process sequence members here try { do { @@ -86,20 +78,23 @@ String localName = ev.getLocalName(); if (localName.equals("single-page-master-reference")) { System.out.println("Found single-page-master-reference"); - subSequenceList.add(new FoSinglePageMasterReference - (foTree, this, ev)); + //subSequenceList.add(new FoSinglePageMasterReference + //(foTree, this, ev)); + new FoSinglePageMasterReference(foTree, this, ev); } else if (localName.equals ("repeatable-page-master-reference")) { System.out.println ("Found repeatable-page-master-reference"); - subSequenceList.add(new FoRepeatablePageMasterReference - (foTree, this, ev)); + //subSequenceList.add(new FoRepeatablePageMasterReference + //(foTree, this, ev)); + new FoRepeatablePageMasterReference(foTree, this, ev); } else if (localName.equals ("repeatable-page-master-alternatives")) { System.out.println ("Found repeatable-page-master-alternatives"); - subSequenceList.add(new FoRepeatablePageMasterAlternatives - (foTree, this, ev)); + //subSequenceList.add(new FoRepeatablePageMasterAlternatives + //(foTree, this, ev)); + new FoRepeatablePageMasterAlternatives(foTree, this, ev); } else throw new FOPException ("Aargh! expectStartElement(events, list)"); @@ -113,8 +108,17 @@ /** * @return a String with the "master-name" attribute value. */ -public String getMasterName() { -return masterName; +public String getMasterName() throws PropertyException { + if (masterName == null) { + PropertyValue name = propertySet[PropNames.MASTER_NAME]; + if (name == null) + throw new PropertyException("master-name property not set"); + if (name.getType() != PropertyValue.NCNAME) + throw new PropertyException + ("master-name property not an NCName."); + masterName = ((NCName)name).getNCName(); + } + return masterName; } /** @@ -208,6 +212,7 @@ parent, event, FOPropertySets.SEQ_MASTER_SET); } + /* public PropertyValue getMasterReference() throws PropertyException { r
cvs commit: xml-fop/src/org/apache/fop/fo/pagination FoPageSequenceMaster.java
pbwest 2002/10/10 10:05:03 Modified:src/org/apache/fop/fo/pagination Tag: FOP_0-20-0_Alt-Design FoPageSequenceMaster.java Log: Incorporate inner classes: FoPageSequenceMaster.FoSinglePageMasterReference FoPageSequenceMaster.FoRepeatablePageMasterReference FoPageSequenceMaster.FoRepeatablePageMasterAlternatives FoPageSequenceMaster.FoRepeatablePageMasterAlternatives.FoConditionalPageMasterReference Revision ChangesPath No revision No revision 1.1.2.7 +126 -4 xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java Index: FoPageSequenceMaster.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- FoPageSequenceMaster.java 9 Oct 2002 06:00:49 - 1.1.2.6 +++ FoPageSequenceMaster.java 10 Oct 2002 17:05:02 - 1.1.2.7 @@ -35,7 +35,6 @@ * children of fo:layout-master-set FOs. Their contents are specified by * (single-page-master-reference|repeatable-page-master-reference *|repeatable-page-master-alternatives)+ - * N.B. The FoPageSequenceMaster is a subclass of FONode. */ public class FoPageSequenceMaster extends FONode { @@ -58,6 +57,10 @@ (XMLNamespaces.XSLNSpaceIndex, "repeatable-page-master-alternatives") }; +private static final XMLEvent.UriLocalName conditionalPageMasterRef = + new XMLEvent.UriLocalName(XMLNamespaces.XSLNSpaceIndex, + "conditional-page-master-reference"); + private String masterName; private ArrayList subSequenceList = new ArrayList(1); @@ -83,14 +86,20 @@ String localName = ev.getLocalName(); if (localName.equals("single-page-master-reference")) { System.out.println("Found single-page-master-reference"); + subSequenceList.add(new FoSinglePageMasterReference + (foTree, this, ev)); } else if (localName.equals ("repeatable-page-master-reference")) { System.out.println ("Found repeatable-page-master-reference"); + subSequenceList.add(new FoRepeatablePageMasterReference + (foTree, this, ev)); } else if (localName.equals ("repeatable-page-master-alternatives")) { System.out.println -("Found repeatable-page-master-reference"); +("Found repeatable-page-master-alternatives"); + subSequenceList.add(new FoRepeatablePageMasterAlternatives + (foTree, this, ev)); } else throw new FOPException ("Aargh! expectStartElement(events, list)"); @@ -107,5 +116,118 @@ public String getMasterName() { return masterName; } + +/** + * Implements the fo:single-page-master-reference flow object. It is + * always a child of an fo:page-sequence-master. + */ +public class FoSinglePageMasterReference extends FONode { + + public FoSinglePageMasterReference + (FOTree foTree, FONode parent, XMLEvent event) + throws Tree.TreeException, FOPException, PropertyException + { + super(foTree, FObjectNames.SINGLE_PAGE_MASTER_REFERENCE, parent, + event, FOPropertySets.SEQ_MASTER_SET); + this.xmlevents.getEndElement(event); + } + + public PropertyValue getMasterReference() throws PropertyException { + return this.getPropertyValue(PropNames.MASTER_REFERENCE); + } + +}// FoSinglePageMasterReference + +/** + * Implements the fo:repeatable-page-master-reference flow object. It is + * always a child of an fo:page-sequence-master. + */ +public class FoRepeatablePageMasterReference extends FONode { + + public FoRepeatablePageMasterReference + (FOTree foTree, FONode parent, XMLEvent event) + throws Tree.TreeException, FOPException, PropertyException + { + super(foTree, FObjectNames.REPEATABLE_PAGE_MASTER_REFERENCE, + parent, event, FOPropertySets.SEQ_MASTER_SET); + this.xmlevents.getEndElement(event); + } + + public PropertyValue getMasterReference() throws PropertyException { + return this.getPrope
cvs commit: xml-fop/src/org/apache/fop/fo/pagination FoPageSequenceMaster.java
pbwest 2002/10/06 07:15:11 Modified:src/org/apache/fop/fo/pagination Tag: FOP_0-20-0_Alt-Design FoPageSequenceMaster.java Log: Remove all SubSequenceSpecifier code. Removed no-event constructor. Revision ChangesPath No revision No revision 1.1.2.5 +14 -93 xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java Index: FoPageSequenceMaster.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- FoPageSequenceMaster.java 2 Oct 2002 15:19:59 - 1.1.2.4 +++ FoPageSequenceMaster.java 6 Oct 2002 14:15:11 - 1.1.2.5 @@ -20,11 +20,14 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.fo.expr.PropertyException; import org.apache.fop.fo.Properties; +import org.apache.fop.fo.PropNames; import org.apache.fop.fo.FOPropertySets; import org.apache.fop.fo.FObjectNames; import org.apache.fop.fo.FOTree; import org.apache.fop.fo.FONode; import org.apache.fop.datastructs.Tree; +import org.apache.fop.datatypes.PropertyValue; +import org.apache.fop.datatypes.NCName; /** * Implements the fo:page-sequence-master flow object. These Fos are @@ -42,30 +45,19 @@ private ArrayList subSequenceList = new ArrayList(1); -public FoPageSequenceMaster -(FOTree foTree, FONode parent, String masterName) -throws Tree.TreeException, FOPException, PropertyException -{ -super(foTree, FObjectNames.PAGE_SEQUENCE_MASTER, parent, null, - FOPropertySets.LAYOUT_SET); -this.masterName = masterName; -} - public FoPageSequenceMaster(FOTree foTree, FONode parent, XMLEvent event) throws Tree.TreeException, FOPException, PropertyException { super(foTree, FObjectNames.PAGE_SEQUENCE_MASTER, parent, event, - FOPropertySets.LAYOUT_SET); -if (event == null) { -System.out.println("Null event; throwing FOPException"); -throw new FOPException -("Null event passed to FoPageSequenceMaster constructor"); -} -try { -masterName = foAttributes.getFoAttrValue("master-name"); -} catch (PropertyException e) { -throw new FOPException(e.getMessage()); -} + FOPropertySets.SEQ_MASTER_SET); +// Check that the property has been set +PropertyValue name = propertySet[PropNames.MASTER_NAME]; +if (name == null) +throw new PropertyException("master-name property not set"); +if (name.getType() != PropertyValue.NCNAME) +throw new PropertyException +("master-name property not an NCName."); +masterName = ((NCName)name).getNCName(); // Process sequence members here LinkedList list = new LinkedList(); list.add((Object)(new XMLEvent.UriLocalName @@ -108,75 +100,4 @@ return masterName; } -/** - * SubSequenceSpecifer objects contain the information about an - * individual sub-sequence. They do not extend FONode - * because they are maintained only in the subSequenceList of an - * FoPageSequenceMaster object. - * When created from fo:single-page-master-reference, - * fo:repeatable-page-master-reference or - * fo:repeatable-page-master-alternatives and - * fo:conditional-page-master-references, the attributes on those - * nodes are merged into the attributes of the parent - * FoPageSequenceMaster object, so that they will be available - * to any children of this node, both - * during the parsing of the fo input and during the page construction - * process. - * Note that there is some ambiguity about the place of properties - * defined on the members of the layout-master-set subtree. Do - * these properties participate in the properties environment of - * elements in page-sequence subtrees? - */ -public class SubSequenceSpecifier { -public static final int UNBOUNDED = -1; -private int minRepeats = 1; -private int maxRepeats = UNBOUNDED; -private ArrayList conditionals = new ArrayList(1); - -public SubSequenceSpecifier() { -// Insert the SSS into the parent FoPageSequenceMaster's -// list -FoPageSequenceMaster.this.subSequenceList.add(this); -} - -public SubSequenceSpecifier(int maxRepeats) { -this(); -minRepeats = 0; -this.maxRe