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