pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1679468 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form: AppearanceGeneratorHelper.java PDAcroForm.java PDButton.java PDChoice.java PDSignatureField.java PDTerminalField.java PDTextField.java
Date Thu, 14 May 2015 22:19:31 GMT
Author: jahewson
Date: Thu May 14 22:19:31 2015
New Revision: 1679468

URL: http://svn.apache.org/r1679468
Log:
PDFBOX-2333: Moved AppearanceGenerator functionality in PDField classes

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTerminalField.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTextField.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java?rev=1679468&r1=1679467&r2=1679468&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Thu May 14 22:19:31 2015
@@ -45,9 +45,7 @@ import org.apache.pdfbox.contentstream.o
 
 /**
  * Create the AcroForms field appearance helper.
- * <p>
- * A helper class to the {@link AppearanceGenerator} to generate update an AcroForm field
appearance.
- * </p>
+ * 
  * @author Stephan Gerhard
  * @author Ben Litchfield
  */

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java?rev=1679468&r1=1679467&r2=1679468&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
Thu May 14 22:19:31 2015
@@ -325,7 +325,8 @@ public final class PDAcroForm implements
     }
 
     /**
-     * Get the value of NeedAppearances.
+     * True if the viewing application should construct the appearances of all field widgets.
+     * The default value is false.
      * 
      * @return the value of NeedAppearances, false if the value isn't set
      */
@@ -335,7 +336,8 @@ public final class PDAcroForm implements
     }
 
     /**
-     * Set the NeedAppearances value.
+     * Set the NeedAppearances value. If this is false, PDFBox will create appearances for
all field
+     * widget.
      * 
      * @param value the value for NeedAppearances
      */

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java?rev=1679468&r1=1679467&r2=1679468&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
Thu May 14 22:19:31 2015
@@ -197,4 +197,11 @@ public abstract class PDButton extends P
             setInheritableAttribute(COSName.OPT, COSArrayList.convertStringListToCOSStringCOSArray(values));
         }
     }
+
+    @Override
+    void constructAppearances() throws IOException
+    {
+        // TODO: implement appearance generation for buttons
+        throw new UnsupportedOperationException("not implemented");
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java?rev=1679468&r1=1679467&r2=1679468&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
Thu May 14 22:19:31 2015
@@ -16,10 +16,10 @@
  */
 package org.apache.pdfbox.pdmodel.interactive.form;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
@@ -493,4 +493,11 @@ public abstract class PDChoice extends P
         Collections.sort(indices);
         setSelectedOptionsIndex(indices);
     }
+
+    @Override
+    void constructAppearances() throws IOException
+    {
+        // TODO: implement appearance generation for choices
+        throw new UnsupportedOperationException("not implemented");
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java?rev=1679468&r1=1679467&r2=1679468&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
Thu May 14 22:19:31 2015
@@ -194,4 +194,11 @@ public class PDSignatureField extends PD
     {
         return "PDSignatureField";
     }
+
+    @Override
+    void constructAppearances() throws IOException
+    {
+        // TODO: implement appearance generation for signatures
+        throw new UnsupportedOperationException("not implemented");
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTerminalField.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTerminalField.java?rev=1679468&r1=1679467&r2=1679468&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTerminalField.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTerminalField.java
Thu May 14 22:19:31 2015
@@ -89,20 +89,26 @@ public abstract class PDTerminalField ex
         }
         return fieldType;
     }
-    
+
     /**
-     * Update the fields appearance stream.
-     * 
-     * The fields appearance stream needs to be updated to reflect the new field
-     * value. This will be done only if the NeedAppearances flag has not been set.
+     * Applies a value change to the field. Generates appearances if required and raises
events.
      * 
      * @throws IOException if the appearance couldn't be generated
      */
-    protected void updateFieldAppearances() throws IOException
+    protected final void applyChange() throws IOException
     {
         if (!acroForm.getNeedAppearances())
         {
-            AppearanceGenerator.generateFieldAppearances(this);
+            constructAppearances();
         }
+        // if we supported JavaScript we would raise a field changed event here
     }
+    
+    /**
+     * Constructs appearance streams and appearance dictionaries for all widget annotations.
+     * Subclasses should not call this method directly but via {@link #applyChange()}.
+     * 
+     * @throws IOException if the appearance couldn't be generated
+     */
+    abstract void constructAppearances() throws IOException;
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTextField.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTextField.java?rev=1679468&r1=1679467&r2=1679468&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTextField.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTextField.java
Thu May 14 22:19:31 2015
@@ -244,9 +244,7 @@ public final class PDTextField extends P
         {
             removeInheritableAttribute(COSName.V);
         }
-        
-        // TODO move appearance generation out of fields PD model
-        updateFieldAppearances();
+        applyChange();
     }
     
     @Override
@@ -259,4 +257,12 @@ public final class PDTextField extends P
         }
         return "";
     }
+
+    @Override
+    void constructAppearances() throws IOException
+    {
+        AppearanceGeneratorHelper apHelper;
+        apHelper = new AppearanceGeneratorHelper(this.getAcroForm(), this);
+        apHelper.setAppearanceValue(getValue());
+    }
 }



Mime
View raw message