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