OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 7 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
8 #include "fpdfsdk/include/fsdk_actionhandler.h" | 8 #include "fpdfsdk/include/fsdk_actionhandler.h" |
9 #include "fpdfsdk/include/fsdk_baseannot.h" | 9 #include "fpdfsdk/include/fsdk_baseannot.h" |
10 #include "fpdfsdk/include/fsdk_baseform.h" | 10 #include "fpdfsdk/include/fsdk_baseform.h" |
11 #include "fpdfsdk/include/fsdk_define.h" | 11 #include "fpdfsdk/include/fsdk_define.h" |
12 #include "fpdfsdk/include/fsdk_mgr.h" | 12 #include "fpdfsdk/include/fsdk_mgr.h" |
13 #include "fpdfsdk/include/javascript/IJavaScript.h" | 13 #include "fpdfsdk/include/javascript/IJavaScript.h" |
14 #include "third_party/base/nonstd_unique_ptr.h" | 14 #include "third_party/base/nonstd_unique_ptr.h" |
15 | 15 |
16 #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) | 16 #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) |
17 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) | 17 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
18 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) | 18 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
19 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) | 19 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
20 | 20 |
21 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, | 21 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, |
22 CPDFSDK_PageView* pPageView, | 22 CPDFSDK_PageView* pPageView, |
23 CPDFSDK_InterForm* pInterForm) | 23 CPDFSDK_InterForm* pInterForm) |
24 : CPDFSDK_BAAnnot(pAnnot, pPageView), | 24 : CPDFSDK_BAAnnot(pAnnot, pPageView), |
25 m_pInterForm(pInterForm), | 25 m_pInterForm(pInterForm), |
26 m_nAppAge(0), | 26 m_nAppAge(0), |
27 m_nValueAge(0) { | 27 m_nValueAge(0) { |
28 ASSERT(m_pInterForm != NULL); | 28 ASSERT(m_pInterForm); |
29 } | 29 } |
30 | 30 |
31 CPDFSDK_Widget::~CPDFSDK_Widget() {} | 31 CPDFSDK_Widget::~CPDFSDK_Widget() {} |
32 | 32 |
33 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( | 33 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( |
34 CPDF_Annot::AppearanceMode mode) { | 34 CPDF_Annot::AppearanceMode mode) { |
35 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); | 35 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
36 if (!pAP) | 36 if (!pAP) |
37 return FALSE; | 37 return FALSE; |
38 | 38 |
(...skipping 23 matching lines...) Expand all Loading... |
62 case FIELDTYPE_RADIOBUTTON: | 62 case FIELDTYPE_RADIOBUTTON: |
63 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { | 63 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { |
64 return pSubDict->GetStream(GetAppState()) != NULL; | 64 return pSubDict->GetStream(GetAppState()) != NULL; |
65 } | 65 } |
66 return FALSE; | 66 return FALSE; |
67 } | 67 } |
68 return TRUE; | 68 return TRUE; |
69 } | 69 } |
70 | 70 |
71 int CPDFSDK_Widget::GetFieldType() const { | 71 int CPDFSDK_Widget::GetFieldType() const { |
72 CPDF_FormField* pField = GetFormField(); | 72 return GetFormField()->GetFieldType(); |
73 ASSERT(pField != NULL); | |
74 | |
75 return pField->GetFieldType(); | |
76 } | 73 } |
77 | 74 |
78 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { | 75 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { |
79 return CPDFSDK_BAAnnot::IsAppearanceValid(); | 76 return CPDFSDK_BAAnnot::IsAppearanceValid(); |
80 } | 77 } |
81 | 78 |
82 int CPDFSDK_Widget::GetFieldFlags() const { | 79 int CPDFSDK_Widget::GetFieldFlags() const { |
83 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); | 80 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); |
84 ASSERT(pPDFInterForm != NULL); | |
85 | |
86 CPDF_FormControl* pFormControl = | 81 CPDF_FormControl* pFormControl = |
87 pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict()); | 82 pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict()); |
88 CPDF_FormField* pFormField = pFormControl->GetField(); | 83 CPDF_FormField* pFormField = pFormControl->GetField(); |
89 return pFormField->GetFieldFlags(); | 84 return pFormField->GetFieldFlags(); |
90 } | 85 } |
91 | 86 |
92 CFX_ByteString CPDFSDK_Widget::GetSubType() const { | 87 CFX_ByteString CPDFSDK_Widget::GetSubType() const { |
93 int nType = GetFieldType(); | 88 int nType = GetFieldType(); |
94 | 89 |
95 if (nType == FIELDTYPE_SIGNATURE) | 90 if (nType == FIELDTYPE_SIGNATURE) |
96 return BFFT_SIGNATURE; | 91 return BFFT_SIGNATURE; |
97 return CPDFSDK_Annot::GetSubType(); | 92 return CPDFSDK_Annot::GetSubType(); |
98 } | 93 } |
99 | 94 |
100 CPDF_FormField* CPDFSDK_Widget::GetFormField() const { | 95 CPDF_FormField* CPDFSDK_Widget::GetFormField() const { |
101 return GetFormControl()->GetField(); | 96 return GetFormControl()->GetField(); |
102 } | 97 } |
103 | 98 |
104 CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const { | 99 CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const { |
105 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); | 100 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); |
106 return pPDFInterForm->GetControlByDict(GetAnnotDict()); | 101 return pPDFInterForm->GetControlByDict(GetAnnotDict()); |
107 } | 102 } |
108 | 103 |
109 CPDF_FormControl* CPDFSDK_Widget::GetFormControl( | 104 CPDF_FormControl* CPDFSDK_Widget::GetFormControl( |
110 CPDF_InterForm* pInterForm, | 105 CPDF_InterForm* pInterForm, |
111 const CPDF_Dictionary* pAnnotDict) { | 106 const CPDF_Dictionary* pAnnotDict) { |
112 ASSERT(pAnnotDict != NULL); | 107 ASSERT(pAnnotDict); |
113 return pInterForm->GetControlByDict(pAnnotDict); | 108 return pInterForm->GetControlByDict(pAnnotDict); |
114 } | 109 } |
115 | 110 |
116 int CPDFSDK_Widget::GetRotate() const { | 111 int CPDFSDK_Widget::GetRotate() const { |
117 CPDF_FormControl* pCtrl = GetFormControl(); | 112 CPDF_FormControl* pCtrl = GetFormControl(); |
118 return pCtrl->GetRotation() % 360; | 113 return pCtrl->GetRotation() % 360; |
119 } | 114 } |
120 | 115 |
121 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { | 116 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { |
122 CPDF_FormControl* pFormCtrl = GetFormControl(); | 117 CPDF_FormControl* pFormCtrl = GetFormControl(); |
123 ASSERT(pFormCtrl != NULL); | |
124 | |
125 int iColorType = 0; | 118 int iColorType = 0; |
126 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); | 119 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); |
127 | 120 |
128 return iColorType != COLORTYPE_TRANSPARENT; | 121 return iColorType != COLORTYPE_TRANSPARENT; |
129 } | 122 } |
130 | 123 |
131 FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const { | 124 FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const { |
132 CPDF_FormControl* pFormCtrl = GetFormControl(); | 125 CPDF_FormControl* pFormCtrl = GetFormControl(); |
133 ASSERT(pFormCtrl != NULL); | |
134 | |
135 int iColorType = 0; | 126 int iColorType = 0; |
136 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); | 127 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); |
137 | 128 |
138 return iColorType != COLORTYPE_TRANSPARENT; | 129 return iColorType != COLORTYPE_TRANSPARENT; |
139 } | 130 } |
140 | 131 |
141 FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const { | 132 FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const { |
142 CPDF_FormControl* pFormCtrl = GetFormControl(); | 133 CPDF_FormControl* pFormCtrl = GetFormControl(); |
143 ASSERT(pFormCtrl != NULL); | |
144 | |
145 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); | 134 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); |
146 if (da.HasColor()) { | 135 if (da.HasColor()) { |
147 FX_ARGB argb; | 136 FX_ARGB argb; |
148 int iColorType = COLORTYPE_TRANSPARENT; | 137 int iColorType = COLORTYPE_TRANSPARENT; |
149 da.GetColor(argb, iColorType); | 138 da.GetColor(argb, iColorType); |
150 color = FX_ARGBTOCOLORREF(argb); | 139 color = FX_ARGBTOCOLORREF(argb); |
151 | 140 |
152 return iColorType != COLORTYPE_TRANSPARENT; | 141 return iColorType != COLORTYPE_TRANSPARENT; |
153 } | 142 } |
154 | 143 |
155 return FALSE; | 144 return FALSE; |
156 } | 145 } |
157 | 146 |
158 FX_FLOAT CPDFSDK_Widget::GetFontSize() const { | 147 FX_FLOAT CPDFSDK_Widget::GetFontSize() const { |
159 CPDF_FormControl* pFormCtrl = GetFormControl(); | 148 CPDF_FormControl* pFormCtrl = GetFormControl(); |
160 ASSERT(pFormCtrl != NULL); | |
161 | |
162 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); | 149 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); |
163 CFX_ByteString csFont = ""; | 150 CFX_ByteString csFont = ""; |
164 FX_FLOAT fFontSize = 0.0f; | 151 FX_FLOAT fFontSize = 0.0f; |
165 pDa.GetFont(csFont, fFontSize); | 152 pDa.GetFont(csFont, fFontSize); |
166 | 153 |
167 return fFontSize; | 154 return fFontSize; |
168 } | 155 } |
169 | 156 |
170 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { | 157 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { |
171 CPDF_FormField* pFormField = GetFormField(); | 158 CPDF_FormField* pFormField = GetFormField(); |
172 return pFormField->GetSelectedIndex(nIndex); | 159 return pFormField->GetSelectedIndex(nIndex); |
173 } | 160 } |
174 | 161 |
175 CFX_WideString CPDFSDK_Widget::GetValue() const { | 162 CFX_WideString CPDFSDK_Widget::GetValue() const { |
176 CPDF_FormField* pFormField = GetFormField(); | 163 CPDF_FormField* pFormField = GetFormField(); |
177 return pFormField->GetValue(); | 164 return pFormField->GetValue(); |
178 } | 165 } |
179 | 166 |
180 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { | 167 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { |
181 CPDF_FormField* pFormField = GetFormField(); | 168 CPDF_FormField* pFormField = GetFormField(); |
182 ASSERT(pFormField != NULL); | |
183 | |
184 return pFormField->GetDefaultValue(); | 169 return pFormField->GetDefaultValue(); |
185 } | 170 } |
186 | 171 |
187 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { | 172 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { |
188 CPDF_FormField* pFormField = GetFormField(); | 173 CPDF_FormField* pFormField = GetFormField(); |
189 ASSERT(pFormField != NULL); | |
190 | |
191 return pFormField->GetOptionLabel(nIndex); | 174 return pFormField->GetOptionLabel(nIndex); |
192 } | 175 } |
193 | 176 |
194 int CPDFSDK_Widget::CountOptions() const { | 177 int CPDFSDK_Widget::CountOptions() const { |
195 CPDF_FormField* pFormField = GetFormField(); | 178 CPDF_FormField* pFormField = GetFormField(); |
196 ASSERT(pFormField != NULL); | |
197 | |
198 return pFormField->CountOptions(); | 179 return pFormField->CountOptions(); |
199 } | 180 } |
200 | 181 |
201 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { | 182 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { |
202 CPDF_FormField* pFormField = GetFormField(); | 183 CPDF_FormField* pFormField = GetFormField(); |
203 return pFormField->IsItemSelected(nIndex); | 184 return pFormField->IsItemSelected(nIndex); |
204 } | 185 } |
205 | 186 |
206 int CPDFSDK_Widget::GetTopVisibleIndex() const { | 187 int CPDFSDK_Widget::GetTopVisibleIndex() const { |
207 CPDF_FormField* pFormField = GetFormField(); | 188 CPDF_FormField* pFormField = GetFormField(); |
208 return pFormField->GetTopVisibleIndex(); | 189 return pFormField->GetTopVisibleIndex(); |
209 } | 190 } |
210 | 191 |
211 FX_BOOL CPDFSDK_Widget::IsChecked() const { | 192 FX_BOOL CPDFSDK_Widget::IsChecked() const { |
212 CPDF_FormControl* pFormCtrl = GetFormControl(); | 193 CPDF_FormControl* pFormCtrl = GetFormControl(); |
213 return pFormCtrl->IsChecked(); | 194 return pFormCtrl->IsChecked(); |
214 } | 195 } |
215 | 196 |
216 int CPDFSDK_Widget::GetAlignment() const { | 197 int CPDFSDK_Widget::GetAlignment() const { |
217 CPDF_FormControl* pFormCtrl = GetFormControl(); | 198 CPDF_FormControl* pFormCtrl = GetFormControl(); |
218 ASSERT(pFormCtrl != NULL); | |
219 | |
220 return pFormCtrl->GetControlAlignment(); | 199 return pFormCtrl->GetControlAlignment(); |
221 } | 200 } |
222 | 201 |
223 int CPDFSDK_Widget::GetMaxLen() const { | 202 int CPDFSDK_Widget::GetMaxLen() const { |
224 CPDF_FormField* pFormField = GetFormField(); | 203 CPDF_FormField* pFormField = GetFormField(); |
225 ASSERT(pFormField != NULL); | |
226 | |
227 return pFormField->GetMaxLen(); | 204 return pFormField->GetMaxLen(); |
228 } | 205 } |
229 | 206 |
230 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { | 207 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { |
231 CPDF_FormControl* pFormCtrl = GetFormControl(); | 208 CPDF_FormControl* pFormCtrl = GetFormControl(); |
232 ASSERT(pFormCtrl != NULL); | |
233 | |
234 CPDF_FormField* pFormField = pFormCtrl->GetField(); | 209 CPDF_FormField* pFormField = pFormCtrl->GetField(); |
235 ASSERT(pFormField != NULL); | |
236 | |
237 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, | 210 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, |
238 bNotify); | 211 bNotify); |
239 } | 212 } |
240 | 213 |
241 void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) { | 214 void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) { |
242 CPDF_FormField* pFormField = GetFormField(); | 215 CPDF_FormField* pFormField = GetFormField(); |
243 ASSERT(pFormField != NULL); | |
244 | |
245 pFormField->SetValue(sValue, bNotify); | 216 pFormField->SetValue(sValue, bNotify); |
246 } | 217 } |
247 | 218 |
248 void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) {} | 219 void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) {} |
249 void CPDFSDK_Widget::SetOptionSelection(int index, | 220 void CPDFSDK_Widget::SetOptionSelection(int index, |
250 FX_BOOL bSelected, | 221 FX_BOOL bSelected, |
251 FX_BOOL bNotify) { | 222 FX_BOOL bNotify) { |
252 CPDF_FormField* pFormField = GetFormField(); | 223 CPDF_FormField* pFormField = GetFormField(); |
253 ASSERT(pFormField != NULL); | |
254 | |
255 pFormField->SetItemSelection(index, bSelected, bNotify); | 224 pFormField->SetItemSelection(index, bSelected, bNotify); |
256 } | 225 } |
257 | 226 |
258 void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) { | 227 void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) { |
259 CPDF_FormField* pFormField = GetFormField(); | 228 CPDF_FormField* pFormField = GetFormField(); |
260 ASSERT(pFormField != NULL); | |
261 | |
262 pFormField->ClearSelection(bNotify); | 229 pFormField->ClearSelection(bNotify); |
263 } | 230 } |
264 | 231 |
265 void CPDFSDK_Widget::SetTopVisibleIndex(int index) {} | 232 void CPDFSDK_Widget::SetTopVisibleIndex(int index) {} |
266 | 233 |
267 void CPDFSDK_Widget::SetAppModified() { | 234 void CPDFSDK_Widget::SetAppModified() { |
268 m_bAppModified = TRUE; | 235 m_bAppModified = TRUE; |
269 } | 236 } |
270 | 237 |
271 void CPDFSDK_Widget::ClearAppModified() { | 238 void CPDFSDK_Widget::ClearAppModified() { |
(...skipping 30 matching lines...) Expand all Loading... |
302 ResetAppearance_ComboBox(sValue); | 269 ResetAppearance_ComboBox(sValue); |
303 break; | 270 break; |
304 case FIELDTYPE_LISTBOX: | 271 case FIELDTYPE_LISTBOX: |
305 ResetAppearance_ListBox(); | 272 ResetAppearance_ListBox(); |
306 break; | 273 break; |
307 case FIELDTYPE_TEXTFIELD: | 274 case FIELDTYPE_TEXTFIELD: |
308 ResetAppearance_TextField(sValue); | 275 ResetAppearance_TextField(sValue); |
309 break; | 276 break; |
310 } | 277 } |
311 | 278 |
312 ASSERT(m_pAnnot != NULL); | |
313 m_pAnnot->ClearCachedAP(); | 279 m_pAnnot->ClearCachedAP(); |
314 } | 280 } |
315 | 281 |
316 CFX_WideString CPDFSDK_Widget::OnFormat(FX_BOOL& bFormated) { | 282 CFX_WideString CPDFSDK_Widget::OnFormat(FX_BOOL& bFormated) { |
317 CPDF_FormField* pFormField = GetFormField(); | 283 CPDF_FormField* pFormField = GetFormField(); |
318 ASSERT(pFormField != NULL); | 284 ASSERT(pFormField); |
319 return m_pInterForm->OnFormat(pFormField, bFormated); | 285 return m_pInterForm->OnFormat(pFormField, bFormated); |
320 } | 286 } |
321 | 287 |
322 void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) { | 288 void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) { |
323 CPDF_FormField* pFormField = GetFormField(); | 289 CPDF_FormField* pFormField = GetFormField(); |
324 ASSERT(pFormField != NULL); | 290 ASSERT(pFormField); |
325 | |
326 ASSERT(m_pInterForm != NULL); | |
327 | |
328 m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); | 291 m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); |
329 } | 292 } |
330 | 293 |
331 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, | 294 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, |
332 const CFX_Matrix* pUser2Device, | 295 const CFX_Matrix* pUser2Device, |
333 CPDF_Annot::AppearanceMode mode, | 296 CPDF_Annot::AppearanceMode mode, |
334 const CPDF_RenderOptions* pOptions) { | 297 const CPDF_RenderOptions* pOptions) { |
335 int nFieldType = GetFieldType(); | 298 int nFieldType = GetFieldType(); |
336 | 299 |
337 if ((nFieldType == FIELDTYPE_CHECKBOX || | 300 if ((nFieldType == FIELDTYPE_CHECKBOX || |
(...skipping 12 matching lines...) Expand all Loading... |
350 | 313 |
351 pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, | 314 pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, |
352 FXFILL_ALTERNATE); | 315 FXFILL_ALTERNATE); |
353 } else { | 316 } else { |
354 CPDFSDK_BAAnnot::DrawAppearance(pDevice, pUser2Device, mode, pOptions); | 317 CPDFSDK_BAAnnot::DrawAppearance(pDevice, pUser2Device, mode, pOptions); |
355 } | 318 } |
356 } | 319 } |
357 | 320 |
358 void CPDFSDK_Widget::UpdateField() { | 321 void CPDFSDK_Widget::UpdateField() { |
359 CPDF_FormField* pFormField = GetFormField(); | 322 CPDF_FormField* pFormField = GetFormField(); |
360 ASSERT(pFormField != NULL); | 323 ASSERT(pFormField); |
361 | |
362 ASSERT(m_pInterForm != NULL); | |
363 m_pInterForm->UpdateField(pFormField); | 324 m_pInterForm->UpdateField(pFormField); |
364 } | 325 } |
365 | 326 |
366 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, | 327 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, |
367 CPDFSDK_PageView* pPageView) { | 328 CPDFSDK_PageView* pPageView) { |
368 ASSERT(m_pInterForm != NULL); | |
369 | |
370 int nFieldType = GetFieldType(); | 329 int nFieldType = GetFieldType(); |
371 if (m_pInterForm->IsNeedHighLight(nFieldType)) { | 330 if (m_pInterForm->IsNeedHighLight(nFieldType)) { |
372 CPDF_Rect rc = GetRect(); | 331 CPDF_Rect rc = GetRect(); |
373 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); | 332 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); |
374 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); | 333 uint8_t alpha = m_pInterForm->GetHighlightAlpha(); |
375 | 334 |
376 CFX_FloatRect rcDevice; | 335 CFX_FloatRect rcDevice; |
377 ASSERT(m_pInterForm->GetDocument()); | 336 ASSERT(m_pInterForm->GetDocument()); |
378 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); | 337 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); |
379 if (!pEnv) | 338 if (!pEnv) |
380 return; | 339 return; |
381 CFX_Matrix page2device; | 340 CFX_Matrix page2device; |
382 pPageView->GetCurrentMatrix(page2device); | 341 pPageView->GetCurrentMatrix(page2device); |
383 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), | 342 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc.bottom), |
384 rcDevice.left, rcDevice.bottom); | 343 rcDevice.left, rcDevice.bottom); |
385 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), | 344 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), |
386 rcDevice.right, rcDevice.top); | 345 rcDevice.right, rcDevice.top); |
387 | 346 |
388 rcDevice.Normalize(); | 347 rcDevice.Normalize(); |
389 | 348 |
390 FX_ARGB argb = ArgbEncode((int)alpha, color); | 349 FX_ARGB argb = ArgbEncode((int)alpha, color); |
391 FX_RECT rcDev((int)rcDevice.left, (int)rcDevice.top, (int)rcDevice.right, | 350 FX_RECT rcDev((int)rcDevice.left, (int)rcDevice.top, (int)rcDevice.right, |
392 (int)rcDevice.bottom); | 351 (int)rcDevice.bottom); |
393 pDevice->FillRect(&rcDev, argb); | 352 pDevice->FillRect(&rcDev, argb); |
394 } | 353 } |
395 } | 354 } |
396 | 355 |
397 void CPDFSDK_Widget::ResetAppearance_PushButton() { | 356 void CPDFSDK_Widget::ResetAppearance_PushButton() { |
398 CPDF_FormControl* pControl = GetFormControl(); | 357 CPDF_FormControl* pControl = GetFormControl(); |
399 ASSERT(pControl != NULL); | |
400 | |
401 CPDF_Rect rcWindow = GetRotatedRect(); | 358 CPDF_Rect rcWindow = GetRotatedRect(); |
402 | |
403 int32_t nLayout = 0; | 359 int32_t nLayout = 0; |
404 | |
405 switch (pControl->GetTextPosition()) { | 360 switch (pControl->GetTextPosition()) { |
406 case TEXTPOS_ICON: | 361 case TEXTPOS_ICON: |
407 nLayout = PPBL_ICON; | 362 nLayout = PPBL_ICON; |
408 break; | 363 break; |
409 case TEXTPOS_BELOW: | 364 case TEXTPOS_BELOW: |
410 nLayout = PPBL_ICONTOPLABELBOTTOM; | 365 nLayout = PPBL_ICONTOPLABELBOTTOM; |
411 break; | 366 break; |
412 case TEXTPOS_ABOVE: | 367 case TEXTPOS_ABOVE: |
413 nLayout = PPBL_LABELTOPICONBOTTOM; | 368 nLayout = PPBL_LABELTOPICONBOTTOM; |
414 break; | 369 break; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 if (pDownIcon) { | 484 if (pDownIcon) { |
530 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { | 485 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { |
531 if (pImageDict->GetString("Name").IsEmpty()) | 486 if (pImageDict->GetString("Name").IsEmpty()) |
532 pImageDict->SetAtString("Name", "ImgC"); | 487 pImageDict->SetAtString("Name", "ImgC"); |
533 } | 488 } |
534 } | 489 } |
535 | 490 |
536 CPDF_IconFit iconFit = pControl->GetIconFit(); | 491 CPDF_IconFit iconFit = pControl->GetIconFit(); |
537 | 492 |
538 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 493 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
539 ASSERT(pDoc != NULL); | |
540 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 494 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
541 | 495 |
542 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 496 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
543 FontMap.Initial(); | 497 FontMap.Initial(); |
544 | 498 |
545 FontMap.SetAPType("N"); | 499 FontMap.SetAPType("N"); |
546 | 500 |
547 CFX_ByteString csAP = | 501 CFX_ByteString csAP = |
548 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + | 502 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
549 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 503 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 if (pDownIcon) | 565 if (pDownIcon) |
612 AddImageToAppearance("D", pDownIcon); | 566 AddImageToAppearance("D", pDownIcon); |
613 } else { | 567 } else { |
614 RemoveAppearance("D"); | 568 RemoveAppearance("D"); |
615 RemoveAppearance("R"); | 569 RemoveAppearance("R"); |
616 } | 570 } |
617 } | 571 } |
618 | 572 |
619 void CPDFSDK_Widget::ResetAppearance_CheckBox() { | 573 void CPDFSDK_Widget::ResetAppearance_CheckBox() { |
620 CPDF_FormControl* pControl = GetFormControl(); | 574 CPDF_FormControl* pControl = GetFormControl(); |
621 ASSERT(pControl != NULL); | |
622 | |
623 CPWL_Color crBackground, crBorder, crText; | 575 CPWL_Color crBackground, crBorder, crText; |
624 | |
625 int iColorType; | 576 int iColorType; |
626 FX_FLOAT fc[4]; | 577 FX_FLOAT fc[4]; |
627 | 578 |
628 pControl->GetOriginalBackgroundColor(iColorType, fc); | 579 pControl->GetOriginalBackgroundColor(iColorType, fc); |
629 if (iColorType > 0) | 580 if (iColorType > 0) |
630 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 581 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
631 | 582 |
632 pControl->GetOriginalBorderColor(iColorType, fc); | 583 pControl->GetOriginalBorderColor(iColorType, fc); |
633 if (iColorType > 0) | 584 if (iColorType > 0) |
634 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 585 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 pControl->GetCheckedAPState()); | 691 pControl->GetCheckedAPState()); |
741 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); | 692 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); |
742 | 693 |
743 CFX_ByteString csAS = GetAppState(); | 694 CFX_ByteString csAS = GetAppState(); |
744 if (csAS.IsEmpty()) | 695 if (csAS.IsEmpty()) |
745 SetAppState("Off"); | 696 SetAppState("Off"); |
746 } | 697 } |
747 | 698 |
748 void CPDFSDK_Widget::ResetAppearance_RadioButton() { | 699 void CPDFSDK_Widget::ResetAppearance_RadioButton() { |
749 CPDF_FormControl* pControl = GetFormControl(); | 700 CPDF_FormControl* pControl = GetFormControl(); |
750 ASSERT(pControl != NULL); | |
751 | |
752 CPWL_Color crBackground, crBorder, crText; | 701 CPWL_Color crBackground, crBorder, crText; |
753 | |
754 int iColorType; | 702 int iColorType; |
755 FX_FLOAT fc[4]; | 703 FX_FLOAT fc[4]; |
756 | 704 |
757 pControl->GetOriginalBackgroundColor(iColorType, fc); | 705 pControl->GetOriginalBackgroundColor(iColorType, fc); |
758 if (iColorType > 0) | 706 if (iColorType > 0) |
759 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 707 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
760 | 708 |
761 pControl->GetOriginalBorderColor(iColorType, fc); | 709 pControl->GetOriginalBorderColor(iColorType, fc); |
762 if (iColorType > 0) | 710 if (iColorType > 0) |
763 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 711 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 pControl->GetCheckedAPState()); | 854 pControl->GetCheckedAPState()); |
907 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); | 855 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); |
908 | 856 |
909 CFX_ByteString csAS = GetAppState(); | 857 CFX_ByteString csAS = GetAppState(); |
910 if (csAS.IsEmpty()) | 858 if (csAS.IsEmpty()) |
911 SetAppState("Off"); | 859 SetAppState("Off"); |
912 } | 860 } |
913 | 861 |
914 void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) { | 862 void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) { |
915 CPDF_FormControl* pControl = GetFormControl(); | 863 CPDF_FormControl* pControl = GetFormControl(); |
916 ASSERT(pControl != NULL); | |
917 CPDF_FormField* pField = pControl->GetField(); | 864 CPDF_FormField* pField = pControl->GetField(); |
918 ASSERT(pField != NULL); | |
919 | |
920 CFX_ByteTextBuf sBody, sLines; | 865 CFX_ByteTextBuf sBody, sLines; |
921 | 866 |
922 CPDF_Rect rcClient = GetClientRect(); | 867 CPDF_Rect rcClient = GetClientRect(); |
923 CPDF_Rect rcButton = rcClient; | 868 CPDF_Rect rcButton = rcClient; |
924 rcButton.left = rcButton.right - 13; | 869 rcButton.left = rcButton.right - 13; |
925 rcButton.Normalize(); | 870 rcButton.Normalize(); |
926 | 871 |
927 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 872 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
928 pEdit->EnableRefresh(FALSE); | 873 pEdit->EnableRefresh(FALSE); |
929 | 874 |
930 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 875 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
931 ASSERT(pDoc != NULL); | |
932 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 876 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
933 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 877 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
934 FontMap.Initial(); | 878 FontMap.Initial(); |
935 pEdit->SetFontMap(&FontMap); | 879 pEdit->SetFontMap(&FontMap); |
936 | 880 |
937 CPDF_Rect rcEdit = rcClient; | 881 CPDF_Rect rcEdit = rcClient; |
938 rcEdit.right = rcButton.left; | 882 rcEdit.right = rcButton.left; |
939 rcEdit.Normalize(); | 883 rcEdit.Normalize(); |
940 | 884 |
941 pEdit->SetPlateRect(rcEdit); | 885 pEdit->SetPlateRect(rcEdit); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 sBody << CPWL_Utils::GetDropButtonAppStream(rcButton); | 929 sBody << CPWL_Utils::GetDropButtonAppStream(rcButton); |
986 | 930 |
987 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + | 931 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + |
988 sLines.GetByteString() + sBody.GetByteString(); | 932 sLines.GetByteString() + sBody.GetByteString(); |
989 | 933 |
990 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 934 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
991 } | 935 } |
992 | 936 |
993 void CPDFSDK_Widget::ResetAppearance_ListBox() { | 937 void CPDFSDK_Widget::ResetAppearance_ListBox() { |
994 CPDF_FormControl* pControl = GetFormControl(); | 938 CPDF_FormControl* pControl = GetFormControl(); |
995 ASSERT(pControl != NULL); | |
996 CPDF_FormField* pField = pControl->GetField(); | 939 CPDF_FormField* pField = pControl->GetField(); |
997 ASSERT(pField != NULL); | |
998 | |
999 CPDF_Rect rcClient = GetClientRect(); | 940 CPDF_Rect rcClient = GetClientRect(); |
1000 | |
1001 CFX_ByteTextBuf sBody, sLines; | 941 CFX_ByteTextBuf sBody, sLines; |
1002 | 942 |
1003 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 943 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
1004 pEdit->EnableRefresh(FALSE); | 944 pEdit->EnableRefresh(FALSE); |
1005 | 945 |
1006 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 946 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1007 ASSERT(pDoc != NULL); | |
1008 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 947 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
1009 | 948 |
1010 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 949 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
1011 FontMap.Initial(); | 950 FontMap.Initial(); |
1012 pEdit->SetFontMap(&FontMap); | 951 pEdit->SetFontMap(&FontMap); |
1013 | 952 |
1014 pEdit->SetPlateRect(CPDF_Rect(rcClient.left, 0.0f, rcClient.right, 0.0f)); | 953 pEdit->SetPlateRect(CPDF_Rect(rcClient.left, 0.0f, rcClient.right, 0.0f)); |
1015 | 954 |
1016 FX_FLOAT fFontSize = GetFontSize(); | 955 FX_FLOAT fFontSize = GetFontSize(); |
1017 | 956 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 } | 1018 } |
1080 | 1019 |
1081 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + | 1020 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + |
1082 sLines.GetByteString() + sBody.GetByteString(); | 1021 sLines.GetByteString() + sBody.GetByteString(); |
1083 | 1022 |
1084 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 1023 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
1085 } | 1024 } |
1086 | 1025 |
1087 void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) { | 1026 void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) { |
1088 CPDF_FormControl* pControl = GetFormControl(); | 1027 CPDF_FormControl* pControl = GetFormControl(); |
1089 ASSERT(pControl != NULL); | |
1090 CPDF_FormField* pField = pControl->GetField(); | 1028 CPDF_FormField* pField = pControl->GetField(); |
1091 ASSERT(pField != NULL); | |
1092 | |
1093 CFX_ByteTextBuf sBody, sLines; | 1029 CFX_ByteTextBuf sBody, sLines; |
1094 | 1030 |
1095 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { | 1031 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
1096 pEdit->EnableRefresh(FALSE); | 1032 pEdit->EnableRefresh(FALSE); |
1097 | 1033 |
1098 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1034 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1099 ASSERT(pDoc != NULL); | |
1100 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1035 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
1101 | 1036 |
1102 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); | 1037 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
1103 FontMap.Initial(); | 1038 FontMap.Initial(); |
1104 pEdit->SetFontMap(&FontMap); | 1039 pEdit->SetFontMap(&FontMap); |
1105 | 1040 |
1106 CPDF_Rect rcClient = GetClientRect(); | 1041 CPDF_Rect rcClient = GetClientRect(); |
1107 pEdit->SetPlateRect(rcClient); | 1042 pEdit->SetPlateRect(rcClient); |
1108 pEdit->SetAlignmentH(pControl->GetControlAlignment()); | 1043 pEdit->SetAlignmentH(pControl->GetControlAlignment()); |
1109 | 1044 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 } | 1243 } |
1309 | 1244 |
1310 return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, | 1245 return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, |
1311 crLeftTop, crRightBottom, nBorderStyle, | 1246 crLeftTop, crRightBottom, nBorderStyle, |
1312 dsBorder); | 1247 dsBorder); |
1313 } | 1248 } |
1314 | 1249 |
1315 CFX_Matrix CPDFSDK_Widget::GetMatrix() const { | 1250 CFX_Matrix CPDFSDK_Widget::GetMatrix() const { |
1316 CFX_Matrix mt; | 1251 CFX_Matrix mt; |
1317 CPDF_FormControl* pControl = GetFormControl(); | 1252 CPDF_FormControl* pControl = GetFormControl(); |
1318 ASSERT(pControl != NULL); | |
1319 | |
1320 CPDF_Rect rcAnnot = GetRect(); | 1253 CPDF_Rect rcAnnot = GetRect(); |
1321 FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left; | 1254 FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left; |
1322 FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom; | 1255 FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom; |
1323 | 1256 |
1324 switch (abs(pControl->GetRotation() % 360)) { | 1257 switch (abs(pControl->GetRotation() % 360)) { |
1325 case 0: | 1258 case 0: |
1326 default: | 1259 default: |
1327 mt = CFX_Matrix(1, 0, 0, 1, 0, 0); | 1260 mt = CFX_Matrix(1, 0, 0, 1, 0, 0); |
1328 break; | 1261 break; |
1329 case 90: | 1262 case 90: |
1330 mt = CFX_Matrix(0, 1, -1, 0, fWidth, 0); | 1263 mt = CFX_Matrix(0, 1, -1, 0, fWidth, 0); |
1331 break; | 1264 break; |
1332 case 180: | 1265 case 180: |
1333 mt = CFX_Matrix(-1, 0, 0, -1, fWidth, fHeight); | 1266 mt = CFX_Matrix(-1, 0, 0, -1, fWidth, fHeight); |
1334 break; | 1267 break; |
1335 case 270: | 1268 case 270: |
1336 mt = CFX_Matrix(0, -1, 1, 0, 0, fHeight); | 1269 mt = CFX_Matrix(0, -1, 1, 0, 0, fHeight); |
1337 break; | 1270 break; |
1338 } | 1271 } |
1339 | 1272 |
1340 return mt; | 1273 return mt; |
1341 } | 1274 } |
1342 | 1275 |
1343 CPWL_Color CPDFSDK_Widget::GetTextPWLColor() const { | 1276 CPWL_Color CPDFSDK_Widget::GetTextPWLColor() const { |
1344 CPWL_Color crText = CPWL_Color(COLORTYPE_GRAY, 0); | 1277 CPWL_Color crText = CPWL_Color(COLORTYPE_GRAY, 0); |
1345 | 1278 |
1346 CPDF_FormControl* pFormCtrl = GetFormControl(); | 1279 CPDF_FormControl* pFormCtrl = GetFormControl(); |
1347 ASSERT(pFormCtrl != NULL); | |
1348 | |
1349 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); | 1280 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); |
1350 if (da.HasColor()) { | 1281 if (da.HasColor()) { |
1351 int32_t iColorType; | 1282 int32_t iColorType; |
1352 FX_FLOAT fc[4]; | 1283 FX_FLOAT fc[4]; |
1353 da.GetColor(iColorType, fc); | 1284 da.GetColor(iColorType, fc); |
1354 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1285 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
1355 } | 1286 } |
1356 | 1287 |
1357 return crText; | 1288 return crText; |
1358 } | 1289 } |
1359 | 1290 |
1360 CPWL_Color CPDFSDK_Widget::GetBorderPWLColor() const { | 1291 CPWL_Color CPDFSDK_Widget::GetBorderPWLColor() const { |
1361 CPWL_Color crBorder; | 1292 CPWL_Color crBorder; |
1362 | 1293 |
1363 CPDF_FormControl* pFormCtrl = GetFormControl(); | 1294 CPDF_FormControl* pFormCtrl = GetFormControl(); |
1364 ASSERT(pFormCtrl != NULL); | |
1365 | |
1366 int32_t iColorType; | 1295 int32_t iColorType; |
1367 FX_FLOAT fc[4]; | 1296 FX_FLOAT fc[4]; |
1368 pFormCtrl->GetOriginalBorderColor(iColorType, fc); | 1297 pFormCtrl->GetOriginalBorderColor(iColorType, fc); |
1369 if (iColorType > 0) | 1298 if (iColorType > 0) |
1370 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1299 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
1371 | 1300 |
1372 return crBorder; | 1301 return crBorder; |
1373 } | 1302 } |
1374 | 1303 |
1375 CPWL_Color CPDFSDK_Widget::GetFillPWLColor() const { | 1304 CPWL_Color CPDFSDK_Widget::GetFillPWLColor() const { |
1376 CPWL_Color crFill; | 1305 CPWL_Color crFill; |
1377 | 1306 |
1378 CPDF_FormControl* pFormCtrl = GetFormControl(); | 1307 CPDF_FormControl* pFormCtrl = GetFormControl(); |
1379 ASSERT(pFormCtrl != NULL); | |
1380 | |
1381 int32_t iColorType; | 1308 int32_t iColorType; |
1382 FX_FLOAT fc[4]; | 1309 FX_FLOAT fc[4]; |
1383 pFormCtrl->GetOriginalBackgroundColor(iColorType, fc); | 1310 pFormCtrl->GetOriginalBackgroundColor(iColorType, fc); |
1384 if (iColorType > 0) | 1311 if (iColorType > 0) |
1385 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1312 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
1386 | 1313 |
1387 return crFill; | 1314 return crFill; |
1388 } | 1315 } |
1389 | 1316 |
1390 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, | 1317 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, |
1391 CPDF_Stream* pImage) { | 1318 CPDF_Stream* pImage) { |
1392 ASSERT(pImage != NULL); | |
1393 | |
1394 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 1319 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
1395 ASSERT(pDoc != NULL); | 1320 ASSERT(pDoc); |
1396 | 1321 |
1397 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); | 1322 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
1398 ASSERT(pAPDict != NULL); | |
1399 | |
1400 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); | 1323 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); |
1401 ASSERT(pStream != NULL); | |
1402 | |
1403 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 1324 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
1404 ASSERT(pStreamDict != NULL); | |
1405 | |
1406 CFX_ByteString sImageAlias = "IMG"; | 1325 CFX_ByteString sImageAlias = "IMG"; |
1407 | 1326 |
1408 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { | 1327 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { |
1409 sImageAlias = pImageDict->GetString("Name"); | 1328 sImageAlias = pImageDict->GetString("Name"); |
1410 if (sImageAlias.IsEmpty()) | 1329 if (sImageAlias.IsEmpty()) |
1411 sImageAlias = "IMG"; | 1330 sImageAlias = "IMG"; |
1412 } | 1331 } |
1413 | 1332 |
1414 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); | 1333 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); |
1415 if (!pStreamResList) { | 1334 if (!pStreamResList) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 } | 1389 } |
1471 default: | 1390 default: |
1472 break; | 1391 break; |
1473 } | 1392 } |
1474 | 1393 |
1475 return CPDF_Action(); | 1394 return CPDF_Action(); |
1476 } | 1395 } |
1477 | 1396 |
1478 CFX_WideString CPDFSDK_Widget::GetAlternateName() const { | 1397 CFX_WideString CPDFSDK_Widget::GetAlternateName() const { |
1479 CPDF_FormField* pFormField = GetFormField(); | 1398 CPDF_FormField* pFormField = GetFormField(); |
1480 ASSERT(pFormField != NULL); | |
1481 | |
1482 return pFormField->GetAlternateName(); | 1399 return pFormField->GetAlternateName(); |
1483 } | 1400 } |
1484 | 1401 |
1485 int32_t CPDFSDK_Widget::GetAppearanceAge() const { | 1402 int32_t CPDFSDK_Widget::GetAppearanceAge() const { |
1486 return m_nAppAge; | 1403 return m_nAppAge; |
1487 } | 1404 } |
1488 | 1405 |
1489 int32_t CPDFSDK_Widget::GetValueAge() const { | 1406 int32_t CPDFSDK_Widget::GetValueAge() const { |
1490 return m_nValueAge; | 1407 return m_nValueAge; |
1491 } | 1408 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 ASSERT(pFormCtrl); | 1511 ASSERT(pFormCtrl); |
1595 CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl); | 1512 CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl); |
1596 if (pWidget) | 1513 if (pWidget) |
1597 widgets->push_back(pWidget); | 1514 widgets->push_back(pWidget); |
1598 } | 1515 } |
1599 } | 1516 } |
1600 | 1517 |
1601 int CPDFSDK_InterForm::GetPageIndexByAnnotDict( | 1518 int CPDFSDK_InterForm::GetPageIndexByAnnotDict( |
1602 CPDF_Document* pDocument, | 1519 CPDF_Document* pDocument, |
1603 CPDF_Dictionary* pAnnotDict) const { | 1520 CPDF_Dictionary* pAnnotDict) const { |
1604 ASSERT(pDocument != NULL); | 1521 ASSERT(pAnnotDict); |
1605 ASSERT(pAnnotDict != NULL); | |
1606 | 1522 |
1607 for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { | 1523 for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { |
1608 if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) { | 1524 if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) { |
1609 if (CPDF_Array* pAnnots = pPageDict->GetArray("Annots")) { | 1525 if (CPDF_Array* pAnnots = pPageDict->GetArray("Annots")) { |
1610 for (int j = 0, jsz = pAnnots->GetCount(); j < jsz; j++) { | 1526 for (int j = 0, jsz = pAnnots->GetCount(); j < jsz; j++) { |
1611 CPDF_Object* pDict = pAnnots->GetElementValue(j); | 1527 CPDF_Object* pDict = pAnnots->GetElementValue(j); |
1612 if (pAnnotDict == pDict) { | 1528 if (pAnnotDict == pDict) { |
1613 return i; | 1529 return i; |
1614 } | 1530 } |
1615 } | 1531 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 } | 1607 } |
1692 | 1608 |
1693 delete pBmp; | 1609 delete pBmp; |
1694 } | 1610 } |
1695 | 1611 |
1696 return pRetStream; | 1612 return pRetStream; |
1697 } | 1613 } |
1698 #endif | 1614 #endif |
1699 | 1615 |
1700 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { | 1616 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { |
1701 ASSERT(m_pDocument != NULL); | |
1702 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1617 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1703 ASSERT(pEnv); | 1618 ASSERT(pEnv); |
1704 if (!pEnv->IsJSInitiated()) | 1619 if (!pEnv->IsJSInitiated()) |
1705 return; | 1620 return; |
1706 | 1621 |
1707 if (m_bBusy) | 1622 if (m_bBusy) |
1708 return; | 1623 return; |
1709 | 1624 |
1710 m_bBusy = TRUE; | 1625 m_bBusy = TRUE; |
1711 | 1626 |
1712 if (IsCalculateEnabled()) { | 1627 if (IsCalculateEnabled()) { |
1713 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 1628 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
1714 ASSERT(pRuntime != NULL); | |
1715 | |
1716 pRuntime->SetReaderDocument(m_pDocument); | 1629 pRuntime->SetReaderDocument(m_pDocument); |
1717 | 1630 |
1718 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); | 1631 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); |
1719 for (int i = 0; i < nSize; i++) { | 1632 for (int i = 0; i < nSize; i++) { |
1720 if (CPDF_FormField* pField = | 1633 if (CPDF_FormField* pField = |
1721 m_pInterForm->GetFieldInCalculationOrder(i)) { | 1634 m_pInterForm->GetFieldInCalculationOrder(i)) { |
1722 int nType = pField->GetFieldType(); | 1635 int nType = pField->GetFieldType(); |
1723 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 1636 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
1724 CPDF_AAction aAction = pField->GetAdditionalAction(); | 1637 CPDF_AAction aAction = pField->GetAdditionalAction(); |
1725 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { | 1638 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { |
1726 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); | 1639 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); |
1727 if (action) { | 1640 if (action) { |
1728 CFX_WideString csJS = action.GetJavaScript(); | 1641 CFX_WideString csJS = action.GetJavaScript(); |
1729 if (!csJS.IsEmpty()) { | 1642 if (!csJS.IsEmpty()) { |
1730 IJS_Context* pContext = pRuntime->NewContext(); | 1643 IJS_Context* pContext = pRuntime->NewContext(); |
1731 ASSERT(pContext != NULL); | |
1732 | |
1733 CFX_WideString sOldValue = pField->GetValue(); | 1644 CFX_WideString sOldValue = pField->GetValue(); |
1734 CFX_WideString sValue = sOldValue; | 1645 CFX_WideString sValue = sOldValue; |
1735 FX_BOOL bRC = TRUE; | 1646 FX_BOOL bRC = TRUE; |
1736 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); | 1647 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); |
1737 | 1648 |
1738 CFX_WideString sInfo; | 1649 CFX_WideString sInfo; |
1739 FX_BOOL bRet = pContext->RunScript(csJS, &sInfo); | 1650 FX_BOOL bRet = pContext->RunScript(csJS, &sInfo); |
1740 pRuntime->ReleaseContext(pContext); | 1651 pRuntime->ReleaseContext(pContext); |
1741 | 1652 |
1742 if (bRet) { | 1653 if (bRet) { |
1743 if (bRC) { | 1654 if (bRC) { |
1744 if (sValue.Compare(sOldValue) != 0) | 1655 if (sValue.Compare(sOldValue) != 0) |
1745 pField->SetValue(sValue, TRUE); | 1656 pField->SetValue(sValue, TRUE); |
1746 } | 1657 } |
1747 } | 1658 } |
1748 } | 1659 } |
1749 } | 1660 } |
1750 } | 1661 } |
1751 } | 1662 } |
1752 } | 1663 } |
1753 } | 1664 } |
1754 } | 1665 } |
1755 | 1666 |
1756 m_bBusy = FALSE; | 1667 m_bBusy = FALSE; |
1757 } | 1668 } |
1758 | 1669 |
1759 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, | 1670 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, |
1760 FX_BOOL& bFormated) { | 1671 FX_BOOL& bFormated) { |
1761 ASSERT(m_pDocument != NULL); | |
1762 ASSERT(pFormField != NULL); | |
1763 | |
1764 CFX_WideString sValue = pFormField->GetValue(); | 1672 CFX_WideString sValue = pFormField->GetValue(); |
1765 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1673 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1766 ASSERT(pEnv); | 1674 ASSERT(pEnv); |
1767 if (!pEnv->IsJSInitiated()) { | 1675 if (!pEnv->IsJSInitiated()) { |
1768 bFormated = FALSE; | 1676 bFormated = FALSE; |
1769 return sValue; | 1677 return sValue; |
1770 } | 1678 } |
1771 | 1679 |
1772 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 1680 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
1773 ASSERT(pRuntime != NULL); | |
1774 | |
1775 pRuntime->SetReaderDocument(m_pDocument); | 1681 pRuntime->SetReaderDocument(m_pDocument); |
1776 | 1682 |
1777 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) { | 1683 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) { |
1778 if (pFormField->CountSelectedItems() > 0) { | 1684 if (pFormField->CountSelectedItems() > 0) { |
1779 int index = pFormField->GetSelectedIndex(0); | 1685 int index = pFormField->GetSelectedIndex(0); |
1780 if (index >= 0) | 1686 if (index >= 0) |
1781 sValue = pFormField->GetOptionLabel(index); | 1687 sValue = pFormField->GetOptionLabel(index); |
1782 } | 1688 } |
1783 } | 1689 } |
1784 | 1690 |
1785 bFormated = FALSE; | 1691 bFormated = FALSE; |
1786 | 1692 |
1787 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 1693 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
1788 if (aAction && aAction.ActionExist(CPDF_AAction::Format)) { | 1694 if (aAction && aAction.ActionExist(CPDF_AAction::Format)) { |
1789 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); | 1695 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); |
1790 if (action) { | 1696 if (action) { |
1791 CFX_WideString script = action.GetJavaScript(); | 1697 CFX_WideString script = action.GetJavaScript(); |
1792 if (!script.IsEmpty()) { | 1698 if (!script.IsEmpty()) { |
1793 CFX_WideString Value = sValue; | 1699 CFX_WideString Value = sValue; |
1794 | 1700 |
1795 IJS_Context* pContext = pRuntime->NewContext(); | 1701 IJS_Context* pContext = pRuntime->NewContext(); |
1796 ASSERT(pContext != NULL); | |
1797 | |
1798 pContext->OnField_Format(pFormField, Value, TRUE); | 1702 pContext->OnField_Format(pFormField, Value, TRUE); |
1799 | 1703 |
1800 CFX_WideString sInfo; | 1704 CFX_WideString sInfo; |
1801 FX_BOOL bRet = pContext->RunScript(script, &sInfo); | 1705 FX_BOOL bRet = pContext->RunScript(script, &sInfo); |
1802 pRuntime->ReleaseContext(pContext); | 1706 pRuntime->ReleaseContext(pContext); |
1803 | 1707 |
1804 if (bRet) { | 1708 if (bRet) { |
1805 sValue = Value; | 1709 sValue = Value; |
1806 bFormated = TRUE; | 1710 bFormated = TRUE; |
1807 } | 1711 } |
1808 } | 1712 } |
1809 } | 1713 } |
1810 } | 1714 } |
1811 | 1715 |
1812 return sValue; | 1716 return sValue; |
1813 } | 1717 } |
1814 | 1718 |
1815 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, | 1719 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, |
1816 const FX_WCHAR* sValue, | 1720 const FX_WCHAR* sValue, |
1817 FX_BOOL bValueChanged) { | 1721 FX_BOOL bValueChanged) { |
1818 ASSERT(pFormField != NULL); | |
1819 | |
1820 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 1722 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
1821 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 1723 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
1822 ASSERT(pFormCtrl != NULL); | 1724 ASSERT(pFormCtrl); |
1823 | |
1824 ASSERT(m_pInterForm != NULL); | |
1825 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) | 1725 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) |
1826 pWidget->ResetAppearance(sValue, bValueChanged); | 1726 pWidget->ResetAppearance(sValue, bValueChanged); |
1827 } | 1727 } |
1828 } | 1728 } |
1829 | 1729 |
1830 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { | 1730 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { |
1831 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 1731 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
1832 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 1732 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
1833 ASSERT(pFormCtrl != NULL); | 1733 ASSERT(pFormCtrl); |
1834 | 1734 |
1835 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { | 1735 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { |
1836 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1736 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1837 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); | 1737 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); |
1838 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); | 1738 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
1839 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE); | 1739 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE); |
1840 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); | 1740 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); |
1841 | 1741 |
1842 pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, | 1742 pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, |
1843 rcBBox.bottom); | 1743 rcBBox.bottom); |
1844 } | 1744 } |
1845 } | 1745 } |
1846 } | 1746 } |
1847 | 1747 |
1848 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, | 1748 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, |
1849 CFX_WideString& csValue, | 1749 CFX_WideString& csValue, |
1850 FX_BOOL& bRC) { | 1750 FX_BOOL& bRC) { |
1851 ASSERT(pFormField != NULL); | |
1852 | |
1853 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 1751 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
1854 if (aAction && aAction.ActionExist(CPDF_AAction::KeyStroke)) { | 1752 if (aAction && aAction.ActionExist(CPDF_AAction::KeyStroke)) { |
1855 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); | 1753 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); |
1856 if (action) { | 1754 if (action) { |
1857 ASSERT(m_pDocument != NULL); | |
1858 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1755 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1859 ASSERT(pEnv != NULL); | |
1860 | |
1861 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | 1756 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
1862 ASSERT(pActionHandler != NULL); | |
1863 | |
1864 PDFSDK_FieldAction fa; | 1757 PDFSDK_FieldAction fa; |
1865 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); | 1758 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); |
1866 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); | 1759 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); |
1867 fa.sValue = csValue; | 1760 fa.sValue = csValue; |
1868 | 1761 |
1869 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, | 1762 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, |
1870 m_pDocument, pFormField, fa); | 1763 m_pDocument, pFormField, fa); |
1871 bRC = fa.bRC; | 1764 bRC = fa.bRC; |
1872 } | 1765 } |
1873 } | 1766 } |
1874 } | 1767 } |
1875 | 1768 |
1876 void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, | 1769 void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, |
1877 CFX_WideString& csValue, | 1770 CFX_WideString& csValue, |
1878 FX_BOOL& bRC) { | 1771 FX_BOOL& bRC) { |
1879 ASSERT(pFormField != NULL); | |
1880 | |
1881 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 1772 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
1882 if (aAction && aAction.ActionExist(CPDF_AAction::Validate)) { | 1773 if (aAction && aAction.ActionExist(CPDF_AAction::Validate)) { |
1883 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); | 1774 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); |
1884 if (action) { | 1775 if (action) { |
1885 ASSERT(m_pDocument != NULL); | |
1886 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1776 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1887 ASSERT(pEnv != NULL); | |
1888 | |
1889 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | 1777 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
1890 ASSERT(pActionHandler != NULL); | |
1891 | |
1892 PDFSDK_FieldAction fa; | 1778 PDFSDK_FieldAction fa; |
1893 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); | 1779 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); |
1894 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); | 1780 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); |
1895 fa.sValue = csValue; | 1781 fa.sValue = csValue; |
1896 | 1782 |
1897 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, | 1783 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, |
1898 m_pDocument, pFormField, fa); | 1784 m_pDocument, pFormField, fa); |
1899 bRC = fa.bRC; | 1785 bRC = fa.bRC; |
1900 } | 1786 } |
1901 } | 1787 } |
1902 } | 1788 } |
1903 | 1789 |
1904 /* ----------------------------- action ----------------------------- */ | |
1905 | |
1906 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { | 1790 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { |
1907 ASSERT(action); | 1791 ASSERT(action); |
1908 | 1792 |
1909 CPDF_ActionFields af = action.GetWidgets(); | 1793 CPDF_ActionFields af = action.GetWidgets(); |
1910 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 1794 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
1911 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 1795 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
1912 | 1796 |
1913 FX_BOOL bHide = action.GetHideStatus(); | 1797 FX_BOOL bHide = action.GetHideStatus(); |
1914 FX_BOOL bChanged = FALSE; | 1798 FX_BOOL bChanged = FALSE; |
1915 | 1799 |
(...skipping 14 matching lines...) Expand all Loading... |
1930 pWidget->GetPageView()->UpdateView(pWidget); | 1814 pWidget->GetPageView()->UpdateView(pWidget); |
1931 bChanged = TRUE; | 1815 bChanged = TRUE; |
1932 } | 1816 } |
1933 } | 1817 } |
1934 } | 1818 } |
1935 | 1819 |
1936 return bChanged; | 1820 return bChanged; |
1937 } | 1821 } |
1938 | 1822 |
1939 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { | 1823 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { |
1940 ASSERT(m_pInterForm != NULL); | |
1941 CFX_WideString sDestination = action.GetFilePath(); | 1824 CFX_WideString sDestination = action.GetFilePath(); |
1942 if (sDestination.IsEmpty()) | 1825 if (sDestination.IsEmpty()) |
1943 return FALSE; | 1826 return FALSE; |
1944 | 1827 |
1945 CPDF_Dictionary* pActionDict = action.GetDict(); | 1828 CPDF_Dictionary* pActionDict = action.GetDict(); |
1946 if (pActionDict->KeyExist("Fields")) { | 1829 if (pActionDict->KeyExist("Fields")) { |
1947 CPDF_ActionFields af = action.GetWidgets(); | 1830 CPDF_ActionFields af = action.GetWidgets(); |
1948 FX_DWORD dwFlags = action.GetFlags(); | 1831 FX_DWORD dwFlags = action.GetFlags(); |
1949 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 1832 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
1950 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 1833 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2043 const CFX_WideString& sFileExt) { | 1926 const CFX_WideString& sFileExt) { |
2044 CFX_WideString sFileName; | 1927 CFX_WideString sFileName; |
2045 return L""; | 1928 return L""; |
2046 } | 1929 } |
2047 | 1930 |
2048 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, | 1931 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, |
2049 FX_BOOL bUrlEncoded) { | 1932 FX_BOOL bUrlEncoded) { |
2050 if (sDestination.IsEmpty()) | 1933 if (sDestination.IsEmpty()) |
2051 return FALSE; | 1934 return FALSE; |
2052 | 1935 |
| 1936 if (!m_pDocument || !m_pInterForm) |
| 1937 return FALSE; |
| 1938 |
2053 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1939 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2054 ASSERT(pEnv != NULL); | |
2055 | |
2056 if (!m_pDocument) | |
2057 return FALSE; | |
2058 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); | 1940 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); |
2059 | |
2060 if (!m_pInterForm) | |
2061 return FALSE; | |
2062 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); | 1941 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); |
2063 if (!pFDFDoc) | 1942 if (!pFDFDoc) |
2064 return FALSE; | 1943 return FALSE; |
2065 | 1944 |
2066 CFX_ByteTextBuf FdfBuffer; | 1945 CFX_ByteTextBuf FdfBuffer; |
2067 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); | 1946 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); |
2068 delete pFDFDoc; | 1947 delete pFDFDoc; |
2069 if (!bRet) | 1948 if (!bRet) |
2070 return FALSE; | 1949 return FALSE; |
2071 | 1950 |
2072 uint8_t* pBuffer = FdfBuffer.GetBuffer(); | 1951 uint8_t* pBuffer = FdfBuffer.GetBuffer(); |
2073 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 1952 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); |
2074 | 1953 |
2075 if (bUrlEncoded) { | 1954 if (bUrlEncoded) { |
2076 if (!FDFToURLEncodedData(pBuffer, nBufSize)) | 1955 if (!FDFToURLEncodedData(pBuffer, nBufSize)) |
2077 return FALSE; | 1956 return FALSE; |
2078 } | 1957 } |
2079 | 1958 |
2080 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); | 1959 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); |
2081 | 1960 |
2082 if (bUrlEncoded) { | 1961 if (bUrlEncoded) { |
2083 FX_Free(pBuffer); | 1962 FX_Free(pBuffer); |
2084 pBuffer = NULL; | 1963 pBuffer = NULL; |
2085 } | 1964 } |
2086 | 1965 |
2087 return TRUE; | 1966 return TRUE; |
2088 } | 1967 } |
2089 | 1968 |
2090 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { | 1969 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { |
2091 ASSERT(m_pInterForm != NULL); | |
2092 ASSERT(m_pDocument != NULL); | |
2093 | |
2094 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); | 1970 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); |
2095 if (!pFDF) | 1971 if (!pFDF) |
2096 return FALSE; | 1972 return FALSE; |
2097 | 1973 |
2098 FX_BOOL bRet = pFDF->WriteBuf(textBuf); | 1974 FX_BOOL bRet = pFDF->WriteBuf(textBuf); |
2099 delete pFDF; | 1975 delete pFDF; |
2100 | 1976 |
2101 return bRet; | 1977 return bRet; |
2102 } | 1978 } |
2103 | 1979 |
(...skipping 23 matching lines...) Expand all Loading... |
2127 if (pObject && pObject->IsString()) { | 2003 if (pObject && pObject->IsString()) { |
2128 CFX_WideString csName = pObject->GetUnicodeText(); | 2004 CFX_WideString csName = pObject->GetUnicodeText(); |
2129 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); | 2005 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); |
2130 if (pField) | 2006 if (pField) |
2131 fields.push_back(pField); | 2007 fields.push_back(pField); |
2132 } | 2008 } |
2133 } | 2009 } |
2134 return fields; | 2010 return fields; |
2135 } | 2011 } |
2136 | 2012 |
2137 /* ----------------------------- CPDF_FormNotify ----------------------------- | |
2138 */ | |
2139 | |
2140 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, | 2013 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, |
2141 CFX_WideString& csValue) { | 2014 CFX_WideString& csValue) { |
2142 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2015 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2143 int nType = pFormField->GetFieldType(); | 2016 int nType = pFormField->GetFieldType(); |
2144 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 2017 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
2145 FX_BOOL bRC = TRUE; | 2018 FX_BOOL bRC = TRUE; |
2146 OnKeyStrokeCommit(pFormField, csValue, bRC); | 2019 OnKeyStrokeCommit(pFormField, csValue, bRC); |
2147 if (bRC) { | 2020 if (bRC) { |
2148 OnValidate(pFormField, csValue, bRC); | 2021 OnValidate(pFormField, csValue, bRC); |
2149 return bRC ? 1 : -1; | 2022 return bRC ? 1 : -1; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 | 2140 |
2268 /* ------------------------- CBA_AnnotIterator ------------------------- */ | 2141 /* ------------------------- CBA_AnnotIterator ------------------------- */ |
2269 | 2142 |
2270 CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView, | 2143 CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView, |
2271 const CFX_ByteString& sType, | 2144 const CFX_ByteString& sType, |
2272 const CFX_ByteString& sSubType) | 2145 const CFX_ByteString& sSubType) |
2273 : m_pPageView(pPageView), | 2146 : m_pPageView(pPageView), |
2274 m_sType(sType), | 2147 m_sType(sType), |
2275 m_sSubType(sSubType), | 2148 m_sSubType(sSubType), |
2276 m_nTabs(BAI_STRUCTURE) { | 2149 m_nTabs(BAI_STRUCTURE) { |
2277 ASSERT(m_pPageView != NULL); | |
2278 | |
2279 CPDF_Page* pPDFPage = m_pPageView->GetPDFPage(); | 2150 CPDF_Page* pPDFPage = m_pPageView->GetPDFPage(); |
2280 ASSERT(pPDFPage != NULL); | |
2281 ASSERT(pPDFPage->m_pFormDict != NULL); | |
2282 | |
2283 CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetString("Tabs"); | 2151 CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetString("Tabs"); |
2284 | 2152 |
2285 if (sTabs == "R") { | 2153 if (sTabs == "R") { |
2286 m_nTabs = BAI_ROW; | 2154 m_nTabs = BAI_ROW; |
2287 } else if (sTabs == "C") { | 2155 } else if (sTabs == "C") { |
2288 m_nTabs = BAI_COLUMN; | 2156 m_nTabs = BAI_COLUMN; |
2289 } else { | 2157 } else { |
2290 m_nTabs = BAI_STRUCTURE; | 2158 m_nTabs = BAI_STRUCTURE; |
2291 } | 2159 } |
2292 | 2160 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); | 2203 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); |
2336 | 2204 |
2337 if (rcAnnot1.left < rcAnnot2.left) | 2205 if (rcAnnot1.left < rcAnnot2.left) |
2338 return -1; | 2206 return -1; |
2339 if (rcAnnot1.left > rcAnnot2.left) | 2207 if (rcAnnot1.left > rcAnnot2.left) |
2340 return 1; | 2208 return 1; |
2341 return 0; | 2209 return 0; |
2342 } | 2210 } |
2343 | 2211 |
2344 int CBA_AnnotIterator::CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { | 2212 int CBA_AnnotIterator::CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { |
2345 ASSERT(p1 != NULL); | 2213 ASSERT(p1); |
2346 ASSERT(p2 != NULL); | 2214 ASSERT(p2); |
2347 | 2215 |
2348 CPDF_Rect rcAnnot1 = GetAnnotRect(p1); | 2216 CPDF_Rect rcAnnot1 = GetAnnotRect(p1); |
2349 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); | 2217 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); |
2350 | 2218 |
2351 if (rcAnnot1.top < rcAnnot2.top) | 2219 if (rcAnnot1.top < rcAnnot2.top) |
2352 return -1; | 2220 return -1; |
2353 if (rcAnnot1.top > rcAnnot2.top) | 2221 if (rcAnnot1.top > rcAnnot2.top) |
2354 return 1; | 2222 return 1; |
2355 return 0; | 2223 return 0; |
2356 } | 2224 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 break; | 2356 break; |
2489 } | 2357 } |
2490 } | 2358 } |
2491 } | 2359 } |
2492 | 2360 |
2493 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { | 2361 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { |
2494 CPDF_Rect rcAnnot; | 2362 CPDF_Rect rcAnnot; |
2495 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2363 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
2496 return rcAnnot; | 2364 return rcAnnot; |
2497 } | 2365 } |
OLD | NEW |