gmazza      2004/12/16 15:59:13

  Modified:    src/java/org/apache/fop/area AreaTreeHandler.java
                        BookmarkData.java CachedRenderPagesModel.java
                        LinkResolver.java PageViewport.java
                        RenderPagesModel.java Resolvable.java
               src/java/org/apache/fop/area/inline
                        UnresolvedPageNumber.java
               src/java/org/apache/fop/layoutmgr
                        PageSequenceLayoutManager.java
  Log:
  More code commenting and minor cleanup of bookmark/Resolvable/ATH code.
  
  Revision  Changes    Path
  1.26      +10 -9     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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- AreaTreeHandler.java      16 Dec 2004 01:03:04 -0000      1.25
  +++ AreaTreeHandler.java      16 Dec 2004 23:59:13 -0000      1.26
  @@ -51,7 +51,7 @@
    * The area tree needs to be simple to render and follow the spec
    * closely.
    * This area tree has the concept of page sequences.
  - * Where ever possible information is discarded or optimized to
  + * Wherever possible information is discarded or optimized to
    * keep memory use low. The data is also organized to make it
    * possible for renderers to minimize their output.
    * A page can be saved if not fully resolved and once rendered
  @@ -82,11 +82,12 @@
       // The fo:root node of the document
       private Root rootFObj;
   
  -    // HashMap of ID's whose area is located on one or more PageViewports
  -    // Each ID has an arraylist of PageViewports sharing the area with this 
