pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1825241 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action: PDActionLaunch.java PDActionRemoteGoTo.java
Date Sat, 24 Feb 2018 14:05:48 GMT
Author: tilman
Date: Sat Feb 24 14:05:47 2018
New Revision: 1825241

URL: http://svn.apache.org/viewvc?rev=1825241&view=rev
Log:
PDFBOX-4117: use new enum type for NewWindow

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionLaunch.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionRemoteGoTo.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionLaunch.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionLaunch.java?rev=1825241&r1=1825240&r2=1825241&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionLaunch.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionLaunch.java
Sat Feb 24 14:05:47 2018
@@ -17,6 +17,7 @@
 package org.apache.pdfbox.pdmodel.interactive.action;
 
 import java.io.IOException;
+import org.apache.pdfbox.cos.COSBoolean;
 
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
@@ -215,7 +216,10 @@ public class PDActionLaunch extends PDAc
      * ignored if the file designated by the F entry is not a PDF document.
      *
      * @return A flag specifying whether to open the destination document in a new window.
+     * 
+     * @deprecated use {@link #getOpenInNewWindow()}
      */
+    @Deprecated
     public boolean shouldOpenInNewWindow()
     {
         return action.getBoolean(COSName.NEW_WINDOW, true);
@@ -225,9 +229,57 @@ public class PDActionLaunch extends PDAc
      * This will specify the destination document to open in a new window.
      *
      * @param value The flag value.
+     * 
+     * @deprecated use {@link #setOpenInNewWindow(OpenMode)}
      */
+    @Deprecated
     public void setOpenInNewWindow( boolean value )
     {
         action.setBoolean(COSName.NEW_WINDOW, value);
     }
+
+    /**
+     * This will specify whether to open the destination document in a new window, in the
same
+     * window, or behave in accordance with the current user preference.
+     *
+     * @return A flag specifying how to open the destination document.
+     */
+    public OpenMode getOpenInNewWindow()
+    {
+        if (getCOSObject().getDictionaryObject(COSName.NEW_WINDOW) instanceof COSBoolean)
+        {
+            COSBoolean b = (COSBoolean) getCOSObject().getDictionaryObject(COSName.NEW_WINDOW);
+            return b.getValue() ? OpenMode.NEW_WINDOW : OpenMode.SAME_WINDOW;
+        }
+        return OpenMode.USER_PREFERENCE;
+    }
+
+    /**
+     * This will specify whether to open the destination document in a new window.
+     *
+     * @param value The flag value.
+     */
+    public void setOpenInNewWindow(OpenMode value)
+    {
+        if (null == value)
+        {
+            getCOSObject().removeItem(COSName.NEW_WINDOW);
+            return;
+        }
+        switch (value)
+        {
+            case USER_PREFERENCE:
+                getCOSObject().removeItem(COSName.NEW_WINDOW);
+                break;
+            case SAME_WINDOW:
+                getCOSObject().setBoolean(COSName.NEW_WINDOW, false);
+                break;
+            case NEW_WINDOW:
+                getCOSObject().setBoolean(COSName.NEW_WINDOW, true);
+                break;
+            default:
+                // shouldn't happen unless the enum type is changed
+                break;
+        }
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionRemoteGoTo.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionRemoteGoTo.java?rev=1825241&r1=1825240&r2=1825241&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionRemoteGoTo.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionRemoteGoTo.java
Sat Feb 24 14:05:47 2018
@@ -19,6 +19,7 @@ package org.apache.pdfbox.pdmodel.intera
 import java.io.IOException;
 
 import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSBoolean;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 
@@ -116,7 +117,10 @@ public class PDActionRemoteGoTo extends
      * should behave in accordance with the current user preference.
      *
      * @return A flag specifying whether to open the destination document in a new window.
+     * 
+     * @deprecated use {@link #getOpenInNewWindow()}
      */
+    @Deprecated
     public boolean shouldOpenInNewWindow()
     {
         return action.getBoolean(COSName.NEW_WINDOW, true );
@@ -126,9 +130,57 @@ public class PDActionRemoteGoTo extends
      * This will specify the destination document to open in a new window.
      *
      * @param value The flag value.
+     * 
+     * @deprecated use {@link #setOpenInNewWindow(OpenMode)}
      */
+    @Deprecated
     public void setOpenInNewWindow( boolean value )
     {
         action.setBoolean(COSName.NEW_WINDOW, value );
     }
+
+    /**
+     * This will specify whether to open the destination document in a new window, in the
same
+     * window, or behave in accordance with the current user preference.
+     *
+     * @return A flag specifying how to open the destination document.
+     */
+    public OpenMode getOpenInNewWindow()
+    {
+        if (getCOSObject().getDictionaryObject(COSName.NEW_WINDOW) instanceof COSBoolean)
+        {
+            COSBoolean b = (COSBoolean) getCOSObject().getDictionaryObject(COSName.NEW_WINDOW);
+            return b.getValue() ? OpenMode.NEW_WINDOW : OpenMode.SAME_WINDOW;
+        }
+        return OpenMode.USER_PREFERENCE;
+    }
+
+    /**
+     * This will specify whether to open the destination document in a new window.
+     *
+     * @param value The flag value.
+     */
+    public void setOpenInNewWindow(OpenMode value)
+    {
+        if (null == value)
+        {
+            getCOSObject().removeItem(COSName.NEW_WINDOW);
+            return;
+        }
+        switch (value)
+        {
+            case USER_PREFERENCE:
+                getCOSObject().removeItem(COSName.NEW_WINDOW);
+                break;
+            case SAME_WINDOW:
+                getCOSObject().setBoolean(COSName.NEW_WINDOW, false);
+                break;
+            case NEW_WINDOW:
+                getCOSObject().setBoolean(COSName.NEW_WINDOW, true);
+                break;
+            default:
+                // shouldn't happen unless the enum type is changed
+                break;
+        }
+    }
 }



Mime
View raw message