]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
1. Child element validity checking added for fo:page-sequence-master.
authorGlen Mazza <gmazza@apache.org>
Thu, 17 Jun 2004 07:02:13 +0000 (07:02 +0000)
committerGlen Mazza <gmazza@apache.org>
Thu, 17 Jun 2004 07:02:13 +0000 (07:02 +0000)
2. AreaTree object moved from Document/Driver to FOTreeHandler, as it is specific to this subclass of FOInputHandler only (RTFHandler and MIFHandler don't use area trees).

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197723 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/apps/Document.java
src/java/org/apache/fop/apps/Driver.java
src/java/org/apache/fop/fo/FOInputHandler.java
src/java/org/apache/fop/fo/FOTreeHandler.java
src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java

index ec28fa89178f9ea21bf52c2100bd2d1304d3fde4..141ed65265dcfd6794c3f3ba87a89ce627320c89 100644 (file)
 package org.apache.fop.apps;
 
 // FOP
-import org.apache.fop.area.AreaTree;
-import org.apache.fop.area.AreaTreeModel;
 import org.apache.fop.fo.FOInputHandler;
 import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.render.Renderer;
 
 // SAX
 import org.xml.sax.SAXException;
@@ -39,11 +38,8 @@ public class Document {
     /** The Font information relevant for this document */
     private FontInfo fontInfo;
     
-    /** The current AreaTree for the PageSequence being rendered. */
-    public AreaTree areaTree;
-
-    /** The AreaTreeModel for the PageSequence being rendered. */
-    public AreaTreeModel atModel;
+    /** The Renderer being used for this document */
+    protected Renderer renderer;
 
     /**
      * Structure handler used to notify structure
@@ -77,12 +73,12 @@ public class Document {
     }
 
     /**
-     * Get the area tree for this layout handler.
+     * Get the renderer for this document
      *
-     * @return the area tree for this document
+     * @return the renderer for this document
      */
-    public AreaTree getAreaTree() {
-        return areaTree;
+    public Renderer getRenderer() {
+        return renderer;
     }
 
     /**
index db981f71642b050840089d84d03fe70fb994efbc..afdee0e4d85aca6470de15b3f415a53d9597810b 100644 (file)
@@ -19,9 +19,6 @@
 package org.apache.fop.apps;
 
 // FOP
-import org.apache.fop.area.AreaTree;
-import org.apache.fop.area.RenderPagesModel;
-
 import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.FOTreeBuilder;
 
@@ -490,11 +487,9 @@ public class Driver {
                         "Renderer not set when using standard foInputHandler");
             }
 
+            currentDocument.renderer = renderer;
             foInputHandler = new FOTreeHandler(currentDocument, true);
-            currentDocument.areaTree = new AreaTree();
-            currentDocument.atModel = new RenderPagesModel(renderer);
-            //this.atModel = new CachedRenderPagesModel(renderer);
-            currentDocument.areaTree.setTreeModel(currentDocument.atModel);
+
             try {
                 renderer.setupFontInfo(currentDocument.getFontInfo());
                 // check that the "any,normal,400" font exists
index c44ddf91ec2a2c76012e24127744abac0770830e..67176aa2b419c63b6f6a846f0f5d406ef943433d 100644 (file)
@@ -119,13 +119,6 @@ public abstract class FOInputHandler {
         return doc;
     }
 
-    /**   
-      * @return the current Area Tree object
-      */   
-     public AreaTree getAreaTree() {
-        return doc.getAreaTree();
-     } 
-    
     /**
      * Returns the Driver object associated with this FOInputHandler.
      * @return the Driver object
index 2082bcb35b888b3b5f45ca1f19c2821a01187bf4..549c73d3be06bc19b2a56fd901b3c91d907431ff 100644 (file)
@@ -30,6 +30,7 @@ import org.xml.sax.SAXException;
 import org.apache.fop.apps.Document;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.area.AreaTree;
+import org.apache.fop.area.RenderPagesModel;
 import org.apache.fop.area.Title;
 import org.apache.fop.fo.extensions.Bookmarks;
 import org.apache.fop.fo.flow.BasicLink;
@@ -76,6 +77,9 @@ public class FOTreeHandler extends FOInputHandler {
      */
     private Runtime runtime;
 
+    /** The current AreaTree for the FOTreeHandler. */
+    public AreaTree areaTree;
+
     /**
      * Keep track of the number of pages rendered.
      */
@@ -105,6 +109,11 @@ public class FOTreeHandler extends FOInputHandler {
      */
     public FOTreeHandler(Document doc, boolean store) {
         super(doc);
+        
+        areaTree = new AreaTree();
+        // this.atModel = new CachedRenderPagesModel(renderer);
+        areaTree.setTreeModel(new RenderPagesModel(doc.getRenderer()));
+        
         if (collectStatistics) {
             runtime = Runtime.getRuntime();
         }
@@ -597,4 +606,12 @@ public class FOTreeHandler extends FOInputHandler {
      */
     public void endPageNumber(PageNumber pagenum) {
     }
+    
+    /**   
+      * @return the current Area Tree object
+      */   
+     public AreaTree getAreaTree() {
+        return areaTree;
+     } 
+    
 }
index 16e54948900f62897bb2a997093660942601eb4e..3101df6e6a1de8404f6f8d61b604f7be84d2d105 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Map;
 
 // XML
 import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
 
 // FOP
 import org.apache.fop.fo.FONode;
@@ -31,7 +32,6 @@ import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.FOElementMapping;
 import org.apache.fop.fo.FOTreeVisitor;
 import org.apache.fop.apps.FOPException;
-import org.xml.sax.Locator;
 
 /**
  * The layout-master-set formatting object.
index f5b53214fc94b1d6c3a4d133514521810887d08a..53617b602dc84d314809ce6767b857986b09999f 100644 (file)
@@ -21,13 +21,15 @@ package org.apache.fop.fo.pagination;
 // Java
 import java.util.List;
 
-// SAX
+// XML
 import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
 
 // FOP
 import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FOElementMapping;
 import org.apache.fop.fo.FOTreeVisitor;
 import org.apache.fop.apps.FOPException;
 
@@ -58,6 +60,33 @@ public class PageSequenceMaster extends FObj {
         super(parent);
     }
 
+
+
+    /**
+     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+     * XSL/FOP: (single-page-master-reference|repeatable-page-master-reference|
+     *     repeatable-page-master-alternatives)+
+     */
+    protected void validateChildNode(Locator loc, String nsURI, String localName) {
+        if (nsURI == FOElementMapping.URI) {
+            if (!localName.equals("single-page-master-reference") 
+                && !localName.equals("repeatable-page-master-reference")
+                && !localName.equals("repeatable-page-master-alternatives")) {   
+                    invalidChildError(loc, nsURI, localName);
+            }
+        } else {
+            invalidChildError(loc, nsURI, localName);
+        }
+    }
+
+    protected void end() {
+        if (children == null) {
+           missingChildElementError("(single-page-master-reference|" +
+            "repeatable-page-master-reference|repeatable-page-master-alternatives)+");
+        }
+    }
+
+
     /**
      * @see org.apache.fop.fo.FObj#addProperties
      */