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 je...@apache.org on 2003/03/27 11:39:31 UTC

cvs commit: xml-fop/src/java/org/apache/fop/pdf PDFGoTo.java PDFFunction.java PDFGoToRemote.java

jeremias    2003/03/27 02:39:31

  Modified:    src/java/org/apache/fop/pdf PDFGoTo.java PDFFunction.java
                        PDFGoToRemote.java
  Log:
  The PDF object number doesn't get passed to the constructor anymore. Adjust for that.
  Use the toPDFString() (returns String) method instead of toPDF() (returns byte[]) where appropriate. String to byte[] conversion is done in PDFObject in a well-defined location instead of scattered around the codebase.
  
  Revision  Changes    Path
  1.2       +7 -11     xml-fop/src/java/org/apache/fop/pdf/PDFGoTo.java
  
  Index: PDFGoTo.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFGoTo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFGoTo.java	11 Mar 2003 13:05:09 -0000	1.1
  +++ PDFGoTo.java	27 Mar 2003 10:39:31 -0000	1.2
  @@ -68,12 +68,11 @@
       /**
        * create a /GoTo object.
        *
  -     * @param number the object's number
        * @param pageReference the pageReference represented by this object
        */
  -    public PDFGoTo(int number, String pageReference) {
  +    public PDFGoTo(String pageReference) {
           /* generic creation of object */
  -        super(number);
  +        super();
   
           this.pageReference = pageReference;
       }
  @@ -124,11 +123,9 @@
       }
   
       /**
  -     * represent the object in PDF
  -     *
  -     * @return the PDF string
  +     * @see org.apache.fop.pdf.PDFObject#toPDFString()
        */
  -    public byte[] toPDF() {
  +    public String toPDFString() {
           String dest;
           if (destination == null) {
               dest = "/D [" + this.pageReference + " /XYZ " + xPosition
  @@ -136,10 +133,9 @@
           } else {
               dest = "/D [" + this.pageReference + " " + destination + "]\n";
           }
  -        String p = new String(this.number + " " + this.generation
  -                              + " obj\n<<\n/S /GoTo\n" + dest
  -                              + ">>\nendobj\n");
  -        return p.getBytes();
  +        return getObjectID() 
  +                    + "<< /Type /Action\n/S /GoTo\n" + dest
  +                    + ">>\nendobj\n";
       }
   
       /*
  
  
  
  1.2       +12 -16    xml-fop/src/java/org/apache/fop/pdf/PDFFunction.java
  
  Index: PDFFunction.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFunction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFunction.java	11 Mar 2003 13:05:09 -0000	1.1
  +++ PDFFunction.java	27 Mar 2003 10:39:31 -0000	1.2
  @@ -239,15 +239,14 @@
        * This is not documented in the Function section of the PDF 1.3 spec,
        * it was deduced from samples that this is sometimes used, even if we may never
        * use it in FOP. It is added for completeness sake.
  -     * @param theNumber The object number of this PDF object.
        * @param theFunctionType This is the type of function (0,2,3, or 4).
        * It should be 0 as this is the constructor for sampled functions.
        */
  -    public PDFFunction(int theNumber, int theFunctionType, List theDomain,
  +    public PDFFunction(int theFunctionType, List theDomain,
                          List theRange, List theSize, int theBitsPerSample,
                          int theOrder, List theEncode, List theDecode,
                          StringBuffer theFunctionDataStream, List theFilter) {
  -        super(theNumber);
  +        super();
   
           this.functionType = 0;      // dang well better be 0;
           this.size = theSize;
  @@ -271,7 +270,6 @@
        * Use null for an optional object parameter if you choose not to use it.
        * For optional int parameters, pass the default.
        *
  -     * @param theNumber the object's number
        * @param theDomain List objects of Double objects.
        * This is the domain of the function.
        * See page 264 of the PDF 1.3 Spec.
  @@ -293,10 +291,10 @@
        * PDF Spec page 268
        * @param theFunctionType The type of the function, which should be 2.
        */
  -    public PDFFunction(int theNumber, int theFunctionType, List theDomain,
  +    public PDFFunction(int theFunctionType, List theDomain,
                          List theRange, List theCZero, List theCOne,
                          double theInterpolationExponentN) {
  -        super(theNumber);
  +        super();
   
           this.functionType = 2;    // dang well better be 2;
   
  @@ -316,7 +314,6 @@
        * Use null for an optional object parameter if you choose not to use it.
        * For optional int parameters, pass the default.
        *
  -     * @param theNumber the object's number
        * @param theDomain List objects of Double objects.
        * This is the domain of the function.
        * See page 264 of the PDF 1.3 Spec.
  @@ -346,10 +343,10 @@
        * @param theFunctionType This is the function type. It should be 3,
        * for a stitching function.
        */
  -    public PDFFunction(int theNumber, int theFunctionType, List theDomain,
  +    public PDFFunction(int theFunctionType, List theDomain,
                          List theRange, List theFunctions,
                          List theBounds, List theEncode) {
  -        super(theNumber);
  +        super();
   
           this.functionType = 3;    // dang well better be 3;
   
  @@ -380,13 +377,12 @@
        *
        * This attribute is required.
        * It's described on page 269 of the PDF 1.3 spec.
  -     * @param theNumber The object number of this PDF object.
        * @param theFunctionType The type of function which should be 4, as this is
        * a Postscript calculator function
        */
  -    public PDFFunction(int theNumber, int theFunctionType, List theDomain,
  +    public PDFFunction(int theFunctionType, List theDomain,
                          List theRange, StringBuffer theFunctionDataStream) {
  -        super(theNumber);
  +        super();
   
           this.functionType = 4;    // dang well better be 4;
           this.functionDataStream = theFunctionDataStream;
  @@ -413,9 +409,9 @@
           int vectorSize = 0;
           int numberOfFunctions = 0;
           int tempInt = 0;
  -        StringBuffer p = new StringBuffer();
  -        p.append(this.number + " " + this.generation
  -                 + " obj\n<< \n/FunctionType " + this.functionType + " \n");
  +        StringBuffer p = new StringBuffer(256);
  +        p.append(getObjectID() 
  +                + "<< \n/FunctionType " + this.functionType + " \n");
   
           // FunctionType 0
           if (this.functionType == 0) {
  @@ -727,7 +723,7 @@
   
           }
   
  -        return (p.toString().getBytes());
  +        return encode(p.toString());
   
       }
   
  
  
  
  1.2       +15 -20    xml-fop/src/java/org/apache/fop/pdf/PDFGoToRemote.java
  
  Index: PDFGoToRemote.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFGoToRemote.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFGoToRemote.java	11 Mar 2003 13:05:09 -0000	1.1
  +++ PDFGoToRemote.java	27 Mar 2003 10:39:31 -0000	1.2
  @@ -65,12 +65,11 @@
       /**
        * create an GoToR object.
        *
  -     * @param number the object's number
        * @param pdfFileSpec the fileSpec associated with the action
        */
  -    public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec) {
  +    public PDFGoToRemote(PDFFileSpec pdfFileSpec) {
           /* generic creation of object */
  -        super(number);
  +        super();
   
           this.pdfFileSpec = pdfFileSpec;
       }
  @@ -78,13 +77,12 @@
       /**
        * create an GoToR object.
        *
  -     * @param number the object's number
        * @param pdfFileSpec the fileSpec associated with the action
        * @param page a page reference within the remote document
        */
  -    public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec, int page) {
  +    public PDFGoToRemote(PDFFileSpec pdfFileSpec, int page) {
           /* generic creation of object */
  -        super(number);
  +        super();
   
           this.pdfFileSpec = pdfFileSpec;
           this.pageReference = page;
  @@ -93,13 +91,12 @@
       /**
        * create an GoToR object.
        *
  -     * @param number the object's number
        * @param pdfFileSpec the fileSpec associated with the action
        * @param dest a named destination within the remote document
        */
  -    public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec, String dest) {
  +    public PDFGoToRemote(PDFFileSpec pdfFileSpec, String dest) {
           /* generic creation of object */
  -        super(number);
  +        super();
   
           this.pdfFileSpec = pdfFileSpec;
           this.destination = dest;
  @@ -115,24 +112,22 @@
       }
   
       /**
  -     * represent the object in PDF
  -     *
  -     * @return the PDF string
  +     * @see org.apache.fop.pdf.PDFObject#toPDFString()
        */
  -    public byte[] toPDF() {
  -        String p = new String(this.number + " " + this.generation + " obj\n"
  -                              + "<<\n/S /GoToR\n" + "/F "
  -                              + pdfFileSpec.referencePDF() + "\n");
  +    public String toPDFString() {
  +        StringBuffer sb = new StringBuffer(64);
  +        sb.append(getObjectID());
  +        sb.append("<<\n/S /GoToR\n/F " + pdfFileSpec.referencePDF() + "\n");
   
           if (destination != null) {
  -            p += "/D (" + this.destination + ")";
  +            sb.append("/D (" + this.destination + ")");
           } else {
  -            p += "/D [ " + this.pageReference + " /XYZ null null null ]";
  +            sb.append("/D [ " + this.pageReference + " /XYZ null null null ]");
           }
   
  -        p += " \n>>\nendobj\n";
  +        sb.append(" \n>>\nendobj\n");
   
  -        return p.getBytes();
  +        return sb.toString();
       }
   
   
  
  
  

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