Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel.interactive.action » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.pdfbox.pdmodel.interactive.action;
   18   
   19   import org.apache.pdfbox.cos.COSBase;
   20   import org.apache.pdfbox.cos.COSDictionary;
   21   
   22   import org.apache.pdfbox.pdmodel.common.COSObjectable;
   23   import org.apache.pdfbox.pdmodel.interactive.action.type.PDAction;
   24   
   25   /**
   26    * This class represents a document catalog's dictionary of actions
   27    * that occur due to events.
   28    *
   29    * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
   30    * @author Panagiotis Toumasis (ptoumasis@mail.gr)
   31    * @version $Revision: 1.2 $
   32    */
   33   public class PDDocumentCatalogAdditionalActions implements COSObjectable
   34   {
   35       private COSDictionary actions;
   36   
   37       /**
   38        * Default constructor.
   39        */
   40       public PDDocumentCatalogAdditionalActions()
   41       {
   42           actions = new COSDictionary();
   43       }
   44   
   45       /**
   46        * Constructor.
   47        *
   48        * @param a The action dictionary.
   49        */
   50       public PDDocumentCatalogAdditionalActions( COSDictionary a )
   51       {
   52           actions = a;
   53       }
   54   
   55       /**
   56        * Convert this standard java object to a COS object.
   57        *
   58        * @return The cos object that matches this Java object.
   59        */
   60       public COSBase getCOSObject()
   61       {
   62           return actions;
   63       }
   64   
   65       /**
   66        * Convert this standard java object to a COS object.
   67        *
   68        * @return The cos object that matches this Java object.
   69        */
   70       public COSDictionary getCOSDictionary()
   71       {
   72           return actions;
   73       }
   74   
   75       /**
   76        * This will get a JavaScript action to be performed
   77        * before closing a document.
   78        * The name WC stands for "will close".
   79        *
   80        * @return The WC entry of document catalog's additional actions dictionary.
   81        */
   82       public PDAction getWC()
   83       {
   84           COSDictionary wc = (COSDictionary)actions.getDictionaryObject( "WC" );
   85           PDAction retval = null;
   86           if( wc != null )
   87           {
   88               retval = PDActionFactory.createAction( wc );
   89           }
   90           return retval;
   91       }
   92   
   93       /**
   94        * This will set a JavaScript action to be performed
   95        * before closing a document.
   96        * The name WC stands for "will close".
   97        *
   98        * @param wc The action to be performed.
   99        */
  100       public void setWC( PDAction wc )
  101       {
  102           actions.setItem( "WC", wc );
  103       }
  104   
  105       /**
  106        * This will get a JavaScript action to be performed
  107        * before saving a document.
  108        * The name WS stands for "will save".
  109        *
  110        * @return The WS entry of document catalog's additional actions dictionary.
  111        */
  112       public PDAction getWS()
  113       {
  114           COSDictionary ws = (COSDictionary)actions.getDictionaryObject( "WS" );
  115           PDAction retval = null;
  116           if( ws != null )
  117           {
  118               retval = PDActionFactory.createAction( ws );
  119           }
  120           return retval;
  121       }
  122   
  123       /**
  124        * This will set a JavaScript action to be performed
  125        * before saving a document.
  126        * The name WS stands for "will save".
  127        *
  128        * @param ws The action to be performed.
  129        */
  130       public void setWS( PDAction ws )
  131       {
  132           actions.setItem( "WS", ws );
  133       }
  134   
  135       /**
  136        * This will get a JavaScript action to be performed
  137        * after saving a document.
  138        * The name DS stands for "did save".
  139        *
  140        * @return The DS entry of document catalog's additional actions dictionary.
  141        */
  142       public PDAction getDS()
  143       {
  144           COSDictionary ds = (COSDictionary)actions.getDictionaryObject( "DS" );
  145           PDAction retval = null;
  146           if( ds != null )
  147           {
  148               retval = PDActionFactory.createAction( ds );
  149           }
  150           return retval;
  151       }
  152   
  153       /**
  154        * This will set a JavaScript action to be performed
  155        * after saving a document.
  156        * The name DS stands for "did save".
  157        *
  158        * @param ds The action to be performed.
  159        */
  160       public void setDS( PDAction ds )
  161       {
  162           actions.setItem( "DS", ds );
  163       }
  164   
  165       /**
  166        * This will get a JavaScript action to be performed
  167        * before printing a document.
  168        * The name WP stands for "will print".
  169        *
  170        * @return The WP entry of document catalog's additional actions dictionary.
  171        */
  172       public PDAction getWP()
  173       {
  174           COSDictionary wp = (COSDictionary)actions.getDictionaryObject( "WP" );
  175           PDAction retval = null;
  176           if( wp != null )
  177           {
  178               retval = PDActionFactory.createAction( wp );
  179           }
  180           return retval;
  181       }
  182   
  183       /**
  184        * This will set a JavaScript action to be performed
  185        * before printing a document.
  186        * The name WP stands for "will print".
  187        *
  188        * @param wp The action to be performed.
  189        */
  190       public void setWP( PDAction wp )
  191       {
  192           actions.setItem( "WP", wp );
  193       }
  194   
  195       /**
  196        * This will get a JavaScript action to be performed
  197        * after printing a document.
  198        * The name DP stands for "did print".
  199        *
  200        * @return The DP entry of document catalog's additional actions dictionary.
  201        */
  202       public PDAction getDP()
  203       {
  204           COSDictionary dp = (COSDictionary)actions.getDictionaryObject( "DP" );
  205           PDAction retval = null;
  206           if( dp != null )
  207           {
  208               retval = PDActionFactory.createAction( dp );
  209           }
  210           return retval;
  211       }
  212   
  213       /**
  214        * This will set a JavaScript action to be performed
  215        * after printing a document.
  216        * The name DP stands for "did print".
  217        *
  218        * @param dp The action to be performed.
  219        */
  220       public void setDP( PDAction dp )
  221       {
  222           actions.setItem( "DP", dp );
  223       }
  224   }

Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel.interactive.action » [javadoc | source]