ID
  +    // HashMap of ID's whose area is located on one or more consecutive 
  +    // PageViewports.  Each ID has an arraylist of PageViewports that
  +    // form the defined area of this ID
       private Map idLocations = new HashMap();
   
  -    // idref's whose corresponding id's have yet to be found
  +    // idref's whose target PageViewports have yet to be identified
       // Each idref has a HashSet of Resolvable objects containing that idref
       private Map unresolvedIDRefs = new HashMap();
   
  @@ -136,8 +137,9 @@
               idLocations.put(id, pvList);
               pvList.add(pv);
   
  -            /* See if this ID is in the unresolved idref list.  Note:
  -             * unresolving occurs at first PV found for a given area. 
  +            /* 
  +             * See if this ID is in the unresolved idref list, if so
  +             * resolve Resolvable objects tied to it.
                */
               Set todo = (Set) unresolvedIDRefs.get(id);
               if (todo != null) {
  @@ -237,7 +239,6 @@
               PageSequenceLayoutManager pageSLM 
                   = new PageSequenceLayoutManager(this, pageSequence);
               pageSLM.activateLayout();
  -            pageSequence.setCurrentPageNumber(pageSLM.getPageCount());
           }
       }
   
  @@ -285,7 +286,7 @@
       private void addOffDocumentItem(OffDocumentItem odi) {
           if (odi instanceof Resolvable) {
               Resolvable res = (Resolvable) odi;
  -            String[] ids = res.getIDs();
  +            String[] ids = res.getIDRefs();
               for (int count = 0; count < ids.length; count++) {
                   if (idLocations.containsKey(ids[count])) {
                       res.resolveIDRef(ids[count], (List) 
idLocations.get(ids[count]));
  
  
  
  1.7       +30 -46    xml-fop/src/java/org/apache/fop/area/BookmarkData.java
  
  Index: BookmarkData.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/BookmarkData.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BookmarkData.java 14 Dec 2004 23:16:44 -0000      1.6
  +++ BookmarkData.java 16 Dec 2004 23:59:13 -0000      1.7
  @@ -23,8 +23,9 @@
   import java.util.HashMap;
   
   /**
  - * An instance of this class is either a PDF bookmark OffDocumentItem and
  - * its child bookmarks.
  + * An instance of this class is either a PDF bookmark-tree and
  + * its child bookmark-items, or a bookmark-item and the child
  + * child bookmark-items under it.
    */
   public class BookmarkData extends OffDocumentItem implements Resolvable {
       private ArrayList subData = new ArrayList();
  @@ -43,9 +44,8 @@
   
       /**
        * Create a new bookmark data object.
  -     * This should only be call by the top level element as its
  -     * idref will be null.
  -     *
  +     * This should only be called by the bookmark-tree item because
  +     * it has no idref item that needs to be resolved.
        */
       public BookmarkData() {
           idRef = null;
  @@ -54,22 +54,23 @@
   
       /**
        * 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.
  +     * This is used by the bookmark-items to create a data object
  +     * with a idref.  During processing, this idref will be
  +     * subsequently resolved to a particular PageViewport.
        *
  -     * @param id the id reference
  +     * @param idref the id reference
        */
  -    public BookmarkData(String id) {
  -        idRef = id;
  +    public BookmarkData(String idref) {
  +        this.idRef = idref;
           unresolvedIDRefs.put(idRef, this);
       }
   
       /**
  -     * Get the id reference for this data.
  +     * Get the idref for this bookmark-item
        *
  -     * @return the id reference
  +     * @return the idref for the bookmark-item
        */
  -    public String getID() {
  +    public String getIDRef() {
           return idRef;
       }
   
  @@ -81,8 +82,8 @@
        */
       public void addSubData(BookmarkData sub) {
           subData.add(sub);
  -        unresolvedIDRefs.put(sub.getID(), sub);
  -        String[] ids = sub.getIDs();
  +        unresolvedIDRefs.put(sub.getIDRef(), sub);
  +        String[] ids = sub.getIDRefs();
           for (int count = 0; count < ids.length; count++) {
               unresolvedIDRefs.put(ids[count], sub);
           }
  @@ -136,63 +137,46 @@
   
       /**
        * Check if this resolvable object has been resolved.
  -     * Once the id reference is null then it has been resolved.
  +     * A BookmarkData object is considered resolved once the idrefs for it
  +     * and for all of its child bookmark-items have been resolved.
        *
  -     * @return true if this has been resolved
  +     * @return true if this object has been resolved
        */
       public boolean isResolved() {
  -        return unresolvedIDRefs == null;
  +        return unresolvedIDRefs == null || (unresolvedIDRefs.size() == 0);
       }
   
       /**
  -     * Get the id references held by this object.
  -     * Also includes all id references of all children.
  -     *
  -     * @return the array of id references
  +     * @see org.apache.fop.area.Resolvable#getIDRefs()
        */
  -    public String[] getIDs() {
  +    public String[] getIDRefs() {
           return (String[])unresolvedIDRefs.keySet().toArray(new String[] {});
       }
   
       /**
        * Resolve this resolvable object.
  -     * This resolves the id reference and if possible also
  +     * This resolves the idref of this object and if possible also
        * resolves id references of child elements that have the same
        * id reference.
        *
  -     * @param id the ID which has already been resolved to one or more
  -     *      PageViewport objects
  -     * @param pages the list of PageViewport objects the ID resolves to
  +     * @see org.apache.fop.area.Resolvable#resolveIDRef(String, List)
  +     * @todo check to make sure works when multiple bookmark-items
  +     * have the same idref
        */
       public void resolveIDRef(String id, List pages) {
  -        // this method is buggy
           if (!id.equals(idRef)) {
  -            BookmarkData bd = (BookmarkData)unresolvedIDRefs.get(id);
  -            unresolvedIDRefs.remove(id);
  +            BookmarkData bd = (BookmarkData) unresolvedIDRefs.get(id);
               if (bd != null) {
                   bd.resolveIDRef(id, pages);
  -                if (bd.isResolved()) {
  -                    checkFinish();
  -                }
  -            } else if (idRef == null) {
  -                checkFinish();
  +                unresolvedIDRefs.remove(id);
               }
           } else {
  -            if (pages != null) {
  -                pageRef = (PageViewport)pages.get(0);
  -            }
  +            pageRef = (PageViewport) pages.get(0);
               // TODO get rect area of id on page
               unresolvedIDRefs.remove(idRef);
  -            checkFinish();
           }
       }
   
  -    private void checkFinish() {
  -        if (unresolvedIDRefs.size() == 0) {
  -            unresolvedIDRefs = null;
  -        }
  -    }
  -    
       /**
        * @see org.apache.fop.area.OffDocumentItem#getName()
        */
  
  
  
  1.7       +1 -1      
xml-fop/src/java/org/apache/fop/area/CachedRenderPagesModel.java
  
  Index: CachedRenderPagesModel.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/area/CachedRenderPagesModel.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CachedRenderPagesModel.java       6 Dec 2004 05:37:17 -0000       1.6
  +++ CachedRenderPagesModel.java       16 Dec 2004 23:59:13 -0000      1.7
  @@ -81,7 +81,7 @@
                   try {
                       renderer.renderPage(p);
                       if (!p.isResolved()) {
  -                        String[] idrefs = p.getIDs();
  +                        String[] idrefs = p.getIDRefs();
                           for (int count = 0; count < idrefs.length; count++) {
                               log.warn("Page " + p.getPageNumber() + 
                                   ": Unresolved id reference \"" + 
idrefs[count] 
  
  
  
  1.7       +2 -2      xml-fop/src/java/org/apache/fop/area/LinkResolver.java
  
  Index: LinkResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/LinkResolver.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LinkResolver.java 4 Dec 2004 06:51:13 -0000       1.6
  +++ LinkResolver.java 16 Dec 2004 23:59:13 -0000      1.7
  @@ -54,7 +54,7 @@
           return resolved;
       }
   
  -    public String[] getIDs() {
  +    public String[] getIDRefs() {
           return new String[] {idRef};
       }
   
  
  
  
  1.10      +1 -1      xml-fop/src/java/org/apache/fop/area/PageViewport.java
  
  Index: PageViewport.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/PageViewport.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PageViewport.java 6 Dec 2004 05:37:17 -0000       1.9
  +++ PageViewport.java 16 Dec 2004 23:59:13 -0000      1.10
  @@ -157,7 +157,7 @@
        * Get the unresolved idrefs for this page.
        * @return String array of idref's that still have not been resolved
        */
  -    public String[] getIDs() {
  +    public String[] getIDRefs() {
           return (unresolvedIDRefs == null) ? null :
               (String[]) unresolvedIDRefs.keySet().toArray(new String[] {});
       }
  
  
  
  1.11      +1 -1      
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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- RenderPagesModel.java     6 Dec 2004 05:37:17 -0000       1.10
  +++ RenderPagesModel.java     16 Dec 2004 23:59:13 -0000      1.11
  @@ -149,7 +149,7 @@
                   try {
                       renderer.renderPage(p);
                       if (!p.isResolved()) {
  -                        String[] idrefs = p.getIDs();
  +                        String[] idrefs = p.getIDRefs();
                           for (int count = 0; count < idrefs.length; count++) {
                               log.warn("Page " + p.getPageNumber() + 
                                   ": Unresolved id reference \"" + 
idrefs[count] 
  
  
  
  1.6       +2 -2      xml-fop/src/java/org/apache/fop/area/Resolvable.java
  
  Index: Resolvable.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/Resolvable.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Resolvable.java   4 Dec 2004 06:51:13 -0000       1.5
  +++ Resolvable.java   16 Dec 2004 23:59:13 -0000      1.6
  @@ -42,7 +42,7 @@
        *
        * @return the id references for resolving this object
        */
  -    String[] getIDs();
  +    String[] getIDRefs();
   
       /**
        * This method allows the Resolvable object to resolve one of
  
  
  
  1.8       +1 -1      
xml-fop/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
  
  Index: UnresolvedPageNumber.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- UnresolvedPageNumber.java 4 Dec 2004 06:51:13 -0000       1.7
  +++ UnresolvedPageNumber.java 16 Dec 2004 23:59:13 -0000      1.8
  @@ -47,7 +47,7 @@
        *
        * @return the id reference for this unresolved page number
        */
  -    public String[] getIDs() {
  +    public String[] getIDRefs() {
           return new String[] {pageIDRef};
       }
   
  
  
  
  1.18      +2 -1      
xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
  
  Index: PageSequenceLayoutManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- PageSequenceLayoutManager.java    16 Dec 2004 01:03:04 -0000      1.17
  +++ PageSequenceLayoutManager.java    16 Dec 2004 23:59:13 -0000      1.18
  @@ -226,6 +226,7 @@
           pageCount--;
           log.debug("Ending layout");
           flush();
  +        fobj.setCurrentPageNumber(getPageCount());
       }
   
       /**
  
  
  

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

Reply via email to