]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Modified to buffer static-content subtree events
authorPeter Bernard West <pbwest@apache.org>
Wed, 21 Jan 2004 07:04:18 +0000 (07:04 +0000)
committerPeter Bernard West <pbwest@apache.org>
Wed, 21 Jan 2004 07:04:18 +0000 (07:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197232 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/flow/FoStaticContent.java

index 21c44d656ee8dc17eea31eb67e5df154e5ae9655..1b8af1f0ef733d95d21551f9e61d2110ce3fb86a 100644 (file)
@@ -60,15 +60,16 @@ import java.util.BitSet;
 
 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 @@ public class FoStaticContent extends FONode {
     /** 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 @@ public class FoStaticContent extends FONode {
     }
 
     /**
-     * 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 @@ public class FoStaticContent extends FONode {
     {
         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;
     }
 
+    
 }