pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1620397 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form: PDTextField.java PDVariableText.java
Date Mon, 25 Aug 2014 18:09:51 GMT
Author: lehmi
Date: Mon Aug 25 18:09:50 2014
New Revision: 1620397

URL: http://svn.apache.org/r1620397
Log:
PDFBOX-2261: added getter/setter for default appearance

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDTextField.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java

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=1620397&r1=1620396&r2=1620397&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
Mon Aug 25 18:09:50 2014
@@ -88,12 +88,12 @@ public final class PDTextField extends P
                 getDictionary().setItem( COSName.V, fieldValue );
             }
             // TODO stream instead of string
-            // TODO creation of appearance stream
         }  
         else
         {
             getDictionary().removeItem(COSName.V);
         }
+        // TODO create/update appearance
     }
 
     /**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java?rev=1620397&r1=1620396&r2=1620397&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
Mon Aug 25 18:09:50 2014
@@ -16,6 +16,7 @@
  */
 package org.apache.pdfbox.pdmodel.interactive.form;
 
+import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSNumber;
@@ -62,7 +63,7 @@ public abstract class PDVariableText ext
     /**
      * DA    Default appearance.
      */
-    private COSString da;
+    private COSString defaultAppearance;
 
     /**
      * A Q value.
@@ -99,7 +100,6 @@ public abstract class PDVariableText ext
     protected PDVariableText(PDAcroForm theAcroForm, COSDictionary field, PDFieldTreeNode
parentNode)
     {
         super( theAcroForm, field, parentNode);
-        da = (COSString) field.getDictionaryObject(COSName.DA);
     }
 
     /**
@@ -229,11 +229,50 @@ public abstract class PDVariableText ext
     }
 
     /**
+     * Get the default appearance.
+     * 
      * @return the DA element of the dictionary object
      */
-    protected COSString getDefaultAppearance()
+    public COSString getDefaultAppearance()
     {
-        return da;
+        if (defaultAppearance == null)
+        {
+            COSBase daValue =  getDictionary().getItem(COSName.DA);
+            if (daValue != null)
+            {
+                defaultAppearance = (COSString)daValue;
+            }
+        }
+        // the default appearance is inheritable
+        // maybe the parent provides a default appearance
+        if (defaultAppearance == null)
+        {
+            PDFieldTreeNode parent = getParent();
+            if (parent instanceof PDVariableText)
+            {
+                defaultAppearance = ((PDVariableText)parent).getDefaultAppearance();
+            }
+        }
+        return defaultAppearance;
+    }
+
+    /**
+     * Set the default appearance.
+     * 
+     * @param daValue a string describing the default appearance
+     */
+    public void setDefaultAppearance(String daValue)
+    {
+        if (daValue != null)
+        {
+            defaultAppearance = new COSString(daValue);
+            getDictionary().setItem(COSName.DA, defaultAppearance);
+        }
+        else
+        {
+            defaultAppearance = null;
+            getDictionary().removeItem(COSName.DA);
+        }
     }
 
     /**



Mime
View raw message