You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by pb...@apache.org on 2004/01/21 08:04:18 UTC

cvs commit: xml-fop/src/java/org/apache/fop/fo/flow FoStaticContent.java

pbwest      2004/01/20 23:04:18

  Modified:    src/java/org/apache/fop/fo/flow Tag: FOP_0-20-0_Alt-Design
                        FoStaticContent.java
  Log:
  Modified to buffer static-content subtree events
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.7   +48 -34    xml-fop/src/java/org/apache/fop/fo/flow/Attic/FoStaticContent.java
  
  Index: FoStaticContent.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Attic/FoStaticContent.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- FoStaticContent.java	20 Jan 2004 05:57:07 -0000	1.1.2.6
  +++ FoStaticContent.java	21 Jan 2004 07:04:18 -0000	1.1.2.7
  @@ -60,15 +60,16 @@
   
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.datastructs.TreeException;
  +import org.apache.fop.datatypes.NCName;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FOTree;
   import org.apache.fop.fo.FObjectNames;
  -import org.apache.fop.fo.FObjects;
   import org.apache.fop.fo.PropNames;
  +import org.apache.fop.fo.expr.PropertyException;
   import org.apache.fop.xml.FoXmlEvent;
   import org.apache.fop.xml.XmlEvent;
   import org.apache.fop.xml.XmlEventReader;
  -import org.apache.fop.xml.UnexpectedStartElementException;
  +import org.apache.fop.xml.XmlEventsArrayBuffer;
   
   /**
    * Implements the fo:simple-page-master flow object
  @@ -92,7 +93,17 @@
       /** The number of applicable properties.  This is the size of the
           <i>sparsePropsSet</i> array. */
       private static final int numProps;
  -
  +    
  +    /**
  +     * The flow-name for this fo:static-content
  +     */
  +    public final String flowName;
  +    
  +    /**
  +     * The buffer which will hold the contents of the fo:static-content subtree
  +     */
  +    private XmlEventsArrayBuffer buffer;
  +    
       static {
           // Collect the sets of properties that apply
           BitSet propsets = new BitSet();
  @@ -110,7 +121,8 @@
       }
   
       /**
  -     * Construct an fo:static-content node, and build the fo:static-content
  +     * Construct an fo:static-content node, and buffer the contents for later
  +* parsing
        * subtree.
        * <p>Content model for fo:static-content: (%block;)+
        * @param foTree the FO tree being built
  @@ -123,36 +135,38 @@
       {
           super(foTree, FObjectNames.STATIC_CONTENT, parent, event,
                 FONode.STATIC_SET, sparsePropsMap, sparseIndices);
  -        XmlEvent ev;
  +        NCName ncName;
           try {
  -            // Get at least one %block;
  -            if ((ev = xmlevents.expectBlock()) == null)
  -                throw new FOPException
  -                        ("%block; not found in fo:static-content");
  -            // Generate the flow object
  -            //System.out.println("Generating first block for static-content.");
  -            FObjects.fobjects.makeFlowObject(
  -                    foTree, this, (FoXmlEvent)ev, FONode.STATIC_SET);
  -            // Clear the blockage
  -            ev = xmlevents.getEndElement(XmlEventReader.DISCARD_EV, ev);
  -            namespaces.relinquishEvent(ev);
  -            // Get the rest of the %block;s
  -            while ((ev = xmlevents.expectBlock()) != null) {
  -                // Generate the flow object
  -                //System.out.println
  -                    //("Generating subsequent block for static-content.");
  -                FObjects.fobjects.makeFlowObject(
  -                        foTree, this, (FoXmlEvent)ev, FONode.STATIC_SET);
  -                ev = xmlevents.getEndElement(XmlEventReader.DISCARD_EV, ev);
  -                namespaces.relinquishEvent(ev);
  -            }
  -        } catch(UnexpectedStartElementException e) {
  -            throw new FOPException
  -            ("Block not found or unexpected non-block in fo:static-content");
  +            ncName = (NCName)(getPropertyValue(PropNames.FLOW_NAME));
  +        } catch (PropertyException e) {
  +            throw new FOPException("Cannot find marker-class-name in fo:marker", e);
  +        } catch (ClassCastException e) {
  +            throw new FOPException("Wrong PropertyValue type in fo:marker", e);
           }
  -
  -        System.out.println("Making sparsePropsSet for static-content.");
  -        makeSparsePropsSet();
  +        flowName = ncName.getNCName();
  +        
  +        // sparsePropsSet cannot be made for static content, because the full
  +        // ancestor tree of properties must be available for the later
  +        // resolution of properties in the static-content subtree and any
  +        // markers which are later attached to the subtree.
  +        // makeSparsePropsSet();
  +        
  +        // Collect the contents of fo:static-content for future processing
  +        buffer = new XmlEventsArrayBuffer(namespaces);
  +        XmlEvent ev = xmlevents.getEndElement(
  +                buffer, XmlEventReader.RETAIN_EV, event);
  +        // The original START_ELEMENT event is still known to the parent
  +        // page-sequence, which will arrange to relinquish it.  Relinquish
  +        // the just-returned END_ELEMENT event
  +        namespaces.relinquishEvent(ev);
  +    }
  +    
  +    /**
  +     * @return the static-content subtree buffer
  +     */
  +    public XmlEventsArrayBuffer getEventBuffer() {
  +        return buffer;
       }
   
  +    
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org