gmazza      2004/10/27 17:06:47

  Modified:    src/java/org/apache/fop/area AreaTreeHandler.java
                        AreaTreeModel.java OffDocumentItem.java
                        RenderPagesModel.java StorePagesModel.java
               src/java/org/apache/fop/render/pdf PDFRenderer.java
  Added:       src/java/org/apache/fop/area BookmarkData.java
  Removed:     src/java/org/apache/fop/area/extensions BookmarkData.java
  Log:
  1.) Changed OffDocumentItem from an interface to an abstract base class.
  
  2.) Removed the "extensions" package.
  
  Revision  Changes    Path
  1.16      +2 -3      xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java
  
  Index: AreaTreeHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- AreaTreeHandler.java      27 Oct 2004 23:36:32 -0000      1.15
  +++ AreaTreeHandler.java      28 Oct 2004 00:06:46 -0000      1.16
  @@ -33,7 +33,6 @@
   // Apache
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.apps.FOUserAgent;
  -import org.apache.fop.area.extensions.BookmarkData;
   import org.apache.fop.fo.FOEventHandler;
   import org.apache.fop.fo.extensions.Outline;
   import org.apache.fop.fo.extensions.Bookmarks;
  @@ -317,7 +316,7 @@
                   }
               }
           } else {
  -            model.handleOffDocumentItem(ext, OffDocumentItem.IMMEDIATELY);
  +            model.handleOffDocumentItem(ext);
           }
       }
   }
  
  
  
  1.10      +1 -2      xml-fop/src/java/org/apache/fop/area/AreaTreeModel.java
  
  Index: AreaTreeModel.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/AreaTreeModel.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AreaTreeModel.java        27 Oct 2004 23:36:32 -0000      1.9
  +++ AreaTreeModel.java        28 Oct 2004 00:06:46 -0000      1.10
  @@ -45,9 +45,8 @@
       /**
        * Handle an OffDocumentItem 
        * @param ext the extension to handle
  -     * @param when when the extension should be handled
        */
  -    public abstract void handleOffDocumentItem(OffDocumentItem ext, int when);
  +    public abstract void handleOffDocumentItem(OffDocumentItem ext);
   
       /**
        * Signal the end of the document for any processing.
  
  
  
  1.2       +17 -6     xml-fop/src/java/org/apache/fop/area/OffDocumentItem.java
  
  Index: OffDocumentItem.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/OffDocumentItem.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OffDocumentItem.java      27 Oct 2004 23:36:32 -0000      1.1
  +++ OffDocumentItem.java      28 Oct 2004 00:06:46 -0000      1.2
  @@ -19,28 +19,39 @@
   package org.apache.fop.area;
   
   /**
  - * Interface for objects that are processed by the renderer outside
  + * Abstract base class for objects that are processed by the renderer outside
    * of the actual document.
    * This object can be handled by the renderer according to three
    * possibilities, IMMEDIATELY, AFTER_PAGE, or END_OF_DOC.
    */
  -public interface OffDocumentItem {
  +public abstract class OffDocumentItem {
  +
       /**
  -     * Render this extension immediately when
  +     * Process this extension immediately when
        * being handled by the area tree.
        */
       public static final int IMMEDIATELY = 0;
   
       /**
  -     * Render this extension after the next page is rendered
  +     * Process this extension after the next page is rendered
        * or prepared when being handled by the area tree.
        */
       public static final int AFTER_PAGE = 1;
   
       /**
  -     * Render this extension at the end of the document once
  +     * Process this extension at the end of the document once
        * all pages have been fully rendered.
        */
       public static final int END_OF_DOC = 2;
   
  +
  +    protected int whenToProcess = IMMEDIATELY;
  +    
  +    /**
  +     * Get an indicator of when this item should be processed
  +     * @return int constant (IMMEDIATELY, AFTER_PAGE, END_OF_DOC)
  +     */
  +    public int getWhenToProcess() {
  +        return whenToProcess;
  +    }
   }
  
  
  
  1.9       +16 -17    xml-fop/src/java/org/apache/fop/area/RenderPagesModel.java
  
  Index: RenderPagesModel.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/RenderPagesModel.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RenderPagesModel.java     27 Oct 2004 23:36:32 -0000      1.8
  +++ RenderPagesModel.java     28 Oct 2004 00:06:46 -0000      1.9
  @@ -52,8 +52,8 @@
        * Pages that have been prepared but not rendered yet.
        */
       protected List prepared = new java.util.ArrayList();
  -    private List pendingExt = new java.util.ArrayList();
  -    private List endDocExt = new java.util.ArrayList();
  +    private List pendingODI = new java.util.ArrayList();
  +    private List endDocODI = new java.util.ArrayList();
   
       /**
        * Create a new render pages model with the given renderer.
  @@ -126,8 +126,8 @@
           boolean cont = checkPreparedPages(page);
   
           if (cont) {
  -            processOffDocumentItems(pendingExt);
  -            pendingExt.clear();
  +            processOffDocumentItems(pendingODI);
  +            pendingODI.clear();
           }
       }
   
  @@ -175,41 +175,40 @@
       }
   
       /**
  -     * @see 
org.apache.fop.area.AreaTreeModel#handleOffDocumentItem(OffDocumentItem, int)
  +     * @see org.apache.fop.area.AreaTreeModel#handleOffDocumentItem(OffDocumentItem)
        */
  -    public void handleOffDocumentItem(OffDocumentItem ext, int when) {
  -        switch(when) {
  +    public void handleOffDocumentItem(OffDocumentItem oDI) {
  +        switch(oDI.getWhenToProcess()) {
               case OffDocumentItem.IMMEDIATELY:
  -                renderer.processOffDocumentItem(ext);
  +                renderer.processOffDocumentItem(oDI);
                   break;
               case OffDocumentItem.AFTER_PAGE:
  -                pendingExt.add(ext);
  +                pendingODI.add(oDI);
                   break;
               case OffDocumentItem.END_OF_DOC:
  -                endDocExt.add(ext);
  +                endDocODI.add(oDI);
                   break;
           }
       }
   
       private void processOffDocumentItems(List list) {
           for (int count = 0; count < list.size(); count++) {
  -            OffDocumentItem ext = (OffDocumentItem)list.get(count);
  -            renderer.processOffDocumentItem(ext);
  +            OffDocumentItem oDI = (OffDocumentItem)list.get(count);
  +            renderer.processOffDocumentItem(oDI);
           }
       }
   
       /**
  -     * End the document. Render any end document extensions.
  +     * End the document. Render any end document OffDocumentItems
        * @see org.apache.fop.area.AreaTreeModel#endDocument()
        */
       public void endDocument() throws SAXException {
           // render any pages that had unresolved ids
           checkPreparedPages(null);
   
  -        processOffDocumentItems(pendingExt);
  -        pendingExt.clear();
  -
  -        processOffDocumentItems(endDocExt);
  +        processOffDocumentItems(pendingODI);
  +        pendingODI.clear();
  +        processOffDocumentItems(endDocODI);
           
           try {
               renderer.stopRenderer();
  
  
  
  1.12      +12 -12    xml-fop/src/java/org/apache/fop/area/StorePagesModel.java
  
  Index: StorePagesModel.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/StorePagesModel.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StorePagesModel.java      27 Oct 2004 23:36:32 -0000      1.11
  +++ StorePagesModel.java      28 Oct 2004 00:06:46 -0000      1.12
  @@ -33,7 +33,7 @@
   public class StorePagesModel extends AreaTreeModel {
       private List pageSequence = null;
       private List currSequence;
  -    private List extensions = new java.util.ArrayList();
  +    private List offDocumentItems = new java.util.ArrayList();
   
       /**
        * Create a new store pages model
  @@ -92,11 +92,11 @@
       }
   
       /**
  -     * @see 
org.apache.fop.area.AreaTreeModel#handleOffDocumentItem(OffDocumentItem, int)
  +     * @see org.apache.fop.area.AreaTreeModel#handleOffDocumentItem(OffDocumentItem)
        */
  -    public void handleOffDocumentItem(OffDocumentItem ext, int when) {
  +    public void handleOffDocumentItem(OffDocumentItem ext) {
           int seq, page;
  -        switch(when) {
  +        switch(ext.getWhenToProcess()) {
               case OffDocumentItem.IMMEDIATELY:
                   seq = pageSequence == null ? 0 : pageSequence.size();
                   page = currSequence == null ? 0 : currSequence.size();
  @@ -106,26 +106,26 @@
               case OffDocumentItem.END_OF_DOC:
                   break;
           }
  -        extensions.add(ext);
  +        offDocumentItems.add(ext);
       }
   
       /**
  -     * Get the list of extensions that apply at a particular
  +     * Get the list of OffDocumentItems that apply at a particular
        * position in the document.
        * @param seq the page sequence number
        * @param count the page count in the sequence
  -     * @return the list of extensions
  +     * @return the list of OffDocumentItems
        */
  -    public List getExtensions(int seq, int count) {
  +    public List getOffDocumentItems(int seq, int count) {
           return null;
       }
   
       /**
  -     * Get the end of document extensions for this stroe pages model.
  -     * @return the list of end extensions
  +     * Get the end of document OffDocumentItems for this store pages model.
  +     * @return the list of end OffDocumentItems
        */
  -    public List getEndExtensions() {
  -        return extensions;
  +    public List getEndOffDocumentItems() {
  +        return offDocumentItems;
       }
   
       /**
  
  
  
  1.1                  xml-fop/src/java/org/apache/fop/area/BookmarkData.java
  
  Index: BookmarkData.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /* $Id: BookmarkData.java,v 1.1 2004/10/28 00:06:46 gmazza Exp $ */
   
  package org.apache.fop.area;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.HashMap;
  
  /**
   * This class holds the PDF bookmark OffDocumentItem
   */
  public class BookmarkData extends OffDocumentItem implements Resolvable {
      private ArrayList subData = new ArrayList();
      private HashMap idRefs = new HashMap();
  
      // area tree model for the top level object to activate when resolved
      private AreaTreeModel areaTreeModel = null;
  
      private String idRef;
      private PageViewport pageRef = null;
      private String label = null;
  
      /**
       * Create a new bookmark data object.
       * This should only be call by the top level element as the
       * id reference will be null.
       */
      public BookmarkData() {
          idRef = null;
          whenToProcess = IMMEDIATELY;
      }
  
      /**
       * Create a new pdf bookmark data object.
       * This is used by the outlines to create a data object
       * with a id reference. The id reference is to be resolved.
       *
       * @param id the id reference
       */
      public BookmarkData(String id) {
          idRef = id;
          idRefs.put(idRef, this);
      }
  
      /**
       * Set the area tree model
       * This should only be called for the top level element.
       * The area tree model is used once resolving is complete.
       *
       * @param atm the area tree model for the current document
       */
      public void setAreaTreeModel(AreaTreeModel atm) {
          areaTreeModel = atm;
      }
  
      /**
       * Get the id reference for this data.
       *
       * @return the id reference
       */
      public String getID() {
          return idRef;
      }
  
      /**
       * Add the child bookmark data object.
       * This adds a child bookmark in the bookmark hierarchy.
       *
       * @param sub the child bookmark data
       */
      public void addSubData(BookmarkData sub) {
          subData.add(sub);
          idRefs.put(sub.getID(), sub);
          String[] ids = sub.getIDs();
          for (int count = 0; count < ids.length; count++) {
              idRefs.put(ids[count], sub);
          }
      }
  
      /**
       * Set the label for this bookmark.
       *
       * @param l the string label
       */
      public void setLabel(String l) {
          label = l;
      }
  
      /**
       * Get the label for this bookmark object.
       *
       * @return the label string
       */
      public String getLabel() {
          return label;
      }
  
      /**
       * Get the size of child data objects.
       *
       * @return the number of child bookmark data
       */
      public int getCount() {
          return subData.size();
      }
  
      /**
       * Get the child data object.
       *
       * @param count the index to get
       * @return the child bookmark data
       */
      public BookmarkData getSubData(int count) {
          return (BookmarkData)subData.get(count);
      }
  
      /**
       * Get the page that this resolves to.
       *
       * @return the PageViewport that this extension resolves to
       */
      public PageViewport getPage() {
          return pageRef;
      }
  
      /**
       * Check if this resolvable object has been resolved.
       * Once the id reference is null then it has been resolved.
       *
       * @return true if this has been resolved
       */
      public boolean isResolved() {
          return idRefs == null;
      }
  
      /**
       * Get the id references held by this object.
       * Also includes all id references of all children.
       *
       * @return the array of id references
       */
      public String[] getIDs() {
          return (String[])idRefs.keySet().toArray(new String[] {});
      }
  
      /**
       * Resolve this resolvable object.
       * This resolves the id reference and if possible also
       * resolves id references of child elements that have the same
       * id reference.
       *
       * @param id the id reference being resolved
       * @param pages the list of pages the the id reference resolves to
       */
      public void resolve(String id, List pages) {
          // this method is buggy
  
          if (!id.equals(idRef)) {
              BookmarkData bd = (BookmarkData)idRefs.get(id);
              idRefs.remove(id);
              if (bd != null) {
                  bd.resolve(id, pages);
                  if (bd.isResolved()) {
                      checkFinish();
                  }
              } else if (idRef == null) {
                  checkFinish();
              }
          } else {
              if (pages != null) {
                  pageRef = (PageViewport)pages.get(0);
              }
              // TODO get rect area of id on page
  
              idRefs.remove(idRef);
              checkFinish();
          }
      }
  
      private void checkFinish() {
          if (idRefs.size() == 0) {
              idRefs = null;
              if (areaTreeModel != null) {
                  areaTreeModel.handleOffDocumentItem(this);
              }
          }
      }
  }
  
  
  
  
  1.59      +1 -1      xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java
  
  Index: PDFRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- PDFRenderer.java  27 Oct 2004 23:36:33 -0000      1.58
  +++ PDFRenderer.java  28 Oct 2004 00:06:47 -0000      1.59
  @@ -47,7 +47,7 @@
   import org.apache.fop.area.RegionViewport;
   import org.apache.fop.area.Trait;
   import org.apache.fop.area.OffDocumentItem;
  -import org.apache.fop.area.extensions.BookmarkData;
  +import org.apache.fop.area.BookmarkData;
   import org.apache.fop.area.inline.Character;
   import org.apache.fop.area.inline.TextArea;
   import org.apache.fop.area.inline.Viewport;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to