pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1752011 - in /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox: cos/COSName.java pdmodel/interactive/action/PDActionSound.java
Date Sat, 09 Jul 2016 15:02:15 GMT
Author: tilman
Date: Sat Jul  9 15:02:15 2016
New Revision: 1752011

URL: http://svn.apache.org/viewvc?rev=1752011&view=rev
Log:
PDFBOX-3324: add entries specific to a sound action; deprecate or delete /S

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionSound.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=1752011&r1=1752010&r2=1752011&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java Sat Jul  9
15:02:15 2016
@@ -340,6 +340,7 @@ public final class COSName extends COSBa
     public static final COSName MEDIA_BOX = new COSName("MediaBox");
     public static final COSName METADATA = new COSName("Metadata");
     public static final COSName MISSING_WIDTH = new COSName("MissingWidth");
+    public static final COSName MIX = new COSName("Mix");
     public static final COSName MK = new COSName("MK");
     public static final COSName ML = new COSName("ML");
     public static final COSName MM_TYPE1 = new COSName("MMType1");
@@ -435,6 +436,7 @@ public final class COSName extends COSBa
     public static final COSName RD = new COSName("RD");
     public static final COSName REASON = new COSName("Reason");
     public static final COSName REASONS = new COSName("Reasons");
+    public static final COSName REPEAT = new COSName("Repeat");
     public static final COSName RECIPIENTS = new COSName("Recipients");
     public static final COSName RECT = new COSName("Rect");
     public static final COSName REGISTRY = new COSName("Registry");
@@ -490,6 +492,7 @@ public final class COSName extends COSBa
     public static final COSName SV = new COSName("SV");
     public static final COSName SW = new COSName("SW");
     public static final COSName SY = new COSName("Sy");
+    public static final COSName SYNCHRONOUS = new COSName("Synchronous");
     // T
     public static final COSName T = new COSName("T");
     public static final COSName TARGET = new COSName("Target");
@@ -536,6 +539,7 @@ public final class COSName extends COSBa
     public static final COSName VIEW_AREA = new COSName("ViewArea");
     public static final COSName VIEW_CLIP = new COSName("ViewClip");
     public static final COSName VIEWER_PREFERENCES = new COSName("ViewerPreferences");
+    public static final COSName VOLUME = new COSName("Volume");
     // W
     public static final COSName W = new COSName("W");
     public static final COSName W2 = new COSName("W2");

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionSound.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionSound.java?rev=1752011&r1=1752010&r2=1752011&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionSound.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionSound.java
Sat Jul  9 15:02:15 2016
@@ -17,8 +17,12 @@
 
 package org.apache.pdfbox.pdmodel.interactive.action;
 
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSBoolean;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.cos.COSStream;
 
 /**
  * This represents a Sound action that can be executed in a PDF document
@@ -57,7 +61,9 @@ public class PDActionSound extends PDAct
      * a Sound action.
      *
      * @return The S entry of the specific Sound action dictionary.
+     * @deprecated use {@link #getSubType() }.
      */
