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 "../../third_party/base/nonstd_unique_ptr.h" | 7 #include "../../third_party/base/nonstd_unique_ptr.h" |
8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
9 #include "../include/fsdk_mgr.h" | 9 #include "../include/fsdk_mgr.h" |
10 #include "../include/fsdk_baseannot.h" | 10 #include "../include/fsdk_baseannot.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 m_nValueAge(0) | 30 m_nValueAge(0) |
31 { | 31 { |
32 ASSERT(m_pInterForm != NULL); | 32 ASSERT(m_pInterForm != NULL); |
33 } | 33 } |
34 | 34 |
35 CPDFSDK_Widget::~CPDFSDK_Widget() | 35 CPDFSDK_Widget::~CPDFSDK_Widget() |
36 { | 36 { |
37 | 37 |
38 } | 38 } |
39 | 39 |
40 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode m
ode) | 40 bool CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode
) |
41 { | 41 { |
42 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); | 42 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
43 if (pAP == NULL) return FALSE; | 43 if (pAP == NULL) return false; |
44 | 44 |
45 // Choose the right sub-ap | 45 // Choose the right sub-ap |
46 const FX_CHAR* ap_entry = "N"; | 46 const FX_CHAR* ap_entry = "N"; |
47 if (mode == CPDF_Annot::Down) | 47 if (mode == CPDF_Annot::Down) |
48 ap_entry = "D"; | 48 ap_entry = "D"; |
49 else if (mode == CPDF_Annot::Rollover) | 49 else if (mode == CPDF_Annot::Rollover) |
50 ap_entry = "R"; | 50 ap_entry = "R"; |
51 if (!pAP->KeyExist(ap_entry)) | 51 if (!pAP->KeyExist(ap_entry)) |
52 ap_entry = "N"; | 52 ap_entry = "N"; |
53 | 53 |
54 // Get the AP stream or subdirectory | 54 // Get the AP stream or subdirectory |
55 CPDF_Object* psub = pAP->GetElementValue(ap_entry); | 55 CPDF_Object* psub = pAP->GetElementValue(ap_entry); |
56 if (psub == NULL) return FALSE; | 56 if (psub == NULL) return false; |
57 | 57 |
58 int nFieldType = GetFieldType(); | 58 int nFieldType = GetFieldType(); |
59 switch (nFieldType) | 59 switch (nFieldType) |
60 { | 60 { |
61 case FIELDTYPE_PUSHBUTTON: | 61 case FIELDTYPE_PUSHBUTTON: |
62 case FIELDTYPE_COMBOBOX: | 62 case FIELDTYPE_COMBOBOX: |
63 case FIELDTYPE_LISTBOX: | 63 case FIELDTYPE_LISTBOX: |
64 case FIELDTYPE_TEXTFIELD: | 64 case FIELDTYPE_TEXTFIELD: |
65 case FIELDTYPE_SIGNATURE: | 65 case FIELDTYPE_SIGNATURE: |
66 return psub->GetType() == PDFOBJ_STREAM; | 66 return psub->GetType() == PDFOBJ_STREAM; |
67 case FIELDTYPE_CHECKBOX: | 67 case FIELDTYPE_CHECKBOX: |
68 case FIELDTYPE_RADIOBUTTON: | 68 case FIELDTYPE_RADIOBUTTON: |
69 if (psub->GetType() == PDFOBJ_DICTIONARY) { | 69 if (psub->GetType() == PDFOBJ_DICTIONARY) { |
70 CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)psub; | 70 CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)psub; |
71 return pSubDict->GetStream(GetAppState()) != NULL; | 71 return pSubDict->GetStream(GetAppState()) != NULL; |
72 } | 72 } |
73 return FALSE; | 73 return false; |
74 } | 74 } |
75 | 75 |
76 return TRUE; | 76 return true; |
77 } | 77 } |
78 | 78 |
79 int CPDFSDK_Widget::GetFieldType() const | 79 int CPDFSDK_Widget::GetFieldType() const |
80 { | 80 { |
81 CPDF_FormField* pField = GetFormField(); | 81 CPDF_FormField* pField = GetFormField(); |
82 ASSERT(pField != NULL); | 82 ASSERT(pField != NULL); |
83 | 83 |
84 return pField->GetFieldType(); | 84 return pField->GetFieldType(); |
85 } | 85 } |
86 | 86 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 134 } |
135 | 135 |
136 int CPDFSDK_Widget::GetRotate() const | 136 int CPDFSDK_Widget::GetRotate() const |
137 { | 137 { |
138 CPDF_FormControl* pCtrl = GetFormControl(); | 138 CPDF_FormControl* pCtrl = GetFormControl(); |
139 ASSERT(pCtrl != NULL); | 139 ASSERT(pCtrl != NULL); |
140 | 140 |
141 return pCtrl->GetRotation() % 360; | 141 return pCtrl->GetRotation() % 360; |
142 } | 142 } |
143 | 143 |
144 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const | 144 bool CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const |
145 { | 145 { |
146 CPDF_FormControl* pFormCtrl = GetFormControl(); | 146 CPDF_FormControl* pFormCtrl = GetFormControl(); |
147 ASSERT(pFormCtrl != NULL); | 147 ASSERT(pFormCtrl != NULL); |
148 | 148 |
149 int iColorType = 0; | 149 int iColorType = 0; |
150 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); | 150 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); |
151 | 151 |
152 return iColorType != COLORTYPE_TRANSPARENT; | 152 return iColorType != COLORTYPE_TRANSPARENT; |
153 } | 153 } |
154 | 154 |
155 FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const | 155 bool CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const |
156 { | 156 { |
157 CPDF_FormControl* pFormCtrl = GetFormControl(); | 157 CPDF_FormControl* pFormCtrl = GetFormControl(); |
158 ASSERT(pFormCtrl != NULL); | 158 ASSERT(pFormCtrl != NULL); |
159 | 159 |
160 int iColorType = 0; | 160 int iColorType = 0; |
161 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); | 161 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); |
162 | 162 |
163 return iColorType != COLORTYPE_TRANSPARENT; | 163 return iColorType != COLORTYPE_TRANSPARENT; |
164 } | 164 } |
165 | 165 |
166 FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const | 166 bool CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const |
167 { | 167 { |
168 CPDF_FormControl* pFormCtrl = GetFormControl(); | 168 CPDF_FormControl* pFormCtrl = GetFormControl(); |
169 ASSERT(pFormCtrl != NULL); | 169 ASSERT(pFormCtrl != NULL); |
170 | 170 |
171 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); | 171 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); |
172 if (da.HasColor()) | 172 if (da.HasColor()) |
173 { | 173 { |
174 FX_ARGB argb; | 174 FX_ARGB argb; |
175 int iColorType = COLORTYPE_TRANSPARENT; | 175 int iColorType = COLORTYPE_TRANSPARENT; |
176 da.GetColor(argb, iColorType); | 176 da.GetColor(argb, iColorType); |
177 color = FX_ARGBTOCOLORREF(argb); | 177 color = FX_ARGBTOCOLORREF(argb); |
178 | 178 |
179 return iColorType != COLORTYPE_TRANSPARENT; | 179 return iColorType != COLORTYPE_TRANSPARENT; |
180 } | 180 } |
181 | 181 |
182 return FALSE; | 182 return false; |
183 } | 183 } |
184 | 184 |
185 FX_FLOAT CPDFSDK_Widget::GetFontSize() const | 185 FX_FLOAT CPDFSDK_Widget::GetFontSize() const |
186 { | 186 { |
187 CPDF_FormControl* pFormCtrl = GetFormControl(); | 187 CPDF_FormControl* pFormCtrl = GetFormControl(); |
188 ASSERT(pFormCtrl != NULL); | 188 ASSERT(pFormCtrl != NULL); |
189 | 189 |
190 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); | 190 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); |
191 CFX_ByteString csFont = ""; | 191 CFX_ByteString csFont = ""; |
192 FX_FLOAT fFontSize = 0.0f; | 192 FX_FLOAT fFontSize = 0.0f; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 228 } |
229 | 229 |
230 int CPDFSDK_Widget::CountOptions() const | 230 int CPDFSDK_Widget::CountOptions() const |
231 { | 231 { |
232 CPDF_FormField* pFormField = GetFormField(); | 232 CPDF_FormField* pFormField = GetFormField(); |
233 ASSERT(pFormField != NULL); | 233 ASSERT(pFormField != NULL); |
234 | 234 |
235 return pFormField->CountOptions(); | 235 return pFormField->CountOptions(); |
236 } | 236 } |
237 | 237 |
238 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const | 238 bool CPDFSDK_Widget::IsOptionSelected(int nIndex) const |
239 { | 239 { |
240 CPDF_FormField* pFormField = GetFormField(); | 240 CPDF_FormField* pFormField = GetFormField(); |
241 ASSERT(pFormField != NULL); | 241 ASSERT(pFormField != NULL); |
242 | 242 |
243 return pFormField->IsItemSelected(nIndex); | 243 return pFormField->IsItemSelected(nIndex); |
244 } | 244 } |
245 | 245 |
246 int CPDFSDK_Widget::GetTopVisibleIndex() const | 246 int CPDFSDK_Widget::GetTopVisibleIndex() const |
247 { | 247 { |
248 CPDF_FormField* pFormField = GetFormField(); | 248 CPDF_FormField* pFormField = GetFormField(); |
249 ASSERT(pFormField != NULL); | 249 ASSERT(pFormField != NULL); |
250 | 250 |
251 return pFormField->GetTopVisibleIndex(); | 251 return pFormField->GetTopVisibleIndex(); |
252 } | 252 } |
253 | 253 |
254 FX_BOOL CPDFSDK_Widget::IsChecked() const | 254 bool CPDFSDK_Widget::IsChecked() const |
255 { | 255 { |
256 CPDF_FormControl* pFormCtrl = GetFormControl(); | 256 CPDF_FormControl* pFormCtrl = GetFormControl(); |
257 ASSERT(pFormCtrl != NULL); | 257 ASSERT(pFormCtrl != NULL); |
258 | 258 |
259 return pFormCtrl->IsChecked(); | 259 return pFormCtrl->IsChecked(); |
260 } | 260 } |
261 | 261 |
262 int CPDFSDK_Widget::GetAlignment() const | 262 int CPDFSDK_Widget::GetAlignment() const |
263 { | 263 { |
264 CPDF_FormControl* pFormCtrl = GetFormControl(); | 264 CPDF_FormControl* pFormCtrl = GetFormControl(); |
265 ASSERT(pFormCtrl != NULL); | 265 ASSERT(pFormCtrl != NULL); |
266 | 266 |
267 return pFormCtrl->GetControlAlignment(); | 267 return pFormCtrl->GetControlAlignment(); |
268 } | 268 } |
269 | 269 |
270 int CPDFSDK_Widget::GetMaxLen() const | 270 int CPDFSDK_Widget::GetMaxLen() const |
271 { | 271 { |
272 CPDF_FormField* pFormField = GetFormField(); | 272 CPDF_FormField* pFormField = GetFormField(); |
273 ASSERT(pFormField != NULL); | 273 ASSERT(pFormField != NULL); |
274 | 274 |
275 return pFormField->GetMaxLen(); | 275 return pFormField->GetMaxLen(); |
276 } | 276 } |
277 | 277 |
278 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) | 278 void CPDFSDK_Widget::SetCheck(bool bChecked, bool bNotify) |
279 { | 279 { |
280 CPDF_FormControl* pFormCtrl = GetFormControl(); | 280 CPDF_FormControl* pFormCtrl = GetFormControl(); |
281 ASSERT(pFormCtrl != NULL); | 281 ASSERT(pFormCtrl != NULL); |
282 | 282 |
283 CPDF_FormField* pFormField = pFormCtrl->GetField(); | 283 CPDF_FormField* pFormField = pFormCtrl->GetField(); |
284 ASSERT(pFormField != NULL); | 284 ASSERT(pFormField != NULL); |
285 | 285 |
286 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, b
Notify); | 286 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, b
Notify); |
287 } | 287 } |
288 | 288 |
289 void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) | 289 void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, bool bNotify) |
290 { | 290 { |
291 CPDF_FormField* pFormField = GetFormField(); | 291 CPDF_FormField* pFormField = GetFormField(); |
292 ASSERT(pFormField != NULL); | 292 ASSERT(pFormField != NULL); |
293 | 293 |
294 pFormField->SetValue(sValue, bNotify); | 294 pFormField->SetValue(sValue, bNotify); |
295 } | 295 } |
296 | 296 |
297 void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) | 297 void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) |
298 { | 298 { |
299 } | 299 } |
300 void CPDFSDK_Widget::SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bN
otify) | 300 void CPDFSDK_Widget::SetOptionSelection(int index, bool bSelected, bool bNotify) |
301 { | 301 { |
302 CPDF_FormField* pFormField = GetFormField(); | 302 CPDF_FormField* pFormField = GetFormField(); |
303 ASSERT(pFormField != NULL); | 303 ASSERT(pFormField != NULL); |
304 | 304 |
305 pFormField->SetItemSelection(index, bSelected, bNotify); | 305 pFormField->SetItemSelection(index, bSelected, bNotify); |
306 } | 306 } |
307 | 307 |
308 void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) | 308 void CPDFSDK_Widget::ClearSelection(bool bNotify) |
309 { | 309 { |
310 CPDF_FormField* pFormField = GetFormField(); | 310 CPDF_FormField* pFormField = GetFormField(); |
311 ASSERT(pFormField != NULL); | 311 ASSERT(pFormField != NULL); |
312 | 312 |
313 pFormField->ClearSelection(bNotify); | 313 pFormField->ClearSelection(bNotify); |
314 } | 314 } |
315 | 315 |
316 void CPDFSDK_Widget::SetTopVisibleIndex(int index) | 316 void CPDFSDK_Widget::SetTopVisibleIndex(int index) |
317 { | 317 { |
318 } | 318 } |
319 | 319 |
320 void CPDFSDK_Widget::SetAppModified() | 320 void CPDFSDK_Widget::SetAppModified() |
321 { | 321 { |
322 m_bAppModified = TRUE; | 322 m_bAppModified = true; |
323 } | 323 } |
324 | 324 |
325 void CPDFSDK_Widget::ClearAppModified() | 325 void CPDFSDK_Widget::ClearAppModified() |
326 { | 326 { |
327 m_bAppModified = FALSE; | 327 m_bAppModified = false; |
328 } | 328 } |
329 | 329 |
330 FX_BOOL CPDFSDK_Widget::IsAppModified() const | 330 bool CPDFSDK_Widget::IsAppModified() const |
331 { | 331 { |
332 return m_bAppModified; | 332 return m_bAppModified; |
333 } | 333 } |
334 | 334 |
335 void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChang
ed) | 335 void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue, bool bValueChanged) |
336 { | 336 { |
337 SetAppModified(); | 337 SetAppModified(); |
338 | 338 |
339 m_nAppAge++; | 339 m_nAppAge++; |
340 if (m_nAppAge > 999999) | 340 if (m_nAppAge > 999999) |
341 m_nAppAge = 0; | 341 m_nAppAge = 0; |
342 if (bValueChanged) | 342 if (bValueChanged) |
343 m_nValueAge++; | 343 m_nValueAge++; |
344 | 344 |
345 int nFieldType = GetFieldType(); | 345 int nFieldType = GetFieldType(); |
(...skipping 17 matching lines...) Expand all Loading... |
363 break; | 363 break; |
364 case FIELDTYPE_TEXTFIELD: | 364 case FIELDTYPE_TEXTFIELD: |
365 ResetAppearance_TextField(sValue); | 365 ResetAppearance_TextField(sValue); |
366 break; | 366 break; |
367 } | 367 } |
368 | 368 |
369 ASSERT(m_pAnnot != NULL); | 369 ASSERT(m_pAnnot != NULL); |
370 m_pAnnot->ClearCachedAP(); | 370 m_pAnnot->ClearCachedAP(); |
371 } | 371 } |
372 | 372 |
373 CFX_WideString CPDFSDK_Widget::OnFormat(FX_BOOL& bFormated) | 373 CFX_WideString CPDFSDK_Widget::OnFormat(bool& bFormated) |
374 { | 374 { |
375 CPDF_FormField* pFormField = GetFormField(); | 375 CPDF_FormField* pFormField = GetFormField(); |
376 ASSERT(pFormField != NULL); | 376 ASSERT(pFormField != NULL); |
377 return m_pInterForm->OnFormat(pFormField, bFormated); | 377 return m_pInterForm->OnFormat(pFormField, bFormated); |
378 } | 378 } |
379 | 379 |
380 void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) | 380 void CPDFSDK_Widget::ResetFieldAppearance(bool bValueChanged) |
381 { | 381 { |
382 CPDF_FormField* pFormField = GetFormField(); | 382 CPDF_FormField* pFormField = GetFormField(); |
383 ASSERT(pFormField != NULL); | 383 ASSERT(pFormField != NULL); |
384 | 384 |
385 ASSERT(m_pInterForm != NULL); | 385 ASSERT(m_pInterForm != NULL); |
386 | 386 |
387 m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); | 387 m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); |
388 } | 388 } |
389 | 389 |
390 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Mat
rix* pUser2Device, | 390 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Mat
rix* pUser2Device, |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 | 1010 |
1011 CFX_ByteTextBuf sBody, sLines; | 1011 CFX_ByteTextBuf sBody, sLines; |
1012 | 1012 |
1013 CPDF_Rect rcClient = GetClientRect(); | 1013 CPDF_Rect rcClient = GetClientRect(); |
1014 CPDF_Rect rcButton = rcClient; | 1014 CPDF_Rect rcButton = rcClient; |
1015 rcButton.left = rcButton.right - 13; | 1015 rcButton.left = rcButton.right - 13; |
1016 rcButton.Normalize(); | 1016 rcButton.Normalize(); |
1017 | 1017 |
1018 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) | 1018 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) |
1019 { | 1019 { |
1020 pEdit->EnableRefresh(FALSE); | 1020 pEdit->EnableRefresh(false); |
1021 | 1021 |
1022 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1022 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1023 ASSERT(pDoc != NULL); | 1023 ASSERT(pDoc != NULL); |
1024 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1024 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
1025 CBA_FontMap FontMap(this,pEnv->GetSysHandler()); | 1025 CBA_FontMap FontMap(this,pEnv->GetSysHandler()); |
1026 FontMap.Initial(); | 1026 FontMap.Initial(); |
1027 pEdit->SetFontMap(&FontMap); | 1027 pEdit->SetFontMap(&FontMap); |
1028 | 1028 |
1029 CPDF_Rect rcEdit = rcClient; | 1029 CPDF_Rect rcEdit = rcClient; |
1030 rcEdit.right = rcButton.left; | 1030 rcEdit.right = rcButton.left; |
1031 rcEdit.Normalize(); | 1031 rcEdit.Normalize(); |
1032 | 1032 |
1033 pEdit->SetPlateRect(rcEdit); | 1033 pEdit->SetPlateRect(rcEdit); |
1034 pEdit->SetAlignmentV(1); | 1034 pEdit->SetAlignmentV(1); |
1035 | 1035 |
1036 FX_FLOAT fFontSize = GetFontSize(); | 1036 FX_FLOAT fFontSize = GetFontSize(); |
1037 if (IsFloatZero(fFontSize)) | 1037 if (IsFloatZero(fFontSize)) |
1038 pEdit->SetAutoFontSize(TRUE); | 1038 pEdit->SetAutoFontSize(true); |
1039 else | 1039 else |
1040 pEdit->SetFontSize(fFontSize); | 1040 pEdit->SetFontSize(fFontSize); |
1041 | 1041 |
1042 pEdit->Initialize(); | 1042 pEdit->Initialize(); |
1043 | 1043 |
1044 if (sValue) | 1044 if (sValue) |
1045 pEdit->SetText(sValue); | 1045 pEdit->SetText(sValue); |
1046 else | 1046 else |
1047 { | 1047 { |
1048 int32_t nCurSel = pField->GetSelectedIndex(0); | 1048 int32_t nCurSel = pField->GetSelectedIndex(0); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 ASSERT(pControl != NULL); | 1086 ASSERT(pControl != NULL); |
1087 CPDF_FormField* pField = pControl->GetField(); | 1087 CPDF_FormField* pField = pControl->GetField(); |
1088 ASSERT(pField != NULL); | 1088 ASSERT(pField != NULL); |
1089 | 1089 |
1090 CPDF_Rect rcClient = GetClientRect(); | 1090 CPDF_Rect rcClient = GetClientRect(); |
1091 | 1091 |
1092 CFX_ByteTextBuf sBody, sLines; | 1092 CFX_ByteTextBuf sBody, sLines; |
1093 | 1093 |
1094 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) | 1094 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) |
1095 { | 1095 { |
1096 pEdit->EnableRefresh(FALSE); | 1096 pEdit->EnableRefresh(false); |
1097 | 1097 |
1098 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1098 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1099 ASSERT(pDoc != NULL); | 1099 ASSERT(pDoc != NULL); |
1100 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1100 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
1101 | 1101 |
1102 CBA_FontMap FontMap(this,pEnv->GetSysHandler()); | 1102 CBA_FontMap FontMap(this,pEnv->GetSysHandler()); |
1103 FontMap.Initial(); | 1103 FontMap.Initial(); |
1104 pEdit->SetFontMap(&FontMap); | 1104 pEdit->SetFontMap(&FontMap); |
1105 | 1105 |
1106 pEdit->SetPlateRect(CPDF_Rect(rcClient.left,0.0f,rcClient.right,0.0f)); | 1106 pEdit->SetPlateRect(CPDF_Rect(rcClient.left,0.0f,rcClient.right,0.0f)); |
1107 | 1107 |
1108 FX_FLOAT fFontSize = GetFontSize(); | 1108 FX_FLOAT fFontSize = GetFontSize(); |
1109 | 1109 |
1110 if (IsFloatZero(fFontSize)) | 1110 if (IsFloatZero(fFontSize)) |
1111 pEdit->SetFontSize(12.0f); | 1111 pEdit->SetFontSize(12.0f); |
1112 else | 1112 else |
1113 pEdit->SetFontSize(fFontSize); | 1113 pEdit->SetFontSize(fFontSize); |
1114 | 1114 |
1115 pEdit->Initialize(); | 1115 pEdit->Initialize(); |
1116 | 1116 |
1117 CFX_ByteTextBuf sList; | 1117 CFX_ByteTextBuf sList; |
1118 FX_FLOAT fy = rcClient.top; | 1118 FX_FLOAT fy = rcClient.top; |
1119 | 1119 |
1120 int32_t nTop = pField->GetTopVisibleIndex(); | 1120 int32_t nTop = pField->GetTopVisibleIndex(); |
1121 int32_t nCount = pField->CountOptions(); | 1121 int32_t nCount = pField->CountOptions(); |
1122 int32_t nSelCount = pField->CountSelectedItems(); | 1122 int32_t nSelCount = pField->CountSelectedItems(); |
1123 | 1123 |
1124 for (int32_t i=nTop; i<nCount; i++) | 1124 for (int32_t i=nTop; i<nCount; i++) |
1125 { | 1125 { |
1126 FX_BOOL bSelected = FALSE; | 1126 bool bSelected = false; |
1127 for (int32_t j=0; j<nSelCount; j++) | 1127 for (int32_t j=0; j<nSelCount; j++) |
1128 { | 1128 { |
1129 if (pField->GetSelectedIndex(j) == i) | 1129 if (pField->GetSelectedIndex(j) == i) |
1130 { | 1130 { |
1131 bSelected = TRUE; | 1131 bSelected = true; |
1132 break; | 1132 break; |
1133 } | 1133 } |
1134 } | 1134 } |
1135 | 1135 |
1136 pEdit->SetText(pField->GetOptionLabel(i).c_str()); | 1136 pEdit->SetText(pField->GetOptionLabel(i).c_str()); |
1137 | 1137 |
1138 CPDF_Rect rcContent = pEdit->GetContentRect(); | 1138 CPDF_Rect rcContent = pEdit->GetContentRect(); |
1139 FX_FLOAT fItemHeight = rcContent.Height(); | 1139 FX_FLOAT fItemHeight = rcContent.Height(); |
1140 | 1140 |
1141 if (bSelected) | 1141 if (bSelected) |
1142 { | 1142 { |
1143 CPDF_Rect rcItem = CPDF_Rect(rcClient.left,fy-fItemHeight,rcClie
nt.right,fy); | 1143 CPDF_Rect rcItem = CPDF_Rect(rcClient.left,fy-fItemHeight,rcClie
nt.right,fy); |
1144 sList << "q\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLOR
TYPE_RGB,0,51.0f/255.0f,113.0f/255.0f),TRUE) | 1144 sList << "q\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLOR
TYPE_RGB,0,51.0f/255.0f,113.0f/255.0f),true) |
1145 << rcItem.left << " " << rcItem.bottom << " " << rcItem.Widt
h() << " " << rcItem.Height() << " re f\n" << "Q\n"; | 1145 << rcItem.left << " " << rcItem.bottom << " " << rcItem.Widt
h() << " " << rcItem.Height() << " re f\n" << "Q\n"; |
1146 | 1146 |
1147 sList << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLO
RTYPE_GRAY,1),TRUE) << | 1147 sList << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLO
RTYPE_GRAY,1),true) << |
1148 CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "
ET\n"; | 1148 CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "
ET\n"; |
1149 } | 1149 } |
1150 else | 1150 else |
1151 { | 1151 { |
1152 CPWL_Color crText = GetTextPWLColor(); | 1152 CPWL_Color crText = GetTextPWLColor(); |
1153 sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << | 1153 sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText,true) << |
1154 CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "ET\n
"; | 1154 CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "ET\n
"; |
1155 } | 1155 } |
1156 | 1156 |
1157 fy -= fItemHeight; | 1157 fy -= fItemHeight; |
1158 } | 1158 } |
1159 | 1159 |
1160 if (sList.GetSize() > 0) | 1160 if (sList.GetSize() > 0) |
1161 { | 1161 { |
1162 sBody << "/Tx BMC\n" << "q\n" << rcClient.left << " " << rcClient.bo
ttom << " " | 1162 sBody << "/Tx BMC\n" << "q\n" << rcClient.left << " " << rcClient.bo
ttom << " " |
1163 << rcClient.Width() << " " << rcClient.Height() << " re\nW\n
n\n"; | 1163 << rcClient.Width() << " " << rcClient.Height() << " re\nW\n
n\n"; |
(...skipping 12 matching lines...) Expand all Loading... |
1176 { | 1176 { |
1177 CPDF_FormControl* pControl = GetFormControl(); | 1177 CPDF_FormControl* pControl = GetFormControl(); |
1178 ASSERT(pControl != NULL); | 1178 ASSERT(pControl != NULL); |
1179 CPDF_FormField* pField = pControl->GetField(); | 1179 CPDF_FormField* pField = pControl->GetField(); |
1180 ASSERT(pField != NULL); | 1180 ASSERT(pField != NULL); |
1181 | 1181 |
1182 CFX_ByteTextBuf sBody, sLines; | 1182 CFX_ByteTextBuf sBody, sLines; |
1183 | 1183 |
1184 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) | 1184 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) |
1185 { | 1185 { |
1186 pEdit->EnableRefresh(FALSE); | 1186 pEdit->EnableRefresh(false); |
1187 | 1187 |
1188 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1188 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1189 ASSERT(pDoc != NULL); | 1189 ASSERT(pDoc != NULL); |
1190 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1190 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
1191 | 1191 |
1192 CBA_FontMap FontMap(this,pEnv->GetSysHandler());//, ISystemHandle::GetSy
stemHandler(m_pBaseForm->GetEnv())); | 1192 CBA_FontMap FontMap(this,pEnv->GetSysHandler());//, ISystemHandle::GetSy
stemHandler(m_pBaseForm->GetEnv())); |
1193 FontMap.Initial(); | 1193 FontMap.Initial(); |
1194 pEdit->SetFontMap(&FontMap); | 1194 pEdit->SetFontMap(&FontMap); |
1195 | 1195 |
1196 CPDF_Rect rcClient = GetClientRect(); | 1196 CPDF_Rect rcClient = GetClientRect(); |
1197 pEdit->SetPlateRect(rcClient); | 1197 pEdit->SetPlateRect(rcClient); |
1198 pEdit->SetAlignmentH(pControl->GetControlAlignment()); | 1198 pEdit->SetAlignmentH(pControl->GetControlAlignment()); |
1199 | 1199 |
1200 FX_DWORD dwFieldFlags = pField->GetFieldFlags(); | 1200 FX_DWORD dwFieldFlags = pField->GetFieldFlags(); |
1201 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; | 1201 bool bMultiLine = (dwFieldFlags >> 12) & 1; |
1202 | 1202 |
1203 if (bMultiLine) | 1203 if (bMultiLine) |
1204 { | 1204 { |
1205 pEdit->SetMultiLine(TRUE); | 1205 pEdit->SetMultiLine(true); |
1206 pEdit->SetAutoReturn(TRUE); | 1206 pEdit->SetAutoReturn(true); |
1207 } | 1207 } |
1208 else | 1208 else |
1209 { | 1209 { |
1210 pEdit->SetAlignmentV(1); | 1210 pEdit->SetAlignmentV(1); |
1211 } | 1211 } |
1212 | 1212 |
1213 FX_WORD subWord = 0; | 1213 FX_WORD subWord = 0; |
1214 if ((dwFieldFlags >> 13) & 1) | 1214 if ((dwFieldFlags >> 13) & 1) |
1215 { | 1215 { |
1216 subWord = '*'; | 1216 subWord = '*'; |
1217 pEdit->SetPasswordChar(subWord); | 1217 pEdit->SetPasswordChar(subWord); |
1218 } | 1218 } |
1219 | 1219 |
1220 int nMaxLen = pField->GetMaxLen(); | 1220 int nMaxLen = pField->GetMaxLen(); |
1221 FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1; | 1221 bool bCharArray = (dwFieldFlags >> 24) & 1; |
1222 FX_FLOAT fFontSize = GetFontSize(); | 1222 FX_FLOAT fFontSize = GetFontSize(); |
1223 | 1223 |
1224 if (nMaxLen > 0) | 1224 if (nMaxLen > 0) |
1225 { | 1225 { |
1226 if (bCharArray) | 1226 if (bCharArray) |
1227 { | 1227 { |
1228 pEdit->SetCharArray(nMaxLen); | 1228 pEdit->SetCharArray(nMaxLen); |
1229 | 1229 |
1230 if (IsFloatZero(fFontSize)) | 1230 if (IsFloatZero(fFontSize)) |
1231 { | 1231 { |
1232 fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(FontMap.GetP
DFFont(0),rcClient,nMaxLen); | 1232 fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(FontMap.GetP
DFFont(0),rcClient,nMaxLen); |
1233 } | 1233 } |
1234 } | 1234 } |
1235 else | 1235 else |
1236 { | 1236 { |
1237 if (sValue) | 1237 if (sValue) |
1238 nMaxLen = wcslen((const wchar_t*)sValue); | 1238 nMaxLen = wcslen((const wchar_t*)sValue); |
1239 pEdit->SetLimitChar(nMaxLen); | 1239 pEdit->SetLimitChar(nMaxLen); |
1240 } | 1240 } |
1241 } | 1241 } |
1242 | 1242 |
1243 if (IsFloatZero(fFontSize)) | 1243 if (IsFloatZero(fFontSize)) |
1244 pEdit->SetAutoFontSize(TRUE); | 1244 pEdit->SetAutoFontSize(true); |
1245 else | 1245 else |
1246 pEdit->SetFontSize(fFontSize); | 1246 pEdit->SetFontSize(fFontSize); |
1247 | 1247 |
1248 pEdit->Initialize(); | 1248 pEdit->Initialize(); |
1249 | 1249 |
1250 if (sValue) | 1250 if (sValue) |
1251 pEdit->SetText(sValue); | 1251 pEdit->SetText(sValue); |
1252 else | 1252 else |
1253 pEdit->SetText(pField->GetValue().c_str()); | 1253 pEdit->SetText(pField->GetValue().c_str()); |
1254 | 1254 |
(...skipping 14 matching lines...) Expand all Loading... |
1269 CPWL_Color crText = GetTextPWLColor(); | 1269 CPWL_Color crText = GetTextPWLColor(); |
1270 sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit <<
"ET\n" << "Q\nEMC\n"; | 1270 sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit <<
"ET\n" << "Q\nEMC\n"; |
1271 } | 1271 } |
1272 | 1272 |
1273 if (bCharArray) | 1273 if (bCharArray) |
1274 { | 1274 { |
1275 switch (GetBorderStyle()) | 1275 switch (GetBorderStyle()) |
1276 { | 1276 { |
1277 case BBS_SOLID: | 1277 case BBS_SOLID: |
1278 { | 1278 { |
1279 CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBor
derPWLColor(),FALSE); | 1279 CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBor
derPWLColor(),false); |
1280 if (sColor.GetLength() > 0) | 1280 if (sColor.GetLength() > 0) |
1281 { | 1281 { |
1282 sLines << "q\n" << GetBorderWidth() << " w\n" | 1282 sLines << "q\n" << GetBorderWidth() << " w\n" |
1283 << CPWL_Utils::GetColorAppStream(GetBorderPWLColor()
,FALSE) << " 2 J 0 j\n"; | 1283 << CPWL_Utils::GetColorAppStream(GetBorderPWLColor()
,false) << " 2 J 0 j\n"; |
1284 | 1284 |
1285 for (int32_t i=1;i<nMaxLen;i++) | 1285 for (int32_t i=1;i<nMaxLen;i++) |
1286 { | 1286 { |
1287 sLines << rcClient.left + ((rcClient.right - rcClien
t.left)/nMaxLen)*i << " " | 1287 sLines << rcClient.left + ((rcClient.right - rcClien
t.left)/nMaxLen)*i << " " |
1288 << rcClient.bottom << " m\n" | 1288 << rcClient.bottom << " m\n" |
1289 << rcClient.left + ((rcClient.right - rcClient.l
eft)/nMaxLen)*i << " " | 1289 << rcClient.left + ((rcClient.right - rcClient.l
eft)/nMaxLen)*i << " " |
1290 << rcClient.top << " l S\n"; | 1290 << rcClient.top << " l S\n"; |
1291 } | 1291 } |
1292 | 1292 |
1293 sLines << "Q\n"; | 1293 sLines << "Q\n"; |
1294 } | 1294 } |
1295 } | 1295 } |
1296 break; | 1296 break; |
1297 case BBS_DASH: | 1297 case BBS_DASH: |
1298 { | 1298 { |
1299 CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBor
derPWLColor(),FALSE); | 1299 CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBor
derPWLColor(),false); |
1300 if (sColor.GetLength() > 0) | 1300 if (sColor.GetLength() > 0) |
1301 { | 1301 { |
1302 CPWL_Dash dsBorder = CPWL_Dash(3, 3, 0); | 1302 CPWL_Dash dsBorder = CPWL_Dash(3, 3, 0); |
1303 | 1303 |
1304 sLines << "q\n" << GetBorderWidth() << " w\n" | 1304 sLines << "q\n" << GetBorderWidth() << " w\n" |
1305 << CPWL_Utils::GetColorAppStream(GetBorderPWLColor()
,FALSE) | 1305 << CPWL_Utils::GetColorAppStream(GetBorderPWLColor()
,false) |
1306 << "[" << dsBorder.nDash << " " | 1306 << "[" << dsBorder.nDash << " " |
1307 << dsBorder.nGap << "] " | 1307 << dsBorder.nGap << "] " |
1308 << dsBorder.nPhase << " d\n"; | 1308 << dsBorder.nPhase << " d\n"; |
1309 | 1309 |
1310 for (int32_t i=1;i<nMaxLen;i++) | 1310 for (int32_t i=1;i<nMaxLen;i++) |
1311 { | 1311 { |
1312 sLines << rcClient.left + ((rcClient.right - rcClien
t.left)/nMaxLen)*i << " " | 1312 sLines << rcClient.left + ((rcClient.right - rcClien
t.left)/nMaxLen)*i << " " |
1313 << rcClient.bottom << " m\n" | 1313 << rcClient.bottom << " m\n" |
1314 << rcClient.left + ((rcClient.right - rcClient.l
eft)/nMaxLen)*i << " " | 1314 << rcClient.left + ((rcClient.right - rcClient.l
eft)/nMaxLen)*i << " " |
1315 << rcClient.top << " l S\n"; | 1315 << rcClient.top << " l S\n"; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 } | 1542 } |
1543 | 1543 |
1544 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) | 1544 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) |
1545 { | 1545 { |
1546 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP")) | 1546 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP")) |
1547 { | 1547 { |
1548 pAPDict->RemoveAt(sAPType); | 1548 pAPDict->RemoveAt(sAPType); |
1549 } | 1549 } |
1550 } | 1550 } |
1551 | 1551 |
1552 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAc
tion& data, CPDFSDK_PageView* pPageView) | 1552 bool CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldActio
n& data, CPDFSDK_PageView* pPageView) |
1553 { | 1553 { |
1554 CPDF_Action action = GetAAction(type); | 1554 CPDF_Action action = GetAAction(type); |
1555 | 1555 |
1556 if (action && action.GetType() != CPDF_Action::Unknown) | 1556 if (action && action.GetType() != CPDF_Action::Unknown) |
1557 { | 1557 { |
1558 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1558 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
1559 ASSERT(pDocument != NULL); | 1559 ASSERT(pDocument != NULL); |
1560 | 1560 |
1561 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 1561 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
1562 ASSERT(pEnv != NULL); | 1562 ASSERT(pEnv != NULL); |
1563 | 1563 |
1564 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();/*(CPDFS
DK_ActionHandler*)pApp->GetActionHandler();*/ | 1564 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();/*(CPDFS
DK_ActionHandler*)pApp->GetActionHandler();*/ |
1565 ASSERT(pActionHandler != NULL); | 1565 ASSERT(pActionHandler != NULL); |
1566 | 1566 |
1567 return pActionHandler->DoAction_Field(action, type, pDocument, GetFormFi
eld(), data); | 1567 return pActionHandler->DoAction_Field(action, type, pDocument, GetFormFi
eld(), data); |
1568 } | 1568 } |
1569 | 1569 |
1570 return FALSE; | 1570 return false; |
1571 } | 1571 } |
1572 | 1572 |
1573 CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) | 1573 CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) |
1574 { | 1574 { |
1575 switch (eAAT) | 1575 switch (eAAT) |
1576 { | 1576 { |
1577 case CPDF_AAction::CursorEnter: | 1577 case CPDF_AAction::CursorEnter: |
1578 case CPDF_AAction::CursorExit: | 1578 case CPDF_AAction::CursorExit: |
1579 case CPDF_AAction::ButtonDown: | 1579 case CPDF_AAction::ButtonDown: |
1580 case CPDF_AAction::ButtonUp: | 1580 case CPDF_AAction::ButtonUp: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 { | 1617 { |
1618 return m_nAppAge; | 1618 return m_nAppAge; |
1619 } | 1619 } |
1620 | 1620 |
1621 int32_t CPDFSDK_Widget::GetValueAge() const | 1621 int32_t CPDFSDK_Widget::GetValueAge() const |
1622 { | 1622 { |
1623 return m_nValueAge; | 1623 return m_nValueAge; |
1624 } | 1624 } |
1625 | 1625 |
1626 | 1626 |
1627 FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY) | 1627 bool CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY) |
1628 { | 1628 { |
1629 CPDF_Annot* pAnnot = GetPDFAnnot(); | 1629 CPDF_Annot* pAnnot = GetPDFAnnot(); |
1630 CFX_FloatRect annotRect; | 1630 CFX_FloatRect annotRect; |
1631 pAnnot->GetRect(annotRect); | 1631 pAnnot->GetRect(annotRect); |
1632 if(annotRect.Contains(pageX, pageY)) | 1632 if(annotRect.Contains(pageX, pageY)) |
1633 { | 1633 { |
1634 if (!IsVisible()) return FALSE; | 1634 if (!IsVisible()) return false; |
1635 | 1635 |
1636 int nFieldFlags = GetFieldFlags(); | 1636 int nFieldFlags = GetFieldFlags(); |
1637 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 1637 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
1638 return FALSE; | 1638 return false; |
1639 | 1639 |
1640 return TRUE; | 1640 return true; |
1641 } | 1641 } |
1642 return FALSE; | 1642 return false; |
1643 } | 1643 } |
1644 | 1644 |
1645 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) | 1645 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) |
1646 :m_pDocument(pDocument), | 1646 :m_pDocument(pDocument), |
1647 m_pInterForm(NULL), | 1647 m_pInterForm(NULL), |
1648 m_bCalculate(TRUE), | 1648 m_bCalculate(true), |
1649 m_bBusy(FALSE) | 1649 m_bBusy(false) |
1650 { | 1650 { |
1651 ASSERT(m_pDocument != NULL); | 1651 ASSERT(m_pDocument != NULL); |
1652 m_pInterForm = new CPDF_InterForm(m_pDocument->GetDocument(), FALSE); | 1652 m_pInterForm = new CPDF_InterForm(m_pDocument->GetDocument(), false); |
1653 ASSERT(m_pInterForm != NULL); | 1653 ASSERT(m_pInterForm != NULL); |
1654 m_pInterForm->SetFormNotify(this); | 1654 m_pInterForm->SetFormNotify(this); |
1655 | 1655 |
1656 for(int i=0; i<6; i++) | 1656 for(int i=0; i<6; i++) |
1657 m_bNeedHightlight[i] = FALSE; | 1657 m_bNeedHightlight[i] = false; |
1658 m_iHighlightAlpha = 0; | 1658 m_iHighlightAlpha = 0; |
1659 } | 1659 } |
1660 | 1660 |
1661 CPDFSDK_InterForm::~CPDFSDK_InterForm() | 1661 CPDFSDK_InterForm::~CPDFSDK_InterForm() |
1662 { | 1662 { |
1663 delete m_pInterForm; | 1663 delete m_pInterForm; |
1664 m_pInterForm = nullptr; | 1664 m_pInterForm = nullptr; |
1665 m_Map.clear(); | 1665 m_Map.clear(); |
1666 } | 1666 } |
1667 | 1667 |
1668 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() | 1668 bool CPDFSDK_InterForm::HighlightWidgets() |
1669 { | 1669 { |
1670 return FALSE; | 1670 return false; |
1671 } | 1671 } |
1672 | 1672 |
1673 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL b
Next) const | 1673 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, bool bNex
t) const |
1674 { | 1674 { |
1675 nonstd::unique_ptr<CBA_AnnotIterator> pIterator( | 1675 nonstd::unique_ptr<CBA_AnnotIterator> pIterator( |
1676 new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", "")); | 1676 new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", "")); |
1677 | 1677 |
1678 if (bNext) { | 1678 if (bNext) { |
1679 return (CPDFSDK_Widget*)pIterator->GetNextAnnot(pWidget); | 1679 return (CPDFSDK_Widget*)pIterator->GetNextAnnot(pWidget); |
1680 } | 1680 } |
1681 return (CPDFSDK_Widget*)pIterator->GetPrevAnnot(pWidget); | 1681 return (CPDFSDK_Widget*)pIterator->GetPrevAnnot(pWidget); |
1682 } | 1682 } |
1683 | 1683 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidg
et) | 1775 void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidg
et) |
1776 { | 1776 { |
1777 m_Map[pControl] = pWidget; | 1777 m_Map[pControl] = pWidget; |
1778 } | 1778 } |
1779 | 1779 |
1780 void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) | 1780 void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) |
1781 { | 1781 { |
1782 m_Map.erase(pControl); | 1782 m_Map.erase(pControl); |
1783 } | 1783 } |
1784 | 1784 |
1785 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) | 1785 void CPDFSDK_InterForm::EnableCalculate(bool bEnabled) |
1786 { | 1786 { |
1787 m_bCalculate = bEnabled; | 1787 m_bCalculate = bEnabled; |
1788 } | 1788 } |
1789 | 1789 |
1790 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const | 1790 bool CPDFSDK_InterForm::IsCalculateEnabled() const |
1791 { | 1791 { |
1792 return m_bCalculate; | 1792 return m_bCalculate; |
1793 } | 1793 } |
1794 | 1794 |
1795 #ifdef _WIN32 | 1795 #ifdef _WIN32 |
1796 CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) | 1796 CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) |
1797 { | 1797 { |
1798 ASSERT(m_pDocument != NULL); | 1798 ASSERT(m_pDocument != NULL); |
1799 CPDF_Document* pDocument = m_pDocument->GetDocument(); | 1799 CPDF_Document* pDocument = m_pDocument->GetDocument(); |
1800 ASSERT(pDocument != NULL); | 1800 ASSERT(pDocument != NULL); |
1801 | 1801 |
1802 CPDF_Stream* pRetStream = NULL; | 1802 CPDF_Stream* pRetStream = NULL; |
1803 | 1803 |
1804 if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile.c_str())) | 1804 if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile.c_str())) |
1805 { | 1805 { |
1806 int nWidth = pBmp->GetWidth(); | 1806 int nWidth = pBmp->GetWidth(); |
1807 int nHeight = pBmp->GetHeight(); | 1807 int nHeight = pBmp->GetHeight(); |
1808 | 1808 |
1809 CPDF_Image Image(pDocument); | 1809 CPDF_Image Image(pDocument); |
1810 Image.SetImage(pBmp, FALSE); | 1810 Image.SetImage(pBmp, false); |
1811 CPDF_Stream* pImageStream = Image.GetStream(); | 1811 CPDF_Stream* pImageStream = Image.GetStream(); |
1812 if (pImageStream) | 1812 if (pImageStream) |
1813 { | 1813 { |
1814 if (pImageStream->GetObjNum() == 0) | 1814 if (pImageStream->GetObjNum() == 0) |
1815 pDocument->AddIndirectObject(pImageStream); | 1815 pDocument->AddIndirectObject(pImageStream); |
1816 | 1816 |
1817 CPDF_Dictionary* pStreamDict = new CPDF_Dictionary(); | 1817 CPDF_Dictionary* pStreamDict = new CPDF_Dictionary(); |
1818 pStreamDict->SetAtName("Subtype", "Form"); | 1818 pStreamDict->SetAtName("Subtype", "Form"); |
1819 pStreamDict->SetAtName("Name", "IMG"); | 1819 pStreamDict->SetAtName("Name", "IMG"); |
1820 CPDF_Array* pMatrix = new CPDF_Array(); | 1820 CPDF_Array* pMatrix = new CPDF_Array(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) | 1860 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) |
1861 { | 1861 { |
1862 ASSERT(m_pDocument != NULL); | 1862 ASSERT(m_pDocument != NULL); |
1863 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1863 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1864 ASSERT(pEnv); | 1864 ASSERT(pEnv); |
1865 if(!pEnv->IsJSInitiated()) | 1865 if(!pEnv->IsJSInitiated()) |
1866 return; | 1866 return; |
1867 | 1867 |
1868 if (m_bBusy) return; | 1868 if (m_bBusy) return; |
1869 | 1869 |
1870 m_bBusy = TRUE; | 1870 m_bBusy = true; |
1871 | 1871 |
1872 if (IsCalculateEnabled()) | 1872 if (IsCalculateEnabled()) |
1873 { | 1873 { |
1874 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 1874 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
1875 ASSERT(pRuntime != NULL); | 1875 ASSERT(pRuntime != NULL); |
1876 | 1876 |
1877 pRuntime->SetReaderDocument(m_pDocument); | 1877 pRuntime->SetReaderDocument(m_pDocument); |
1878 | 1878 |
1879 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); | 1879 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); |
1880 for (int i=0; i<nSize; i++) | 1880 for (int i=0; i<nSize; i++) |
(...skipping 11 matching lines...) Expand all Loading... |
1892 if (action) | 1892 if (action) |
1893 { | 1893 { |
1894 CFX_WideString csJS = action.GetJavaScript(); | 1894 CFX_WideString csJS = action.GetJavaScript(); |
1895 if (!csJS.IsEmpty()) | 1895 if (!csJS.IsEmpty()) |
1896 { | 1896 { |
1897 IFXJS_Context* pContext = pRuntime->NewContext()
; | 1897 IFXJS_Context* pContext = pRuntime->NewContext()
; |
1898 ASSERT(pContext != NULL); | 1898 ASSERT(pContext != NULL); |
1899 | 1899 |
1900 CFX_WideString sOldValue = pField->GetValue(); | 1900 CFX_WideString sOldValue = pField->GetValue(); |
1901 CFX_WideString sValue = sOldValue; | 1901 CFX_WideString sValue = sOldValue; |
1902 FX_BOOL bRC = TRUE; | 1902 bool bRC = true; |
1903 pContext->OnField_Calculate(pFormField, pField,
sValue, bRC); | 1903 pContext->OnField_Calculate(pFormField, pField,
sValue, bRC); |
1904 | 1904 |
1905 CFX_WideString sInfo; | 1905 CFX_WideString sInfo; |
1906 FX_BOOL bRet = pContext->RunScript(csJS, sInfo); | 1906 bool bRet = pContext->RunScript(csJS, sInfo); |
1907 pRuntime->ReleaseContext(pContext); | 1907 pRuntime->ReleaseContext(pContext); |
1908 | 1908 |
1909 if (bRet) | 1909 if (bRet) |
1910 { | 1910 { |
1911 if (bRC) | 1911 if (bRC) |
1912 { | 1912 { |
1913 if (sValue.Compare(sOldValue) != 0) | 1913 if (sValue.Compare(sOldValue) != 0) |
1914 pField->SetValue(sValue, TRUE); | 1914 pField->SetValue(sValue, true); |
1915 } | 1915 } |
1916 } | 1916 } |
1917 } | 1917 } |
1918 } | 1918 } |
1919 } | 1919 } |
1920 } | 1920 } |
1921 } | 1921 } |
1922 } | 1922 } |
1923 | 1923 |
1924 | 1924 |
1925 } | 1925 } |
1926 | 1926 |
1927 m_bBusy = FALSE; | 1927 m_bBusy = false; |
1928 } | 1928 } |
1929 | 1929 |
1930 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, FX_BOOL&
bFormated) | 1930 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, bool& bFo
rmated) |
1931 { | 1931 { |
1932 ASSERT(m_pDocument != NULL); | 1932 ASSERT(m_pDocument != NULL); |
1933 ASSERT(pFormField != NULL); | 1933 ASSERT(pFormField != NULL); |
1934 | 1934 |
1935 CFX_WideString sValue = pFormField->GetValue(); | 1935 CFX_WideString sValue = pFormField->GetValue(); |
1936 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1936 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1937 ASSERT(pEnv); | 1937 ASSERT(pEnv); |
1938 if(!pEnv->IsJSInitiated()) | 1938 if(!pEnv->IsJSInitiated()) |
1939 { | 1939 { |
1940 bFormated = FALSE; | 1940 bFormated = false; |
1941 return sValue; | 1941 return sValue; |
1942 } | 1942 } |
1943 | 1943 |
1944 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 1944 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
1945 ASSERT(pRuntime != NULL); | 1945 ASSERT(pRuntime != NULL); |
1946 | 1946 |
1947 pRuntime->SetReaderDocument(m_pDocument); | 1947 pRuntime->SetReaderDocument(m_pDocument); |
1948 | 1948 |
1949 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) | 1949 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) |
1950 { | 1950 { |
1951 if (pFormField->CountSelectedItems() > 0) | 1951 if (pFormField->CountSelectedItems() > 0) |
1952 { | 1952 { |
1953 int index = pFormField->GetSelectedIndex(0); | 1953 int index = pFormField->GetSelectedIndex(0); |
1954 if (index >= 0) | 1954 if (index >= 0) |
1955 sValue = pFormField->GetOptionLabel(index); | 1955 sValue = pFormField->GetOptionLabel(index); |
1956 } | 1956 } |
1957 } | 1957 } |
1958 | 1958 |
1959 bFormated = FALSE; | 1959 bFormated = false; |
1960 | 1960 |
1961 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 1961 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
1962 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format)) | 1962 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format)) |
1963 { | 1963 { |
1964 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); | 1964 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); |
1965 if (action) | 1965 if (action) |
1966 { | 1966 { |
1967 CFX_WideString script = action.GetJavaScript(); | 1967 CFX_WideString script = action.GetJavaScript(); |
1968 if (!script.IsEmpty()) | 1968 if (!script.IsEmpty()) |
1969 { | 1969 { |
1970 CFX_WideString Value = sValue; | 1970 CFX_WideString Value = sValue; |
1971 | 1971 |
1972 IFXJS_Context* pContext = pRuntime->NewContext(); | 1972 IFXJS_Context* pContext = pRuntime->NewContext(); |
1973 ASSERT(pContext != NULL); | 1973 ASSERT(pContext != NULL); |
1974 | 1974 |
1975 pContext->OnField_Format(pFormField, Value, TRUE); | 1975 pContext->OnField_Format(pFormField, Value, true); |
1976 | 1976 |
1977 CFX_WideString sInfo; | 1977 CFX_WideString sInfo; |
1978 FX_BOOL bRet = pContext->RunScript(script, sInfo); | 1978 bool bRet = pContext->RunScript(script, sInfo); |
1979 pRuntime->ReleaseContext(pContext); | 1979 pRuntime->ReleaseContext(pContext); |
1980 | 1980 |
1981 if (bRet) | 1981 if (bRet) |
1982 { | 1982 { |
1983 sValue = Value; | 1983 sValue = Value; |
1984 bFormated = TRUE; | 1984 bFormated = true; |
1985 } | 1985 } |
1986 } | 1986 } |
1987 } | 1987 } |
1988 } | 1988 } |
1989 | 1989 |
1990 return sValue; | 1990 return sValue; |
1991 } | 1991 } |
1992 | 1992 |
1993 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, const F
X_WCHAR* sValue, FX_BOOL bValueChanged) | 1993 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, const F
X_WCHAR* sValue, bool bValueChanged) |
1994 { | 1994 { |
1995 ASSERT(pFormField != NULL); | 1995 ASSERT(pFormField != NULL); |
1996 | 1996 |
1997 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) | 1997 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) |
1998 { | 1998 { |
1999 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 1999 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
2000 ASSERT(pFormCtrl != NULL); | 2000 ASSERT(pFormCtrl != NULL); |
2001 | 2001 |
2002 ASSERT(m_pInterForm != NULL); | 2002 ASSERT(m_pInterForm != NULL); |
2003 if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) | 2003 if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) |
2004 pWidget->ResetAppearance(sValue, bValueChanged); | 2004 pWidget->ResetAppearance(sValue, bValueChanged); |
2005 } | 2005 } |
2006 } | 2006 } |
2007 | 2007 |
2008 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) | 2008 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) |
2009 { | 2009 { |
2010 ASSERT(pFormField != NULL); | 2010 ASSERT(pFormField != NULL); |
2011 | 2011 |
2012 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) | 2012 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) |
2013 { | 2013 { |
2014 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2014 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
2015 ASSERT(pFormCtrl != NULL); | 2015 ASSERT(pFormCtrl != NULL); |
2016 | 2016 |
2017 if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) | 2017 if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) |
2018 { | 2018 { |
2019 CPDFDoc_Environment * pEnv = m_pDocument->GetEnv(); | 2019 CPDFDoc_Environment * pEnv = m_pDocument->GetEnv(); |
2020 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); | 2020 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); |
2021 | 2021 |
2022 CPDF_Page * pPage = pWidget->GetPDFPage(); | 2022 CPDF_Page * pPage = pWidget->GetPDFPage(); |
2023 CPDFSDK_PageView * pPageView = m_pDocument->GetPageView(pPage,FALSE)
; | 2023 CPDFSDK_PageView * pPageView = m_pDocument->GetPageView(pPage,false)
; |
2024 | 2024 |
2025 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); | 2025 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); |
2026 | 2026 |
2027 pEnv->FFI_Invalidate(pPage,rcBBox.left, rcBBox.top, rcBBox.right, rc
BBox.bottom); | 2027 pEnv->FFI_Invalidate(pPage,rcBBox.left, rcBBox.top, rcBBox.right, rc
BBox.bottom); |
2028 } | 2028 } |
2029 } | 2029 } |
2030 } | 2030 } |
2031 | 2031 |
2032 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, CFX_WideSt
ring& csValue, FX_BOOL& bRC) | 2032 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, CFX_WideSt
ring& csValue, bool& bRC) |
2033 { | 2033 { |
2034 ASSERT(pFormField != NULL); | 2034 ASSERT(pFormField != NULL); |
2035 | 2035 |
2036 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 2036 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
2037 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::KeyStroke)) | 2037 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::KeyStroke)) |
2038 { | 2038 { |
2039 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); | 2039 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); |
2040 if (action) | 2040 if (action) |
2041 { | 2041 { |
2042 ASSERT(m_pDocument != NULL); | 2042 ASSERT(m_pDocument != NULL); |
2043 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2043 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2044 ASSERT(pEnv != NULL); | 2044 ASSERT(pEnv != NULL); |
2045 | 2045 |
2046 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | 2046 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
2047 ASSERT(pActionHandler != NULL); | 2047 ASSERT(pActionHandler != NULL); |
2048 | 2048 |
2049 PDFSDK_FieldAction fa; | 2049 PDFSDK_FieldAction fa; |
2050 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); | 2050 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); |
2051 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); | 2051 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); |
2052 fa.sValue = csValue; | 2052 fa.sValue = csValue; |
2053 | 2053 |
2054 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeySt
roke, | 2054 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeySt
roke, |
2055 m_pDocument, pFormField, fa); | 2055 m_pDocument, pFormField, fa); |
2056 bRC = fa.bRC; | 2056 bRC = fa.bRC; |
2057 } | 2057 } |
2058 } | 2058 } |
2059 } | 2059 } |
2060 | 2060 |
2061 void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, CFX_WideString& c
sValue, FX_BOOL& bRC) | 2061 void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, CFX_WideString& c
sValue, bool& bRC) |
2062 { | 2062 { |
2063 ASSERT(pFormField != NULL); | 2063 ASSERT(pFormField != NULL); |
2064 | 2064 |
2065 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 2065 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
2066 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Validate)) | 2066 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Validate)) |
2067 { | 2067 { |
2068 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); | 2068 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); |
2069 if (action) | 2069 if (action) |
2070 { | 2070 { |
2071 ASSERT(m_pDocument != NULL); | 2071 ASSERT(m_pDocument != NULL); |
(...skipping 10 matching lines...) Expand all Loading... |
2082 | 2082 |
2083 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Valid
ate, m_pDocument, pFormField, fa); | 2083 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Valid
ate, m_pDocument, pFormField, fa); |
2084 bRC = fa.bRC; | 2084 bRC = fa.bRC; |
2085 | 2085 |
2086 } | 2086 } |
2087 } | 2087 } |
2088 } | 2088 } |
2089 | 2089 |
2090 /* ----------------------------- action ----------------------------- */ | 2090 /* ----------------------------- action ----------------------------- */ |
2091 | 2091 |
2092 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) | 2092 bool CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) |
2093 { | 2093 { |
2094 ASSERT(action); | 2094 ASSERT(action); |
2095 | 2095 |
2096 CPDF_ActionFields af = action.GetWidgets(); | 2096 CPDF_ActionFields af = action.GetWidgets(); |
2097 CFX_PtrArray fieldObjects; | 2097 CFX_PtrArray fieldObjects; |
2098 af.GetAllFields(fieldObjects); | 2098 af.GetAllFields(fieldObjects); |
2099 CFX_PtrArray widgetArray; | 2099 CFX_PtrArray widgetArray; |
2100 CFX_PtrArray fields; | 2100 CFX_PtrArray fields; |
2101 GetFieldFromObjects(fieldObjects, fields); | 2101 GetFieldFromObjects(fieldObjects, fields); |
2102 | 2102 |
2103 FX_BOOL bHide = action.GetHideStatus(); | 2103 bool bHide = action.GetHideStatus(); |
2104 | 2104 |
2105 FX_BOOL bChanged = FALSE; | 2105 bool bChanged = false; |
2106 | 2106 |
2107 for (int i=0, sz=fields.GetSize(); i<sz; i++) | 2107 for (int i=0, sz=fields.GetSize(); i<sz; i++) |
2108 { | 2108 { |
2109 CPDF_FormField* pField = (CPDF_FormField*)fields[i]; | 2109 CPDF_FormField* pField = (CPDF_FormField*)fields[i]; |
2110 ASSERT(pField != NULL); | 2110 ASSERT(pField != NULL); |
2111 | 2111 |
2112 | 2112 |
2113 for (int j=0,jsz=pField->CountControls(); j<jsz; j++) | 2113 for (int j=0,jsz=pField->CountControls(); j<jsz; j++) |
2114 { | 2114 { |
2115 CPDF_FormControl* pControl = pField->GetControl(j); | 2115 CPDF_FormControl* pControl = pField->GetControl(j); |
(...skipping 14 matching lines...) Expand all Loading... |
2130 nFlags &= (~ANNOTFLAG_HIDDEN); | 2130 nFlags &= (~ANNOTFLAG_HIDDEN); |
2131 nFlags &= (~ANNOTFLAG_NOVIEW); | 2131 nFlags &= (~ANNOTFLAG_NOVIEW); |
2132 } | 2132 } |
2133 pWidget->SetFlags(nFlags); | 2133 pWidget->SetFlags(nFlags); |
2134 | 2134 |
2135 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); | 2135 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); |
2136 ASSERT(pPageView != NULL); | 2136 ASSERT(pPageView != NULL); |
2137 | 2137 |
2138 pPageView->UpdateView(pWidget); | 2138 pPageView->UpdateView(pWidget); |
2139 | 2139 |
2140 bChanged = TRUE; | 2140 bChanged = true; |
2141 } | 2141 } |
2142 } | 2142 } |
2143 } | 2143 } |
2144 | 2144 |
2145 return bChanged; | 2145 return bChanged; |
2146 } | 2146 } |
2147 | 2147 |
2148 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) | 2148 bool CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) |
2149 { | 2149 { |
2150 ASSERT(m_pInterForm != NULL); | 2150 ASSERT(m_pInterForm != NULL); |
2151 CFX_WideString sDestination = action.GetFilePath(); | 2151 CFX_WideString sDestination = action.GetFilePath(); |
2152 if (sDestination.IsEmpty()) | 2152 if (sDestination.IsEmpty()) |
2153 return FALSE; | 2153 return false; |
2154 | 2154 |
2155 CPDF_Dictionary* pActionDict = action.GetDict(); | 2155 CPDF_Dictionary* pActionDict = action.GetDict(); |
2156 if (pActionDict->KeyExist("Fields")) | 2156 if (pActionDict->KeyExist("Fields")) |
2157 { | 2157 { |
2158 CPDF_ActionFields af = action.GetWidgets(); | 2158 CPDF_ActionFields af = action.GetWidgets(); |
2159 FX_DWORD dwFlags = action.GetFlags(); | 2159 FX_DWORD dwFlags = action.GetFlags(); |
2160 CFX_PtrArray fieldObjects; | 2160 CFX_PtrArray fieldObjects; |
2161 af.GetAllFields(fieldObjects); | 2161 af.GetAllFields(fieldObjects); |
2162 | 2162 |
2163 CFX_PtrArray fields; | 2163 CFX_PtrArray fields; |
2164 GetFieldFromObjects(fieldObjects, fields); | 2164 GetFieldFromObjects(fieldObjects, fields); |
2165 if (fields.GetSize() != 0) | 2165 if (fields.GetSize() != 0) |
2166 { | 2166 { |
2167 FX_BOOL bIncludeOrExclude = !(dwFlags & 0x01); | 2167 bool bIncludeOrExclude = !(dwFlags & 0x01); |
2168 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) | 2168 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) |
2169 return FALSE; | 2169 return false; |
2170 | 2170 |
2171 return SubmitFields(sDestination, fields, bIncludeOrExclude, FALSE); | 2171 return SubmitFields(sDestination, fields, bIncludeOrExclude, false); |
2172 } | 2172 } |
2173 } | 2173 } |
2174 if (m_pInterForm->CheckRequiredFields()) | 2174 if (m_pInterForm->CheckRequiredFields()) |
2175 return FALSE; | 2175 return false; |
2176 | 2176 |
2177 return SubmitForm(sDestination, FALSE); | 2177 return SubmitForm(sDestination, false); |
2178 } | 2178 } |
2179 | 2179 |
2180 FX_BOOL CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, con
st CFX_PtrArray& fields, | 2180 bool CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, const
CFX_PtrArray& fields, |
2181 FX_BOOL bIncludeOrExclude, FX_BOOL bUrlEncod
ed) | 2181 bool bIncludeOrExclude, bool bUrlEncoded) |
2182 { | 2182 { |
2183 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2183 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2184 ASSERT(pEnv != NULL); | 2184 ASSERT(pEnv != NULL); |
2185 | 2185 |
2186 CFX_ByteTextBuf textBuf; | 2186 CFX_ByteTextBuf textBuf; |
2187 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); | 2187 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); |
2188 | 2188 |
2189 uint8_t* pBuffer = textBuf.GetBuffer(); | 2189 uint8_t* pBuffer = textBuf.GetBuffer(); |
2190 FX_STRSIZE nBufSize = textBuf.GetLength(); | 2190 FX_STRSIZE nBufSize = textBuf.GetLength(); |
2191 | 2191 |
2192 if (bUrlEncoded) | 2192 if (bUrlEncoded) |
2193 { | 2193 { |
2194 if(!FDFToURLEncodedData(pBuffer, nBufSize)) | 2194 if(!FDFToURLEncodedData(pBuffer, nBufSize)) |
2195 return FALSE; | 2195 return false; |
2196 } | 2196 } |
2197 | 2197 |
2198 pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); | 2198 pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); |
2199 | 2199 |
2200 return TRUE; | 2200 return true; |
2201 } | 2201 } |
2202 | 2202 |
2203 void CPDFSDK_InterForm::DoFDFBuffer(CFX_ByteString sBuffer) | 2203 void CPDFSDK_InterForm::DoFDFBuffer(CFX_ByteString sBuffer) |
2204 { | 2204 { |
2205 ASSERT(m_pDocument != NULL); | 2205 ASSERT(m_pDocument != NULL); |
2206 | 2206 |
2207 if (CFDF_Document *pFDFDocument = CFDF_Document::ParseMemory((const unsigned
char *)sBuffer.GetBuffer(sBuffer.GetLength()), sBuffer.GetLength())) | 2207 if (CFDF_Document *pFDFDocument = CFDF_Document::ParseMemory((const unsigned
char *)sBuffer.GetBuffer(sBuffer.GetLength()), sBuffer.GetLength())) |
2208 { | 2208 { |
2209 CPDF_Dictionary* pRootDic = pFDFDocument->GetRoot(); | 2209 CPDF_Dictionary* pRootDic = pFDFDocument->GetRoot(); |
2210 if(pRootDic) | 2210 if(pRootDic) |
(...skipping 18 matching lines...) Expand all Loading... |
2229 | 2229 |
2230 } | 2230 } |
2231 } | 2231 } |
2232 } | 2232 } |
2233 delete pFDFDocument; | 2233 delete pFDFDocument; |
2234 } | 2234 } |
2235 | 2235 |
2236 sBuffer.ReleaseBuffer(); | 2236 sBuffer.ReleaseBuffer(); |
2237 } | 2237 } |
2238 | 2238 |
2239 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_Wid
eString csTxtFile) | 2239 bool CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_WideSt
ring csTxtFile) |
2240 { | 2240 { |
2241 return TRUE; | 2241 return true; |
2242 } | 2242 } |
2243 | 2243 |
2244 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufS
ize) | 2244 bool CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize
) |
2245 { | 2245 { |
2246 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); | 2246 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); |
2247 if (pFDF) | 2247 if (pFDF) |
2248 { | 2248 { |
2249 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); | 2249 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); |
2250 if (pMainDict == NULL) return FALSE; | 2250 if (pMainDict == NULL) return false; |
2251 | 2251 |
2252 // Get fields | 2252 // Get fields |
2253 CPDF_Array* pFields = pMainDict->GetArray("Fields"); | 2253 CPDF_Array* pFields = pMainDict->GetArray("Fields"); |
2254 if (pFields == NULL) return FALSE; | 2254 if (pFields == NULL) return false; |
2255 | 2255 |
2256 CFX_ByteTextBuf fdfEncodedData; | 2256 CFX_ByteTextBuf fdfEncodedData; |
2257 | 2257 |
2258 for (FX_DWORD i = 0; i < pFields->GetCount(); i ++) | 2258 for (FX_DWORD i = 0; i < pFields->GetCount(); i ++) |
2259 { | 2259 { |
2260 CPDF_Dictionary* pField = pFields->GetDict(i); | 2260 CPDF_Dictionary* pField = pFields->GetDict(i); |
2261 if (pField == NULL) continue; | 2261 if (pField == NULL) continue; |
2262 CFX_WideString name; | 2262 CFX_WideString name; |
2263 name = pField->GetUnicodeText("T"); | 2263 name = pField->GetUnicodeText("T"); |
2264 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); | 2264 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); |
2265 CFX_ByteString csBValue = pField->GetString("V"); | 2265 CFX_ByteString csBValue = pField->GetString("V"); |
2266 CFX_WideString csWValue = PDF_DecodeText(csBValue); | 2266 CFX_WideString csWValue = PDF_DecodeText(csBValue); |
2267 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); | 2267 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); |
2268 | 2268 |
2269 fdfEncodedData = fdfEncodedData<<name_b.GetBuffer(name_b.GetLength()
); | 2269 fdfEncodedData = fdfEncodedData<<name_b.GetBuffer(name_b.GetLength()
); |
2270 name_b.ReleaseBuffer(); | 2270 name_b.ReleaseBuffer(); |
2271 fdfEncodedData = fdfEncodedData<<"="; | 2271 fdfEncodedData = fdfEncodedData<<"="; |
2272 fdfEncodedData = fdfEncodedData<<csValue_b.GetBuffer(csValue_b.GetLe
ngth()); | 2272 fdfEncodedData = fdfEncodedData<<csValue_b.GetBuffer(csValue_b.GetLe
ngth()); |
2273 csValue_b.ReleaseBuffer(); | 2273 csValue_b.ReleaseBuffer(); |
2274 if(i != pFields->GetCount()-1) | 2274 if(i != pFields->GetCount()-1) |
2275 fdfEncodedData = fdfEncodedData<<"&"; | 2275 fdfEncodedData = fdfEncodedData<<"&"; |
2276 } | 2276 } |
2277 | 2277 |
2278 nBufSize = fdfEncodedData.GetLength(); | 2278 nBufSize = fdfEncodedData.GetLength(); |
2279 pBuf = FX_Alloc(uint8_t, nBufSize); | 2279 pBuf = FX_Alloc(uint8_t, nBufSize); |
2280 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); | 2280 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); |
2281 } | 2281 } |
2282 return TRUE; | 2282 return true; |
2283 } | 2283 } |
2284 | 2284 |
2285 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,F
X_BOOL bIncludeOrExclude, CFX_ByteTextBuf& textBuf) | 2285 bool CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,bool
bIncludeOrExclude, CFX_ByteTextBuf& textBuf) |
2286 { | 2286 { |
2287 ASSERT(m_pDocument != NULL); | 2287 ASSERT(m_pDocument != NULL); |
2288 ASSERT(m_pInterForm != NULL); | 2288 ASSERT(m_pInterForm != NULL); |
2289 | 2289 |
2290 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),(CFX_
PtrArray&)fields, bIncludeOrExclude); | 2290 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),(CFX_
PtrArray&)fields, bIncludeOrExclude); |
2291 if (!pFDF) return FALSE; | 2291 if (!pFDF) return false; |
2292 FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;// | 2292 bool bRet = pFDF->WriteBuf(textBuf); // = false;// |
2293 delete pFDF; | 2293 delete pFDF; |
2294 | 2294 |
2295 return bRet; | 2295 return bRet; |
2296 } | 2296 } |
2297 | 2297 |
2298 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName(const CFX_WideString& sFi
leExt) | 2298 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName(const CFX_WideString& sFi
leExt) |
2299 { | 2299 { |
2300 CFX_WideString sFileName; | 2300 CFX_WideString sFileName; |
2301 return L""; | 2301 return L""; |
2302 } | 2302 } |
2303 | 2303 |
2304 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, FX_BOO
L bUrlEncoded) | 2304 bool CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, bool bUrl
Encoded) |
2305 { | 2305 { |
2306 if (sDestination.IsEmpty()) return FALSE; | 2306 if (sDestination.IsEmpty()) return false; |
2307 | 2307 |
2308 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2308 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2309 ASSERT(pEnv != NULL); | 2309 ASSERT(pEnv != NULL); |
2310 | 2310 |
2311 if(NULL == m_pDocument) return FALSE; | 2311 if(NULL == m_pDocument) return false; |
2312 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); | 2312 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); |
2313 | 2313 |
2314 if(NULL == m_pInterForm) return FALSE; | 2314 if(NULL == m_pInterForm) return false; |
2315 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); | 2315 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); |
2316 if (NULL == pFDFDoc) return FALSE; | 2316 if (NULL == pFDFDoc) return false; |
2317 | 2317 |
2318 CFX_ByteTextBuf FdfBuffer; | 2318 CFX_ByteTextBuf FdfBuffer; |
2319 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); | 2319 bool bRet = pFDFDoc->WriteBuf(FdfBuffer); |
2320 delete pFDFDoc; | 2320 delete pFDFDoc; |
2321 if (!bRet) return FALSE; | 2321 if (!bRet) return false; |
2322 | 2322 |
2323 uint8_t* pBuffer = FdfBuffer.GetBuffer(); | 2323 uint8_t* pBuffer = FdfBuffer.GetBuffer(); |
2324 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 2324 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); |
2325 | 2325 |
2326 if (bUrlEncoded) | 2326 if (bUrlEncoded) |
2327 { | 2327 { |
2328 if(!FDFToURLEncodedData(pBuffer, nBufSize)) | 2328 if(!FDFToURLEncodedData(pBuffer, nBufSize)) |
2329 return FALSE; | 2329 return false; |
2330 } | 2330 } |
2331 | 2331 |
2332 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); | 2332 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); |
2333 | 2333 |
2334 if (bUrlEncoded && pBuffer) | 2334 if (bUrlEncoded && pBuffer) |
2335 { | 2335 { |
2336 FX_Free(pBuffer); | 2336 FX_Free(pBuffer); |
2337 pBuffer = NULL; | 2337 pBuffer = NULL; |
2338 } | 2338 } |
2339 | 2339 |
2340 return TRUE; | 2340 return true; |
2341 } | 2341 } |
2342 | 2342 |
2343 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) | 2343 bool CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) |
2344 { | 2344 { |
2345 | 2345 |
2346 ASSERT(m_pInterForm != NULL); | 2346 ASSERT(m_pInterForm != NULL); |
2347 ASSERT(m_pDocument != NULL); | 2347 ASSERT(m_pDocument != NULL); |
2348 | 2348 |
2349 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); | 2349 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); |
2350 if (!pFDF) return FALSE; | 2350 if (!pFDF) return false; |
2351 | 2351 |
2352 FX_BOOL bRet = pFDF->WriteBuf(textBuf); | 2352 bool bRet = pFDF->WriteBuf(textBuf); |
2353 delete pFDF; | 2353 delete pFDF; |
2354 | 2354 |
2355 return bRet; | 2355 return bRet; |
2356 } | 2356 } |
2357 | 2357 |
2358 | 2358 |
2359 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) | 2359 bool CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) |
2360 { | 2360 { |
2361 ASSERT(action); | 2361 ASSERT(action); |
2362 | 2362 |
2363 CPDF_Dictionary* pActionDict = action.GetDict(); | 2363 CPDF_Dictionary* pActionDict = action.GetDict(); |
2364 if (pActionDict->KeyExist("Fields")) | 2364 if (pActionDict->KeyExist("Fields")) |
2365 { | 2365 { |
2366 CPDF_ActionFields af = action.GetWidgets(); | 2366 CPDF_ActionFields af = action.GetWidgets(); |
2367 FX_DWORD dwFlags = action.GetFlags(); | 2367 FX_DWORD dwFlags = action.GetFlags(); |
2368 | 2368 |
2369 CFX_PtrArray fieldObjects; | 2369 CFX_PtrArray fieldObjects; |
2370 af.GetAllFields(fieldObjects); | 2370 af.GetAllFields(fieldObjects); |
2371 CFX_PtrArray fields; | 2371 CFX_PtrArray fields; |
2372 GetFieldFromObjects(fieldObjects, fields); | 2372 GetFieldFromObjects(fieldObjects, fields); |
2373 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), TRUE); | 2373 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true); |
2374 } | 2374 } |
2375 | 2375 |
2376 return m_pInterForm->ResetForm(TRUE); | 2376 return m_pInterForm->ResetForm(true); |
2377 } | 2377 } |
2378 | 2378 |
2379 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) | 2379 bool CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) |
2380 { | 2380 { |
2381 return FALSE; | 2381 return false; |
2382 } | 2382 } |
2383 | 2383 |
2384 void CPDFSDK_InterForm::GetFieldFromObjects(const CFX_PtrArray& objects, CFX_Ptr
Array& fields) | 2384 void CPDFSDK_InterForm::GetFieldFromObjects(const CFX_PtrArray& objects, CFX_Ptr
Array& fields) |
2385 { | 2385 { |
2386 ASSERT(m_pInterForm != NULL); | 2386 ASSERT(m_pInterForm != NULL); |
2387 | 2387 |
2388 int iCount = objects.GetSize(); | 2388 int iCount = objects.GetSize(); |
2389 for (int i = 0; i < iCount; i ++) | 2389 for (int i = 0; i < iCount; i ++) |
2390 { | 2390 { |
2391 CPDF_Object* pObject = (CPDF_Object*)objects[i]; | 2391 CPDF_Object* pObject = (CPDF_Object*)objects[i]; |
(...skipping 16 matching lines...) Expand all Loading... |
2408 } | 2408 } |
2409 | 2409 |
2410 /* ----------------------------- CPDF_FormNotify ----------------------------- *
/ | 2410 /* ----------------------------- CPDF_FormNotify ----------------------------- *
/ |
2411 | 2411 |
2412 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, CFX_WideS
tring& csValue) | 2412 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, CFX_WideS
tring& csValue) |
2413 { | 2413 { |
2414 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2414 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2415 int nType = pFormField->GetFieldType(); | 2415 int nType = pFormField->GetFieldType(); |
2416 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) | 2416 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) |
2417 { | 2417 { |
2418 FX_BOOL bRC = TRUE; | 2418 bool bRC = true; |
2419 OnKeyStrokeCommit(pFormField, csValue, bRC); | 2419 OnKeyStrokeCommit(pFormField, csValue, bRC); |
2420 if (bRC) | 2420 if (bRC) |
2421 { | 2421 { |
2422 OnValidate(pFormField, csValue, bRC); | 2422 OnValidate(pFormField, csValue, bRC); |
2423 return bRC ? 1 : -1; | 2423 return bRC ? 1 : -1; |
2424 } | 2424 } |
2425 return -1; | 2425 return -1; |
2426 } | 2426 } |
2427 return 0; | 2427 return 0; |
2428 } | 2428 } |
2429 | 2429 |
2430 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) | 2430 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) |
2431 { | 2431 { |
2432 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2432 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2433 int nType = pFormField->GetFieldType(); | 2433 int nType = pFormField->GetFieldType(); |
2434 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) | 2434 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) |
2435 { | 2435 { |
2436 OnCalculate(pFormField); | 2436 OnCalculate(pFormField); |
2437 FX_BOOL bFormated = FALSE; | 2437 bool bFormated = false; |
2438 CFX_WideString sValue = OnFormat(pFormField, bFormated); | 2438 CFX_WideString sValue = OnFormat(pFormField, bFormated); |
2439 if (bFormated) | 2439 if (bFormated) |
2440 ResetFieldAppearance(pFormField, sValue.c_str(), TRUE); | 2440 ResetFieldAppearance(pFormField, sValue.c_str(), true); |
2441 else | 2441 else |
2442 ResetFieldAppearance(pFormField, NULL, TRUE); | 2442 ResetFieldAppearance(pFormField, NULL, true); |
2443 UpdateField(pFormField); | 2443 UpdateField(pFormField); |
2444 } | 2444 } |
2445 return 0; | 2445 return 0; |
2446 } | 2446 } |
2447 | 2447 |
2448 int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField, CFX_W
ideString& csValue) | 2448 int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField, CFX_W
ideString& csValue) |
2449 { | 2449 { |
2450 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2450 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2451 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) | 2451 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) |
2452 return 0; | 2452 return 0; |
2453 | 2453 |
2454 FX_BOOL bRC = TRUE; | 2454 bool bRC = true; |
2455 OnKeyStrokeCommit(pFormField, csValue, bRC); | 2455 OnKeyStrokeCommit(pFormField, csValue, bRC); |
2456 if (!bRC) | 2456 if (!bRC) |
2457 return -1; | 2457 return -1; |
2458 | 2458 |
2459 OnValidate(pFormField, csValue, bRC); | 2459 OnValidate(pFormField, csValue, bRC); |
2460 if (!bRC) | 2460 if (!bRC) |
2461 return -1; | 2461 return -1; |
2462 | 2462 |
2463 return 1; | 2463 return 1; |
2464 } | 2464 } |
2465 | 2465 |
2466 int CPDFSDK_InterForm::AfterSelectionChange(const CPDF_FormField* pField) | 2466 int CPDFSDK_InterForm::AfterSelectionChange(const CPDF_FormField* pField) |
2467 { | 2467 { |
2468 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2468 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2469 if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX) | 2469 if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX) |
2470 { | 2470 { |
2471 OnCalculate(pFormField); | 2471 OnCalculate(pFormField); |
2472 ResetFieldAppearance(pFormField, NULL, TRUE); | 2472 ResetFieldAppearance(pFormField, NULL, true); |
2473 UpdateField(pFormField); | 2473 UpdateField(pFormField); |
2474 } | 2474 } |
2475 return 0; | 2475 return 0; |
2476 } | 2476 } |
2477 | 2477 |
2478 int CPDFSDK_InterForm::AfterCheckedStatusChange(const CPDF_FormField* pField, co
nst CFX_ByteArray& statusArray) | 2478 int CPDFSDK_InterForm::AfterCheckedStatusChange(const CPDF_FormField* pField, co
nst CFX_ByteArray& statusArray) |
2479 { | 2479 { |
2480 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2480 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2481 int nType = pFormField->GetFieldType(); | 2481 int nType = pFormField->GetFieldType(); |
2482 if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON) | 2482 if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON) |
(...skipping 19 matching lines...) Expand all Loading... |
2502 { | 2502 { |
2503 return 0; | 2503 return 0; |
2504 } | 2504 } |
2505 | 2505 |
2506 int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm) | 2506 int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm) |
2507 { | 2507 { |
2508 OnCalculate(nullptr); | 2508 OnCalculate(nullptr); |
2509 return 0; | 2509 return 0; |
2510 } | 2510 } |
2511 | 2511 |
2512 FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) | 2512 bool CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) |
2513 { | 2513 { |
2514 if(nFieldType <1 || nFieldType > 6) | 2514 if(nFieldType <1 || nFieldType > 6) |
2515 return FALSE; | 2515 return false; |
2516 return m_bNeedHightlight[nFieldType-1]; | 2516 return m_bNeedHightlight[nFieldType-1]; |
2517 } | 2517 } |
2518 | 2518 |
2519 void CPDFSDK_InterForm::RemoveAllHighLight() | 2519 void CPDFSDK_InterForm::RemoveAllHighLight() |
2520 { | 2520 { |
2521 memset((void*)m_bNeedHightlight, 0, 6*sizeof(FX_BOOL)); | 2521 memset((void*)m_bNeedHightlight, 0, 6*sizeof(bool)); |
2522 } | 2522 } |
2523 void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) | 2523 void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) |
2524 { | 2524 { |
2525 if(nFieldType <0 || nFieldType > 6) return; | 2525 if(nFieldType <0 || nFieldType > 6) return; |
2526 switch(nFieldType) | 2526 switch(nFieldType) |
2527 { | 2527 { |
2528 case 0: | 2528 case 0: |
2529 { | 2529 { |
2530 for(int i=0; i<6; i++) | 2530 for(int i=0; i<6; i++) |
2531 { | 2531 { |
2532 m_aHighlightColor[i] = clr; | 2532 m_aHighlightColor[i] = clr; |
2533 m_bNeedHightlight[i] = TRUE; | 2533 m_bNeedHightlight[i] = true; |
2534 } | 2534 } |
2535 break; | 2535 break; |
2536 } | 2536 } |
2537 default: | 2537 default: |
2538 { | 2538 { |
2539 m_aHighlightColor[nFieldType-1] = clr; | 2539 m_aHighlightColor[nFieldType-1] = clr; |
2540 m_bNeedHightlight[nFieldType-1] = TRUE; | 2540 m_bNeedHightlight[nFieldType-1] = true; |
2541 break; | 2541 break; |
2542 } | 2542 } |
2543 } | 2543 } |
2544 | 2544 |
2545 } | 2545 } |
2546 | 2546 |
2547 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) | 2547 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) |
2548 { | 2548 { |
2549 if (nFieldType < 0 || nFieldType > 6) | 2549 if (nFieldType < 0 || nFieldType > 6) |
2550 return FXSYS_RGB(255,255,255); | 2550 return FXSYS_RGB(255,255,255); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 ASSERT(pAnnot != NULL); | 2776 ASSERT(pAnnot != NULL); |
2777 | 2777 |
2778 if (pAnnot->GetType() == m_sType | 2778 if (pAnnot->GetType() == m_sType |
2779 && pAnnot->GetSubType() == m_sSubType) | 2779 && pAnnot->GetSubType() == m_sSubType) |
2780 sa.Add(pAnnot); | 2780 sa.Add(pAnnot); |
2781 } | 2781 } |
2782 } | 2782 } |
2783 | 2783 |
2784 if (sa.GetSize() > 0) | 2784 if (sa.GetSize() > 0) |
2785 { | 2785 { |
2786 sa.Sort(CBA_AnnotIterator::CompareByTop, FALSE); | 2786 sa.Sort(CBA_AnnotIterator::CompareByTop, false); |
2787 } | 2787 } |
2788 | 2788 |
2789 while (sa.GetSize() > 0) | 2789 while (sa.GetSize() > 0) |
2790 { | 2790 { |
2791 int nLeftTopIndex = -1; | 2791 int nLeftTopIndex = -1; |
2792 | 2792 |
2793 { | 2793 { |
2794 FX_FLOAT fLeft = -1.0f; | 2794 FX_FLOAT fLeft = -1.0f; |
2795 | 2795 |
2796 for (int i=sa.GetSize()-1; i>=0; i--) | 2796 for (int i=sa.GetSize()-1; i>=0; i--) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2869 | 2869 |
2870 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 2870 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
2871 ASSERT(pPDFAnnot != NULL); | 2871 ASSERT(pPDFAnnot != NULL); |
2872 | 2872 |
2873 CPDF_Rect rcAnnot; | 2873 CPDF_Rect rcAnnot; |
2874 pPDFAnnot->GetRect(rcAnnot); | 2874 pPDFAnnot->GetRect(rcAnnot); |
2875 | 2875 |
2876 return rcAnnot; | 2876 return rcAnnot; |
2877 } | 2877 } |
2878 | 2878 |
OLD | NEW |