]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
1. add an AreaTreeControl interface
authorWilliam Victor Mote <vmote@apache.org>
Mon, 6 Oct 2003 16:38:48 +0000 (16:38 +0000)
committerWilliam Victor Mote <vmote@apache.org>
Mon, 6 Oct 2003 16:38:48 +0000 (16:38 +0000)
2. make apps/Document implement it
3. tie the AreaTree to an AreaTreeControl object
4. clean up AreaTree to use its parent AreaTreeControl object

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196944 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/area/AreaTree.java
src/java/org/apache/fop/area/AreaTreeControl.java [new file with mode: 0644]
src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java
src/java/org/apache/fop/tools/AreaTreeBuilder.java

index b5efd34eb6a648314d9cc94e655aeb19660117c9..b284c5dfb30a4156d135ec673c3e5a7433306bef 100644 (file)
@@ -61,6 +61,7 @@ import java.util.HashSet;
 import org.apache.fop.apps.FOUserAgent;
 
 import org.apache.fop.area.AreaTree;
+import org.apache.fop.area.AreaTreeControl;
 import org.apache.fop.area.AreaTreeModel;
 
 import org.apache.fop.fo.extensions.Bookmarks;
@@ -83,7 +84,8 @@ import org.apache.avalon.framework.logger.Logger;
  * Class storing information for the FOP Document being processed, and managing
  * the processing of it.
  */
-public class Document implements FOTreeControl, FOTreeListener {
+public class Document implements FOTreeControl, FOTreeListener,
+        AreaTreeControl {
 
     /** The parent Driver object */
     private Driver driver;
index add324ed54300315421e1e79a0f2f743a244f0c6..3ed6d47fb0de33dac39c86640809489eaf6d8606 100644 (file)
@@ -590,7 +590,7 @@ public class Driver implements LogEnabled {
             if (foInputHandler instanceof FOTreeHandler) {
                 FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler;
                 foTreeHandler.addFOTreeListener(currentDocument);
-                currentDocument.areaTree = new AreaTree();
+                currentDocument.areaTree = new AreaTree(currentDocument);
                 currentDocument.atModel = new RenderPagesModel(renderer);
                 //this.atModel = new CachedRenderPagesModel(renderer);
                 currentDocument.areaTree.setTreeModel(currentDocument.atModel);
index 2191be9168adfbd0974aadd0710357614d9579f0..0076ef16b468644e6aaa14656a9242fc3bfc2d4d 100644 (file)
@@ -83,6 +83,7 @@ public class AreaTree {
     // allows for different models to deal with adding/rendering
     // in different situations
     private AreaTreeModel model;
+    private AreaTreeControl atControl;
 
     // hashmap of arraylists containing pages with id area
     private Map idLocations = new HashMap();
@@ -90,6 +91,15 @@ public class AreaTree {
     private Map resolve = new HashMap();
     private List treeExtensions = new ArrayList();
 
+    /**
+     * Constructor.
+     * @param atControl the AreaTreeControl object controlling this AreaTree
+     */
+    public AreaTree (AreaTreeControl atControl) {
+        this.atControl = atControl;
+    }
+
+
     /**
      * Create a new store pages model.
      * @return StorePagesModel the new model
@@ -241,14 +251,14 @@ public class AreaTree {
     /**
      * Create the bookmark data in the area tree.
      */
-    public void addBookmarksToAreaTree(Document document) {
-        if (document.getBookmarks() == null) {
+    public void addBookmarksToAreaTree() {
+        if (atControl.getBookmarks() == null) {
             return;
         }
-        document.getDriver().getLogger().debug("adding bookmarks to area tree");
+        atControl.getLogger().debug("adding bookmarks to area tree");
         BookmarkData data = new BookmarkData();
-        for (int count = 0; count < document.getBookmarks().getOutlines().size(); count++) {
-            Outline out = (Outline)(document.getBookmarks().getOutlines()).get(count);
+        for (int count = 0; count < atControl.getBookmarks().getOutlines().size(); count++) {
+            Outline out = (Outline)(atControl.getBookmarks().getOutlines()).get(count);
             data.addSubData(createBookmarkData(out));
         }
         addTreeExtension(data);
diff --git a/src/java/org/apache/fop/area/AreaTreeControl.java b/src/java/org/apache/fop/area/AreaTreeControl.java
new file mode 100644 (file)
index 0000000..1db9373
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ * ============================================================================
+ *                    The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ *    include the following acknowledgment: "This product includes software
+ *    developed by the Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself, if
+ *    and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ *    endorse or promote products derived from this software without prior
+ *    written permission. For written permission, please contact
+ *    apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ *    "Apache" appear in their name, without prior written permission of the
+ *    Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation and was originally created by
+ * James Tauber <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.area;
+
+// FOP
+import org.apache.fop.fo.extensions.Bookmarks;
+
+// Avalon
+import org.apache.avalon.framework.logger.Logger;
+
+/**
+ * An interface for classes that are conceptually the parent class of the
+ * area.AreaTree object. The purpose of the interface is to keep the AreaTree
+ * isolated from apps, but to acknowledge that a higher-level object is needed
+ * to control the Area Tree, to provide it with information about the
+ * environment, and to keep track of meta information.
+ */
+public interface AreaTreeControl {
+
+    /**
+     * @return the Bookmark object encapsulating the bookmarks for the FO Tree.
+     */
+    Bookmarks getBookmarks();
+
+    /**
+     * @return the Logger being used with this FO Tree
+     */
+    Logger getLogger();
+
+}
index bcf8692aad786499e554dc832c594d985c6b7cd2..c63281b5fb9105d59f6ef4be16d05cc016786c11 100644 (file)
@@ -94,7 +94,7 @@ public class LayoutManagerLS extends LayoutStrategy {
             return;
         }
 
-        areaTree.addBookmarksToAreaTree(this.document);
+        areaTree.addBookmarksToAreaTree();
 
         // Initialize if already used?
         //    this.layoutMasterSet.resetPageMasters();
index 2f4eafc39c2ee2f02640e00c0b4bb8164482afe7..2440939904df49a6fe37abeaac184dec4dcb16ea 100644 (file)
@@ -273,7 +273,7 @@ class TreeLoader extends AbstractLogEnabled {
         Element root = null;
         root = doc.getDocumentElement();
 
-        areaTree = new AreaTree();
+        areaTree = new AreaTree(fontInfo);
         areaTree.setTreeModel(model);
 
         readAreaTree(root);