Initial commit.
[pdfium.git] / fpdfsdk / src / javascript / Field.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../include/javascript/JavaScript.h"\r
8 #include "../../include/javascript/IJavaScript.h"\r
9 #include "../../include/javascript/JS_Define.h"\r
10 #include "../../include/javascript/JS_Object.h"\r
11 #include "../../include/javascript/JS_Value.h"\r
12 #include "../../include/javascript/Field.h"\r
13 #include "../../include/javascript/JS_EventHandler.h"\r
14 //#include "../include/JS_ResMgr.h"\r
15 #include "../../include/javascript/JS_Context.h"\r
16 #include "../../include/javascript/JS_Runtime.h"\r
17 #include "../../include/javascript/Document.h"\r
18 #include "../../include/javascript/color.h"\r
19 #include "../../include/javascript/PublicMethods.h"\r
20 #include "../../include/javascript/Icon.h"\r
21 \r
22 \r
23 /* ---------------------- Field ---------------------- */\r
24 \r
25 BEGIN_JS_STATIC_CONST(CJS_Field)\r
26 END_JS_STATIC_CONST()\r
27 \r
28 BEGIN_JS_STATIC_PROP(CJS_Field)\r
29         JS_STATIC_PROP_ENTRY(alignment)\r
30         JS_STATIC_PROP_ENTRY(borderStyle)\r
31         JS_STATIC_PROP_ENTRY(buttonAlignX)\r
32         JS_STATIC_PROP_ENTRY(buttonAlignY)\r
33         JS_STATIC_PROP_ENTRY(buttonFitBounds)\r
34         JS_STATIC_PROP_ENTRY(buttonPosition)\r
35         JS_STATIC_PROP_ENTRY(buttonScaleHow)\r
36         JS_STATIC_PROP_ENTRY(buttonScaleWhen)\r
37         JS_STATIC_PROP_ENTRY(calcOrderIndex)\r
38         JS_STATIC_PROP_ENTRY(charLimit)\r
39         JS_STATIC_PROP_ENTRY(comb)\r
40         JS_STATIC_PROP_ENTRY(commitOnSelChange)\r
41         JS_STATIC_PROP_ENTRY(currentValueIndices)\r
42         JS_STATIC_PROP_ENTRY(defaultStyle)\r
43         JS_STATIC_PROP_ENTRY(defaultValue)\r
44         JS_STATIC_PROP_ENTRY(doNotScroll)\r
45         JS_STATIC_PROP_ENTRY(doNotSpellCheck)\r
46         JS_STATIC_PROP_ENTRY(delay)\r
47         JS_STATIC_PROP_ENTRY(display)\r
48         JS_STATIC_PROP_ENTRY(doc)\r
49         JS_STATIC_PROP_ENTRY(editable)\r
50         JS_STATIC_PROP_ENTRY(exportValues)\r
51         JS_STATIC_PROP_ENTRY(hidden)\r
52         JS_STATIC_PROP_ENTRY(fileSelect)\r
53         JS_STATIC_PROP_ENTRY(fillColor)\r
54         JS_STATIC_PROP_ENTRY(lineWidth)\r
55         JS_STATIC_PROP_ENTRY(highlight)\r
56         JS_STATIC_PROP_ENTRY(multiline)\r
57         JS_STATIC_PROP_ENTRY(multipleSelection)\r
58         JS_STATIC_PROP_ENTRY(name)\r
59         JS_STATIC_PROP_ENTRY(numItems)\r
60         JS_STATIC_PROP_ENTRY(page)\r
61         JS_STATIC_PROP_ENTRY(password)\r
62         JS_STATIC_PROP_ENTRY(print)\r
63         JS_STATIC_PROP_ENTRY(radiosInUnison)\r
64         JS_STATIC_PROP_ENTRY(readonly)\r
65         JS_STATIC_PROP_ENTRY(rect)\r
66         JS_STATIC_PROP_ENTRY(required)\r
67         JS_STATIC_PROP_ENTRY(richText)\r
68         JS_STATIC_PROP_ENTRY(richValue)\r
69         JS_STATIC_PROP_ENTRY(rotation)\r
70         JS_STATIC_PROP_ENTRY(strokeColor)\r
71         JS_STATIC_PROP_ENTRY(style)\r
72         JS_STATIC_PROP_ENTRY(submitName)\r
73         JS_STATIC_PROP_ENTRY(textColor)\r
74         JS_STATIC_PROP_ENTRY(textFont)\r
75         JS_STATIC_PROP_ENTRY(textSize)\r
76         JS_STATIC_PROP_ENTRY(type)\r
77         JS_STATIC_PROP_ENTRY(userName)\r
78         JS_STATIC_PROP_ENTRY(value)\r
79         JS_STATIC_PROP_ENTRY(valueAsString)\r
80         JS_STATIC_PROP_ENTRY(source)\r
81 END_JS_STATIC_PROP()\r
82 \r
83 BEGIN_JS_STATIC_METHOD(CJS_Field)\r
84         JS_STATIC_METHOD_ENTRY(browseForFileToSubmit,      0)\r
85         JS_STATIC_METHOD_ENTRY(buttonGetCaption,           1)\r
86         JS_STATIC_METHOD_ENTRY(buttonGetIcon,              1)\r
87         JS_STATIC_METHOD_ENTRY(buttonImportIcon,           0)\r
88         JS_STATIC_METHOD_ENTRY(buttonSetCaption,           2)\r
89         JS_STATIC_METHOD_ENTRY(buttonSetIcon,              2)\r
90         JS_STATIC_METHOD_ENTRY(checkThisBox,               2)\r
91         JS_STATIC_METHOD_ENTRY(clearItems,                 0)\r
92         JS_STATIC_METHOD_ENTRY(defaultIsChecked,           2)\r
93         JS_STATIC_METHOD_ENTRY(deleteItemAt,               1)\r
94         JS_STATIC_METHOD_ENTRY(getArray ,                  0)\r
95         JS_STATIC_METHOD_ENTRY(getItemAt,                  0)\r
96         JS_STATIC_METHOD_ENTRY(getLock,                    0)\r
97         JS_STATIC_METHOD_ENTRY(insertItemAt,               0)\r
98         JS_STATIC_METHOD_ENTRY(isBoxChecked,               1)\r
99         JS_STATIC_METHOD_ENTRY(isDefaultChecked,           1)\r
100         JS_STATIC_METHOD_ENTRY(setAction,                  2)\r
101         JS_STATIC_METHOD_ENTRY(setFocus,                   0)\r
102         JS_STATIC_METHOD_ENTRY(setItems,                   1)\r
103         JS_STATIC_METHOD_ENTRY(setLock,                    0)\r
104         JS_STATIC_METHOD_ENTRY(signatureGetModifications,  0)\r
105         JS_STATIC_METHOD_ENTRY(signatureGetSeedValue,      0)\r
106         JS_STATIC_METHOD_ENTRY(signatureInfo,              0)\r
107         JS_STATIC_METHOD_ENTRY(signatureSetSeedValue,      0)\r
108         JS_STATIC_METHOD_ENTRY(signatureSign,              0)\r
109         JS_STATIC_METHOD_ENTRY(signatureValidate,          0)\r
110 END_JS_STATIC_METHOD()\r
111 \r
112 IMPLEMENT_JS_CLASS(CJS_Field, Field)\r
113 \r
114 FX_BOOL CJS_Field::InitInstance(IFXJS_Context* cc)\r
115 {\r
116         CJS_Context* pContext = (CJS_Context*)cc;\r
117         ASSERT(pContext != NULL);\r
118 \r
119         Field* pField = (Field*)GetEmbedObject();\r
120         ASSERT(pField != NULL);\r
121 \r
122         pField->SetIsolate(pContext->GetJSRuntime()->GetIsolate());\r
123 \r
124         return TRUE;\r
125 };\r
126 \r
127 Field::Field(CJS_Object* pJSObject): CJS_EmbedObj(pJSObject),\r
128         m_pJSDoc(NULL),\r
129         m_pDocument(NULL),\r
130         m_nFormControlIndex(-1),\r
131         m_bCanSet(FALSE),\r
132         m_bDelay(FALSE),\r
133         m_isolate(NULL)\r
134 {\r
135 }\r
136 \r
137 Field::~Field()\r
138 {\r
139 }\r
140 \r
141 //note: iControlNo = -1, means not a widget.\r
142 void Field::ParseFieldName(const std::wstring &strFieldNameParsed,std::wstring &strFieldName,int & iControlNo)\r
143 {\r
144         int iStart = strFieldNameParsed.find_last_of(L'.');\r
145         if (iStart == -1)\r
146         {\r
147                 strFieldName = strFieldNameParsed;\r
148                 iControlNo = -1;\r
149                 return;\r
150         }\r
151         std::wstring suffixal = strFieldNameParsed.substr(iStart+1);\r
152         iControlNo = FXSYS_wtoi((FX_LPCWSTR)suffixal.c_str());\r
153         if (iControlNo == 0)\r
154         {\r
155                 int iStart;\r
156                 while((iStart = suffixal.find_last_of(L" ")) != -1)\r
157                 {\r
158                         suffixal.erase(iStart,1);\r
159                 }\r
160 \r
161                 if (suffixal.compare(L"0") != 0)\r
162                 {\r
163                         strFieldName = strFieldNameParsed;\r
164                         iControlNo = -1;\r
165                         return;\r
166                 }\r
167 \r
168         }\r
169         strFieldName = strFieldNameParsed.substr(0,iStart);    \r
170 }\r
171 \r
172 FX_BOOL Field::AttachField(Document* pDocument, const CFX_WideString& csFieldName)\r
173 {\r
174         ASSERT(pDocument != NULL);\r
175         m_pJSDoc = pDocument;\r
176 \r
177         m_pDocument = pDocument->GetReaderDoc();\r
178         ASSERT(m_pDocument != NULL);\r
179 \r
180         m_bCanSet = m_pDocument->GetPermissions(FPDFPERM_FILL_FORM) || \r
181                 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || \r
182                 m_pDocument->GetPermissions(FPDFPERM_MODIFY);\r
183 \r
184         CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm();\r
185         ASSERT(pRDInterForm != NULL);\r
186 \r
187         CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();\r
188         ASSERT(pInterForm != NULL);\r
189 \r
190         CFX_WideString swFieldNameTemp = csFieldName;\r
191         swFieldNameTemp.Replace((FX_LPCWSTR)L"..", (FX_LPCWSTR)L".");\r
192 \r
193         if (pInterForm->CountFields(swFieldNameTemp) <= 0)\r
194         {\r
195                 std::wstring strFieldName;\r
196                 int iControlNo = -1;\r
197                 ParseFieldName((wchar_t*)(FX_LPCWSTR)swFieldNameTemp, strFieldName, iControlNo);\r
198                 if (iControlNo == -1) return FALSE;\r
199                 \r
200                 m_FieldName = strFieldName.c_str();\r
201                 m_nFormControlIndex = iControlNo;\r
202                 return TRUE;\r
203         }\r
204 \r
205         m_FieldName = swFieldNameTemp;\r
206         m_nFormControlIndex = -1;\r
207 \r
208         return TRUE;\r
209 }\r
210 \r
211 void Field::GetFormFields(CPDFSDK_Document* pDocument, const CFX_WideString& csFieldName, CFX_PtrArray& FieldArray)\r
212 {\r
213         ASSERT(pDocument != NULL);\r
214 \r
215         CPDFSDK_InterForm* pReaderInterForm = pDocument->GetInterForm();\r
216         ASSERT(pReaderInterForm != NULL);\r
217 \r
218         CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();\r
219         ASSERT(pInterForm != NULL);\r
220 \r
221         ASSERT(FieldArray.GetSize() == 0);\r
222 \r
223         for (int i=0,sz=pInterForm->CountFields(csFieldName); i<sz; i++)\r
224         {\r
225                 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName))\r
226                         FieldArray.Add((void*)pFormField);\r
227         }\r
228 }\r
229 \r
230 void Field::GetFormFields(const CFX_WideString& csFieldName, CFX_PtrArray& FieldArray)\r
231 {\r
232         ASSERT(m_pDocument != NULL);\r
233 \r
234         Field::GetFormFields(m_pDocument, csFieldName, FieldArray);\r
235 }\r
236 \r
237 void Field::UpdateFormField(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, \r
238                                                         FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh)\r
239 {\r
240         ASSERT(pDocument != NULL);\r
241         ASSERT(pFormField != NULL);\r
242 \r
243         CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();\r
244         ASSERT(pInterForm != NULL);\r
245 \r
246         CFX_PtrArray widgets;\r
247         pInterForm->GetWidgets(pFormField, widgets);\r
248 \r
249         if (bResetAP)\r
250         {\r
251                 int nFieldType = pFormField->GetFieldType();\r
252                 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD)\r
253                 {\r
254                         for (int i=0,sz=widgets.GetSize(); i<sz; i++)\r
255                         {\r
256                                 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i);\r
257                                 ASSERT(pWidget != NULL);\r
258 \r
259                                 FX_BOOL bFormated = FALSE;\r
260                                 CFX_WideString sValue = pWidget->OnFormat(0, bFormated);\r
261                                 if (bFormated)\r
262                                         pWidget->ResetAppearance(sValue, FALSE);\r
263                                 else\r
264                                         pWidget->ResetAppearance(NULL, FALSE);\r
265                         }\r
266                 }\r
267                 else\r
268                 {\r
269                         for (int i=0,sz=widgets.GetSize(); i<sz; i++)\r
270                         {\r
271                                 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i);\r
272                                 ASSERT(pWidget != NULL);\r
273 \r
274                                 pWidget->ResetAppearance(NULL, FALSE);\r
275                         }\r
276                 }\r
277         }\r
278 \r
279         if (bRefresh)\r
280         {\r
281                 for (int i=0,sz=widgets.GetSize(); i<sz; i++)\r
282                 {\r
283                         CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i);\r
284                         ASSERT(pWidget != NULL);\r
285                         \r
286                         CPDFSDK_InterForm * pInterForm = pWidget->GetInterForm();\r
287                         CPDFSDK_Document* pDoc = pInterForm->GetDocument();\r
288 //                      CReader_Page* pPage = pWidget->GetPage();\r
289                         ASSERT(pDoc != NULL);\r
290                         pDoc->UpdateAllViews(NULL, pWidget);\r
291                 }\r
292         }               \r
293         \r
294         if (bChangeMark)\r
295                 pDocument->SetChangeMark();\r
296 }\r
297 \r
298 void Field::UpdateFormControl(CPDFSDK_Document* pDocument, CPDF_FormControl* pFormControl, \r
299                                                         FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh)\r
300 {\r
301         ASSERT(pDocument != NULL);\r
302         ASSERT(pFormControl != NULL);\r
303 \r
304         CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();\r
305         ASSERT(pInterForm != NULL);\r
306 \r
307         CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl);\r
308         \r
309         if (pWidget)\r
310         {\r
311                 if (bResetAP)\r
312                 {\r
313                         int nFieldType = pWidget->GetFieldType();\r
314                         if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD)\r
315                         {\r
316                                 FX_BOOL bFormated = FALSE;\r
317                                 CFX_WideString sValue = pWidget->OnFormat(0, bFormated);\r
318                                 if (bFormated)\r
319                                         pWidget->ResetAppearance(sValue, FALSE);\r
320                                 else\r
321                                         pWidget->ResetAppearance(NULL, FALSE);\r
322                         }\r
323                         else\r
324                         {\r
325                                 pWidget->ResetAppearance(NULL, FALSE);\r
326                         }\r
327                 }\r
328 \r
329                 if (bRefresh)\r
330                 {\r
331                         CPDFSDK_InterForm * pInterForm = pWidget->GetInterForm();\r
332                         CPDFSDK_Document* pDoc = pInterForm->GetDocument();\r
333                         ASSERT(pDoc != NULL);\r
334                         pDoc->UpdateAllViews(NULL, pWidget);\r
335                 }\r
336 \r
337         }\r
338 \r
339         if (bChangeMark)\r
340                 pDocument->SetChangeMark();\r
341 }\r
342 \r
343 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument, CPDF_FormControl* pFormControl)\r
344 {\r
345         ASSERT(pDocument != NULL);\r
346         ASSERT(pFormControl != NULL);\r
347 \r
348         CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();\r
349         ASSERT(pInterForm != NULL);\r
350 \r
351         return pInterForm->GetWidget(pFormControl);\r
352 }\r
353 \r
354 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel)\r
355 {\r
356         ASSERT(pFormField != NULL);\r
357 \r
358         for (int i=0,sz = pFormField->CountOptions(); i < sz; i++)\r
359         {\r
360                 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0)\r
361                         return TRUE;\r
362         }\r
363 \r
364         return FALSE;\r
365 }\r
366 \r
367 CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField)\r
368 {\r
369         ASSERT(pFormField != NULL);\r
370         if(!pFormField->CountControls() || m_nFormControlIndex>=pFormField->CountControls()) return NULL;\r
371 \r
372         if (m_nFormControlIndex<0)\r
373                 return pFormField->GetControl(0);\r
374         else\r
375                 return pFormField->GetControl(m_nFormControlIndex);\r
376 }\r
377 \r
378 /* ---------------------------------------- property ---------------------------------------- */\r
379 \r
380 FX_BOOL Field::alignment(OBJ_PROP_PARAMS)\r
381 {\r
382         ASSERT(m_pDocument != NULL);\r
383 \r
384         if (vp.IsSetting())\r
385         {\r
386                 if (!m_bCanSet) return FALSE;\r
387 \r
388                 CFX_ByteString alignStr;\r
389                 vp >> alignStr;\r
390 \r
391                 if (m_bDelay)\r
392                 {\r
393                         AddDelay_String(FP_ALIGNMENT, alignStr);\r
394                 }\r
395                 else\r
396                 {\r
397                         Field::SetAlignment(m_pDocument, m_FieldName, m_nFormControlIndex, alignStr);\r
398                 }\r
399         }\r
400         else\r
401         {\r
402                 CFX_PtrArray FieldArray;\r
403                 GetFormFields(m_FieldName, FieldArray);\r
404                 if (FieldArray.GetSize() <= 0) return FALSE;\r
405 \r
406                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
407                 ASSERT(pFormField != NULL);\r
408 \r
409                 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)\r
410                         return FALSE;\r
411 \r
412                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
413                 if (!pFormControl)return FALSE;\r
414 \r
415                 switch (pFormControl->GetControlAlignment())\r
416                 {\r
417                         case 1:\r
418                                 vp << (FX_LPCWSTR)L"center";\r
419                                 break;\r
420                         case 0:\r
421                                 vp << (FX_LPCWSTR)L"left";\r
422                                 break;\r
423                         case 2:\r
424                                 vp << (FX_LPCWSTR)L"right";\r
425                                 break;\r
426                         default:\r
427                                 vp << (FX_LPCWSTR)L"";\r
428                 }\r
429         }\r
430 \r
431         return TRUE;\r
432 }\r
433 \r
434 void Field::SetAlignment(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, \r
435                                                  const CFX_ByteString& string)\r
436 {\r
437         //Not supported.\r
438 }\r
439 \r
440 FX_BOOL Field::borderStyle(OBJ_PROP_PARAMS)\r
441 {       \r
442         ASSERT(m_pDocument != NULL);\r
443 \r
444         if (vp.IsSetting())\r
445         {\r
446                 if (!m_bCanSet) return FALSE;\r
447 \r
448                 CFX_ByteString strType = "";\r
449                 vp >> strType;\r
450 \r
451                 if (m_bDelay)\r
452                 {\r
453                         AddDelay_String(FP_BORDERSTYLE, strType);\r
454                 }\r
455                 else\r
456                 {\r
457                         Field::SetBorderStyle(m_pDocument, m_FieldName, m_nFormControlIndex, strType);\r
458                 }\r
459         }\r
460         else\r
461         {\r
462                 CFX_PtrArray FieldArray;\r
463                 GetFormFields(m_FieldName, FieldArray);\r
464                 if (FieldArray.GetSize() <= 0) return FALSE;\r
465 \r
466                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
467                 if (!pFormField) return FALSE;\r
468 \r
469                 CPDFSDK_Widget* pWidget = GetWidget(m_pDocument, GetSmartFieldControl(pFormField));\r
470                 if (!pWidget) return FALSE;\r
471 \r
472                 int nBorderstyle = pWidget->GetBorderStyle();\r
473 \r
474                 switch (nBorderstyle)\r
475                 {\r
476                         case BBS_SOLID:\r
477                                 vp << (FX_LPCWSTR)L"solid";\r
478                                 break;\r
479                         case BBS_DASH:\r
480                                 vp << (FX_LPCWSTR)L"dashed";\r
481                                 break;\r
482                         case BBS_BEVELED:\r
483                                 vp << (FX_LPCWSTR)L"beveled";\r
484                                 break;\r
485                         case BBS_INSET:\r
486                                 vp << (FX_LPCWSTR)L"inset";\r
487                                 break;\r
488                         case BBS_UNDERLINE:\r
489                                 vp << (FX_LPCWSTR)L"underline";\r
490                                 break;\r
491                         default:\r
492                                 vp << (FX_LPCWSTR)L"";\r
493                                 break;\r
494                 }\r
495         }\r
496 \r
497         return TRUE;\r
498 }\r
499 \r
500 void Field::SetBorderStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, \r
501                                                    const CFX_ByteString& string)\r
502 {\r
503         ASSERT(pDocument != NULL);\r
504 \r
505         int nBorderStyle = 0;\r
506 \r
507         if (string == "solid")\r
508                 nBorderStyle = BBS_SOLID;\r
509         else if (string == "beveled")\r
510                 nBorderStyle = BBS_BEVELED;\r
511         else if (string == "dashed")\r
512                 nBorderStyle = BBS_DASH;\r
513         else if (string == "inset")\r
514                 nBorderStyle = BBS_INSET;\r
515         else if (string == "underline")\r
516                 nBorderStyle = BBS_UNDERLINE;\r
517         else return;\r
518 \r
519         CFX_PtrArray FieldArray;\r
520         GetFormFields(pDocument, swFieldName, FieldArray);\r
521 \r
522         for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)\r
523         {\r
524                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);\r
525                 ASSERT(pFormField != NULL);\r
526 \r
527                 if (nControlIndex < 0)\r
528                 {\r
529                         FX_BOOL bSet = FALSE;\r
530                         for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)\r
531                         {\r
532                                 if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormField->GetControl(j)))\r
533                                 {\r
534                                         if (pWidget->GetBorderStyle() != nBorderStyle)\r
535                                         {\r
536                                                 pWidget->SetBorderStyle(nBorderStyle);\r
537                                                 bSet = TRUE;\r
538                                         }\r
539                                 }\r
540                         }\r
541                         if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);\r
542                 }\r
543                 else\r
544                 {\r
545                         if(nControlIndex >= pFormField->CountControls()) return;\r
546                         if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))\r
547                         {\r
548                                 if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormControl))\r
549                                 {\r
550                                         if (pWidget->GetBorderStyle() != nBorderStyle)\r
551                                         {\r
552                                                 pWidget->SetBorderStyle(nBorderStyle);\r
553                                                 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);\r
554                                         }\r
555                                 }\r
556                         }\r
557                 }\r
558         }\r
559 }\r
560 \r
561 FX_BOOL Field::buttonAlignX(OBJ_PROP_PARAMS)\r
562 {\r
563         ASSERT(m_pDocument != NULL);\r
564 \r
565         if (vp.IsSetting())\r
566         {\r
567                 if (!m_bCanSet) return FALSE;\r
568 \r
569                 int nVP;\r
570                 vp >> nVP;\r
571 \r
572                 if (m_bDelay)\r
573                 {\r
574                         AddDelay_Int(FP_BUTTONALIGNX, nVP);\r
575                 }\r
576                 else\r
577                 {\r
578                         Field::SetButtonAlignX(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
579                 }\r
580         }\r
581         else\r
582         {               \r
583                 CFX_PtrArray FieldArray;\r
584                 GetFormFields(m_FieldName,FieldArray);\r
585                 if (FieldArray.GetSize() <= 0) return FALSE;\r
586 \r
587                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
588                 ASSERT(pFormField != NULL);\r
589 \r
590                 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)\r
591                         return FALSE;\r
592 \r
593                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
594                 if (!pFormControl)return FALSE;\r
595 \r
596                 CPDF_IconFit IconFit = pFormControl->GetIconFit();\r
597 \r
598                 FX_FLOAT fLeft,fBottom;\r
599                 IconFit.GetIconPosition(fLeft,fBottom);\r
600 \r
601                 vp << (FX_INT32)fLeft;\r
602         }\r
603 \r
604         return TRUE;\r
605 }\r
606 \r
607 void Field::SetButtonAlignX(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
608 {\r
609         //Not supported.\r
610 }\r
611 \r
612 FX_BOOL Field::buttonAlignY(OBJ_PROP_PARAMS)\r
613 {\r
614         ASSERT(m_pDocument != NULL);\r
615 \r
616         if (vp.IsSetting())\r
617         {\r
618                 if (!m_bCanSet) return FALSE;\r
619 \r
620                 int nVP;\r
621                 vp >> nVP;\r
622 \r
623                 if (m_bDelay)\r
624                 {\r
625                         AddDelay_Int(FP_BUTTONALIGNY, nVP);\r
626                 }\r
627                 else\r
628                 {\r
629                         Field::SetButtonAlignY(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
630                 }\r
631         }\r
632         else\r
633         {\r
634                 CFX_PtrArray FieldArray;\r
635                 GetFormFields(m_FieldName,FieldArray);\r
636                 if (FieldArray.GetSize() <= 0) return FALSE;\r
637 \r
638                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
639                 ASSERT(pFormField != NULL);\r
640 \r
641                 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)\r
642                         return FALSE;\r
643 \r
644                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
645                 if (!pFormControl)return FALSE;\r
646 \r
647                 CPDF_IconFit IconFit = pFormControl->GetIconFit();\r
648 \r
649                 FX_FLOAT fLeft,fBottom;\r
650                 IconFit.GetIconPosition(fLeft,fBottom);\r
651 \r
652                 vp <<  (FX_INT32)fBottom;\r
653         }\r
654 \r
655         return TRUE;\r
656 }\r
657 \r
658 void Field::SetButtonAlignY(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
659 {\r
660         //Not supported.\r
661 }\r
662 \r
663 FX_BOOL Field::buttonFitBounds(OBJ_PROP_PARAMS)\r
664 {\r
665         ASSERT(m_pDocument != NULL);\r
666 \r
667         if (vp.IsSetting())\r
668         {\r
669                 if (!m_bCanSet) return FALSE;\r
670 \r
671                 bool bVP;\r
672                 vp >> bVP;\r
673 \r
674                 if (m_bDelay)\r
675                 {\r
676                         AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP);\r
677                 }\r
678                 else\r
679                 {\r
680                         Field::SetButtonFitBounds(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);\r
681                 }\r
682         }\r
683         else\r
684         {\r
685                 CFX_PtrArray FieldArray;\r
686                 GetFormFields(m_FieldName,FieldArray);\r
687                 if (FieldArray.GetSize() <= 0) return FALSE;\r
688 \r
689                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
690                 ASSERT(pFormField != NULL);\r
691 \r
692                 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)\r
693                         return FALSE;\r
694 \r
695                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
696                 if (!pFormControl)return FALSE;\r
697 \r
698                 CPDF_IconFit IconFit = pFormControl->GetIconFit();\r
699                 vp << IconFit.GetFittingBounds();               \r
700         }\r
701 \r
702         return TRUE;\r
703 }\r
704 \r
705 void Field::SetButtonFitBounds(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)\r
706 {\r
707         //Not supported.\r
708 }\r
709 \r
710 FX_BOOL Field::buttonPosition(OBJ_PROP_PARAMS)\r
711 {\r
712         ASSERT(m_pDocument != NULL);\r
713 \r
714         if (vp.IsSetting())\r
715         {\r
716                 if (!m_bCanSet) return FALSE;\r
717 \r
718                 int nVP;\r
719                 vp >> nVP;\r
720 \r
721                 if (m_bDelay)\r
722                 {\r
723                         AddDelay_Int(FP_BUTTONPOSITION, nVP);\r
724                 }\r
725                 else\r
726                 {\r
727                         Field::SetButtonPosition(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
728                 }\r
729         }\r
730         else\r
731         {\r
732                 CFX_PtrArray FieldArray;\r
733                 GetFormFields(m_FieldName,FieldArray);\r
734                 if (FieldArray.GetSize() <= 0) return FALSE;\r
735 \r
736                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
737                 ASSERT(pFormField != NULL);\r
738 \r
739                 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)\r
740                         return FALSE;\r
741 \r
742                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
743                 if (!pFormControl)return FALSE;\r
744 \r
745                 vp <<  pFormControl->GetTextPosition();\r
746         }\r
747         return TRUE;\r
748 }\r
749 \r
750 void Field::SetButtonPosition(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
751 {\r
752         //Not supported.\r
753 }\r
754 \r
755 FX_BOOL Field::buttonScaleHow(OBJ_PROP_PARAMS)\r
756 {\r
757         ASSERT(m_pDocument != NULL);\r
758 \r
759         if (vp.IsSetting())\r
760         {\r
761                 if (!m_bCanSet) return FALSE;\r
762 \r
763                 int nVP;\r
764                 vp >> nVP;\r
765 \r
766                 if (m_bDelay)\r
767                 {\r
768                         AddDelay_Int(FP_BUTTONSCALEHOW, nVP);\r
769                 }\r
770                 else\r
771                 {\r
772                         Field::SetButtonScaleHow(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
773                 }\r
774         }\r
775         else\r
776         {\r
777                 CFX_PtrArray FieldArray;\r
778                 GetFormFields(m_FieldName, FieldArray);\r
779                 if (FieldArray.GetSize() <= 0) return FALSE;\r
780 \r
781                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
782                 ASSERT(pFormField != NULL);\r
783 \r
784                 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)\r
785                         return FALSE;\r
786 \r
787                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
788                 if (!pFormControl)return FALSE;\r
789 \r
790                 CPDF_IconFit IconFit = pFormControl->GetIconFit();\r
791                 if (IconFit.IsProportionalScale())\r
792                         vp << (FX_INT32)0;\r
793                 else\r
794                         vp << (FX_INT32)1;\r
795         }\r
796 \r
797         return TRUE;\r
798 }\r
799 \r
800 void Field::SetButtonScaleHow(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
801 {\r
802         //Not supported.\r
803 }\r
804 \r
805 FX_BOOL Field::buttonScaleWhen(OBJ_PROP_PARAMS)\r
806 {\r
807         ASSERT(m_pDocument != NULL);\r
808 \r
809         if (vp.IsSetting())\r
810         {\r
811                 if (!m_bCanSet) return FALSE;\r
812 \r
813                 int nVP;\r
814                 vp >> nVP;\r
815 \r
816                 if (m_bDelay)\r
817                 {\r
818                         AddDelay_Int(FP_BUTTONSCALEWHEN, nVP);\r
819                 }\r
820                 else\r
821                 {\r
822                         Field::SetButtonScaleWhen(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
823                 }\r
824         }\r
825         else\r
826         {\r
827                 CFX_PtrArray FieldArray;\r
828                 GetFormFields(m_FieldName,FieldArray);\r
829                 if (FieldArray.GetSize() <= 0) return FALSE;\r
830 \r
831                 CPDF_FormField* pFormField = (CPDF_FormField*) FieldArray.ElementAt(0);\r
832                 ASSERT(pFormField != NULL);\r
833 \r
834                 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)\r
835                         return FALSE;\r
836 \r
837                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
838                 if (!pFormControl) return FALSE;\r
839 \r
840                 CPDF_IconFit IconFit = pFormControl->GetIconFit();\r
841                 int ScaleM = IconFit.GetScaleMethod();\r
842                 switch (ScaleM)\r
843                 {\r
844                         case CPDF_IconFit::Always :\r
845                                 vp <<  (FX_INT32) CPDF_IconFit::Always;\r
846                                 break;\r
847                         case CPDF_IconFit::Bigger :\r
848                                 vp <<  (FX_INT32) CPDF_IconFit::Bigger;\r
849                                 break;\r
850                         case CPDF_IconFit::Never :\r
851                                 vp <<  (FX_INT32) CPDF_IconFit::Never;\r
852                                 break;\r
853                         case CPDF_IconFit::Smaller :\r
854                                 vp <<  (FX_INT32) CPDF_IconFit::Smaller;\r
855                                 break;\r
856                 }\r
857         }\r
858 \r
859         return TRUE;\r
860 }\r
861 \r
862 void Field::SetButtonScaleWhen(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
863 {\r
864         //Not supported.\r
865 }\r
866 \r
867 FX_BOOL Field::calcOrderIndex(OBJ_PROP_PARAMS)\r
868 {\r
869         ASSERT(m_pDocument != NULL);\r
870 \r
871         if (vp.IsSetting())\r
872         {       \r
873                 if (!m_bCanSet) return FALSE;\r
874 \r
875                 int nVP;\r
876                 vp >> nVP;\r
877 \r
878                 if (m_bDelay)\r
879                 {\r
880                         AddDelay_Int(FP_CALCORDERINDEX, nVP);\r
881                 }\r
882                 else\r
883                 {\r
884                         Field::SetCalcOrderIndex(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
885                 }\r
886         }\r
887         else\r
888         {\r
889                 CFX_PtrArray FieldArray;\r
890                 GetFormFields(m_FieldName, FieldArray);\r
891                 if (FieldArray.GetSize() <= 0) return FALSE;\r
892 \r
893                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
894                 ASSERT(pFormField != NULL);\r
895 \r
896                 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)\r
897                         return FALSE;\r
898 \r
899                 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm();\r
900                 ASSERT(pRDInterForm != NULL);\r
901 \r
902                 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();\r
903                 ASSERT(pInterForm != NULL);\r
904 \r
905                 vp << (FX_INT32)pInterForm->FindFieldInCalculationOrder(pFormField);\r
906         }\r
907 \r
908         return TRUE;\r
909 }\r
910 \r
911 void Field::SetCalcOrderIndex(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
912 {\r
913         //Not supported.\r
914 }\r
915 \r
916 FX_BOOL Field::charLimit(OBJ_PROP_PARAMS)\r
917 {\r
918         ASSERT(m_pDocument != NULL);\r
919 \r
920         if (vp.IsSetting())\r
921         {\r
922                 if (!m_bCanSet) return FALSE;\r
923 \r
924                 int nVP;\r
925                 vp >> nVP;\r
926 \r
927                 if (m_bDelay)\r
928                 {\r
929                         AddDelay_Int(FP_CHARLIMIT, nVP);\r
930                 }\r
931                 else\r
932                 {\r
933                         Field::SetCharLimit(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
934                 }\r
935         }\r
936         else\r
937         {\r
938                 CFX_PtrArray FieldArray;\r
939                 GetFormFields(m_FieldName, FieldArray);\r
940                 if (FieldArray.GetSize() <= 0) return FALSE;\r
941 \r
942                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
943                 ASSERT(pFormField != NULL);\r
944 \r
945                 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)\r
946                         return FALSE;\r
947 \r
948                 vp << (FX_INT32)pFormField->GetMaxLen();\r
949         }\r
950         return TRUE;\r
951 }\r
952 \r
953 void Field::SetCharLimit(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
954 {\r
955         //Not supported.\r
956 }\r
957 \r
958 FX_BOOL Field::comb(OBJ_PROP_PARAMS)\r
959 {\r
960         ASSERT(m_pDocument != NULL);\r
961 \r
962         if (vp.IsSetting())\r
963         {\r
964                 if (!m_bCanSet) return FALSE;\r
965 \r
966                 bool bVP;\r
967                 vp >> bVP;\r
968 \r
969                 if (m_bDelay)\r
970                 {\r
971                         AddDelay_Bool(FP_COMB, bVP);\r
972                 }\r
973                 else\r
974                 {\r
975                         Field::SetComb(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);\r
976                 }\r
977         }\r
978         else\r
979         {       \r
980                 CFX_PtrArray FieldArray;\r
981                 GetFormFields(m_FieldName,FieldArray);\r
982                 if (FieldArray.GetSize() <= 0) return FALSE;\r
983 \r
984                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
985                 ASSERT(pFormField != NULL);\r
986 \r
987                 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)\r
988                         return FALSE;\r
989 \r
990                 if (pFormField->GetFieldFlags() & FIELDFLAG_COMB)\r
991                         vp << true;\r
992                 else\r
993                         vp << false;\r
994         }\r
995 \r
996         return TRUE;\r
997 }\r
998 \r
999 void Field::SetComb(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)\r
1000 {\r
1001         //Not supported.\r
1002 }\r
1003 \r
1004 FX_BOOL Field::commitOnSelChange(OBJ_PROP_PARAMS)\r
1005 {\r
1006         ASSERT(m_pDocument != NULL);\r
1007 \r
1008         if (vp.IsSetting())\r
1009         {\r
1010                 if (!m_bCanSet) return FALSE;\r
1011 \r
1012                 bool bVP;\r
1013                 vp >> bVP;\r
1014 \r
1015                 if (m_bDelay)\r
1016                 {\r
1017                         AddDelay_Bool(FP_COMMITONSELCHANGE, bVP);\r
1018                 }\r
1019                 else\r
1020                 {\r
1021                         Field::SetCommitOnSelChange(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);\r
1022                 }\r
1023         }\r
1024         else\r
1025         {\r
1026                 CFX_PtrArray FieldArray;\r
1027                 GetFormFields(m_FieldName,FieldArray);\r
1028                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1029 \r
1030                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1031                 ASSERT(pFormField != NULL);\r
1032 \r
1033                 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetFieldType() != FIELDTYPE_LISTBOX)\r
1034                         return FALSE;\r
1035 \r
1036                 if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)\r
1037                         vp << true;\r
1038                 else\r
1039                         vp << false;\r
1040         }\r
1041 \r
1042         return TRUE;\r
1043 }\r
1044 \r
1045 void Field::SetCommitOnSelChange(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)\r
1046 {\r
1047         //Not supported.\r
1048 }\r
1049 \r
1050 FX_BOOL Field::currentValueIndices(OBJ_PROP_PARAMS)\r
1051 {\r
1052         ASSERT(m_pDocument != NULL);\r
1053 \r
1054         if (vp.IsSetting())\r
1055         {\r
1056                 if (!m_bCanSet) return FALSE;\r
1057 \r
1058                 CFX_DWordArray array;\r
1059 \r
1060                 if (vp.GetType() == VT_number)\r
1061                 {\r
1062                         int iSelecting = 0;\r
1063                         vp >> iSelecting;\r
1064                         array.Add(iSelecting);\r
1065                 }\r
1066                 else if (vp.IsArrayObject())\r
1067                 {\r
1068                         CJS_Array SelArray(m_isolate);\r
1069                         CJS_Value SelValue(m_isolate);\r
1070                         int iSelecting;\r
1071                         vp >> SelArray;\r
1072                         for (int i=0,sz=SelArray.GetLength(); i<sz; i++)\r
1073                         {\r
1074                                 SelArray.GetElement(i,SelValue);\r
1075                                 iSelecting = (FX_INT32)SelValue;\r
1076                                 array.Add(iSelecting);\r
1077                         }\r
1078                 }\r
1079                 \r
1080                 if (m_bDelay)\r
1081                 {\r
1082                         AddDelay_WordArray(FP_CURRENTVALUEINDICES, array);\r
1083                 }\r
1084                 else\r
1085                 {\r
1086                         Field::SetCurrentValueIndices(m_pDocument, m_FieldName, m_nFormControlIndex, array);\r
1087                 }\r
1088         }\r
1089         else\r
1090         {\r
1091                 CFX_PtrArray FieldArray;\r
1092                 GetFormFields(m_FieldName,FieldArray);\r
1093                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1094 \r
1095                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1096                 ASSERT(pFormField != NULL);\r
1097 \r
1098                 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetFieldType() != FIELDTYPE_LISTBOX)\r
1099                         return FALSE;\r
1100 \r
1101                 if (pFormField->CountSelectedItems() == 1)\r
1102                         vp << pFormField->GetSelectedIndex(0);\r
1103                 else if (pFormField->CountSelectedItems() > 1)\r
1104                 {\r
1105                         CJS_Array SelArray(m_isolate);\r
1106                         for (int i=0,sz=pFormField->CountSelectedItems(); i<sz; i++)\r
1107                         {\r
1108                                 SelArray.SetElement(i, CJS_Value(m_isolate,pFormField->GetSelectedIndex(i)));\r
1109                         }\r
1110                         vp << SelArray;\r
1111                 }\r
1112                 else\r
1113                         vp << -1;\r
1114         }\r
1115 \r
1116         return TRUE;\r
1117 }\r
1118 \r
1119 void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, \r
1120                                                                    const CFX_DWordArray& array)\r
1121 {\r
1122         ASSERT(pDocument != NULL);\r
1123 \r
1124         CFX_PtrArray FieldArray;\r
1125         GetFormFields(pDocument, swFieldName, FieldArray);\r
1126 \r
1127         for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)\r
1128         {\r
1129                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);\r
1130                 ASSERT(pFormField != NULL);\r
1131 \r
1132                 int nFieldType = pFormField->GetFieldType();\r
1133                 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX)\r
1134                 {\r
1135                         FX_DWORD dwFieldFlags = pFormField->GetFieldFlags();\r
1136                         pFormField->ClearSelection(TRUE);\r
1137 \r
1138                         for (int i=0,sz=array.GetSize(); i<sz; i++)\r
1139                         {\r
1140                                 if (i>0 && !(dwFieldFlags & (1<<21)))\r
1141                                 {\r
1142                                         break;\r
1143                                 }\r
1144 \r
1145                                 int iSelecting = (FX_INT32)array.GetAt(i);\r
1146                                 if (iSelecting < pFormField->CountOptions() && !pFormField->IsItemSelected(iSelecting))\r
1147                                         pFormField->SetItemSelection(iSelecting, TRUE);\r
1148 \r
1149                         }\r
1150                         UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);\r
1151                 }\r
1152         }\r
1153 }\r
1154 \r
1155 FX_BOOL Field::defaultStyle(OBJ_PROP_PARAMS)\r
1156 {\r
1157         // MQG sError = JSGetStringFromID(IDS_STRING_NOTSUPPORT);\r
1158         return FALSE;\r
1159 \r
1160         if (vp.IsSetting())\r
1161         {\r
1162                 if (!m_bCanSet) return FALSE;\r
1163 \r
1164                 ;               \r
1165         }\r
1166         else\r
1167         {\r
1168                 ;\r
1169         }\r
1170         return TRUE;\r
1171 }\r
1172 \r
1173 void Field::SetDefaultStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex)\r
1174 {\r
1175         //Not supported.\r
1176 }\r
1177 \r
1178 FX_BOOL Field::defaultValue(OBJ_PROP_PARAMS)\r
1179 {\r
1180         ASSERT(m_pDocument != NULL);\r
1181 \r
1182         if (vp.IsSetting())\r
1183         {\r
1184                 if (!m_bCanSet) return FALSE;\r
1185 \r
1186                 CFX_WideString WideStr;\r
1187                 vp >> WideStr; \r
1188 \r
1189                 if (m_bDelay)\r
1190                 {\r
1191                         AddDelay_WideString(FP_DEFAULTVALUE, WideStr);\r
1192                 }\r
1193                 else\r
1194                 {\r
1195                         Field::SetDefaultValue(m_pDocument, m_FieldName, m_nFormControlIndex, WideStr);\r
1196                 }\r
1197         }\r
1198         else\r
1199         {\r
1200                 CFX_PtrArray FieldArray;\r
1201                 GetFormFields(m_FieldName,FieldArray);\r
1202                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1203 \r
1204                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1205                 ASSERT(pFormField != NULL);\r
1206 \r
1207                 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON || \r
1208                         pFormField->GetFieldType() == FIELDTYPE_SIGNATURE)\r
1209                         return FALSE;\r
1210 \r
1211                 vp << pFormField->GetDefaultValue();\r
1212         }\r
1213         return TRUE;\r
1214 }\r
1215 \r
1216 void Field::SetDefaultValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex,\r
1217                                                         const CFX_WideString& string)\r
1218 {\r
1219         //Not supported.\r
1220 }\r
1221 \r
1222 FX_BOOL Field::doNotScroll(OBJ_PROP_PARAMS)\r
1223 {\r
1224         ASSERT(m_pDocument != NULL);\r
1225 \r
1226         if (vp.IsSetting())\r
1227         {\r
1228                 if (!m_bCanSet) return FALSE;\r
1229 \r
1230                 bool bVP;\r
1231                 vp >> bVP;\r
1232 \r
1233                 if (m_bDelay)\r
1234                 {\r
1235                         AddDelay_Bool(FP_DONOTSCROLL, bVP);\r
1236                 }\r
1237                 else\r
1238                 {\r
1239                         Field::SetDoNotScroll(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);\r
1240                 }\r
1241         }\r
1242         else\r
1243         {\r
1244                 CFX_PtrArray FieldArray;\r
1245                 GetFormFields(m_FieldName,FieldArray);\r
1246                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1247 \r
1248                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1249                 ASSERT(pFormField != NULL);\r
1250 \r
1251                 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)\r
1252                         return FALSE;\r
1253 \r
1254                 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)\r
1255                         vp << true;\r
1256                 else\r
1257                         vp << false;\r
1258         }\r
1259 \r
1260         return TRUE;\r
1261 }\r
1262 \r
1263 void Field::SetDoNotScroll(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)\r
1264 {\r
1265         //Not supported.\r
1266 }\r
1267 \r
1268 FX_BOOL Field::doNotSpellCheck(OBJ_PROP_PARAMS)\r
1269 {\r
1270         ASSERT(m_pDocument != NULL);\r
1271 \r
1272         if (vp.IsSetting())\r
1273         {\r
1274                 if (!m_bCanSet) return FALSE;\r
1275 \r
1276                 bool bVP;\r
1277                 vp >> bVP;\r
1278         }\r
1279         else\r
1280         {\r
1281                 CFX_PtrArray FieldArray;\r
1282                 GetFormFields(m_FieldName,FieldArray);\r
1283                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1284 \r
1285                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1286                 ASSERT(pFormField != NULL);\r
1287 \r
1288                 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD && \r
1289                         pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)\r
1290                         return FALSE;\r
1291 \r
1292                 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)\r
1293                         vp << true;\r
1294                 else\r
1295                         vp << false;\r
1296         }\r
1297 \r
1298         return TRUE;\r
1299 }\r
1300 \r
1301 void Field::SetDelay(FX_BOOL bDelay)\r
1302 {\r
1303         m_bDelay = bDelay;\r
1304 \r
1305         if (!m_bDelay)\r
1306         {\r
1307                 if (m_pJSDoc)\r
1308                         m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex);\r
1309         }\r
1310 }\r
1311 \r
1312 FX_BOOL Field::delay(OBJ_PROP_PARAMS)\r
1313 {\r
1314         if (vp.IsSetting())\r
1315         {\r
1316                 if (!m_bCanSet) return FALSE;\r
1317                 \r
1318                 bool bVP;\r
1319                 vp >> bVP;\r
1320 \r
1321                 SetDelay(bVP);\r
1322         }\r
1323         else\r
1324         {\r
1325                 vp << m_bDelay;\r
1326         }\r
1327         return TRUE;\r
1328 }\r
1329 \r
1330 FX_BOOL Field::display(OBJ_PROP_PARAMS)\r
1331 {\r
1332         ASSERT(m_pDocument != NULL);\r
1333 \r
1334         if (vp.IsSetting())\r
1335         {\r
1336                 if (!m_bCanSet) return FALSE;\r
1337 \r
1338                 int nVP;\r
1339                 vp >> nVP;      \r
1340 \r
1341                 if (m_bDelay)\r
1342                 {\r
1343                         AddDelay_Int(FP_DISPLAY, nVP);\r
1344                 }\r
1345                 else\r
1346                 {\r
1347                         Field::SetDisplay(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
1348                 }\r
1349         }\r
1350         else\r
1351         {\r
1352                 CFX_PtrArray FieldArray;\r
1353                 GetFormFields(m_FieldName,FieldArray);\r
1354                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1355 \r
1356                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1357                 ASSERT(pFormField != NULL);\r
1358 \r
1359                 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();\r
1360                 ASSERT(pInterForm != NULL);\r
1361 \r
1362                 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));\r
1363                 if (!pWidget)return FALSE;\r
1364 \r
1365                 FX_DWORD dwFlag = pWidget->GetFlags();\r
1366 \r
1367                 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) \r
1368                 {\r
1369                         vp << (FX_INT32)1;\r
1370                 }\r
1371                 else \r
1372                 {\r
1373                         if (ANNOTFLAG_PRINT & dwFlag)\r
1374                         {\r
1375                                 if (ANNOTFLAG_NOVIEW & dwFlag)\r
1376                                 {\r
1377                                         vp << (FX_INT32)3;\r
1378                                 }\r
1379                                 else\r
1380                                 {\r
1381                                         vp << (FX_INT32)0;\r
1382                                 }\r
1383                         }\r
1384                         else\r
1385                         {\r
1386                                 vp << (FX_INT32)2;\r
1387                         }                               \r
1388                 }\r
1389         }\r
1390 \r
1391         return TRUE;\r
1392 }\r
1393 \r
1394 void Field::SetDisplay(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
1395 {\r
1396         ASSERT(pDocument != NULL);\r
1397 \r
1398         CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();\r
1399         ASSERT(pInterForm != NULL);\r
1400 \r
1401         CFX_PtrArray FieldArray;\r
1402         GetFormFields(pDocument, swFieldName, FieldArray);\r
1403 \r
1404         for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)\r
1405         {\r
1406                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);\r
1407                 ASSERT(pFormField != NULL);\r
1408 \r
1409                 if (nControlIndex < 0)\r
1410                 {\r
1411                         FX_BOOL bSet = FALSE;\r
1412                         for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)\r
1413                         {\r
1414                                 CPDF_FormControl* pFormControl = pFormField->GetControl(j);\r
1415                                 ASSERT(pFormControl != NULL);\r
1416 \r
1417                                 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))\r
1418                                 {\r
1419                                         FX_DWORD dwFlag = pWidget->GetFlags();\r
1420                                         switch (number)\r
1421                                         {\r
1422                                         case 0:\r
1423                                                 dwFlag &= (~ANNOTFLAG_INVISIBLE);\r
1424                                                 dwFlag &= (~ANNOTFLAG_HIDDEN);\r
1425                                                 dwFlag &= (~ANNOTFLAG_NOVIEW);\r
1426                                                 dwFlag |= ANNOTFLAG_PRINT;                                                      \r
1427                                                 break;\r
1428                                         case 1:\r
1429                                                 dwFlag &= (~ANNOTFLAG_INVISIBLE);\r
1430                                                 dwFlag &= (~ANNOTFLAG_NOVIEW);\r
1431                                                 dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);\r
1432                                                 break;\r
1433                                         case 2:\r
1434                                                 dwFlag &= (~ANNOTFLAG_INVISIBLE);\r
1435                                                 dwFlag &= (~ANNOTFLAG_PRINT);\r
1436                                                 dwFlag &= (~ANNOTFLAG_HIDDEN);\r
1437                                                 dwFlag &= (~ANNOTFLAG_NOVIEW);\r
1438                                                 break;\r
1439                                         case 3:\r
1440                                                 dwFlag |= ANNOTFLAG_NOVIEW;\r
1441                                                 dwFlag |= ANNOTFLAG_PRINT;\r
1442                                                 dwFlag &= (~ANNOTFLAG_HIDDEN);\r
1443                                                 break;\r
1444                                         }       \r
1445 \r
1446                                         if (dwFlag != pWidget->GetFlags())\r
1447                                         {\r
1448                                                 pWidget->SetFlags(dwFlag);\r
1449                                                 bSet = TRUE;\r
1450                                         }\r
1451                                 }\r
1452                         }               \r
1453                         \r
1454                         if (bSet) UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);\r
1455                 }\r
1456                 else\r
1457                 {\r
1458                         if(nControlIndex >= pFormField->CountControls()) return;\r
1459                         if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))\r
1460                         {\r
1461                                 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))\r
1462                                 {\r
1463 \r
1464                                         FX_DWORD dwFlag = pWidget->GetFlags();\r
1465                                         switch (number)\r
1466                                         {\r
1467                                         case 0:\r
1468                                                 dwFlag &= (~ANNOTFLAG_INVISIBLE);\r
1469                                                 dwFlag &= (~ANNOTFLAG_HIDDEN);\r
1470                                                 dwFlag &= (~ANNOTFLAG_NOVIEW);\r
1471                                                 dwFlag |= ANNOTFLAG_PRINT;                                                      \r
1472                                                 break;\r
1473                                         case 1:\r
1474                                                 dwFlag &= (~ANNOTFLAG_INVISIBLE);\r
1475                                                 dwFlag &= (~ANNOTFLAG_NOVIEW);\r
1476                                                 dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);\r
1477                                                 break;\r
1478                                         case 2:\r
1479                                                 dwFlag &= (~ANNOTFLAG_INVISIBLE);\r
1480                                                 dwFlag &= (~ANNOTFLAG_PRINT);\r
1481                                                 dwFlag &= (~ANNOTFLAG_HIDDEN);\r
1482                                                 dwFlag &= (~ANNOTFLAG_NOVIEW);\r
1483                                                 break;\r
1484                                         case 3:\r
1485                                                 dwFlag |= ANNOTFLAG_NOVIEW;\r
1486                                                 dwFlag |= ANNOTFLAG_PRINT;\r
1487                                                 dwFlag &= (~ANNOTFLAG_HIDDEN);\r
1488                                                 break;\r
1489                                         }       \r
1490                                         if (dwFlag != pWidget->GetFlags())\r
1491                                         {\r
1492                                                 pWidget->SetFlags(dwFlag);\r
1493                                                 UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE);\r
1494                                         }\r
1495                                 }\r
1496                         }\r
1497                 }\r
1498         }\r
1499 }\r
1500 \r
1501 FX_BOOL Field::doc(OBJ_PROP_PARAMS)\r
1502 {\r
1503         ASSERT(m_pJSDoc != NULL);\r
1504 \r
1505         if (!vp.IsGetting())return FALSE;\r
1506 \r
1507         vp << (CJS_Object*)(*m_pJSDoc);\r
1508 \r
1509         return TRUE;\r
1510 }\r
1511 \r
1512 FX_BOOL Field::editable(OBJ_PROP_PARAMS)\r
1513 {\r
1514         ASSERT(m_pDocument != NULL);\r
1515 \r
1516         if (vp.IsSetting())\r
1517         {\r
1518                 if (!m_bCanSet) return FALSE;\r
1519 \r
1520                 bool bVP;\r
1521                 vp >> bVP;\r
1522 \r
1523         }\r
1524         else\r
1525         {\r
1526                 CFX_PtrArray FieldArray;\r
1527                 GetFormFields(m_FieldName, FieldArray);\r
1528                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1529 \r
1530                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1531                 ASSERT(pFormField != NULL);\r
1532 \r
1533                 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)\r
1534                         return FALSE;\r
1535 \r
1536                 if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT)\r
1537                         vp << true;\r
1538                 else\r
1539                         vp << false;\r
1540         }\r
1541 \r
1542         return TRUE;\r
1543 }\r
1544 \r
1545 FX_BOOL Field::exportValues(OBJ_PROP_PARAMS)\r
1546 {\r
1547         ASSERT(m_pDocument != NULL);\r
1548 \r
1549         CFX_PtrArray FieldArray;\r
1550         GetFormFields(m_FieldName,FieldArray);\r
1551         if (FieldArray.GetSize() <= 0) return FALSE;\r
1552 \r
1553         CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1554         ASSERT(pFormField != NULL);\r
1555 \r
1556         if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && \r
1557                 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)\r
1558                 return FALSE;\r
1559 \r
1560         if (vp.IsSetting())\r
1561         {       \r
1562                 if (!m_bCanSet) return FALSE;\r
1563                 if (!vp.IsArrayObject())return FALSE;\r
1564         }\r
1565         else\r
1566         {\r
1567                 CJS_Array ExportValusArray(m_isolate);\r
1568 \r
1569                 if (m_nFormControlIndex < 0)\r
1570                 {\r
1571                         for (int i=0,sz=pFormField->CountControls(); i<sz; i++)\r
1572                         {\r
1573                                 CPDF_FormControl* pFormControl = pFormField->GetControl(i);\r
1574                                 ASSERT(pFormControl != NULL);\r
1575 \r
1576                                 ExportValusArray.SetElement(i, CJS_Value(m_isolate,(FX_LPCWSTR)pFormControl->GetExportValue()));\r
1577                         }\r
1578                 }\r
1579                 else\r
1580                 {\r
1581                         if(m_nFormControlIndex >= pFormField->CountControls()) return FALSE;\r
1582                         CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex);\r
1583                         if (!pFormControl) return FALSE;\r
1584 \r
1585                         ExportValusArray.SetElement(0, CJS_Value(m_isolate,(FX_LPCWSTR)pFormControl->GetExportValue()));\r
1586                 }\r
1587 \r
1588                 vp << ExportValusArray;\r
1589         }\r
1590 \r
1591         return TRUE;\r
1592 }\r
1593 \r
1594 FX_BOOL Field::fileSelect(OBJ_PROP_PARAMS)\r
1595 {\r
1596         ASSERT(m_pDocument != NULL);\r
1597 \r
1598         CFX_PtrArray FieldArray;\r
1599         GetFormFields(m_FieldName, FieldArray);\r
1600         if (FieldArray.GetSize() <= 0) return FALSE;\r
1601 \r
1602         CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1603         ASSERT(pFormField != NULL);\r
1604 \r
1605         if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)\r
1606                 return FALSE;\r
1607 \r
1608         if (vp.IsSetting())\r
1609         {\r
1610                 if (!m_bCanSet) return FALSE;\r
1611 \r
1612                 bool bVP;\r
1613                 vp >> bVP;\r
1614 \r
1615         }\r
1616         else\r
1617         {\r
1618                 if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)\r
1619                         vp << true;\r
1620                 else\r
1621                         vp << false;\r
1622         }\r
1623 \r
1624         return TRUE;\r
1625 }\r
1626 \r
1627 FX_BOOL Field::fillColor(OBJ_PROP_PARAMS)\r
1628 {\r
1629         ASSERT(m_pDocument != NULL);\r
1630 \r
1631         CJS_Array crArray(m_isolate);\r
1632 \r
1633         CFX_PtrArray FieldArray;\r
1634         GetFormFields(m_FieldName,FieldArray);\r
1635         if (FieldArray.GetSize() <= 0) return FALSE;\r
1636 \r
1637         if (vp.IsSetting())\r
1638         {\r
1639                 if (!m_bCanSet) return FALSE;\r
1640                 if (!vp.IsArrayObject()) return FALSE;\r
1641 \r
1642                 vp >> crArray;\r
1643 \r
1644                 CPWL_Color color;\r
1645                 color::ConvertArrayToPWLColor(crArray, color);\r
1646 \r
1647                 if (m_bDelay)\r
1648                 {\r
1649                         AddDelay_Color(FP_FILLCOLOR, color);\r
1650                 }\r
1651                 else\r
1652                 {\r
1653                         Field::SetFillColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);\r
1654                 }\r
1655         }\r
1656         else\r
1657         {\r
1658                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1659                 ASSERT(pFormField != NULL);\r
1660 \r
1661                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
1662                 if (!pFormControl)return FALSE;\r
1663 \r
1664                 int iColorType;\r
1665                 pFormControl->GetBackgroundColor(iColorType);\r
1666 \r
1667                 CPWL_Color color;\r
1668 \r
1669                 if (iColorType == COLORTYPE_TRANSPARENT)\r
1670                 {\r
1671                         color = CPWL_Color(COLORTYPE_TRANSPARENT);\r
1672                 }\r
1673                 else if (iColorType == COLORTYPE_GRAY)\r
1674                 {\r
1675                         color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBackgroundColor(0));\r
1676                 }\r
1677                 else if (iColorType == COLORTYPE_RGB)\r
1678                 {\r
1679                         color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0),\r
1680                                 pFormControl->GetOriginalBackgroundColor(1),\r
1681                                 pFormControl->GetOriginalBackgroundColor(2));\r
1682                 }\r
1683                 else if (iColorType == COLORTYPE_CMYK)\r
1684                 {\r
1685                         color = CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBackgroundColor(0),\r
1686                                 pFormControl->GetOriginalBackgroundColor(1),\r
1687                                 pFormControl->GetOriginalBackgroundColor(2),\r
1688                                 pFormControl->GetOriginalBackgroundColor(3));\r
1689                 }\r
1690                 else\r
1691                         return FALSE;\r
1692 \r
1693                 color::ConvertPWLColorToArray(color, crArray);\r
1694         vp  <<  crArray;\r
1695         }\r
1696 \r
1697         return TRUE;\r
1698 }\r
1699 \r
1700 void Field::SetFillColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color)\r
1701 {\r
1702         //Not supported.\r
1703 }\r
1704 \r
1705 FX_BOOL Field::hidden(OBJ_PROP_PARAMS)\r
1706 {\r
1707         ASSERT(m_pDocument != NULL);\r
1708 \r
1709         if (vp.IsSetting())\r
1710         {\r
1711                 if (!m_bCanSet) return FALSE;\r
1712 \r
1713                 bool bVP;\r
1714                 vp >> bVP;\r
1715 \r
1716                 if (m_bDelay)\r
1717                 {\r
1718                         AddDelay_Bool(FP_HIDDEN, bVP);\r
1719                 }\r
1720                 else\r
1721                 {\r
1722                         Field::SetHidden(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);\r
1723                 }\r
1724         }\r
1725         else\r
1726         {\r
1727                 CFX_PtrArray FieldArray;\r
1728                 GetFormFields(m_FieldName,FieldArray);\r
1729                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1730 \r
1731                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1732                 ASSERT(pFormField != NULL);\r
1733 \r
1734                 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();\r
1735                 ASSERT(pInterForm != NULL);\r
1736 \r
1737                 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));\r
1738                 if (!pWidget) return FALSE;\r
1739 \r
1740                 FX_DWORD dwFlags = pWidget->GetFlags();\r
1741 \r
1742                 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) \r
1743                 {\r
1744                         vp << true;\r
1745                 }\r
1746                 else \r
1747                         vp << false;\r
1748         }\r
1749 \r
1750         return TRUE;\r
1751 }\r
1752 \r
1753 void Field::SetHidden(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)\r
1754 {\r
1755         ASSERT(pDocument != NULL);\r
1756 \r
1757         CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();\r
1758         ASSERT(pInterForm != NULL);\r
1759 \r
1760         CFX_PtrArray FieldArray;\r
1761         GetFormFields(pDocument, swFieldName, FieldArray);\r
1762 \r
1763         for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)\r
1764         {\r
1765                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);\r
1766                 ASSERT(pFormField != NULL);\r
1767 \r
1768                 if (nControlIndex < 0)\r
1769                 {\r
1770                         FX_BOOL bSet = FALSE;\r
1771                         for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)\r
1772                         {\r
1773                                 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(j)))\r
1774                                 {                                       \r
1775                                         FX_DWORD dwFlags = pWidget->GetFlags();\r
1776                                         \r
1777                                         if (b)\r
1778                                         {\r
1779                                                 dwFlags &= (~ANNOTFLAG_INVISIBLE);\r
1780                                                 dwFlags &= (~ANNOTFLAG_NOVIEW);\r
1781                                                 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);\r
1782                                         }\r
1783                                         else\r
1784                                         {\r
1785                                                 dwFlags &= (~ANNOTFLAG_INVISIBLE);\r
1786                                                 dwFlags &= (~ANNOTFLAG_HIDDEN);\r
1787                                                 dwFlags &= (~ANNOTFLAG_NOVIEW);\r
1788                                                 dwFlags |= ANNOTFLAG_PRINT;     \r
1789                                         }\r
1790 \r
1791                                         if (dwFlags != pWidget->GetFlags())\r
1792                                         {\r
1793                                                 pWidget->SetFlags(dwFlags);     \r
1794                                                 bSet = TRUE;\r
1795                                         }\r
1796                                 }\r
1797                         }\r
1798 \r
1799                         if (bSet)\r
1800                                 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);      \r
1801                 }\r
1802                 else\r
1803                 {\r
1804                         if(nControlIndex >= pFormField->CountControls()) return;\r
1805                         if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))\r
1806                         {\r
1807                                 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))\r
1808                                 {\r
1809                                         FX_DWORD dwFlags = pWidget->GetFlags();\r
1810                                         \r
1811                                         if (b)\r
1812                                         {\r
1813                                                 dwFlags &= (~ANNOTFLAG_INVISIBLE);\r
1814                                                 dwFlags &= (~ANNOTFLAG_NOVIEW);\r
1815                                                 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT);\r
1816                                         }\r
1817                                         else\r
1818                                         {\r
1819                                                 dwFlags &= (~ANNOTFLAG_INVISIBLE);\r
1820                                                 dwFlags &= (~ANNOTFLAG_HIDDEN);\r
1821                                                 dwFlags &= (~ANNOTFLAG_NOVIEW);\r
1822                                                 dwFlags |= ANNOTFLAG_PRINT;     \r
1823                                         }\r
1824 \r
1825                                         if (dwFlags != pWidget->GetFlags())\r
1826                                         {\r
1827                                                 pWidget->SetFlags(dwFlags);     \r
1828                                                 UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE);  \r
1829                                         }\r
1830                                 }\r
1831                         }\r
1832                 }\r
1833         }\r
1834 }\r
1835 \r
1836 FX_BOOL Field::highlight(OBJ_PROP_PARAMS)\r
1837 {\r
1838         ASSERT(m_pDocument != NULL);\r
1839 \r
1840         if (vp.IsSetting())\r
1841         {\r
1842                 if (!m_bCanSet) return FALSE;\r
1843 \r
1844                 CFX_ByteString strMode;\r
1845                 vp >> strMode;\r
1846 \r
1847                 if (m_bDelay)\r
1848                 {\r
1849                         AddDelay_String(FP_HIGHLIGHT, strMode);\r
1850                 }\r
1851                 else\r
1852                 {\r
1853                         Field::SetHighlight(m_pDocument, m_FieldName, m_nFormControlIndex, strMode);\r
1854                 }\r
1855         }\r
1856         else\r
1857         {\r
1858                 CFX_PtrArray FieldArray;\r
1859                 GetFormFields(m_FieldName,FieldArray);\r
1860                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1861 \r
1862                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1863                 ASSERT(pFormField != NULL);\r
1864 \r
1865                 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)\r
1866                         return FALSE;\r
1867 \r
1868                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
1869                 if (!pFormControl) return FALSE;\r
1870 \r
1871                 int eHM = pFormControl->GetHighlightingMode();\r
1872                 switch (eHM)\r
1873                 {\r
1874                 case CPDF_FormControl::None:\r
1875                         vp  <<  (FX_LPCWSTR)L"none";\r
1876                         break;\r
1877                 case CPDF_FormControl::Push:\r
1878                         vp  <<  (FX_LPCWSTR)L"push";\r
1879                         break;\r
1880                 case CPDF_FormControl::Invert:\r
1881                         vp  <<  (FX_LPCWSTR)L"invert";\r
1882                         break;\r
1883                 case CPDF_FormControl::Outline:\r
1884                         vp  <<  (FX_LPCWSTR)L"outline";\r
1885                         break;\r
1886                 case CPDF_FormControl::Toggle:\r
1887                          vp  <<  (FX_LPCWSTR)L"toggle";\r
1888                          break;\r
1889                 }\r
1890         }\r
1891 \r
1892         return TRUE;\r
1893 }\r
1894 \r
1895 void Field::SetHighlight(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string)\r
1896 {\r
1897         //Not supported.\r
1898 }\r
1899 \r
1900 FX_BOOL Field::lineWidth(OBJ_PROP_PARAMS)\r
1901 {\r
1902         ASSERT(m_pDocument != NULL);\r
1903 \r
1904         if (vp.IsSetting())\r
1905         {\r
1906                 if (!m_bCanSet) return FALSE;\r
1907 \r
1908                 int iWidth;\r
1909                 vp >> iWidth;\r
1910 \r
1911                 if (m_bDelay)\r
1912                 {\r
1913                         AddDelay_Int(FP_LINEWIDTH, iWidth);\r
1914                 }\r
1915                 else\r
1916                 {\r
1917                         Field::SetLineWidth(m_pDocument, m_FieldName, m_nFormControlIndex, iWidth);\r
1918                 }\r
1919         }\r
1920         else\r
1921         {\r
1922                 CFX_PtrArray FieldArray;\r
1923                 GetFormFields(m_FieldName,FieldArray);\r
1924                 if (FieldArray.GetSize() <= 0) return FALSE;\r
1925 \r
1926                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
1927                 ASSERT(pFormField != NULL);\r
1928 \r
1929                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
1930                 if (!pFormControl) return FALSE;\r
1931 \r
1932                 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();\r
1933                 ASSERT(pInterForm != NULL);\r
1934 \r
1935                 if(!pFormField->CountControls()) return FALSE;\r
1936 \r
1937                 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0));\r
1938                 if (!pWidget) return FALSE;\r
1939 \r
1940                 vp << (FX_INT32)pWidget->GetBorderWidth();\r
1941         }\r
1942 \r
1943         return TRUE;\r
1944 }\r
1945 \r
1946 void Field::SetLineWidth(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
1947 {\r
1948         ASSERT(pDocument != NULL);\r
1949 \r
1950         CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();\r
1951         ASSERT(pInterForm != NULL);\r
1952 \r
1953         CFX_PtrArray FieldArray;\r
1954         GetFormFields(pDocument, swFieldName, FieldArray);\r
1955 \r
1956         for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)\r
1957         {\r
1958                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);\r
1959                 ASSERT(pFormField != NULL);\r
1960 \r
1961                 if (nControlIndex < 0)\r
1962                 {\r
1963                         FX_BOOL bSet = FALSE;\r
1964                         for (int j=0,jsz=pFormField->CountControls(); j<jsz; j++)\r
1965                         {\r
1966                                 CPDF_FormControl* pFormControl = pFormField->GetControl(j);\r
1967                                 ASSERT(pFormControl != NULL);\r
1968                                 \r
1969                                 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))\r
1970                                 {\r
1971                                         if (number != pWidget->GetBorderWidth())\r
1972                                         {\r
1973                                                 pWidget->SetBorderWidth(number);\r
1974                                                 bSet = TRUE;\r
1975                                         }\r
1976                                 }\r
1977                         }\r
1978                         if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);\r
1979                 }\r
1980                 else\r
1981                 {\r
1982                         if(nControlIndex >= pFormField->CountControls()) return;\r
1983                         if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))\r
1984                         {\r
1985                                 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))\r
1986                                 {\r
1987                                         if (number != pWidget->GetBorderWidth())\r
1988                                         {\r
1989                                                 pWidget->SetBorderWidth(number);\r
1990                                                 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);\r
1991                                         }\r
1992                                 }\r
1993                         }\r
1994                 }\r
1995         }\r
1996 }\r
1997 \r
1998 FX_BOOL Field::multiline(OBJ_PROP_PARAMS)\r
1999 {\r
2000         ASSERT(m_pDocument != NULL);\r
2001 \r
2002         if (vp.IsSetting())\r
2003         {\r
2004                 if (!m_bCanSet) return FALSE;\r
2005 \r
2006                 bool bVP;\r
2007                 vp >> bVP;\r
2008 \r
2009                 if (m_bDelay)\r
2010                 {\r
2011                         AddDelay_Bool(FP_MULTILINE, bVP);\r
2012                 }\r
2013                 else\r
2014                 {\r
2015                         Field::SetMultiline(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);\r
2016                 }\r
2017         }\r
2018         else\r
2019         {\r
2020                 CFX_PtrArray FieldArray;\r
2021                 GetFormFields(m_FieldName, FieldArray);\r
2022                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2023 \r
2024                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2025                 ASSERT(pFormField != NULL);\r
2026 \r
2027                 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)\r
2028                         return FALSE;\r
2029 \r
2030                 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)\r
2031                         vp << true;\r
2032                 else\r
2033                         vp << false;\r
2034         }\r
2035 \r
2036         return TRUE;\r
2037 }\r
2038 \r
2039 void Field::SetMultiline(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)\r
2040 {\r
2041         //Not supported.\r
2042 }\r
2043 \r
2044 FX_BOOL Field::multipleSelection(OBJ_PROP_PARAMS)\r
2045 {\r
2046         ASSERT(m_pDocument != NULL);\r
2047 \r
2048         if (vp.IsSetting())\r
2049         {\r
2050                 if (!m_bCanSet) return FALSE;\r
2051 \r
2052                 bool bVP;\r
2053                 vp >> bVP;\r
2054 \r
2055                 if (m_bDelay)\r
2056                 {\r
2057                         AddDelay_Bool(FP_MULTIPLESELECTION, bVP);\r
2058                 }\r
2059                 else\r
2060                 {\r
2061                         Field::SetMultipleSelection(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);\r
2062                 }\r
2063         }\r
2064         else\r
2065         {\r
2066                 CFX_PtrArray FieldArray;\r
2067                 GetFormFields(m_FieldName,FieldArray);\r
2068                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2069 \r
2070                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2071                 ASSERT(pFormField != NULL);\r
2072 \r
2073                 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)\r
2074                         return FALSE;\r
2075 \r
2076                 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)\r
2077                         vp << true;\r
2078                 else\r
2079                         vp << false;\r
2080         }\r
2081 \r
2082         return TRUE;\r
2083 }\r
2084 \r
2085 void Field::SetMultipleSelection(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)\r
2086 {\r
2087         //Not supported.\r
2088 }\r
2089 \r
2090 FX_BOOL Field::name(OBJ_PROP_PARAMS)\r
2091 {\r
2092         if (!vp.IsGetting()) return FALSE;\r
2093 \r
2094         CFX_PtrArray FieldArray;\r
2095         GetFormFields(m_FieldName, FieldArray);\r
2096         if (FieldArray.GetSize() <= 0) return FALSE;\r
2097 \r
2098         vp << m_FieldName;\r
2099 \r
2100         return TRUE;\r
2101 }\r
2102 \r
2103 FX_BOOL Field::numItems(OBJ_PROP_PARAMS)\r
2104 {       \r
2105         CFX_PtrArray FieldArray;\r
2106         GetFormFields(m_FieldName, FieldArray);\r
2107         if (FieldArray.GetSize() <= 0) return FALSE;\r
2108 \r
2109         CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2110         ASSERT(pFormField != NULL);\r
2111 \r
2112         if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&\r
2113                 pFormField->GetFieldType() != FIELDTYPE_LISTBOX)\r
2114                 return FALSE;\r
2115 \r
2116         if (!vp.IsGetting()) return FALSE;\r
2117 \r
2118         vp << (FX_INT32)pFormField->CountOptions();\r
2119 \r
2120         return TRUE;\r
2121 }\r
2122 \r
2123 FX_BOOL Field::page(OBJ_PROP_PARAMS)\r
2124 {\r
2125         if (!vp.IsGetting()) return FALSE;\r
2126 \r
2127         CFX_PtrArray FieldArray;\r
2128         GetFormFields(m_FieldName, FieldArray);\r
2129         if (FieldArray.GetSize() <= 0) return FALSE;\r
2130 \r
2131         CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2132         if (!pFormField) return FALSE;\r
2133 \r
2134         ASSERT(m_pDocument != NULL);\r
2135 \r
2136         CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();\r
2137         ASSERT(pInterForm != NULL);\r
2138 \r
2139         CFX_PtrArray widgetArray;\r
2140         pInterForm->GetWidgets(pFormField, widgetArray);\r
2141 \r
2142         if (widgetArray.GetSize() > 0)\r
2143         {\r
2144                 CJS_Array PageArray(m_isolate);\r
2145 \r
2146                 for (int i=0,sz=widgetArray.GetSize(); i<sz; i++)\r
2147                 {\r
2148                         CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgetArray.GetAt(i);\r
2149                         ASSERT(pWidget != NULL);\r
2150 \r
2151                         CPDFSDK_PageView* pPageView = pWidget->GetPageView();\r
2152                         if(!pPageView)\r
2153                                 return FALSE;\r
2154 \r
2155                         PageArray.SetElement(i, CJS_Value(m_isolate,(FX_INT32)pPageView->GetPageIndex()));\r
2156                 }\r
2157 \r
2158                 vp << PageArray;\r
2159         }\r
2160         else\r
2161         {\r
2162                 vp << (FX_INT32) -1;\r
2163         }\r
2164 \r
2165         return TRUE;\r
2166 }\r
2167 \r
2168 FX_BOOL Field::password(OBJ_PROP_PARAMS)\r
2169 {\r
2170         ASSERT(m_pDocument != NULL);\r
2171 \r
2172         if (vp.IsSetting())\r
2173         {\r
2174                 if (!m_bCanSet) return FALSE;\r
2175 \r
2176                 bool bVP;\r
2177                 vp >> bVP;\r
2178 \r
2179                 if (m_bDelay)\r
2180                 {\r
2181                         AddDelay_Bool(FP_PASSWORD, bVP);\r
2182                 }\r
2183                 else\r
2184                 {\r
2185                         Field::SetPassword(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);\r
2186                 }       \r
2187         }\r
2188         else\r
2189         {\r
2190                 CFX_PtrArray FieldArray;\r
2191                 GetFormFields(m_FieldName,FieldArray);\r
2192                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2193 \r
2194                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2195                 ASSERT(pFormField != NULL);\r
2196 \r
2197                 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)\r
2198                         return FALSE;\r
2199 \r
2200                 if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)\r
2201                         vp << true;\r
2202                 else\r
2203                         vp << false;\r
2204         }\r
2205 \r
2206         return TRUE;\r
2207 }\r
2208 \r
2209 void Field::SetPassword(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)\r
2210 {\r
2211         //Not supported.\r
2212 }\r
2213 \r
2214 FX_BOOL Field::print(OBJ_PROP_PARAMS)\r
2215 {\r
2216         ASSERT(m_pDocument != NULL);\r
2217 \r
2218         CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();\r
2219         ASSERT(pInterForm != NULL);\r
2220 \r
2221         CFX_PtrArray FieldArray;\r
2222         GetFormFields(m_FieldName, FieldArray);\r
2223         if (FieldArray.GetSize() <= 0) return FALSE;\r
2224 \r
2225         if (vp.IsSetting())\r
2226         {\r
2227                 if (!m_bCanSet) return FALSE;\r
2228 \r
2229                 bool bVP;\r
2230                 vp >> bVP;\r
2231 \r
2232                 for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)\r
2233                 {\r
2234                         CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);\r
2235                         ASSERT(pFormField != NULL);\r
2236 \r
2237                         if (m_nFormControlIndex < 0)\r
2238                         {\r
2239                                 FX_BOOL bSet = FALSE;\r
2240                                 for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++)\r
2241                                 {\r
2242                                         if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(j)))\r
2243                                         {\r
2244                                                 FX_DWORD dwFlags = pWidget->GetFlags();\r
2245                                                 if (bVP)\r
2246                                                         dwFlags |= ANNOTFLAG_PRINT;\r
2247                                                 else\r
2248                                                         dwFlags &= ~ANNOTFLAG_PRINT;\r
2249 \r
2250                                                 if (dwFlags != pWidget->GetFlags())\r
2251                                                 {\r
2252                                                         pWidget->SetFlags(dwFlags);\r
2253                                                         bSet = TRUE;\r
2254                                                 }\r
2255                                         }\r
2256                                 }\r
2257 \r
2258                                 if (bSet)\r
2259                                         UpdateFormField(m_pDocument, pFormField, TRUE, FALSE, TRUE);\r
2260                         }\r
2261                         else\r
2262                         {\r
2263                                 if(m_nFormControlIndex >= pFormField->CountControls()) return FALSE;\r
2264                                 if (CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex))\r
2265                                 {\r
2266                                         if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))\r
2267                                         {\r
2268                                                 FX_DWORD dwFlags = pWidget->GetFlags();\r
2269                                                 if (bVP)\r
2270                                                         dwFlags |= ANNOTFLAG_PRINT;\r
2271                                                 else\r
2272                                                         dwFlags &= ~ANNOTFLAG_PRINT;\r
2273 \r
2274                                                 if (dwFlags != pWidget->GetFlags())\r
2275                                                 {\r
2276                                                         pWidget->SetFlags(dwFlags);\r
2277                                                         UpdateFormControl(m_pDocument, pFormField->GetControl(m_nFormControlIndex), TRUE, FALSE, TRUE);\r
2278                                                 }\r
2279                                         }\r
2280                                 }\r
2281                         }\r
2282                 }\r
2283         }\r
2284         else\r
2285         {\r
2286                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2287                 ASSERT(pFormField != NULL);\r
2288                 \r
2289                 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));\r
2290                 if (!pWidget) return FALSE;\r
2291 \r
2292                 if (pWidget->GetFlags() & ANNOTFLAG_PRINT)\r
2293                         vp << true;\r
2294                 else\r
2295                         vp << false;\r
2296         }\r
2297 \r
2298         return TRUE;\r
2299 }\r
2300 \r
2301 FX_BOOL Field::radiosInUnison(OBJ_PROP_PARAMS)\r
2302 {\r
2303         ASSERT(m_pDocument != NULL);\r
2304 \r
2305         CFX_PtrArray FieldArray;\r
2306         GetFormFields(m_FieldName,FieldArray);\r
2307         if (FieldArray.GetSize() <= 0) return FALSE;\r
2308 \r
2309         if (vp.IsSetting())\r
2310         {\r
2311                 if (!m_bCanSet) return FALSE;\r
2312 \r
2313                 bool bVP;\r
2314                 vp >> bVP;\r
2315 \r
2316         }\r
2317         else\r
2318         {\r
2319                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2320                 ASSERT(pFormField != NULL);\r
2321 \r
2322                 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)\r
2323                         return FALSE;\r
2324 \r
2325                 if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)\r
2326                         vp << true;\r
2327                 else\r
2328                         vp << false;\r
2329         }\r
2330 \r
2331         return TRUE;\r
2332 }\r
2333 \r
2334 FX_BOOL Field::readonly(OBJ_PROP_PARAMS)\r
2335 {\r
2336         ASSERT(m_pDocument != NULL);\r
2337 \r
2338         CFX_PtrArray FieldArray;\r
2339         GetFormFields(m_FieldName,FieldArray);\r
2340         if (FieldArray.GetSize() <= 0) return FALSE;\r
2341 \r
2342         if (vp.IsSetting())\r
2343         {\r
2344                 if (!m_bCanSet) return FALSE;\r
2345 \r
2346                 bool bVP;\r
2347                 vp >> bVP;\r
2348 \r
2349         }\r
2350         else\r
2351         {\r
2352                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2353                 ASSERT(pFormField != NULL);\r
2354 \r
2355                 if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY)\r
2356                         vp << true;\r
2357                 else\r
2358                         vp << false;\r
2359         }\r
2360 \r
2361         return TRUE;\r
2362 }\r
2363 \r
2364 FX_BOOL Field::rect(OBJ_PROP_PARAMS)\r
2365 {\r
2366         ASSERT(m_pDocument != NULL);\r
2367 \r
2368         if (vp.IsSetting())\r
2369         {\r
2370                 if (!m_bCanSet) return FALSE;\r
2371                 if (!vp.IsArrayObject())return FALSE;\r
2372 \r
2373                 CJS_Array rcArray(m_isolate);\r
2374                 vp >> rcArray;\r
2375                 CJS_Value Upper_Leftx(m_isolate), Upper_Lefty(m_isolate), Lower_Rightx(m_isolate), Lower_Righty(m_isolate);\r
2376                 rcArray.GetElement(0, Upper_Leftx);\r
2377                 rcArray.GetElement(1, Upper_Lefty);\r
2378                 rcArray.GetElement(2, Lower_Rightx);\r
2379                 rcArray.GetElement(3, Lower_Righty);\r
2380 \r
2381                 FX_FLOAT pArray[4] = {0.0f,0.0f,0.0f,0.0f};\r
2382                 pArray[0] = (FX_FLOAT)(FX_INT32)Upper_Leftx;\r
2383                 pArray[1] = (FX_FLOAT)(FX_INT32)Lower_Righty;\r
2384                 pArray[2] = (FX_FLOAT)(FX_INT32)Lower_Rightx;\r
2385                 pArray[3] = (FX_FLOAT)(FX_INT32)Upper_Lefty;\r
2386 \r
2387                 CPDF_Rect crRect(pArray);\r
2388 \r
2389                 if (m_bDelay)\r
2390                 {\r
2391                         AddDelay_Rect(FP_RECT, crRect);\r
2392                 }\r
2393                 else\r
2394                 {\r
2395                         Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect);\r
2396                 }       \r
2397         }\r
2398         else\r
2399         {\r
2400                 CFX_PtrArray FieldArray;\r
2401                 GetFormFields(m_FieldName,FieldArray);\r
2402                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2403 \r
2404                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2405                 ASSERT(pFormField != NULL);\r
2406 \r
2407                 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();\r
2408                 ASSERT(pInterForm != NULL);\r
2409 \r
2410                 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField));\r
2411                 if (!pWidget) return FALSE;\r
2412 \r
2413                 CFX_FloatRect crRect = pWidget->GetRect();\r
2414                 CJS_Value Upper_Leftx(m_isolate),Upper_Lefty(m_isolate),Lower_Rightx(m_isolate),Lower_Righty(m_isolate);\r
2415                 Upper_Leftx = (FX_INT32)crRect.left;\r
2416                 Upper_Lefty = (FX_INT32)crRect.top;\r
2417                 Lower_Rightx = (FX_INT32)crRect.right;\r
2418                 Lower_Righty = (FX_INT32)crRect.bottom;\r
2419 \r
2420                 CJS_Array rcArray(m_isolate);\r
2421                 rcArray.SetElement(0,Upper_Leftx);\r
2422                 rcArray.SetElement(1,Upper_Lefty);\r
2423                 rcArray.SetElement(2,Lower_Rightx);\r
2424                 rcArray.SetElement(3,Lower_Righty);\r
2425 \r
2426                 vp  <<  rcArray;                        \r
2427         }\r
2428 \r
2429         return TRUE;\r
2430 }\r
2431 \r
2432 void Field::SetRect(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPDF_Rect& rect)\r
2433 {\r
2434         ASSERT(pDocument != NULL);\r
2435 \r
2436         CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm();\r
2437         ASSERT(pInterForm != NULL);\r
2438 \r
2439         CFX_PtrArray FieldArray;\r
2440         GetFormFields(pDocument, swFieldName, FieldArray);\r
2441 \r
2442         for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)\r
2443         {\r
2444                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);\r
2445                 ASSERT(pFormField != NULL);\r
2446 \r
2447                 if (nControlIndex < 0)\r
2448                 {\r
2449                         FX_BOOL bSet = FALSE;\r
2450                         for (int i=0, sz=pFormField->CountControls(); i<sz; i++)\r
2451                         {\r
2452                                 CPDF_FormControl* pFormControl = pFormField->GetControl(i);\r
2453                                 ASSERT(pFormControl != NULL);\r
2454 \r
2455                                 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))\r
2456                                 {\r
2457                                         CPDF_Rect crRect = rect;\r
2458 \r
2459                                         CPDF_Page* pPDFPage = pWidget->GetPDFPage();\r
2460                                         ASSERT(pPDFPage != NULL);\r
2461 \r
2462 //                                      CPDF_Page* pPDFPage = pPage->GetPage();\r
2463 //                                      ASSERT(pPDFPage != NULL);\r
2464 \r
2465                                         crRect.Intersect(pPDFPage->GetPageBBox());\r
2466 \r
2467                                         if (!crRect.IsEmpty())\r
2468                                         {\r
2469                                                 CPDF_Rect rcOld = pWidget->GetRect();\r
2470                                                 if (crRect.left != rcOld.left ||\r
2471                                                         crRect.right != rcOld.right ||\r
2472                                                         crRect.top != rcOld.top ||\r
2473                                                         crRect.bottom != rcOld.bottom)\r
2474                                                 {\r
2475                                                         pWidget->SetRect(crRect);\r
2476                                                         bSet = TRUE;\r
2477                                                 }\r
2478                                         }\r
2479                                 }\r
2480                         }\r
2481 \r
2482                         if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE);\r
2483                 }\r
2484                 else\r
2485                 {\r
2486                         if(nControlIndex >= pFormField->CountControls()) return;\r
2487                         if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControlIndex))\r
2488                         {\r
2489                                 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl))\r
2490                                 {\r
2491                                         CPDF_Rect crRect = rect;\r
2492                                         \r
2493                                         CPDF_Page* pPDFPage = pWidget->GetPDFPage();\r
2494                                         ASSERT(pPDFPage != NULL);\r
2495 \r
2496 //                                      CPDF_Page* pPDFPage = pPage->GetPage();\r
2497 //                                      ASSERT(pPDFPage != NULL);\r
2498 \r
2499                                         crRect.Intersect(pPDFPage->GetPageBBox());\r
2500 \r
2501                                         if (!crRect.IsEmpty())\r
2502                                         {\r
2503                                                 CPDF_Rect rcOld = pWidget->GetRect();\r
2504                                                 if (crRect.left != rcOld.left ||\r
2505                                                         crRect.right != rcOld.right ||\r
2506                                                         crRect.top != rcOld.top ||\r
2507                                                         crRect.bottom != rcOld.bottom)\r
2508                                                 {\r
2509                                                         pWidget->SetRect(crRect);\r
2510                                                         UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE);\r
2511                                                 }\r
2512                                         }\r
2513                                 }\r
2514                         }\r
2515                 }\r
2516         }\r
2517 }\r
2518 \r
2519 FX_BOOL Field::required(OBJ_PROP_PARAMS)\r
2520 {\r
2521         ASSERT(m_pDocument != NULL);\r
2522 \r
2523         CFX_PtrArray FieldArray;\r
2524         GetFormFields(m_FieldName,FieldArray);\r
2525         if (FieldArray.GetSize() <= 0) return FALSE;\r
2526 \r
2527         if (vp.IsSetting())\r
2528         {\r
2529                 if (!m_bCanSet) return FALSE;\r
2530 \r
2531 \r
2532                 bool bVP;\r
2533                 vp >> bVP;\r
2534 \r
2535         }\r
2536         else\r
2537         {\r
2538                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2539                 ASSERT(pFormField != NULL);\r
2540 \r
2541                 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)\r
2542                         return FALSE;\r
2543 \r
2544                 if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)\r
2545                         vp << true;\r
2546                 else\r
2547                         vp << false;\r
2548         }\r
2549 \r
2550         return TRUE;\r
2551 }\r
2552 \r
2553 FX_BOOL Field::richText(OBJ_PROP_PARAMS)\r
2554 {\r
2555         ASSERT(m_pDocument != NULL);\r
2556 \r
2557         if (vp.IsSetting())\r
2558         {\r
2559                 if (!m_bCanSet) return FALSE;\r
2560 \r
2561                 bool bVP;\r
2562                 vp >> bVP;\r
2563 \r
2564                 if (m_bDelay)\r
2565                 {\r
2566                         AddDelay_Bool(FP_RICHTEXT, bVP);\r
2567                 }\r
2568                 else\r
2569                 {\r
2570                         Field::SetRichText(m_pDocument, m_FieldName, m_nFormControlIndex, bVP);\r
2571                 }       \r
2572         }\r
2573         else\r
2574         {\r
2575                 CFX_PtrArray FieldArray;\r
2576                 GetFormFields(m_FieldName,FieldArray);\r
2577                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2578 \r
2579                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2580                 ASSERT(pFormField != NULL);\r
2581 \r
2582                 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)\r
2583                         return FALSE;\r
2584 \r
2585                 if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)\r
2586                         vp << true;\r
2587                 else\r
2588                         vp << false;\r
2589         }\r
2590 \r
2591         return TRUE;\r
2592 }\r
2593 \r
2594 void Field::SetRichText(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b)\r
2595 {\r
2596         //Not supported.\r
2597 }\r
2598 \r
2599 FX_BOOL Field::richValue(OBJ_PROP_PARAMS)\r
2600 {\r
2601         return TRUE;\r
2602         if (vp.IsSetting())\r
2603         {\r
2604                 if (!m_bCanSet) return FALSE;\r
2605                 ;\r
2606         }\r
2607         else\r
2608         {\r
2609                 ;\r
2610         }\r
2611         return TRUE;\r
2612 }\r
2613 \r
2614 void Field::SetRichValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex)\r
2615 {\r
2616         //Not supported.\r
2617 }\r
2618 \r
2619 FX_BOOL Field::rotation(OBJ_PROP_PARAMS)\r
2620 {\r
2621         ASSERT(m_pDocument != NULL);\r
2622 \r
2623         if (vp.IsSetting())\r
2624         {\r
2625                 if (!m_bCanSet) return FALSE;\r
2626 \r
2627                 int nVP;\r
2628                 vp >> nVP;\r
2629 \r
2630                 if (m_bDelay)\r
2631                 {\r
2632                         AddDelay_Int(FP_ROTATION, nVP);\r
2633                 }\r
2634                 else\r
2635                 {\r
2636                         Field::SetRotation(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
2637                 }       \r
2638         }\r
2639         else\r
2640         {\r
2641                 CFX_PtrArray FieldArray;\r
2642                 GetFormFields(m_FieldName,FieldArray);\r
2643                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2644 \r
2645                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2646                 ASSERT(pFormField != NULL);\r
2647 \r
2648                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
2649                 if (!pFormControl)return FALSE;\r
2650 \r
2651                 vp << (FX_INT32)pFormControl->GetRotation();\r
2652         }\r
2653 \r
2654         return TRUE;\r
2655 }\r
2656 \r
2657 void Field::SetRotation(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
2658 {\r
2659         //Not supported.\r
2660 }\r
2661 \r
2662 FX_BOOL Field::strokeColor(OBJ_PROP_PARAMS)\r
2663 {\r
2664         ASSERT(m_pDocument != NULL);\r
2665 \r
2666         if (vp.IsSetting())\r
2667         {\r
2668                 if (!m_bCanSet) return FALSE;\r
2669 \r
2670                 if (!vp.IsArrayObject())return FALSE;\r
2671 \r
2672                 CJS_Array crArray(m_isolate);\r
2673                 vp >> crArray;\r
2674 \r
2675                 CPWL_Color color;\r
2676                 color::ConvertArrayToPWLColor(crArray, color);\r
2677 \r
2678                 if (m_bDelay)\r
2679                 {\r
2680                         AddDelay_Color(FP_STROKECOLOR, color);\r
2681                 }\r
2682                 else\r
2683                 {\r
2684                         Field::SetStrokeColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);\r
2685                 }       \r
2686         }\r
2687         else\r
2688         {\r
2689                 CFX_PtrArray FieldArray;\r
2690                 GetFormFields(m_FieldName,FieldArray);\r
2691                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2692 \r
2693                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2694                 ASSERT(pFormField != NULL);\r
2695 \r
2696                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
2697                 if (!pFormControl)return FALSE;\r
2698 \r
2699                 int iColorType;\r
2700                 pFormControl->GetBorderColor(iColorType);\r
2701 \r
2702                 CPWL_Color color;\r
2703 \r
2704                 if (iColorType == COLORTYPE_TRANSPARENT)\r
2705                 {\r
2706                         color = CPWL_Color(COLORTYPE_TRANSPARENT);\r
2707                 }\r
2708                 else if (iColorType == COLORTYPE_GRAY)\r
2709                 {\r
2710                         color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0));\r
2711                 }\r
2712                 else if (iColorType == COLORTYPE_RGB)\r
2713                 {\r
2714                         color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0),\r
2715                                 pFormControl->GetOriginalBorderColor(1),\r
2716                                 pFormControl->GetOriginalBorderColor(2));\r
2717                 }\r
2718                 else if (iColorType == COLORTYPE_CMYK)\r
2719                 {\r
2720                         color = CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0),\r
2721                                 pFormControl->GetOriginalBorderColor(1),\r
2722                                 pFormControl->GetOriginalBorderColor(2),\r
2723                                 pFormControl->GetOriginalBorderColor(3));\r
2724                 }\r
2725                 else\r
2726                         return FALSE;\r
2727 \r
2728                 CJS_Array crArray(m_isolate);\r
2729                 color::ConvertPWLColorToArray(color, crArray);\r
2730         vp  <<  crArray;\r
2731         }\r
2732 \r
2733         return TRUE;\r
2734 }\r
2735 \r
2736 void Field::SetStrokeColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color)\r
2737 {\r
2738         //Not supported.\r
2739 }\r
2740 \r
2741 FX_BOOL Field::style(OBJ_PROP_PARAMS)\r
2742 {\r
2743         ASSERT(m_pDocument != NULL);\r
2744 \r
2745         if (vp.IsSetting())\r
2746         {\r
2747                 if (!m_bCanSet) return FALSE;\r
2748 \r
2749                 CFX_ByteString csBCaption;\r
2750                 vp >> csBCaption;\r
2751 \r
2752                 if (m_bDelay)\r
2753                 {\r
2754                         AddDelay_String(FP_STYLE, csBCaption);\r
2755                 }\r
2756                 else\r
2757                 {\r
2758                         Field::SetStyle(m_pDocument, m_FieldName, m_nFormControlIndex, csBCaption);\r
2759                 }       \r
2760         }\r
2761         else\r
2762         {\r
2763                 CFX_PtrArray FieldArray;\r
2764                 GetFormFields(m_FieldName,FieldArray);\r
2765                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2766 \r
2767                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2768                 ASSERT(pFormField != NULL);\r
2769 \r
2770                 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON && \r
2771                         pFormField->GetFieldType() != FIELDTYPE_CHECKBOX)\r
2772                         return FALSE;\r
2773 \r
2774                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
2775                 if (!pFormControl) return FALSE;\r
2776 \r
2777                 CFX_WideString csWCaption = pFormControl->GetNormalCaption();\r
2778                 CFX_ByteString csBCaption;\r
2779 \r
2780                 switch (csWCaption[0])\r
2781                 {\r
2782                         case L'l':\r
2783                                 csBCaption = "circle";\r
2784                                 break;\r
2785                         case L'8':\r
2786                                 csBCaption = "cross";\r
2787                                 break;\r
2788                         case L'u':\r
2789                                 csBCaption = "diamond";\r
2790                                 break;\r
2791                         case L'n':\r
2792                                 csBCaption = "square";\r
2793                                 break;\r
2794                         case L'H':\r
2795                                 csBCaption = "star";\r
2796                                 break;\r
2797                         default: //L'4'\r
2798                                 csBCaption = "check";\r
2799                                 break;\r
2800                 }\r
2801                 vp << csBCaption;\r
2802         }\r
2803 \r
2804         return TRUE;\r
2805 }\r
2806 \r
2807 void Field::SetStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, \r
2808                                          const CFX_ByteString& string)\r
2809 {\r
2810         //Not supported.\r
2811 }\r
2812 \r
2813 FX_BOOL Field::submitName(OBJ_PROP_PARAMS)\r
2814 {\r
2815         return TRUE;\r
2816 }\r
2817 \r
2818 FX_BOOL Field::textColor(OBJ_PROP_PARAMS)\r
2819 {\r
2820         ASSERT(m_pDocument != NULL);\r
2821 \r
2822         if (vp.IsSetting())\r
2823         {\r
2824                 if (!m_bCanSet) return FALSE;\r
2825 \r
2826                 CJS_Array crArray(m_isolate);\r
2827                 if (!vp.IsArrayObject())return FALSE;\r
2828                 vp >> crArray;\r
2829 \r
2830                 CPWL_Color color;\r
2831                 color::ConvertArrayToPWLColor(crArray, color);\r
2832 \r
2833                 if (m_bDelay)\r
2834                 {\r
2835                         AddDelay_Color(FP_TEXTCOLOR, color);\r
2836                 }\r
2837                 else\r
2838                 {\r
2839                         Field::SetTextColor(m_pDocument, m_FieldName, m_nFormControlIndex, color);\r
2840                 }       \r
2841         }\r
2842         else\r
2843         {\r
2844                 CFX_PtrArray FieldArray;\r
2845                 GetFormFields(m_FieldName,FieldArray);\r
2846                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2847 \r
2848                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2849                 ASSERT(pFormField != NULL);\r
2850 \r
2851                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
2852                 if (!pFormControl)return FALSE;\r
2853                 \r
2854                 int iColorType;\r
2855                 FX_ARGB color;\r
2856                 CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();\r
2857                 FieldAppearance.GetColor(color, iColorType);\r
2858                 FX_INT32 a,r,g,b;\r
2859                 ArgbDecode(color, a, r, g, b);\r
2860 \r
2861                 CPWL_Color crRet = CPWL_Color(COLORTYPE_RGB, r / 255.0f,\r
2862                                 g / 255.0f,\r
2863                                 b / 255.0f);\r
2864 \r
2865                 if (iColorType == COLORTYPE_TRANSPARENT)\r
2866                         crRet = CPWL_Color(COLORTYPE_TRANSPARENT);\r
2867 \r
2868                 CJS_Array crArray(m_isolate);\r
2869                 color::ConvertPWLColorToArray(crRet, crArray);\r
2870         vp  <<  crArray;                \r
2871         }\r
2872 \r
2873         return TRUE;\r
2874 }\r
2875 \r
2876 void Field::SetTextColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color)\r
2877 {\r
2878         //Not supported.\r
2879 }\r
2880 \r
2881 FX_BOOL Field::textFont(OBJ_PROP_PARAMS)\r
2882 {\r
2883         ASSERT(m_pDocument != NULL);\r
2884 \r
2885         if (vp.IsSetting())\r
2886         {\r
2887                 if (!m_bCanSet) return FALSE;\r
2888 \r
2889                 CFX_ByteString csFontName;\r
2890                 vp >> csFontName;\r
2891                 if (csFontName.IsEmpty()) return FALSE;\r
2892 \r
2893                 if (m_bDelay)\r
2894                 {\r
2895                         AddDelay_String(FP_TEXTFONT, csFontName);\r
2896                 }\r
2897                 else\r
2898                 {\r
2899                         Field::SetTextFont(m_pDocument, m_FieldName, m_nFormControlIndex, csFontName);\r
2900                 }       \r
2901         }\r
2902         else\r
2903         {\r
2904                 CFX_PtrArray FieldArray;\r
2905                 GetFormFields(m_FieldName,FieldArray);\r
2906                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2907 \r
2908                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2909                 ASSERT(pFormField != NULL);\r
2910 \r
2911                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
2912                 if (!pFormControl)return FALSE;\r
2913 \r
2914                 int nFieldType = pFormField->GetFieldType();\r
2915 \r
2916                 if (nFieldType == FIELDTYPE_PUSHBUTTON || \r
2917                         nFieldType == FIELDTYPE_COMBOBOX || \r
2918                         nFieldType == FIELDTYPE_LISTBOX ||\r
2919                         nFieldType == FIELDTYPE_TEXTFIELD)\r
2920                 {\r
2921                         CPDF_Font * pFont = pFormControl->GetDefaultControlFont();\r
2922                         if (!pFont) return FALSE;\r
2923 \r
2924                         vp << pFont->GetBaseFont();\r
2925                 }\r
2926                 else\r
2927                         return FALSE;\r
2928         }\r
2929 \r
2930         return TRUE;\r
2931 }\r
2932 \r
2933 void Field::SetTextFont(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string)\r
2934 {\r
2935         //Not supported.\r
2936 }\r
2937 \r
2938 FX_BOOL Field::textSize(OBJ_PROP_PARAMS)\r
2939 {\r
2940         ASSERT(m_pDocument != NULL);\r
2941 \r
2942         if (vp.IsSetting())\r
2943         {\r
2944                 if (!m_bCanSet) return FALSE;\r
2945 \r
2946                 int nVP;\r
2947                 vp >> nVP;\r
2948 \r
2949                 if (m_bDelay)\r
2950                 {\r
2951                         AddDelay_Int(FP_TEXTSIZE, nVP);\r
2952                 }\r
2953                 else\r
2954                 {\r
2955                         Field::SetTextSize(m_pDocument, m_FieldName, m_nFormControlIndex, nVP);\r
2956                 }       \r
2957         }\r
2958         else\r
2959         {\r
2960                 CFX_PtrArray FieldArray;\r
2961                 GetFormFields(m_FieldName,FieldArray);\r
2962                 if (FieldArray.GetSize() <= 0) return FALSE;\r
2963 \r
2964                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2965                 ASSERT(pFormField != NULL);\r
2966 \r
2967                 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);\r
2968                 if (!pFormControl)return FALSE;\r
2969 \r
2970                 CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();\r
2971 \r
2972                 CFX_ByteString csFontNameTag;\r
2973                 FX_FLOAT fFontSize;\r
2974                 FieldAppearance.GetFont(csFontNameTag,fFontSize);\r
2975 \r
2976                 vp << (int)fFontSize;\r
2977         }\r
2978 \r
2979         return TRUE;\r
2980 }\r
2981 \r
2982 void Field::SetTextSize(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number)\r
2983 {\r
2984         //Not supported.\r
2985 }\r
2986 \r
2987 FX_BOOL Field::type(OBJ_PROP_PARAMS)\r
2988 {\r
2989         ASSERT(m_pDocument != NULL);\r
2990 \r
2991         if (!vp.IsGetting()) return FALSE;\r
2992 \r
2993         CFX_PtrArray FieldArray;\r
2994         GetFormFields(m_FieldName,FieldArray);\r
2995         if (FieldArray.GetSize() <= 0) return FALSE;\r
2996 \r
2997         CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
2998         ASSERT(pFormField != NULL);\r
2999 \r
3000         switch (pFormField->GetFieldType())\r
3001         {\r
3002                 case FIELDTYPE_UNKNOWN:\r
3003                         vp << (FX_LPCWSTR)L"unknown";\r
3004                         break;\r
3005                 case FIELDTYPE_PUSHBUTTON:\r
3006                         vp << (FX_LPCWSTR)L"button";\r
3007                         break;\r
3008                 case FIELDTYPE_CHECKBOX:\r
3009                         vp << (FX_LPCWSTR)L"checkbox";\r
3010                         break;\r
3011                 case FIELDTYPE_RADIOBUTTON:\r
3012                         vp << (FX_LPCWSTR)L"radiobutton";\r
3013                         break;\r
3014                 case FIELDTYPE_COMBOBOX:\r
3015                         vp << (FX_LPCWSTR)L"combobox";\r
3016                         break;\r
3017                 case FIELDTYPE_LISTBOX:\r
3018                         vp << (FX_LPCWSTR)L"listbox";\r
3019                         break;\r
3020                 case FIELDTYPE_TEXTFIELD:\r
3021                         vp << (FX_LPCWSTR)L"text";\r
3022                         break;\r
3023                 case FIELDTYPE_SIGNATURE:\r
3024                         vp << (FX_LPCWSTR)L"signature";\r
3025                         break;\r
3026                 default :\r
3027                         vp << (FX_LPCWSTR)L"unknown";\r
3028                         break;\r
3029         }\r
3030 \r
3031         return TRUE;\r
3032 }\r
3033 \r
3034 FX_BOOL Field::userName(OBJ_PROP_PARAMS)\r
3035 {\r
3036         ASSERT(m_pDocument != NULL);\r
3037 \r
3038         if (vp.IsSetting())\r
3039         {\r
3040                 if (!m_bCanSet) return FALSE;\r
3041 \r
3042                 CFX_WideString swName;\r
3043                 vp >> swName;\r
3044 \r
3045                 if (m_bDelay)\r
3046                 {\r
3047                         AddDelay_WideString(FP_USERNAME, swName);\r
3048                 }\r
3049                 else\r
3050                 {\r
3051                         Field::SetUserName(m_pDocument, m_FieldName, m_nFormControlIndex, swName);\r
3052                 }       \r
3053         }\r
3054         else\r
3055         {\r
3056                 CFX_PtrArray FieldArray;\r
3057                 GetFormFields(m_FieldName,FieldArray);\r
3058                 if (FieldArray.GetSize() <= 0) return FALSE;\r
3059 \r
3060                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
3061                 ASSERT(pFormField != NULL);\r
3062 \r
3063                 vp << (CFX_WideString)pFormField->GetAlternateName();\r
3064         }\r
3065 \r
3066         return TRUE;\r
3067 }\r
3068 \r
3069 void Field::SetUserName(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_WideString& string)\r
3070 {\r
3071         //Not supported.\r
3072 }\r
3073 \r
3074 FX_BOOL Field::value(OBJ_PROP_PARAMS)\r
3075 {\r
3076         ASSERT(m_pDocument != NULL);\r
3077 \r
3078         if (vp.IsSetting())\r
3079         {               \r
3080                 if (!m_bCanSet) return FALSE;\r
3081 \r
3082                 CJS_WideStringArray strArray;\r
3083 \r
3084                 if (vp.IsArrayObject())\r
3085                 {\r
3086                         CJS_Array ValueArray(m_isolate);\r
3087                         vp.ConvertToArray(ValueArray);\r
3088                         for (int i = 0,sz = ValueArray.GetLength(); i < sz; i++)\r
3089                         {\r
3090                                 CJS_Value ElementValue(m_isolate);\r
3091                                 ValueArray.GetElement(i, ElementValue);\r
3092                                 strArray.Add(ElementValue.operator CFX_WideString());\r
3093                         }\r
3094                 }\r
3095                 else\r
3096                 {\r
3097                         CFX_WideString swValue;\r
3098                         vp >> swValue;\r
3099 \r
3100                         strArray.Add(swValue);\r
3101                 }\r
3102 \r
3103                 if (m_bDelay)\r
3104                 {\r
3105                         AddDelay_WideStringArray(FP_VALUE, strArray);\r
3106                 }\r
3107                 else\r
3108                 {\r
3109                         Field::SetValue(m_pDocument, m_FieldName, m_nFormControlIndex, strArray);\r
3110                 }\r
3111         }\r
3112         else\r
3113         {\r
3114                 CFX_PtrArray FieldArray;\r
3115                 GetFormFields(m_FieldName,FieldArray);\r
3116                 if (FieldArray.GetSize() <= 0) return FALSE;\r
3117 \r
3118                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);\r
3119                 ASSERT(pFormField != NULL);\r
3120 \r
3121 \r
3122 \r
3123                 switch (pFormField->GetFieldType())\r
3124                 {\r
3125                 case FIELDTYPE_PUSHBUTTON:\r
3126                         return FALSE;\r
3127                 case FIELDTYPE_COMBOBOX:\r
3128                 case FIELDTYPE_TEXTFIELD:\r
3129                         {\r
3130                                 CFX_WideString swValue = pFormField->GetValue();\r
3131 \r
3132                                 double dRet;\r
3133                                 FX_BOOL bDot;\r
3134                                 if (CJS_PublicMethods::ConvertStringToNumber(swValue,dRet,bDot))\r
3135                                 {\r
3136                                         if (bDot)\r
3137                                                 vp << dRet;\r
3138                                         else\r
3139                                                 vp << dRet;\r
3140                                 }\r
3141                                 else\r
3142                                         vp << swValue;\r
3143                         }\r
3144                         break;\r
3145                 case FIELDTYPE_LISTBOX:\r
3146                         {\r
3147                                 if (pFormField->CountSelectedItems() > 1)\r
3148                                 {\r
3149                                         CJS_Array ValueArray(m_isolate);\r
3150                                         CJS_Value ElementValue(m_isolate);\r
3151                                         int iIndex;\r
3152                                         for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++)\r
3153                                         {\r
3154                                                 iIndex = pFormField->GetSelectedIndex(i);\r
3155                                                 ElementValue = pFormField->GetOptionValue(iIndex);\r
3156                                                 if (FXSYS_wcslen((FX_LPCWSTR)ElementValue.operator CFX_WideString()) == 0)\r
3157                                                         ElementValue = pFormField->GetOptionLabel(iIndex);\r
3158                                                 ValueArray.SetElement(i, ElementValue);\r
3159                                         }\r
3160                                         vp << ValueArray;\r
3161                                 }\r
3162                                 else\r
3163                                 {\r
3164                                         CFX_WideString swValue = pFormField->GetValue();\r
3165                                 \r
3166                                         double dRet;\r
3167                                         FX_BOOL bDot;\r
3168                                         if (CJS_PublicMethods::ConvertStringToNumber(swValue,dRet,bDot))\r
3169                                         {\r
3170                                                 if (bDot)\r
3171                                                         vp << dRet;\r
3172                                                 else\r
3173                                                         vp << dRet;\r
3174                                         }\r
3175                                         else\r
3176                                                 vp << swValue;  \r
3177                                 }\r
3178                         }\r
3179                         break;\r
3180                 case FIELDTYPE_CHECKBOX:\r
3181                 case FIELDTYPE_RADIOBUTTON:\r
3182                         {\r
3183                                 FX_BOOL bFind = FALSE;\r
3184                                 for (int i = 0 , sz = pFormField->CountControls(); i < sz; i++)\r
3185                                 {\r
3186                                         if (pFormField->GetControl(i)->IsChecked())\r
3187                                         {\r
3188                                                 CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue();\r
3189                                                 \r
3190                                                 double dRet;\r
3191                                                 FX_BOOL bDot;\r
3192                                                 if (CJS_PublicMethods::ConvertStringToNumber(swValue,dRet,bDot))\r
3193                                                 {\r
3194                                                         if (bDot)\r
3195                                                                 vp << dRet;\r
3196                                                         else\r
3197                                                                 vp << dRet;\r
3198                                                 }\r
3199                                                 else\r
3200                                                         vp << swValue;\r
3201 \r
3202                                                 bFind = TRUE;\r
3203                                                 break;\r
3204                                         }\r
3205                                         else\r
3206                                                 continue;\r
3207                                 }\r
3208                                 if (!bFind)\r
3209                                         vp << (FX_LPCWSTR)L"Off";                                       \r
3210                         }\r
3211                         break;\r
3212                 default:\r
3213                         vp << pFormField->GetValue();\r
3214                         break;\r
3215                 }\r
3216         }\r
3217 \r
3218         return TRUE;\r
3219 }\r
3220 \r
3221 void Field::SetValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, \r
3222                                          int nControlIndex, const CJS_WideStringArray& strArray)\r
3223 {\r
3224         ASSERT(pDocument != NULL);\r
3225 \r
3226         if (strArray.GetSize() < 1) return;\r
3227 \r
3228         CFX_PtrArray FieldArray;\r
3229         GetFormFields(pDocument, swFieldName, FieldArray);\r
3230 \r
3231         for (int i=0,isz=FieldArray.GetSize(); i<isz; i++)\r
3232         {\r
3233                 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i);\r
3234                 ASSERT(pFormField != NULL);\r
3235 \r
3236                 if (pFormField->GetFullName().Compare(swFieldName) != 0)\r
3237                         continue;\r
3238 \r
3239                 switch (pFormField->GetFieldType())\r
3240                 {\r
3241                 case FIELDTYPE_TEXTFIELD:\r
3242                 case FIELDTYPE_COMBOBOX:\r
3243                         if (pFormField->GetValue() != strArray.GetAt(0))\r
3244                         {\r
3245                                 CFX_WideString WideString = strArray.GetAt(0);\r
3246                                 pFormField->SetValue(strArray.GetAt(0), TRUE);  \r
3247                                 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);\r
3248                         }\r
3249                         break;\r
3250                 case FIELDTYPE_CHECKBOX: //mantis: 0004493\r
3251                 case FIELDTYPE_RADIOBUTTON:\r
3252                         {\r
3253                                 if (pFormField->GetValue() != strArray.GetAt(0))\r
3254                                 {\r
3255                                         pFormField->SetValue(strArray.GetAt(0), TRUE);  \r
3256                                         UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE);\r
3257                                 }\r
3258                         }\r
3259                         break;\r
3260                 case FIELDTYPE_LISTBOX:\r
3261                         {\r
3262                                 FX_BOOL bModified = FALSE;\r
3263 \r
3264                                 for (int i=0,sz=strArray.GetSize(); i<sz; i++)\r
3265