+    @Deprecated
     public String getS()
     {
         return action.getNameAsString(COSName.S);
@@ -68,10 +74,157 @@ public class PDActionSound extends PDAct
      * a Sound action.
      *
      * @param s The Sound action.
+     * @deprecated use {@link #setSubType(java.lang.String) }.
      */
+    @Deprecated
     public void setS(String s)
     {
         action.setName(COSName.S, s);
     }
 
+    /**
+     * Sets the sound object.
+     *
+     * @param sound the sound object defining the sound that shall be played.
+     */
+    public void setSound(COSStream sound)
+    {
+        action.setItem(COSName.SOUND, sound);
+    }
+
+    /**
+     * Gets the sound object.
+     *
+     * @return The sound object defining the sound that shall be played.
+     */
+    public COSStream getSound()
+    {
+        COSBase base = action.getDictionaryObject(COSName.SOUND);
+        if (base instanceof COSStream)
+        {
+            return (COSStream) base;
+        }
+        return null;
+    }
+
+    /**
+     * Gets the volume at which to play the sound, in the range −1.0 to 1.0.
+     *
+     * @param volume The volume at which to play the sound, in the range −1.0 to 1.0.
+     *
+     * @throws IllegalArgumentException if the volume parameter is outside of the range −1.0
to 1.0.
+     */
+    public void setVolume(float volume)
+    {
+        if (volume < -1 || volume > 1)
+        {
+            throw new IllegalArgumentException("volume outside of the range −1.0 to
1.0");
+        }
+        action.setFloat(COSName.VOLUME, volume);
+    }
+
+    /**
+     * Sets the volume.
+     *
+     * @return The volume at which to play the sound, in the range −1.0 to 1.0. Default
value: 1.0.
+     */
+    public float getVolume()
+    {
+        COSBase base = action.getDictionaryObject(COSName.VOLUME);
+        if (base instanceof COSNumber)
+        {
+            float volume = ((COSNumber) base).floatValue();
+            if (volume < -1 || volume > 1)
+            {
+                volume = 1;
+            }
+            return volume;
+        }
+        return 1;
+    }
+
+    /**
+     * A flag specifying whether to play the sound synchronously or asynchronously. When
true, the
+     * reader allows no further user interaction other than canceling the sound until the
sound has
+     * been completely played.
+     *
+     * @param synchronous Whether to play the sound synchronously (true) or asynchronously
(false).
+     */
+    public void setSynchronous(boolean synchronous)
+    {
+        action.setBoolean(COSName.SYNCHRONOUS, synchronous);
+    }
+
+    /**
+     * Gets the synchronous flag. It specifyes whether to play the sound synchronously or
+     * asynchronously. When true, the reader allows no further user interaction other than
canceling
+     * the sound until the sound has been completely played.
+     *
+     * @return Whether to play the sound synchronously (true) or asynchronously (false, also
the
+     * default).
+     */
+    public boolean getSynchronous()
+    {
+        COSBase base = action.getDictionaryObject(COSName.SYNCHRONOUS);
+        if (base instanceof COSBoolean)
+        {
+            return ((COSBoolean) base).getValue();
+        }
+        return false;
+    }
+
+    /**
+     * A flag specifying whether to repeat the sound indefinitely.
+     *
+     * @param repeat Whether to repeat the sound indefinitely.
+     */
+    public void setRepeat(boolean repeat)
+    {
+        action.setBoolean(COSName.REPEAT, repeat);
+    }
+
+    /**
+     * Gets whether to repeat the sound indefinitely.
+     *
+     * @return Whether to repeat the sound indefinitely (default: false).
+     */
+    public boolean getRepeat()
+    {
+        COSBase base = action.getDictionaryObject(COSName.REPEAT);
+        if (base instanceof COSBoolean)
+        {
+            return ((COSBoolean) base).getValue();
+        }
+        return false;
+    }
+
+    /**
+     * The flag specifying whether to mix this sound with any other sound already playing.
If this
+     * flag is false, any previously playing sound shall be stopped before starting this
sound; this
+     * can be used to stop a repeating sound (see Repeat). Default value: false.
+     *
+     * @param mix whether to mix this sound with any other sound already playing. (false).
+     */
+    public void setMix(boolean mix)
+    {
+        action.setBoolean(COSName.MIX, mix);
+    }
+
+    /**
+     * Gets the flag specifying whether to mix this sound with any other sound already playing.
If
+     * this flag is false, any previously playing sound shall be stopped before starting
this sound;
+     * this can be used to stop a repeating sound (see Repeat).
+     *
+     * @return whether to mix this sound with any other sound already playing (default: false).
+     */
+    public boolean getMix()
+    {
+        COSBase base = action.getDictionaryObject(COSName.MIX);
+        if (base instanceof COSBoolean)
+        {
+            return ((COSBoolean) base).getValue();
+        }
+        return false;
+    }
+
 }



Mime
View raw message