]> _ Git - cubeextranet.git/blob
e9025d8c101060e03b4eb348af287ba35b74b343
[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 form field'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 PDFormFieldAdditionalActions implements COSObjectable\r
34 {\r
35     private COSDictionary actions;\r
36 \r
37     /**\r
38      * Default constructor.\r
39      */\r
40     public PDFormFieldAdditionalActions()\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 PDFormFieldAdditionalActions( 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 when the user\r
77      * types a keystroke into a text field or combo box or modifies the\r
78      * selection in a scrollable list box. This allows the keystroke to\r
79      * be checked for validity and rejected or modified.\r
80      *\r
81      * @return The K entry of form field's additional actions dictionary.\r
82      */\r
83     public PDAction getK()\r
84     {\r
85         COSDictionary k = (COSDictionary)actions.getDictionaryObject( "K" );\r
86         PDAction retval = null;\r
87         if( k != null )\r
88         {\r
89             retval = PDActionFactory.createAction( k );\r
90         }\r
91         return retval;\r
92     }\r
93 \r
94     /**\r
95      * This will set a JavaScript action to be performed when the user\r
96      * types a keystroke into a text field or combo box or modifies the\r
97      * selection in a scrollable list box. This allows the keystroke to\r
98      * be checked for validity and rejected or modified.\r
99      *\r
100      * @param k The action to be performed.\r
101      */\r
102     public void setK( PDAction k )\r
103     {\r
104         actions.setItem( "K", k );\r
105     }\r
106 \r
107     /**\r
108      * This will get a JavaScript action to be performed before\r
109      * the field is formatted to display its current value. This\r
110      * allows the field's value to be modified before formatting.\r
111      *\r
112      * @return The F entry of form field's additional actions dictionary.\r
113      */\r
114     public PDAction getF()\r
115     {\r
116         COSDictionary f = (COSDictionary)actions.getDictionaryObject( "F" );\r
117         PDAction retval = null;\r
118         if( f != null )\r
119         {\r
120             retval = PDActionFactory.createAction( f );\r
121         }\r
122         return retval;\r
123     }\r
124 \r
125     /**\r
126      * This will set a JavaScript action to be performed before\r
127      * the field is formatted to display its current value. This\r
128      * allows the field's value to be modified before formatting.\r
129      *\r
130      * @param f The action to be performed.\r
131      */\r
132     public void setF( PDAction f )\r
133     {\r
134         actions.setItem( "F", f );\r
135     }\r
136 \r
137     /**\r
138      * This will get a JavaScript action to be performed\r
139      * when the field's value is changed. This allows the\r
140      * new value to be checked for validity.\r
141      * The name V stands for "validate".\r
142      *\r
143      * @return The V entry of form field's additional actions dictionary.\r
144      */\r
145     public PDAction getV()\r
146     {\r
147         COSDictionary v = (COSDictionary)actions.getDictionaryObject( "V" );\r
148         PDAction retval = null;\r
149         if( v != null )\r
150         {\r
151             retval = PDActionFactory.createAction( v );\r
152         }\r
153         return retval;\r
154     }\r
155 \r
156     /**\r
157      * This will set a JavaScript action to be performed\r
158      * when the field's value is changed. This allows the\r
159      * new value to be checked for validity.\r
160      * The name V stands for "validate".\r
161      *\r
162      * @param v The action to be performed.\r
163      */\r
164     public void setV( PDAction v )\r
165     {\r
166         actions.setItem( "V", v );\r
167     }\r
168 \r
169     /**\r
170      * This will get a JavaScript action to be performed in order to recalculate\r
171      * the value of this field when that of another field changes. The order in which\r
172      * the document's fields are recalculated is defined by the CO entry in the\r
173      * interactive form dictionary.\r
174      * The name C stands for "calculate".\r
175      *\r
176      * @return The C entry of form field's additional actions dictionary.\r
177      */\r
178     public PDAction getC()\r
179     {\r
180         COSDictionary c = (COSDictionary)actions.getDictionaryObject( "C" );\r
181         PDAction retval = null;\r
182         if( c != null )\r
183         {\r
184             retval = PDActionFactory.createAction( c );\r
185         }\r
186         return retval;\r
187     }\r
188 \r
189     /**\r
190      * This will set a JavaScript action to be performed in order to recalculate\r
191      * the value of this field when that of another field changes. The order in which\r
192      * the document's fields are recalculated is defined by the CO entry in the\r
193      * interactive form dictionary.\r
194      * The name C stands for "calculate".\r
195      *\r
196      * @param c The action to be performed.\r
197      */\r
198     public void setC( PDAction c )\r
199     {\r
200         actions.setItem( "C", c );\r
201     }\r
202 }\r