KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > interactive > action > PDDocumentCatalogAdditionalActions


1 /**
2  * Copyright (c) 2004, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.pdmodel.interactive.action;
32
33 import org.pdfbox.cos.COSBase;
34 import org.pdfbox.cos.COSDictionary;
35
36 import org.pdfbox.pdmodel.common.COSObjectable;
37 import org.pdfbox.pdmodel.interactive.action.type.PDAction;
38
39 /**
40  * This class represents a document catalog's dictionary of actions
41  * that occur due to events.
42  *
43  * @author <a HREF="mailto:ben@benlitchfield.com">Ben Litchfield</a>
44  * @author Panagiotis Toumasis (ptoumasis@mail.gr)
45  * @version $Revision: 1.2 $
46  */

47 public class PDDocumentCatalogAdditionalActions implements COSObjectable
48 {
49     private COSDictionary actions;
50
51     /**
52      * Default constructor.
53      */

54     public PDDocumentCatalogAdditionalActions()
55     {
56         actions = new COSDictionary();
57     }
58
59     /**
60      * Constructor.
61      *
62      * @param a The action dictionary.
63      */

64     public PDDocumentCatalogAdditionalActions( COSDictionary a )
65     {
66         actions = a;
67     }
68
69     /**
70      * Convert this standard java object to a COS object.
71      *
72      * @return The cos object that matches this Java object.
73      */

74     public COSBase getCOSObject()
75     {
76         return actions;
77     }
78
79     /**
80      * Convert this standard java object to a COS object.
81      *
82      * @return The cos object that matches this Java object.
83      */

84     public COSDictionary getCOSDictionary()
85     {
86         return actions;
87     }
88
89     /**
90      * This will get a JavaScript action to be performed
91      * before closing a document.
92      * The name WC stands for "will close".
93      *
94      * @return The WC entry of document catalog's additional actions dictionary.
95      */

96     public PDAction getWC()
97     {
98         COSDictionary wc = (COSDictionary)actions.getDictionaryObject( "WC" );
99         PDAction retval = null;
100         if( wc != null )
101         {
102             retval = PDActionFactory.createAction( wc );
103         }
104         return retval;
105     }
106
107     /**
108      * This will set a JavaScript action to be performed
109      * before closing a document.
110      * The name WC stands for "will close".
111      *
112      * @param wc The action to be performed.
113      */

114     public void setWC( PDAction wc )
115     {
116         actions.setItem( "WC", wc );
117     }
118
119     /**
120      * This will get a JavaScript action to be performed
121      * before saving a document.
122      * The name WS stands for "will save".
123      *
124      * @return The WS entry of document catalog's additional actions dictionary.
125      */

126     public PDAction getWS()
127     {
128         COSDictionary ws = (COSDictionary)actions.getDictionaryObject( "WS" );
129         PDAction retval = null;
130         if( ws != null )
131         {
132             retval = PDActionFactory.createAction( ws );
133         }
134         return retval;
135     }
136
137     /**
138      * This will set a JavaScript action to be performed
139      * before saving a document.
140      * The name WS stands for "will save".
141      *
142      * @param ws The action to be performed.
143      */

144     public void setWS( PDAction ws )
145     {
146         actions.setItem( "WS", ws );
147     }
148
149     /**
150      * This will get a JavaScript action to be performed
151      * after saving a document.
152      * The name DS stands for "did save".
153      *
154      * @return The DS entry of document catalog's additional actions dictionary.
155      */

156     public PDAction getDS()
157     {
158         COSDictionary ds = (COSDictionary)actions.getDictionaryObject( "DS" );
159         PDAction retval = null;
160         if( ds != null )
161         {
162             retval = PDActionFactory.createAction( ds );
163         }
164         return retval;
165     }
166
167     /**
168      * This will set a JavaScript action to be performed
169      * after saving a document.
170      * The name DS stands for "did save".
171      *
172      * @param ds The action to be performed.
173      */

174     public void setDS( PDAction ds )
175     {
176         actions.setItem( "DS", ds );
177     }
178
179     /**
180      * This will get a JavaScript action to be performed
181      * before printing a document.
182      * The name WP stands for "will print".
183      *
184      * @return The WP entry of document catalog's additional actions dictionary.
185      */

186     public PDAction getWP()
187     {
188         COSDictionary wp = (COSDictionary)actions.getDictionaryObject( "WP" );
189         PDAction retval = null;
190         if( wp != null )
191         {
192             retval = PDActionFactory.createAction( wp );
193         }
194         return retval;
195     }
196
197     /**
198      * This will set a JavaScript action to be performed
199      * before printing a document.
200      * The name WP stands for "will print".
201      *
202      * @param wp The action to be performed.
203      */

204     public void setWP( PDAction wp )
205     {
206         actions.setItem( "WP", wp );
207     }
208
209     /**
210      * This will get a JavaScript action to be performed
211      * after printing a document.
212      * The name DP stands for "did print".
213      *
214      * @return The DP entry of document catalog's additional actions dictionary.
215      */

216     public PDAction getDP()
217     {
218         COSDictionary dp = (COSDictionary)actions.getDictionaryObject( "DP" );
219         PDAction retval = null;
220         if( dp != null )
221         {
222             retval = PDActionFactory.createAction( dp );
223         }
224         return retval;
225     }
226
227     /**
228      * This will set a JavaScript action to be performed
229      * after printing a document.
230      * The name DP stands for "did print".
231      *
232      * @param dp The action to be performed.
233      */

234     public void setDP( PDAction dp )
235     {
236         actions.setItem( "DP", dp );
237     }
238 }
Popular Tags