You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ge...@apache.org on 2001/08/31 01:21:40 UTC

cvs commit: xml-fop/src/org/apache/fop/pdf PDFDocument.java

gears       01/08/30 16:21:40

  Modified:    src/org/apache/fop/datatypes IDReferences.java
               src/org/apache/fop/pdf PDFDocument.java
  Log:
  Applies lmckenzi@ca.ibm.com's patch, which would have been very hard
  to characterize had he not already done so. That he fixed it is just gravy.
  There is one line I'm not sure about, but it passed my tests, so I'll
  leave it in and just comment it.
  
  Revision  Changes    Path
  1.14      +62 -3     xml-fop/src/org/apache/fop/datatypes/IDReferences.java
  
  Index: IDReferences.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/IDReferences.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- IDReferences.java	2001/08/01 23:08:54	1.13
  +++ IDReferences.java	2001/08/30 23:21:40	1.14
  @@ -1,5 +1,5 @@
   /*
  - * $Id: IDReferences.java,v 1.13 2001/08/01 23:08:54 gears Exp $
  + * $Id: IDReferences.java,v 1.14 2001/08/30 23:21:40 gears Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -27,9 +27,15 @@
     Modified by Mark Lillywhite mark-fop@inomial.com. Added
     getInvalidElements() so that StreamRenderer cna tell what
     hasn't been determined yet.
  +
  +  Modified by lmckenzi@ca.ibm.com
  +  Sometimes IDs are created, but not validated. This code fixes
  +  the incorrect complaint that the ID already exists which prevents
  +  basic-links from working (sometimes).
  +   
     */
   public class IDReferences {
  -    private Hashtable idReferences, idValidation;
  +    private Hashtable idReferences, idValidation, idUnvalidated;
   
       final static int ID_PADDING = 5000;    // space to add before id y position
   
  @@ -39,6 +45,7 @@
       public IDReferences() {
           idReferences = new Hashtable();
           idValidation = new Hashtable();
  +        idUnvalidated = new Hashtable();
       }
   
   
  @@ -64,7 +71,12 @@
        */
       public void createID(String id) throws FOPException {
           if (id != null &&!id.equals("")) {
  -            if (doesIDExist(id)) {
  +            if (doesUnvalidatedIDExist(id)) {
  +                removeFromUnvalidatedIDList(id);
  +                //Steve's (gears@apache.org) comment: Is this right? 
  +                removeFromIdValidationList(id);
  +            }
  +            else if (doesIDExist(id)) {
                   throw new FOPException("The id \"" + id
                                          + "\" already exists in this document");
               } else {
  @@ -75,6 +87,53 @@
           }
       }
   
  +    /**
  +     * Creates id entry that hasn't been validated
  +     *
  +     * @param id     The id to create
  +     * @exception FOPException
  +     */
  +    public void createUnvalidatedID(String id) {
  +        if (id != null &&!id.equals("")) {
  +            if (!doesIDExist(id)) {
  +                createNewId(id);
  +                addToUnvalidatedIdList(id);
  +            } 
  +        }
  +    }
  +
  +    /**
  +     * Adds created id list of unvalidated ids that have already 
  +     * been created. This should be used if it is unsure whether
  +     * the id is valid but it must be anyhow.
  +     *
  +     * @param id     The id to create
  +     */
  +    public void addToUnvalidatedIdList(String id) {
  +        idUnvalidated.put(id,"");
  +    }
  +
  +    /**
  +     * Removes id from list of unvalidated ids.
  +     * This should be used if the id has been determined 
  +     * to be valid. 
  +     *
  +     * @param id     The id to remove
  +     */
  +    public void removeFromUnvalidatedIDList(String id) {
  +        idUnvalidated.remove(id);
  +    }
  +
  +    /**
  +     * Determines whether specified id already exists in
  +     * idUnvalidated
  +     *
  +     * @param id     The id to search for
  +     * @return true if ID was found, false otherwise
  +     */
  +    public boolean doesUnvalidatedIDExist(String id) {
  +        return idUnvalidated.containsKey(id);
  +    }
   
       /**
        * Configures this id
  
  
  
  1.28      +11 -2     xml-fop/src/org/apache/fop/pdf/PDFDocument.java
  
  Index: PDFDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFDocument.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- PDFDocument.java	2001/08/06 09:43:07	1.27
  +++ PDFDocument.java	2001/08/30 23:21:40	1.28
  @@ -1,5 +1,5 @@
   /*
  - * $Id: PDFDocument.java,v 1.27 2001/08/06 09:43:07 keiron Exp $
  + * $Id: PDFDocument.java,v 1.28 2001/08/30 23:21:40 gears Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -51,6 +51,10 @@
    * ability to write the /Pages object after writing the rest
    * of the document; ability to write to a stream and flush
    * the object list; enhanced trailer output; cleanups.
  + *
  + * Modified by lmckenzi@ca.ibm.com
  + * Sometimes IDs are created, but not validated. This tracks
  + * the difference.
    */
   public class PDFDocument {
       private static final Integer locationPlaceholder = new Integer(0);
  @@ -1006,7 +1010,12 @@
                   addTrailerObject(idReferences.getPDFGoTo(destination));
               }
           } else {        // id was not found, so create it
  -            idReferences.createNewId(destination);
  +
  +            //next line by lmckenzi@ca.ibm.com
  +            //solves when IDNode made before IDReferences.createID called
  +            //idReferences.createNewId(destination);
  + 
  +            idReferences.createUnvalidatedID(destination); 
               idReferences.addToIdValidationList(destination);
               goToReference = idReferences.createInternalLinkGoTo(destination,
                               ++this.objectcount);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org