| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
| 8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
| 9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
| 10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
| 11 #include "../../include/javascript/JS_Value.h" | 11 #include "../../include/javascript/JS_Value.h" |
| 12 #include "../../include/javascript/Field.h" | 12 #include "../../include/javascript/Field.h" |
| 13 #include "../../include/javascript/JS_EventHandler.h" | 13 #include "../../include/javascript/JS_EventHandler.h" |
| 14 #include "../../include/javascript/JS_Context.h" | 14 #include "../../include/javascript/JS_Context.h" |
| 15 #include "../../include/javascript/JS_Runtime.h" | 15 #include "../../include/javascript/JS_Runtime.h" |
| 16 #include "../../include/javascript/Document.h" | 16 #include "../../include/javascript/Document.h" |
| 17 #include "../../include/javascript/color.h" | 17 #include "../../include/javascript/color.h" |
| 18 #include "../../include/javascript/PublicMethods.h" | 18 #include "../../include/javascript/PublicMethods.h" |
| 19 #include "../../include/javascript/Icon.h" | 19 #include "../../include/javascript/Icon.h" |
| 20 | 20 |
| 21 | |
| 22 /* ---------------------- Field ---------------------- */ | 21 /* ---------------------- Field ---------------------- */ |
| 23 | 22 |
| 24 BEGIN_JS_STATIC_CONST(CJS_Field) | 23 BEGIN_JS_STATIC_CONST(CJS_Field) |
| 25 END_JS_STATIC_CONST() | 24 END_JS_STATIC_CONST() |
| 26 | 25 |
| 27 BEGIN_JS_STATIC_PROP(CJS_Field) | 26 BEGIN_JS_STATIC_PROP(CJS_Field) |
| 28 JS_STATIC_PROP_ENTRY(alignment) | 27 JS_STATIC_PROP_ENTRY(alignment) |
| 29 JS_STATIC_PROP_ENTRY(borderStyle) | 28 JS_STATIC_PROP_ENTRY(borderStyle) |
| 30 JS_STATIC_PROP_ENTRY(buttonAlignX) | 29 JS_STATIC_PROP_ENTRY(buttonAlignX) |
| 31 JS_STATIC_PROP_ENTRY(buttonAlignY) | 30 JS_STATIC_PROP_ENTRY(buttonAlignY) |
| 32 JS_STATIC_PROP_ENTRY(buttonFitBounds) | 31 JS_STATIC_PROP_ENTRY(buttonFitBounds) |
| 33 JS_STATIC_PROP_ENTRY(buttonPosition) | 32 JS_STATIC_PROP_ENTRY(buttonPosition) |
| 34 JS_STATIC_PROP_ENTRY(buttonScaleHow) | 33 JS_STATIC_PROP_ENTRY(buttonScaleHow) |
| 35 JS_STATIC_PROP_ENTRY(buttonScaleWhen) | 34 JS_STATIC_PROP_ENTRY(buttonScaleWhen) |
| 36 JS_STATIC_PROP_ENTRY(calcOrderIndex) | 35 JS_STATIC_PROP_ENTRY(calcOrderIndex) |
| 37 JS_STATIC_PROP_ENTRY(charLimit) | 36 JS_STATIC_PROP_ENTRY(charLimit) |
| 38 JS_STATIC_PROP_ENTRY(comb) | 37 JS_STATIC_PROP_ENTRY(comb) |
| 39 JS_STATIC_PROP_ENTRY(commitOnSelChange) | 38 JS_STATIC_PROP_ENTRY(commitOnSelChange) |
| 40 JS_STATIC_PROP_ENTRY(currentValueIndices) | 39 JS_STATIC_PROP_ENTRY(currentValueIndices) |
| 41 JS_STATIC_PROP_ENTRY(defaultStyle) | 40 JS_STATIC_PROP_ENTRY(defaultStyle) |
| 42 JS_STATIC_PROP_ENTRY(defaultValue) | 41 JS_STATIC_PROP_ENTRY(defaultValue) |
| 43 JS_STATIC_PROP_ENTRY(doNotScroll) | 42 JS_STATIC_PROP_ENTRY(doNotScroll) |
| 44 JS_STATIC_PROP_ENTRY(doNotSpellCheck) | 43 JS_STATIC_PROP_ENTRY(doNotSpellCheck) |
| 45 JS_STATIC_PROP_ENTRY(delay) | 44 JS_STATIC_PROP_ENTRY(delay) |
| 46 JS_STATIC_PROP_ENTRY(display) | 45 JS_STATIC_PROP_ENTRY(display) |
| 47 JS_STATIC_PROP_ENTRY(doc) | 46 JS_STATIC_PROP_ENTRY(doc) |
| 48 JS_STATIC_PROP_ENTRY(editable) | 47 JS_STATIC_PROP_ENTRY(editable) |
| 49 JS_STATIC_PROP_ENTRY(exportValues) | 48 JS_STATIC_PROP_ENTRY(exportValues) |
| 50 JS_STATIC_PROP_ENTRY(hidden) | 49 JS_STATIC_PROP_ENTRY(hidden) |
| 51 JS_STATIC_PROP_ENTRY(fileSelect) | 50 JS_STATIC_PROP_ENTRY(fileSelect) |
| 52 JS_STATIC_PROP_ENTRY(fillColor) | 51 JS_STATIC_PROP_ENTRY(fillColor) |
| 53 JS_STATIC_PROP_ENTRY(lineWidth) | 52 JS_STATIC_PROP_ENTRY(lineWidth) |
| 54 JS_STATIC_PROP_ENTRY(highlight) | 53 JS_STATIC_PROP_ENTRY(highlight) |
| 55 JS_STATIC_PROP_ENTRY(multiline) | 54 JS_STATIC_PROP_ENTRY(multiline) |
| 56 JS_STATIC_PROP_ENTRY(multipleSelection) | 55 JS_STATIC_PROP_ENTRY(multipleSelection) |
| 57 JS_STATIC_PROP_ENTRY(name) | 56 JS_STATIC_PROP_ENTRY(name) |
| 58 JS_STATIC_PROP_ENTRY(numItems) | 57 JS_STATIC_PROP_ENTRY(numItems) |
| 59 JS_STATIC_PROP_ENTRY(page) | 58 JS_STATIC_PROP_ENTRY(page) |
| 60 JS_STATIC_PROP_ENTRY(password) | 59 JS_STATIC_PROP_ENTRY(password) |
| 61 JS_STATIC_PROP_ENTRY(print) | 60 JS_STATIC_PROP_ENTRY(print) |
| 62 JS_STATIC_PROP_ENTRY(radiosInUnison) | 61 JS_STATIC_PROP_ENTRY(radiosInUnison) |
| 63 JS_STATIC_PROP_ENTRY(readonly) | 62 JS_STATIC_PROP_ENTRY(readonly) |
| 64 JS_STATIC_PROP_ENTRY(rect) | 63 JS_STATIC_PROP_ENTRY(rect) |
| 65 JS_STATIC_PROP_ENTRY(required) | 64 JS_STATIC_PROP_ENTRY(required) |
| 66 JS_STATIC_PROP_ENTRY(richText) | 65 JS_STATIC_PROP_ENTRY(richText) |
| 67 JS_STATIC_PROP_ENTRY(richValue) | 66 JS_STATIC_PROP_ENTRY(richValue) |
| 68 JS_STATIC_PROP_ENTRY(rotation) | 67 JS_STATIC_PROP_ENTRY(rotation) |
| 69 JS_STATIC_PROP_ENTRY(strokeColor) | 68 JS_STATIC_PROP_ENTRY(strokeColor) |
| 70 JS_STATIC_PROP_ENTRY(style) | 69 JS_STATIC_PROP_ENTRY(style) |
| 71 JS_STATIC_PROP_ENTRY(submitName) | 70 JS_STATIC_PROP_ENTRY(submitName) |
| 72 JS_STATIC_PROP_ENTRY(textColor) | 71 JS_STATIC_PROP_ENTRY(textColor) |
| 73 JS_STATIC_PROP_ENTRY(textFont) | 72 JS_STATIC_PROP_ENTRY(textFont) |
| 74 JS_STATIC_PROP_ENTRY(textSize) | 73 JS_STATIC_PROP_ENTRY(textSize) |
| 75 JS_STATIC_PROP_ENTRY(type) | 74 JS_STATIC_PROP_ENTRY(type) |
| 76 JS_STATIC_PROP_ENTRY(userName) | 75 JS_STATIC_PROP_ENTRY(userName) |
| 77 JS_STATIC_PROP_ENTRY(value) | 76 JS_STATIC_PROP_ENTRY(value) |
| 78 JS_STATIC_PROP_ENTRY(valueAsString) | 77 JS_STATIC_PROP_ENTRY(valueAsString) |
| 79 JS_STATIC_PROP_ENTRY(source) | 78 JS_STATIC_PROP_ENTRY(source) |
| 80 END_JS_STATIC_PROP() | 79 END_JS_STATIC_PROP() |
| 81 | 80 |
| 82 BEGIN_JS_STATIC_METHOD(CJS_Field) | 81 BEGIN_JS_STATIC_METHOD(CJS_Field) |
| 83 JS_STATIC_METHOD_ENTRY(browseForFileToSubmit) | 82 JS_STATIC_METHOD_ENTRY(browseForFileToSubmit) |
| 84 JS_STATIC_METHOD_ENTRY(buttonGetCaption) | 83 JS_STATIC_METHOD_ENTRY(buttonGetCaption) |
| 85 JS_STATIC_METHOD_ENTRY(buttonGetIcon) | 84 JS_STATIC_METHOD_ENTRY(buttonGetIcon) |
| 86 JS_STATIC_METHOD_ENTRY(buttonImportIcon) | 85 JS_STATIC_METHOD_ENTRY(buttonImportIcon) |
| 87 JS_STATIC_METHOD_ENTRY(buttonSetCaption) | 86 JS_STATIC_METHOD_ENTRY(buttonSetCaption) |
| 88 JS_STATIC_METHOD_ENTRY(buttonSetIcon) | 87 JS_STATIC_METHOD_ENTRY(buttonSetIcon) |
| 89 JS_STATIC_METHOD_ENTRY(checkThisBox) | 88 JS_STATIC_METHOD_ENTRY(checkThisBox) |
| 90 JS_STATIC_METHOD_ENTRY(clearItems) | 89 JS_STATIC_METHOD_ENTRY(clearItems) |
| 91 JS_STATIC_METHOD_ENTRY(defaultIsChecked) | 90 JS_STATIC_METHOD_ENTRY(defaultIsChecked) |
| 92 JS_STATIC_METHOD_ENTRY(deleteItemAt) | 91 JS_STATIC_METHOD_ENTRY(deleteItemAt) |
| 93 JS_STATIC_METHOD_ENTRY(getArray ) | 92 JS_STATIC_METHOD_ENTRY(getArray) |
| 94 JS_STATIC_METHOD_ENTRY(getItemAt) | 93 JS_STATIC_METHOD_ENTRY(getItemAt) |
| 95 JS_STATIC_METHOD_ENTRY(getLock) | 94 JS_STATIC_METHOD_ENTRY(getLock) |
| 96 JS_STATIC_METHOD_ENTRY(insertItemAt) | 95 JS_STATIC_METHOD_ENTRY(insertItemAt) |
| 97 JS_STATIC_METHOD_ENTRY(isBoxChecked) | 96 JS_STATIC_METHOD_ENTRY(isBoxChecked) |
| 98 JS_STATIC_METHOD_ENTRY(isDefaultChecked) | 97 JS_STATIC_METHOD_ENTRY(isDefaultChecked) |
| 99 JS_STATIC_METHOD_ENTRY(setAction) | 98 JS_STATIC_METHOD_ENTRY(setAction) |
| 100 JS_STATIC_METHOD_ENTRY(setFocus) | 99 JS_STATIC_METHOD_ENTRY(setFocus) |
| 101 JS_STATIC_METHOD_ENTRY(setItems) | 100 JS_STATIC_METHOD_ENTRY(setItems) |
| 102 JS_STATIC_METHOD_ENTRY(setLock) | 101 JS_STATIC_METHOD_ENTRY(setLock) |
| 103 JS_STATIC_METHOD_ENTRY(signatureGetModifications) | 102 JS_STATIC_METHOD_ENTRY(signatureGetModifications) |
| 104 JS_STATIC_METHOD_ENTRY(signatureGetSeedValue) | 103 JS_STATIC_METHOD_ENTRY(signatureGetSeedValue) |
| 105 JS_STATIC_METHOD_ENTRY(signatureInfo) | 104 JS_STATIC_METHOD_ENTRY(signatureInfo) |
| 106 JS_STATIC_METHOD_ENTRY(signatureSetSeedValue) | 105 JS_STATIC_METHOD_ENTRY(signatureSetSeedValue) |
| 107 JS_STATIC_METHOD_ENTRY(signatureSign) | 106 JS_STATIC_METHOD_ENTRY(signatureSign) |
| 108 JS_STATIC_METHOD_ENTRY(signatureValidate) | 107 JS_STATIC_METHOD_ENTRY(signatureValidate) |
| 109 END_JS_STATIC_METHOD() | 108 END_JS_STATIC_METHOD() |
| 110 | 109 |
| 111 IMPLEMENT_JS_CLASS(CJS_Field, Field) | 110 IMPLEMENT_JS_CLASS(CJS_Field, Field) |
| 112 | 111 |
| 113 FX_BOOL CJS_Field::InitInstance(IFXJS_Context* cc) | 112 FX_BOOL CJS_Field::InitInstance(IFXJS_Context* cc) { |
| 114 { | 113 CJS_Context* pContext = (CJS_Context*)cc; |
| 115 CJS_Context* pContext = (CJS_Context*)cc; | 114 ASSERT(pContext != NULL); |
| 116 ASSERT(pContext != NULL); | 115 |
| 117 | 116 Field* pField = (Field*)GetEmbedObject(); |
| 118 Field* pField = (Field*)GetEmbedObject(); | 117 ASSERT(pField != NULL); |
| 119 ASSERT(pField != NULL); | 118 |
| 120 | 119 pField->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); |
| 121 pField->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); | 120 |
| 122 | 121 return TRUE; |
| 122 }; |
| 123 |
| 124 Field::Field(CJS_Object* pJSObject) |
| 125 : CJS_EmbedObj(pJSObject), |
| 126 m_pJSDoc(NULL), |
| 127 m_pDocument(NULL), |
| 128 m_nFormControlIndex(-1), |
| 129 m_bCanSet(FALSE), |
| 130 m_bDelay(FALSE), |
| 131 m_isolate(NULL) {} |
| 132 |
| 133 Field::~Field() {} |
| 134 |
| 135 // note: iControlNo = -1, means not a widget. |
| 136 void Field::ParseFieldName(const std::wstring& strFieldNameParsed, |
| 137 std::wstring& strFieldName, |
| 138 int& iControlNo) { |
| 139 int iStart = strFieldNameParsed.find_last_of(L'.'); |
| 140 if (iStart == -1) { |
| 141 strFieldName = strFieldNameParsed; |
| 142 iControlNo = -1; |
| 143 return; |
| 144 } |
| 145 std::wstring suffixal = strFieldNameParsed.substr(iStart + 1); |
| 146 iControlNo = FXSYS_wtoi(suffixal.c_str()); |
| 147 if (iControlNo == 0) { |
| 148 int iStart; |
| 149 while ((iStart = suffixal.find_last_of(L" ")) != -1) { |
| 150 suffixal.erase(iStart, 1); |
| 151 } |
| 152 |
| 153 if (suffixal.compare(L"0") != 0) { |
| 154 strFieldName = strFieldNameParsed; |
| 155 iControlNo = -1; |
| 156 return; |
| 157 } |
| 158 } |
| 159 strFieldName = strFieldNameParsed.substr(0, iStart); |
| 160 } |
| 161 |
| 162 FX_BOOL Field::AttachField(Document* pDocument, |
| 163 const CFX_WideString& csFieldName) { |
| 164 ASSERT(pDocument != NULL); |
| 165 m_pJSDoc = pDocument; |
| 166 |
| 167 m_pDocument = pDocument->GetReaderDoc(); |
| 168 ASSERT(m_pDocument != NULL); |
| 169 |
| 170 m_bCanSet = m_pDocument->GetPermissions(FPDFPERM_FILL_FORM) || |
| 171 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
| 172 m_pDocument->GetPermissions(FPDFPERM_MODIFY); |
| 173 |
| 174 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); |
| 175 ASSERT(pRDInterForm != NULL); |
| 176 |
| 177 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); |
| 178 ASSERT(pInterForm != NULL); |
| 179 |
| 180 CFX_WideString swFieldNameTemp = csFieldName; |
| 181 swFieldNameTemp.Replace(L"..", L"."); |
| 182 |
| 183 if (pInterForm->CountFields(swFieldNameTemp) <= 0) { |
| 184 std::wstring strFieldName; |
| 185 int iControlNo = -1; |
| 186 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo); |
| 187 if (iControlNo == -1) |
| 188 return FALSE; |
| 189 |
| 190 m_FieldName = strFieldName.c_str(); |
| 191 m_nFormControlIndex = iControlNo; |
| 123 return TRUE; | 192 return TRUE; |
| 124 }; | 193 } |
| 125 | 194 |
| 126 Field::Field(CJS_Object* pJSObject): CJS_EmbedObj(pJSObject), | 195 m_FieldName = swFieldNameTemp; |
| 127 m_pJSDoc(NULL), | 196 m_nFormControlIndex = -1; |
| 128 m_pDocument(NULL), | 197 |
| 129 m_nFormControlIndex(-1), | 198 return TRUE; |
| 130 m_bCanSet(FALSE), | 199 } |
| 131 m_bDelay(FALSE), | 200 |
| 132 m_isolate(NULL) | 201 void Field::GetFormFields(CPDFSDK_Document* pDocument, |
| 133 { | 202 const CFX_WideString& csFieldName, |
| 134 } | 203 CFX_PtrArray& FieldArray) { |
| 135 | 204 ASSERT(pDocument != NULL); |
| 136 Field::~Field() | 205 |
| 137 { | 206 CPDFSDK_InterForm* pReaderInterForm = pDocument->GetInterForm(); |
| 138 } | 207 ASSERT(pReaderInterForm != NULL); |
| 139 | 208 |
| 140 //note: iControlNo = -1, means not a widget. | 209 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); |
| 141 void Field::ParseFieldName(const std::wstring &strFieldNameParsed,std::wstring &
strFieldName,int & iControlNo) | 210 ASSERT(pInterForm != NULL); |
| 142 { | 211 |
| 143 int iStart = strFieldNameParsed.find_last_of(L'.'); | 212 ASSERT(FieldArray.GetSize() == 0); |
| 144 if (iStart == -1) | 213 |
| 145 { | 214 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; i++) { |
| 146 strFieldName = strFieldNameParsed; | 215 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) |
| 147 iControlNo = -1; | 216 FieldArray.Add((void*)pFormField); |
| 148 return; | 217 } |
| 149 } | 218 } |
| 150 std::wstring suffixal = strFieldNameParsed.substr(iStart+1); | 219 |
| 151 iControlNo = FXSYS_wtoi(suffixal.c_str()); | 220 void Field::GetFormFields(const CFX_WideString& csFieldName, |
| 152 if (iControlNo == 0) | 221 CFX_PtrArray& FieldArray) { |
| 153 { | 222 ASSERT(m_pDocument != NULL); |
| 154 int iStart; | 223 |
| 155 while((iStart = suffixal.find_last_of(L" ")) != -1) | 224 Field::GetFormFields(m_pDocument, csFieldName, FieldArray); |
| 156 { | 225 } |
| 157 suffixal.erase(iStart,1); | 226 |
| 158 } | 227 void Field::UpdateFormField(CPDFSDK_Document* pDocument, |
| 159 | 228 CPDF_FormField* pFormField, |
| 160 if (suffixal.compare(L"0") != 0) | 229 FX_BOOL bChangeMark, |
| 161 { | 230 FX_BOOL bResetAP, |
| 162 strFieldName = strFieldNameParsed; | 231 FX_BOOL bRefresh) { |
| 163 iControlNo = -1; | 232 ASSERT(pDocument != NULL); |
| 164 return; | 233 ASSERT(pFormField != NULL); |
| 165 } | 234 |
| 166 | 235 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 167 } | 236 ASSERT(pInterForm != NULL); |
| 168 strFieldName = strFieldNameParsed.substr(0,iStart); | 237 |
| 169 } | 238 CFX_PtrArray widgets; |
| 170 | 239 pInterForm->GetWidgets(pFormField, widgets); |
| 171 FX_BOOL Field::AttachField(Document* pDocument, const CFX_WideString& csFieldNam
e) | 240 |
| 172 { | 241 if (bResetAP) { |
| 173 ASSERT(pDocument != NULL); | 242 int nFieldType = pFormField->GetFieldType(); |
| 174 m_pJSDoc = pDocument; | 243 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { |
| 175 | 244 for (int i = 0, sz = widgets.GetSize(); i < sz; i++) { |
| 176 m_pDocument = pDocument->GetReaderDoc(); | 245 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i); |
| 177 ASSERT(m_pDocument != NULL); | 246 ASSERT(pWidget != NULL); |
| 178 | 247 |
| 179 m_bCanSet = m_pDocument->GetPermissions(FPDFPERM_FILL_FORM) || | 248 FX_BOOL bFormated = FALSE; |
| 180 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 249 CFX_WideString sValue = pWidget->OnFormat(bFormated); |
| 181 m_pDocument->GetPermissions(FPDFPERM_MODIFY); | 250 if (bFormated) |
| 182 | 251 pWidget->ResetAppearance(sValue.c_str(), FALSE); |
| 183 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); | |
| 184 ASSERT(pRDInterForm != NULL); | |
| 185 | |
| 186 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); | |
| 187 ASSERT(pInterForm != NULL); | |
| 188 | |
| 189 CFX_WideString swFieldNameTemp = csFieldName; | |
| 190 swFieldNameTemp.Replace(L"..", L"."); | |
| 191 | |
| 192 if (pInterForm->CountFields(swFieldNameTemp) <= 0) | |
| 193 { | |
| 194 std::wstring strFieldName; | |
| 195 int iControlNo = -1; | |
| 196 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo); | |
| 197 if (iControlNo == -1) return FALSE; | |
| 198 | |
| 199 m_FieldName = strFieldName.c_str(); | |
| 200 m_nFormControlIndex = iControlNo; | |
| 201 return TRUE; | |
| 202 } | |
| 203 | |
| 204 m_FieldName = swFieldNameTemp; | |
| 205 m_nFormControlIndex = -1; | |
| 206 | |
| 207 return TRUE; | |
| 208 } | |
| 209 | |
| 210 void Field::GetFormFields(CPDFSDK_Document* pDocument, const CFX_WideString& csF
ieldName, CFX_PtrArray& FieldArray) | |
| 211 { | |
| 212 ASSERT(pDocument != NULL); | |
| 213 | |
| 214 CPDFSDK_InterForm* pReaderInterForm = pDocument->GetInterForm(); | |
| 215 ASSERT(pReaderInterForm != NULL); | |
| 216 | |
| 217 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); | |
| 218 ASSERT(pInterForm != NULL); | |
| 219 | |
| 220 ASSERT(FieldArray.GetSize() == 0); | |
| 221 | |
| 222 for (int i=0,sz=pInterForm->CountFields(csFieldName); i<sz; i++) | |
| 223 { | |
| 224 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) | |
| 225 FieldArray.Add((void*)pFormField); | |
| 226 } | |
| 227 } | |
| 228 | |
| 229 void Field::GetFormFields(const CFX_WideString& csFieldName, CFX_PtrArray& Field
Array) | |
| 230 { | |
| 231 ASSERT(m_pDocument != NULL); | |
| 232 | |
| 233 Field::GetFormFields(m_pDocument, csFieldName, FieldArray); | |
| 234 } | |
| 235 | |
| 236 void Field::UpdateFormField(CPDFSDK_Document* pDocument, CPDF_FormField* pFormFi
eld, | |
| 237 FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefr
esh) | |
| 238 { | |
| 239 ASSERT(pDocument != NULL); | |
| 240 ASSERT(pFormField != NULL); | |
| 241 | |
| 242 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(
); | |
| 243 ASSERT(pInterForm != NULL); | |
| 244 | |
| 245 CFX_PtrArray widgets; | |
| 246 pInterForm->GetWidgets(pFormField, widgets); | |
| 247 | |
| 248 if (bResetAP) | |
| 249 { | |
| 250 int nFieldType = pFormField->GetFieldType(); | |
| 251 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIEL
D) | |
| 252 { | |
| 253 for (int i=0,sz=widgets.GetSize(); i<sz; i++) | |
| 254 { | |
| 255 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i); | |
| 256 ASSERT(pWidget != NULL); | |
| 257 | |
| 258 FX_BOOL bFormated = FALSE; | |
| 259 CFX_WideString sValue = pWidget->OnFormat(bFormated); | |
| 260 if (bFormated) | |
| 261 pWidget->ResetAppearance(sValue.c_str(), FALSE); | |
| 262 else | |
| 263 pWidget->ResetAppearance(NULL, FALSE); | |
| 264 } | |
| 265 } | |
| 266 else | 252 else |
| 267 { | 253 pWidget->ResetAppearance(NULL, FALSE); |
| 268 for (int i=0,sz=widgets.GetSize(); i<sz; i++) | 254 } |
| 269 { | 255 } else { |
| 270 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i); | 256 for (int i = 0, sz = widgets.GetSize(); i < sz; i++) { |
| 271 ASSERT(pWidget != NULL); | 257 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i); |
| 272 | 258 ASSERT(pWidget != NULL); |
| 273 pWidget->ResetAppearance(NULL, FALSE); | 259 |
| 274 } | 260 pWidget->ResetAppearance(NULL, FALSE); |
| 275 } | 261 } |
| 276 } | 262 } |
| 277 | 263 } |
| 278 if (bRefresh) | 264 |
| 279 { | 265 if (bRefresh) { |
| 280 for (int i=0,sz=widgets.GetSize(); i<sz; i++) | 266 for (int i = 0, sz = widgets.GetSize(); i < sz; i++) { |
| 281 { | 267 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i); |
| 282 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets.GetAt(i); | 268 ASSERT(pWidget != NULL); |
| 283 ASSERT(pWidget != NULL); | 269 |
| 284 | 270 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
| 285 CPDFSDK_InterForm * pInterForm = pWidget->GetInterForm(); | 271 CPDFSDK_Document* pDoc = pInterForm->GetDocument(); |
| 286 CPDFSDK_Document* pDoc = pInterForm->GetDocument(); | 272 // CReader_Page* pPage = pWidget->GetPage(); |
| 287 // CReader_Page* pPage = pWidget->GetPage(); | 273 ASSERT(pDoc != NULL); |
| 288 ASSERT(pDoc != NULL); | 274 pDoc->UpdateAllViews(NULL, pWidget); |
| 289 pDoc->UpdateAllViews(NULL, pWidget); | 275 } |
| 290 } | 276 } |
| 291 } | 277 |
| 292 | 278 if (bChangeMark) |
| 293 if (bChangeMark) | 279 pDocument->SetChangeMark(); |
| 294 pDocument->SetChangeMark(); | 280 } |
| 295 } | 281 |
| 296 | 282 void Field::UpdateFormControl(CPDFSDK_Document* pDocument, |
| 297 void Field::UpdateFormControl(CPDFSDK_Document* pDocument, CPDF_FormControl* pFo
rmControl, | 283 CPDF_FormControl* pFormControl, |
| 298 FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefr
esh) | 284 FX_BOOL bChangeMark, |
| 299 { | 285 FX_BOOL bResetAP, |
| 300 ASSERT(pDocument != NULL); | 286 FX_BOOL bRefresh) { |
| 301 ASSERT(pFormControl != NULL); | 287 ASSERT(pDocument != NULL); |
| 302 | 288 ASSERT(pFormControl != NULL); |
| 303 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(
); | 289 |
| 304 ASSERT(pInterForm != NULL); | 290 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 305 | 291 ASSERT(pInterForm != NULL); |
| 306 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl); | 292 |
| 307 | 293 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl); |
| 308 if (pWidget) | 294 |
| 309 { | 295 if (pWidget) { |
| 310 if (bResetAP) | 296 if (bResetAP) { |
| 311 { | 297 int nFieldType = pWidget->GetFieldType(); |
| 312 int nFieldType = pWidget->GetFieldType(); | 298 if (nFieldType == FIELDTYPE_COMBOBOX || |
| 313 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXT
FIELD) | 299 nFieldType == FIELDTYPE_TEXTFIELD) { |
| 314 { | 300 FX_BOOL bFormated = FALSE; |
| 315 FX_BOOL bFormated = FALSE; | 301 CFX_WideString sValue = pWidget->OnFormat(bFormated); |
| 316 CFX_WideString sValue = pWidget->OnFormat(bFormated); | 302 if (bFormated) |
| 317 if (bFormated) | 303 pWidget->ResetAppearance(sValue.c_str(), FALSE); |
| 318 pWidget->ResetAppearance(sValue.c_str(), FALSE); | |
| 319 else | |
| 320 pWidget->ResetAppearance(NULL, FALSE); | |
| 321 } | |
| 322 else | |
| 323 { | |
| 324 pWidget->ResetAppearance(NULL, FALSE); | |
| 325 } | |
| 326 } | |
| 327 | |
| 328 if (bRefresh) | |
| 329 { | |
| 330 CPDFSDK_InterForm * pInterForm = pWidget->GetInterForm(); | |
| 331 CPDFSDK_Document* pDoc = pInterForm->GetDocument(); | |
| 332 ASSERT(pDoc != NULL); | |
| 333 pDoc->UpdateAllViews(NULL, pWidget); | |
| 334 } | |
| 335 | |
| 336 } | |
| 337 | |
| 338 if (bChangeMark) | |
| 339 pDocument->SetChangeMark(); | |
| 340 } | |
| 341 | |
| 342 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument, CPDF_FormControl*
pFormControl) | |
| 343 { | |
| 344 ASSERT(pDocument != NULL); | |
| 345 ASSERT(pFormControl != NULL); | |
| 346 | |
| 347 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(
); | |
| 348 ASSERT(pInterForm != NULL); | |
| 349 | |
| 350 return pInterForm->GetWidget(pFormControl); | |
| 351 } | |
| 352 | |
| 353 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabe
l) | |
| 354 { | |
| 355 ASSERT(pFormField != NULL); | |
| 356 | |
| 357 for (int i=0,sz = pFormField->CountOptions(); i < sz; i++) | |
| 358 { | |
| 359 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) | |
| 360 return TRUE; | |
| 361 } | |
| 362 | |
| 363 return FALSE; | |
| 364 } | |
| 365 | |
| 366 CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) | |
| 367 { | |
| 368 if (!pFormField->CountControls() || m_nFormControlIndex >= pFormField->Count
Controls()) | |
| 369 return NULL; | |
| 370 | |
| 371 if (m_nFormControlIndex < 0) | |
| 372 return pFormField->GetControl(0); | |
| 373 | |
| 374 return pFormField->GetControl(m_nFormControlIndex); | |
| 375 } | |
| 376 | |
| 377 /* ---------------------------------------- property ---------------------------
------------- */ | |
| 378 | |
| 379 FX_BOOL Field::alignment(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | |
| 380 { | |
| 381 ASSERT(m_pDocument != NULL); | |
| 382 | |
| 383 if (vp.IsSetting()) | |
| 384 { | |
| 385 if (!m_bCanSet) return FALSE; | |
| 386 | |
| 387 CFX_ByteString alignStr; | |
| 388 vp >> alignStr; | |
| 389 | |
| 390 if (m_bDelay) | |
| 391 { | |
| 392 AddDelay_String(FP_ALIGNMENT, alignStr); | |
| 393 } | |
| 394 else | 304 else |
| 395 { | 305 pWidget->ResetAppearance(NULL, FALSE); |
| 396 Field::SetAlignment(m_pDocument, m_FieldName, m_nFormControlIndex, a
lignStr); | 306 } else { |
| 397 } | 307 pWidget->ResetAppearance(NULL, FALSE); |
| 398 } | 308 } |
| 399 else | 309 } |
| 400 { | 310 |
| 401 CFX_PtrArray FieldArray; | 311 if (bRefresh) { |
| 402 GetFormFields(m_FieldName, FieldArray); | 312 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
| 403 if (FieldArray.GetSize() <= 0) return FALSE; | 313 CPDFSDK_Document* pDoc = pInterForm->GetDocument(); |
| 404 | 314 ASSERT(pDoc != NULL); |
| 405 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 315 pDoc->UpdateAllViews(NULL, pWidget); |
| 406 ASSERT(pFormField != NULL); | 316 } |
| 407 | 317 } |
| 408 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 318 |
| 409 return FALSE; | 319 if (bChangeMark) |
| 410 | 320 pDocument->SetChangeMark(); |
| 411 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 321 } |
| 412 if (!pFormControl)return FALSE; | 322 |
| 413 | 323 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument, |
| 414 switch (pFormControl->GetControlAlignment()) | 324 CPDF_FormControl* pFormControl) { |
| 415 { | 325 ASSERT(pDocument != NULL); |
| 416 case 1: | 326 ASSERT(pFormControl != NULL); |
| 417 vp << L"center"; | 327 |
| 418 break; | 328 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 419 case 0: | 329 ASSERT(pInterForm != NULL); |
| 420 vp << L"left"; | 330 |
| 421 break; | 331 return pInterForm->GetWidget(pFormControl); |
| 422 case 2: | 332 } |
| 423 vp << L"right"; | 333 |
| 424 break; | 334 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, |
| 425 default: | 335 CFX_WideString csOptLabel) { |
| 426 vp << L""; | 336 ASSERT(pFormField != NULL); |
| 427 } | 337 |
| 428 } | 338 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) { |
| 429 | 339 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) |
| 430 return TRUE; | 340 return TRUE; |
| 431 } | 341 } |
| 432 | 342 |
| 433 void Field::SetAlignment(CPDFSDK_Document* pDocument, const CFX_WideString& swFi
eldName, int nControlIndex, | 343 return FALSE; |
| 434 const CFX_ByteString& string) | 344 } |
| 435 { | 345 |
| 436 //Not supported. | 346 CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) { |
| 437 } | 347 if (!pFormField->CountControls() || |
| 438 | 348 m_nFormControlIndex >= pFormField->CountControls()) |
| 439 FX_BOOL Field::borderStyle(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 349 return NULL; |
| 440 { | 350 |
| 441 ASSERT(m_pDocument != NULL); | 351 if (m_nFormControlIndex < 0) |
| 442 | 352 return pFormField->GetControl(0); |
| 443 if (vp.IsSetting()) | 353 |
| 444 { | 354 return pFormField->GetControl(m_nFormControlIndex); |
| 445 if (!m_bCanSet) return FALSE; | 355 } |
| 446 | 356 |
| 447 CFX_ByteString strType = ""; | 357 /* ---------------------------------------- property |
| 448 vp >> strType; | 358 * ---------------------------------------- */ |
| 449 | 359 |
| 450 if (m_bDelay) | 360 FX_BOOL Field::alignment(IFXJS_Context* cc, |
| 451 { | 361 CJS_PropValue& vp, |
| 452 AddDelay_String(FP_BORDERSTYLE, strType); | 362 CFX_WideString& sError) { |
| 453 } | 363 ASSERT(m_pDocument != NULL); |
| 454 else | 364 |
| 455 { | 365 if (vp.IsSetting()) { |
| 456 Field::SetBorderStyle(m_pDocument, m_FieldName, m_nFormControlIndex,
strType); | 366 if (!m_bCanSet) |
| 457 } | 367 return FALSE; |
| 458 } | 368 |
| 459 else | 369 CFX_ByteString alignStr; |
| 460 { | 370 vp >> alignStr; |
| 461 CFX_PtrArray FieldArray; | 371 |
| 462 GetFormFields(m_FieldName, FieldArray); | 372 if (m_bDelay) { |
| 463 if (FieldArray.GetSize() <= 0) return FALSE; | 373 AddDelay_String(FP_ALIGNMENT, alignStr); |
| 464 | 374 } else { |
| 465 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 375 Field::SetAlignment(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 466 if (!pFormField) return FALSE; | 376 alignStr); |
| 467 | 377 } |
| 468 CPDFSDK_Widget* pWidget = GetWidget(m_pDocument, GetSmartFieldControl(pF
ormField)); | 378 } else { |
| 469 if (!pWidget) return FALSE; | |
| 470 | |
| 471 int nBorderstyle = pWidget->GetBorderStyle(); | |
| 472 | |
| 473 switch (nBorderstyle) | |
| 474 { | |
| 475 case BBS_SOLID: | |
| 476 vp << L"solid"; | |
| 477 break; | |
| 478 case BBS_DASH: | |
| 479 vp << L"dashed"; | |
| 480 break; | |
| 481 case BBS_BEVELED: | |
| 482 vp << L"beveled"; | |
| 483 break; | |
| 484 case BBS_INSET: | |
| 485 vp << L"inset"; | |
| 486 break; | |
| 487 case BBS_UNDERLINE: | |
| 488 vp << L"underline"; | |
| 489 break; | |
| 490 default: | |
| 491 vp << L""; | |
| 492 break; | |
| 493 } | |
| 494 } | |
| 495 | |
| 496 return TRUE; | |
| 497 } | |
| 498 | |
| 499 void Field::SetBorderStyle(CPDFSDK_Document* pDocument, const CFX_WideString& sw
FieldName, int nControlIndex, | |
| 500 const CFX_ByteString& string) | |
| 501 { | |
| 502 ASSERT(pDocument != NULL); | |
| 503 | |
| 504 int nBorderStyle = 0; | |
| 505 | |
| 506 if (string == "solid") | |
| 507 nBorderStyle = BBS_SOLID; | |
| 508 else if (string == "beveled") | |
| 509 nBorderStyle = BBS_BEVELED; | |
| 510 else if (string == "dashed") | |
| 511 nBorderStyle = BBS_DASH; | |
| 512 else if (string == "inset") | |
| 513 nBorderStyle = BBS_INSET; | |
| 514 else if (string == "underline") | |
| 515 nBorderStyle = BBS_UNDERLINE; | |
| 516 else return; | |
| 517 | |
| 518 CFX_PtrArray FieldArray; | |
| 519 GetFormFields(pDocument, swFieldName, FieldArray); | |
| 520 | |
| 521 for (int i=0,isz=FieldArray.GetSize(); i<isz; i++) | |
| 522 { | |
| 523 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
| 524 ASSERT(pFormField != NULL); | |
| 525 | |
| 526 if (nControlIndex < 0) | |
| 527 { | |
| 528 FX_BOOL bSet = FALSE; | |
| 529 for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++) | |
| 530 { | |
| 531 if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormField->G
etControl(j))) | |
| 532 { | |
| 533 if (pWidget->GetBorderStyle() != nBorderStyle) | |
| 534 { | |
| 535 pWidget->SetBorderStyle(nBorderStyle); | |
| 536 bSet = TRUE; | |
| 537 } | |
| 538 } | |
| 539 } | |
| 540 if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); | |
| 541 } | |
| 542 else | |
| 543 { | |
| 544 if(nControlIndex >= pFormField->CountControls()) return; | |
| 545 if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControl
Index)) | |
| 546 { | |
| 547 if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormControl)
) | |
| 548 { | |
| 549 if (pWidget->GetBorderStyle() != nBorderStyle) | |
| 550 { | |
| 551 pWidget->SetBorderStyle(nBorderStyle); | |
| 552 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, T
RUE); | |
| 553 } | |
| 554 } | |
| 555 } | |
| 556 } | |
| 557 } | |
| 558 } | |
| 559 | |
| 560 FX_BOOL Field::buttonAlignX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | |
| 561 { | |
| 562 ASSERT(m_pDocument != NULL); | |
| 563 | |
| 564 if (vp.IsSetting()) | |
| 565 { | |
| 566 if (!m_bCanSet) return FALSE; | |
| 567 | |
| 568 int nVP; | |
| 569 vp >> nVP; | |
| 570 | |
| 571 if (m_bDelay) | |
| 572 { | |
| 573 AddDelay_Int(FP_BUTTONALIGNX, nVP); | |
| 574 } | |
| 575 else | |
| 576 { | |
| 577 Field::SetButtonAlignX(m_pDocument, m_FieldName, m_nFormControlIndex
, nVP); | |
| 578 } | |
| 579 } | |
| 580 else | |
| 581 { | |
| 582 CFX_PtrArray FieldArray; | |
| 583 GetFormFields(m_FieldName,FieldArray); | |
| 584 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 585 | |
| 586 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 587 ASSERT(pFormField != NULL); | |
| 588 | |
| 589 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | |
| 590 return FALSE; | |
| 591 | |
| 592 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 593 if (!pFormControl)return FALSE; | |
| 594 | |
| 595 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | |
| 596 | |
| 597 FX_FLOAT fLeft,fBottom; | |
| 598 IconFit.GetIconPosition(fLeft,fBottom); | |
| 599 | |
| 600 vp << (int32_t)fLeft; | |
| 601 } | |
| 602 | |
| 603 return TRUE; | |
| 604 } | |
| 605 | |
| 606 void Field::SetButtonAlignX(CPDFSDK_Document* pDocument, const CFX_WideString& s
wFieldName, int nControlIndex, int number) | |
| 607 { | |
| 608 //Not supported. | |
| 609 } | |
| 610 | |
| 611 FX_BOOL Field::buttonAlignY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | |
| 612 { | |
| 613 ASSERT(m_pDocument != NULL); | |
| 614 | |
| 615 if (vp.IsSetting()) | |
| 616 { | |
| 617 if (!m_bCanSet) return FALSE; | |
| 618 | |
| 619 int nVP; | |
| 620 vp >> nVP; | |
| 621 | |
| 622 if (m_bDelay) | |
| 623 { | |
| 624 AddDelay_Int(FP_BUTTONALIGNY, nVP); | |
| 625 } | |
| 626 else | |
| 627 { | |
| 628 Field::SetButtonAlignY(m_pDocument, m_FieldName, m_nFormControlIndex
, nVP); | |
| 629 } | |
| 630 } | |
| 631 else | |
| 632 { | |
| 633 CFX_PtrArray FieldArray; | |
| 634 GetFormFields(m_FieldName,FieldArray); | |
| 635 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 636 | |
| 637 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 638 ASSERT(pFormField != NULL); | |
| 639 | |
| 640 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | |
| 641 return FALSE; | |
| 642 | |
| 643 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 644 if (!pFormControl)return FALSE; | |
| 645 | |
| 646 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | |
| 647 | |
| 648 FX_FLOAT fLeft,fBottom; | |
| 649 IconFit.GetIconPosition(fLeft,fBottom); | |
| 650 | |
| 651 vp << (int32_t)fBottom; | |
| 652 } | |
| 653 | |
| 654 return TRUE; | |
| 655 } | |
| 656 | |
| 657 void Field::SetButtonAlignY(CPDFSDK_Document* pDocument, const CFX_WideString& s
wFieldName, int nControlIndex, int number) | |
| 658 { | |
| 659 //Not supported. | |
| 660 } | |
| 661 | |
| 662 FX_BOOL Field::buttonFitBounds(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) | |
| 663 { | |
| 664 ASSERT(m_pDocument != NULL); | |
| 665 | |
| 666 if (vp.IsSetting()) | |
| 667 { | |
| 668 if (!m_bCanSet) return FALSE; | |
| 669 | |
| 670 bool bVP; | |
| 671 vp >> bVP; | |
| 672 | |
| 673 if (m_bDelay) | |
| 674 { | |
| 675 AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP); | |
| 676 } | |
| 677 else | |
| 678 { | |
| 679 Field::SetButtonFitBounds(m_pDocument, m_FieldName, m_nFormControlIn
dex, bVP); | |
| 680 } | |
| 681 } | |
| 682 else | |
| 683 { | |
| 684 CFX_PtrArray FieldArray; | |
| 685 GetFormFields(m_FieldName,FieldArray); | |
| 686 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 687 | |
| 688 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 689 ASSERT(pFormField != NULL); | |
| 690 | |
| 691 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | |
| 692 return FALSE; | |
| 693 | |
| 694 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 695 if (!pFormControl)return FALSE; | |
| 696 | |
| 697 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | |
| 698 vp << IconFit.GetFittingBounds(); | |
| 699 } | |
| 700 | |
| 701 return TRUE; | |
| 702 } | |
| 703 | |
| 704 void Field::SetButtonFitBounds(CPDFSDK_Document* pDocument, const CFX_WideString
& swFieldName, int nControlIndex, bool b) | |
| 705 { | |
| 706 //Not supported. | |
| 707 } | |
| 708 | |
| 709 FX_BOOL Field::buttonPosition(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStri
ng& sError) | |
| 710 { | |
| 711 ASSERT(m_pDocument != NULL); | |
| 712 | |
| 713 if (vp.IsSetting()) | |
| 714 { | |
| 715 if (!m_bCanSet) return FALSE; | |
| 716 | |
| 717 int nVP; | |
| 718 vp >> nVP; | |
| 719 | |
| 720 if (m_bDelay) | |
| 721 { | |
| 722 AddDelay_Int(FP_BUTTONPOSITION, nVP); | |
| 723 } | |
| 724 else | |
| 725 { | |
| 726 Field::SetButtonPosition(m_pDocument, m_FieldName, m_nFormControlInd
ex, nVP); | |
| 727 } | |
| 728 } | |
| 729 else | |
| 730 { | |
| 731 CFX_PtrArray FieldArray; | |
| 732 GetFormFields(m_FieldName,FieldArray); | |
| 733 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 734 | |
| 735 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 736 ASSERT(pFormField != NULL); | |
| 737 | |
| 738 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | |
| 739 return FALSE; | |
| 740 | |
| 741 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 742 if (!pFormControl)return FALSE; | |
| 743 | |
| 744 vp << pFormControl->GetTextPosition(); | |
| 745 } | |
| 746 return TRUE; | |
| 747 } | |
| 748 | |
| 749 void Field::SetButtonPosition(CPDFSDK_Document* pDocument, const CFX_WideString&
swFieldName, int nControlIndex, int number) | |
| 750 { | |
| 751 //Not supported. | |
| 752 } | |
| 753 | |
| 754 FX_BOOL Field::buttonScaleHow(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStri
ng& sError) | |
| 755 { | |
| 756 ASSERT(m_pDocument != NULL); | |
| 757 | |
| 758 if (vp.IsSetting()) | |
| 759 { | |
| 760 if (!m_bCanSet) return FALSE; | |
| 761 | |
| 762 int nVP; | |
| 763 vp >> nVP; | |
| 764 | |
| 765 if (m_bDelay) | |
| 766 { | |
| 767 AddDelay_Int(FP_BUTTONSCALEHOW, nVP); | |
| 768 } | |
| 769 else | |
| 770 { | |
| 771 Field::SetButtonScaleHow(m_pDocument, m_FieldName, m_nFormControlInd
ex, nVP); | |
| 772 } | |
| 773 } | |
| 774 else | |
| 775 { | |
| 776 CFX_PtrArray FieldArray; | |
| 777 GetFormFields(m_FieldName, FieldArray); | |
| 778 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 779 | |
| 780 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 781 ASSERT(pFormField != NULL); | |
| 782 | |
| 783 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | |
| 784 return FALSE; | |
| 785 | |
| 786 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 787 if (!pFormControl)return FALSE; | |
| 788 | |
| 789 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | |
| 790 if (IconFit.IsProportionalScale()) | |
| 791 vp << (int32_t)0; | |
| 792 else | |
| 793 vp << (int32_t)1; | |
| 794 } | |
| 795 | |
| 796 return TRUE; | |
| 797 } | |
| 798 | |
| 799 void Field::SetButtonScaleHow(CPDFSDK_Document* pDocument, const CFX_WideString&
swFieldName, int nControlIndex, int number) | |
| 800 { | |
| 801 //Not supported. | |
| 802 } | |
| 803 | |
| 804 FX_BOOL Field::buttonScaleWhen(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) | |
| 805 { | |
| 806 ASSERT(m_pDocument != NULL); | |
| 807 | |
| 808 if (vp.IsSetting()) | |
| 809 { | |
| 810 if (!m_bCanSet) return FALSE; | |
| 811 | |
| 812 int nVP; | |
| 813 vp >> nVP; | |
| 814 | |
| 815 if (m_bDelay) | |
| 816 { | |
| 817 AddDelay_Int(FP_BUTTONSCALEWHEN, nVP); | |
| 818 } | |
| 819 else | |
| 820 { | |
| 821 Field::SetButtonScaleWhen(m_pDocument, m_FieldName, m_nFormControlIn
dex, nVP); | |
| 822 } | |
| 823 } | |
| 824 else | |
| 825 { | |
| 826 CFX_PtrArray FieldArray; | |
| 827 GetFormFields(m_FieldName,FieldArray); | |
| 828 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 829 | |
| 830 CPDF_FormField* pFormField = (CPDF_FormField*) FieldArray.ElementAt(0); | |
| 831 ASSERT(pFormField != NULL); | |
| 832 | |
| 833 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | |
| 834 return FALSE; | |
| 835 | |
| 836 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 837 if (!pFormControl) return FALSE; | |
| 838 | |
| 839 CPDF_IconFit IconFit = pFormControl->GetIconFit(); | |
| 840 int ScaleM = IconFit.GetScaleMethod(); | |
| 841 switch (ScaleM) | |
| 842 { | |
| 843 case CPDF_IconFit::Always : | |
| 844 vp << (int32_t) CPDF_IconFit::Always; | |
| 845 break; | |
| 846 case CPDF_IconFit::Bigger : | |
| 847 vp << (int32_t) CPDF_IconFit::Bigger; | |
| 848 break; | |
| 849 case CPDF_IconFit::Never : | |
| 850 vp << (int32_t) CPDF_IconFit::Never; | |
| 851 break; | |
| 852 case CPDF_IconFit::Smaller : | |
| 853 vp << (int32_t) CPDF_IconFit::Smaller; | |
| 854 break; | |
| 855 } | |
| 856 } | |
| 857 | |
| 858 return TRUE; | |
| 859 } | |
| 860 | |
| 861 void Field::SetButtonScaleWhen(CPDFSDK_Document* pDocument, const CFX_WideString
& swFieldName, int nControlIndex, int number) | |
| 862 { | |
| 863 //Not supported. | |
| 864 } | |
| 865 | |
| 866 FX_BOOL Field::calcOrderIndex(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStri
ng& sError) | |
| 867 { | |
| 868 ASSERT(m_pDocument != NULL); | |
| 869 | |
| 870 if (vp.IsSetting()) | |
| 871 { | |
| 872 if (!m_bCanSet) return FALSE; | |
| 873 | |
| 874 int nVP; | |
| 875 vp >> nVP; | |
| 876 | |
| 877 if (m_bDelay) | |
| 878 { | |
| 879 AddDelay_Int(FP_CALCORDERINDEX, nVP); | |
| 880 } | |
| 881 else | |
| 882 { | |
| 883 Field::SetCalcOrderIndex(m_pDocument, m_FieldName, m_nFormControlInd
ex, nVP); | |
| 884 } | |
| 885 } | |
| 886 else | |
| 887 { | |
| 888 CFX_PtrArray FieldArray; | |
| 889 GetFormFields(m_FieldName, FieldArray); | |
| 890 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 891 | |
| 892 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 893 ASSERT(pFormField != NULL); | |
| 894 | |
| 895 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetF
ieldType() != FIELDTYPE_TEXTFIELD) | |
| 896 return FALSE; | |
| 897 | |
| 898 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); | |
| 899 ASSERT(pRDInterForm != NULL); | |
| 900 | |
| 901 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); | |
| 902 ASSERT(pInterForm != NULL); | |
| 903 | |
| 904 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); | |
| 905 } | |
| 906 | |
| 907 return TRUE; | |
| 908 } | |
| 909 | |
| 910 void Field::SetCalcOrderIndex(CPDFSDK_Document* pDocument, const CFX_WideString&
swFieldName, int nControlIndex, int number) | |
| 911 { | |
| 912 //Not supported. | |
| 913 } | |
| 914 | |
| 915 FX_BOOL Field::charLimit(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | |
| 916 { | |
| 917 ASSERT(m_pDocument != NULL); | |
| 918 | |
| 919 if (vp.IsSetting()) | |
| 920 { | |
| 921 if (!m_bCanSet) return FALSE; | |
| 922 | |
| 923 int nVP; | |
| 924 vp >> nVP; | |
| 925 | |
| 926 if (m_bDelay) | |
| 927 { | |
| 928 AddDelay_Int(FP_CHARLIMIT, nVP); | |
| 929 } | |
| 930 else | |
| 931 { | |
| 932 Field::SetCharLimit(m_pDocument, m_FieldName, m_nFormControlIndex, n
VP); | |
| 933 } | |
| 934 } | |
| 935 else | |
| 936 { | |
| 937 CFX_PtrArray FieldArray; | |
| 938 GetFormFields(m_FieldName, FieldArray); | |
| 939 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 940 | |
| 941 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 942 ASSERT(pFormField != NULL); | |
| 943 | |
| 944 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | |
| 945 return FALSE; | |
| 946 | |
| 947 vp << (int32_t)pFormField->GetMaxLen(); | |
| 948 } | |
| 949 return TRUE; | |
| 950 } | |
| 951 | |
| 952 void Field::SetCharLimit(CPDFSDK_Document* pDocument, const CFX_WideString& swFi
eldName, int nControlIndex, int number) | |
| 953 { | |
| 954 //Not supported. | |
| 955 } | |
| 956 | |
| 957 FX_BOOL Field::comb(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) | |
| 958 { | |
| 959 ASSERT(m_pDocument != NULL); | |
| 960 | |
| 961 if (vp.IsSetting()) | |
| 962 { | |
| 963 if (!m_bCanSet) return FALSE; | |
| 964 | |
| 965 bool bVP; | |
| 966 vp >> bVP; | |
| 967 | |
| 968 if (m_bDelay) | |
| 969 { | |
| 970 AddDelay_Bool(FP_COMB, bVP); | |
| 971 } | |
| 972 else | |
| 973 { | |
| 974 Field::SetComb(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); | |
| 975 } | |
| 976 } | |
| 977 else | |
| 978 { | |
| 979 CFX_PtrArray FieldArray; | |
| 980 GetFormFields(m_FieldName,FieldArray); | |
| 981 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 982 | |
| 983 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 984 ASSERT(pFormField != NULL); | |
| 985 | |
| 986 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | |
| 987 return FALSE; | |
| 988 | |
| 989 if (pFormField->GetFieldFlags() & FIELDFLAG_COMB) | |
| 990 vp << true; | |
| 991 else | |
| 992 vp << false; | |
| 993 } | |
| 994 | |
| 995 return TRUE; | |
| 996 } | |
| 997 | |
| 998 void Field::SetComb(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldNa
me, int nControlIndex, bool b) | |
| 999 { | |
| 1000 //Not supported. | |
| 1001 } | |
| 1002 | |
| 1003 FX_BOOL Field::commitOnSelChange(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideS
tring& sError) | |
| 1004 { | |
| 1005 ASSERT(m_pDocument != NULL); | |
| 1006 | |
| 1007 if (vp.IsSetting()) | |
| 1008 { | |
| 1009 if (!m_bCanSet) return FALSE; | |
| 1010 | |
| 1011 bool bVP; | |
| 1012 vp >> bVP; | |
| 1013 | |
| 1014 if (m_bDelay) | |
| 1015 { | |
| 1016 AddDelay_Bool(FP_COMMITONSELCHANGE, bVP); | |
| 1017 } | |
| 1018 else | |
| 1019 { | |
| 1020 Field::SetCommitOnSelChange(m_pDocument, m_FieldName, m_nFormControl
Index, bVP); | |
| 1021 } | |
| 1022 } | |
| 1023 else | |
| 1024 { | |
| 1025 CFX_PtrArray FieldArray; | |
| 1026 GetFormFields(m_FieldName,FieldArray); | |
| 1027 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1028 | |
| 1029 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1030 ASSERT(pFormField != NULL); | |
| 1031 | |
| 1032 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetF
ieldType() != FIELDTYPE_LISTBOX) | |
| 1033 return FALSE; | |
| 1034 | |
| 1035 if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE) | |
| 1036 vp << true; | |
| 1037 else | |
| 1038 vp << false; | |
| 1039 } | |
| 1040 | |
| 1041 return TRUE; | |
| 1042 } | |
| 1043 | |
| 1044 void Field::SetCommitOnSelChange(CPDFSDK_Document* pDocument, const CFX_WideStri
ng& swFieldName, int nControlIndex, bool b) | |
| 1045 { | |
| 1046 //Not supported. | |
| 1047 } | |
| 1048 | |
| 1049 FX_BOOL Field::currentValueIndices(IFXJS_Context* cc, CJS_PropValue& vp, CFX_Wid
eString& sError) | |
| 1050 { | |
| 1051 ASSERT(m_pDocument != NULL); | |
| 1052 | |
| 1053 if (vp.IsSetting()) | |
| 1054 { | |
| 1055 if (!m_bCanSet) return FALSE; | |
| 1056 | |
| 1057 CFX_DWordArray array; | |
| 1058 | |
| 1059 if (vp.GetType() == VT_number) | |
| 1060 { | |
| 1061 int iSelecting = 0; | |
| 1062 vp >> iSelecting; | |
| 1063 array.Add(iSelecting); | |
| 1064 } | |
| 1065 else if (vp.IsArrayObject()) | |
| 1066 { | |
| 1067 CJS_Array SelArray(m_isolate); | |
| 1068 CJS_Value SelValue(m_isolate); | |
| 1069 int iSelecting; | |
| 1070 vp >> SelArray; | |
| 1071 for (int i=0,sz=SelArray.GetLength(); i<sz; i++) | |
| 1072 { | |
| 1073 SelArray.GetElement(i,SelValue); | |
| 1074 iSelecting = SelValue.ToInt(); | |
| 1075 array.Add(iSelecting); | |
| 1076 } | |
| 1077 } | |
| 1078 | |
| 1079 if (m_bDelay) | |
| 1080 { | |
| 1081 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array); | |
| 1082 } | |
| 1083 else | |
| 1084 { | |
| 1085 Field::SetCurrentValueIndices(m_pDocument, m_FieldName, m_nFormContr
olIndex, array); | |
| 1086 } | |
| 1087 } | |
| 1088 else | |
| 1089 { | |
| 1090 CFX_PtrArray FieldArray; | |
| 1091 GetFormFields(m_FieldName,FieldArray); | |
| 1092 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1093 | |
| 1094 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1095 ASSERT(pFormField != NULL); | |
| 1096 | |
| 1097 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && pFormField->GetF
ieldType() != FIELDTYPE_LISTBOX) | |
| 1098 return FALSE; | |
| 1099 | |
| 1100 if (pFormField->CountSelectedItems() == 1) | |
| 1101 vp << pFormField->GetSelectedIndex(0); | |
| 1102 else if (pFormField->CountSelectedItems() > 1) | |
| 1103 { | |
| 1104 CJS_Array SelArray(m_isolate); | |
| 1105 for (int i=0,sz=pFormField->CountSelectedItems(); i<sz; i++) | |
| 1106 { | |
| 1107 SelArray.SetElement(i, CJS_Value(m_isolate,pFormField->GetSelect
edIndex(i))); | |
| 1108 } | |
| 1109 vp << SelArray; | |
| 1110 } | |
| 1111 else | |
| 1112 vp << -1; | |
| 1113 } | |
| 1114 | |
| 1115 return TRUE; | |
| 1116 } | |
| 1117 | |
| 1118 void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument, const CFX_WideSt
ring& swFieldName, int nControlIndex, | |
| 1119 const CFX_DWordArray& array) | |
| 1120 { | |
| 1121 ASSERT(pDocument != NULL); | |
| 1122 | |
| 1123 CFX_PtrArray FieldArray; | |
| 1124 GetFormFields(pDocument, swFieldName, FieldArray); | |
| 1125 | |
| 1126 for (int i=0,isz=FieldArray.GetSize(); i<isz; i++) | |
| 1127 { | |
| 1128 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
| 1129 ASSERT(pFormField != NULL); | |
| 1130 | |
| 1131 int nFieldType = pFormField->GetFieldType(); | |
| 1132 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX) | |
| 1133 { | |
| 1134 FX_DWORD dwFieldFlags = pFormField->GetFieldFlags(); | |
| 1135 pFormField->ClearSelection(TRUE); | |
| 1136 | |
| 1137 for (int i=0,sz=array.GetSize(); i<sz; i++) | |
| 1138 { | |
| 1139 if (i>0 && !(dwFieldFlags & (1<<21))) | |
| 1140 { | |
| 1141 break; | |
| 1142 } | |
| 1143 | |
| 1144 int iSelecting = (int32_t)array.GetAt(i); | |
| 1145 if (iSelecting < pFormField->CountOptions() && !pFormField->IsIt
emSelected(iSelecting)) | |
| 1146 pFormField->SetItemSelection(iSelecting, TRUE); | |
| 1147 | |
| 1148 } | |
| 1149 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); | |
| 1150 } | |
| 1151 } | |
| 1152 } | |
| 1153 | |
| 1154 FX_BOOL Field::defaultStyle(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | |
| 1155 { | |
| 1156 // MQG sError = JSGetStringFromID(IDS_STRING_NOTSUPPORT); | |
| 1157 return FALSE; | |
| 1158 | |
| 1159 if (vp.IsSetting()) | |
| 1160 { | |
| 1161 if (!m_bCanSet) return FALSE; | |
| 1162 | |
| 1163 ; | |
| 1164 } | |
| 1165 else | |
| 1166 { | |
| 1167 ; | |
| 1168 } | |
| 1169 return TRUE; | |
| 1170 } | |
| 1171 | |
| 1172 void Field::SetDefaultStyle(CPDFSDK_Document* pDocument, const CFX_WideString& s
wFieldName, int nControlIndex) | |
| 1173 { | |
| 1174 //Not supported. | |
| 1175 } | |
| 1176 | |
| 1177 FX_BOOL Field::defaultValue(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | |
| 1178 { | |
| 1179 ASSERT(m_pDocument != NULL); | |
| 1180 | |
| 1181 if (vp.IsSetting()) | |
| 1182 { | |
| 1183 if (!m_bCanSet) return FALSE; | |
| 1184 | |
| 1185 CFX_WideString WideStr; | |
| 1186 vp >> WideStr; | |
| 1187 | |
| 1188 if (m_bDelay) | |
| 1189 { | |
| 1190 AddDelay_WideString(FP_DEFAULTVALUE, WideStr); | |
| 1191 } | |
| 1192 else | |
| 1193 { | |
| 1194 Field::SetDefaultValue(m_pDocument, m_FieldName, m_nFormControlIndex
, WideStr); | |
| 1195 } | |
| 1196 } | |
| 1197 else | |
| 1198 { | |
| 1199 CFX_PtrArray FieldArray; | |
| 1200 GetFormFields(m_FieldName,FieldArray); | |
| 1201 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1202 | |
| 1203 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1204 ASSERT(pFormField != NULL); | |
| 1205 | |
| 1206 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON || | |
| 1207 pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) | |
| 1208 return FALSE; | |
| 1209 | |
| 1210 vp << pFormField->GetDefaultValue(); | |
| 1211 } | |
| 1212 return TRUE; | |
| 1213 } | |
| 1214 | |
| 1215 void Field::SetDefaultValue(CPDFSDK_Document* pDocument, const CFX_WideString& s
wFieldName, int nControlIndex, | |
| 1216 const CFX_WideString& string) | |
| 1217 { | |
| 1218 //Not supported. | |
| 1219 } | |
| 1220 | |
| 1221 FX_BOOL Field::doNotScroll(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | |
| 1222 { | |
| 1223 ASSERT(m_pDocument != NULL); | |
| 1224 | |
| 1225 if (vp.IsSetting()) | |
| 1226 { | |
| 1227 if (!m_bCanSet) return FALSE; | |
| 1228 | |
| 1229 bool bVP; | |
| 1230 vp >> bVP; | |
| 1231 | |
| 1232 if (m_bDelay) | |
| 1233 { | |
| 1234 AddDelay_Bool(FP_DONOTSCROLL, bVP); | |
| 1235 } | |
| 1236 else | |
| 1237 { | |
| 1238 Field::SetDoNotScroll(m_pDocument, m_FieldName, m_nFormControlIndex,
bVP); | |
| 1239 } | |
| 1240 } | |
| 1241 else | |
| 1242 { | |
| 1243 CFX_PtrArray FieldArray; | |
| 1244 GetFormFields(m_FieldName,FieldArray); | |
| 1245 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1246 | |
| 1247 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1248 ASSERT(pFormField != NULL); | |
| 1249 | |
| 1250 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | |
| 1251 return FALSE; | |
| 1252 | |
| 1253 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL) | |
| 1254 vp << true; | |
| 1255 else | |
| 1256 vp << false; | |
| 1257 } | |
| 1258 | |
| 1259 return TRUE; | |
| 1260 } | |
| 1261 | |
| 1262 void Field::SetDoNotScroll(CPDFSDK_Document* pDocument, const CFX_WideString& sw
FieldName, int nControlIndex, bool b) | |
| 1263 { | |
| 1264 //Not supported. | |
| 1265 } | |
| 1266 | |
| 1267 FX_BOOL Field::doNotSpellCheck(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) | |
| 1268 { | |
| 1269 ASSERT(m_pDocument != NULL); | |
| 1270 | |
| 1271 if (vp.IsSetting()) | |
| 1272 { | |
| 1273 if (!m_bCanSet) return FALSE; | |
| 1274 | |
| 1275 bool bVP; | |
| 1276 vp >> bVP; | |
| 1277 } | |
| 1278 else | |
| 1279 { | |
| 1280 CFX_PtrArray FieldArray; | |
| 1281 GetFormFields(m_FieldName,FieldArray); | |
| 1282 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1283 | |
| 1284 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1285 ASSERT(pFormField != NULL); | |
| 1286 | |
| 1287 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD && | |
| 1288 pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) | |
| 1289 return FALSE; | |
| 1290 | |
| 1291 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK) | |
| 1292 vp << true; | |
| 1293 else | |
| 1294 vp << false; | |
| 1295 } | |
| 1296 | |
| 1297 return TRUE; | |
| 1298 } | |
| 1299 | |
| 1300 void Field::SetDelay(FX_BOOL bDelay) | |
| 1301 { | |
| 1302 m_bDelay = bDelay; | |
| 1303 | |
| 1304 if (!m_bDelay) | |
| 1305 { | |
| 1306 if (m_pJSDoc) | |
| 1307 m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex); | |
| 1308 } | |
| 1309 } | |
| 1310 | |
| 1311 FX_BOOL Field::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) | |
| 1312 { | |
| 1313 if (vp.IsSetting()) | |
| 1314 { | |
| 1315 if (!m_bCanSet) return FALSE; | |
| 1316 | |
| 1317 bool bVP; | |
| 1318 vp >> bVP; | |
| 1319 | |
| 1320 SetDelay(bVP); | |
| 1321 } | |
| 1322 else | |
| 1323 { | |
| 1324 vp << m_bDelay; | |
| 1325 } | |
| 1326 return TRUE; | |
| 1327 } | |
| 1328 | |
| 1329 FX_BOOL Field::display(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | |
| 1330 { | |
| 1331 ASSERT(m_pDocument != NULL); | |
| 1332 | |
| 1333 if (vp.IsSetting()) | |
| 1334 { | |
| 1335 if (!m_bCanSet) return FALSE; | |
| 1336 | |
| 1337 int nVP; | |
| 1338 vp >> nVP; | |
| 1339 | |
| 1340 if (m_bDelay) | |
| 1341 { | |
| 1342 AddDelay_Int(FP_DISPLAY, nVP); | |
| 1343 } | |
| 1344 else | |
| 1345 { | |
| 1346 Field::SetDisplay(m_pDocument, m_FieldName, m_nFormControlIndex, nVP
); | |
| 1347 } | |
| 1348 } | |
| 1349 else | |
| 1350 { | |
| 1351 CFX_PtrArray FieldArray; | |
| 1352 GetFormFields(m_FieldName,FieldArray); | |
| 1353 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1354 | |
| 1355 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1356 ASSERT(pFormField != NULL); | |
| 1357 | |
| 1358 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | |
| 1359 ASSERT(pInterForm != NULL); | |
| 1360 | |
| 1361 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFo
rmField)); | |
| 1362 if (!pWidget)return FALSE; | |
| 1363 | |
| 1364 FX_DWORD dwFlag = pWidget->GetFlags(); | |
| 1365 | |
| 1366 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) | |
| 1367 { | |
| 1368 vp << (int32_t)1; | |
| 1369 } | |
| 1370 else | |
| 1371 { | |
| 1372 if (ANNOTFLAG_PRINT & dwFlag) | |
| 1373 { | |
| 1374 if (ANNOTFLAG_NOVIEW & dwFlag) | |
| 1375 { | |
| 1376 vp << (int32_t)3; | |
| 1377 } | |
| 1378 else | |
| 1379 { | |
| 1380 vp << (int32_t)0; | |
| 1381 } | |
| 1382 } | |
| 1383 else | |
| 1384 { | |
| 1385 vp << (int32_t)2; | |
| 1386 } | |
| 1387 } | |
| 1388 } | |
| 1389 | |
| 1390 return TRUE; | |
| 1391 } | |
| 1392 | |
| 1393 void Field::SetDisplay(CPDFSDK_Document* pDocument, const CFX_WideString& swFiel
dName, int nControlIndex, int number) | |
| 1394 { | |
| 1395 ASSERT(pDocument != NULL); | |
| 1396 | |
| 1397 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(
); | |
| 1398 ASSERT(pInterForm != NULL); | |
| 1399 | |
| 1400 CFX_PtrArray FieldArray; | |
| 1401 GetFormFields(pDocument, swFieldName, FieldArray); | |
| 1402 | |
| 1403 for (int i=0,isz=FieldArray.GetSize(); i<isz; i++) | |
| 1404 { | |
| 1405 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
| 1406 ASSERT(pFormField != NULL); | |
| 1407 | |
| 1408 if (nControlIndex < 0) | |
| 1409 { | |
| 1410 FX_BOOL bSet = FALSE; | |
| 1411 for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++) | |
| 1412 { | |
| 1413 CPDF_FormControl* pFormControl = pFormField->GetControl(j); | |
| 1414 ASSERT(pFormControl != NULL); | |
| 1415 | |
| 1416 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl
)) | |
| 1417 { | |
| 1418 FX_DWORD dwFlag = pWidget->GetFlags(); | |
| 1419 switch (number) | |
| 1420 { | |
| 1421 case 0: | |
| 1422 dwFlag &= (~ANNOTFLAG_INVISIBLE); | |
| 1423 dwFlag &= (~ANNOTFLAG_HIDDEN); | |
| 1424 dwFlag &= (~ANNOTFLAG_NOVIEW); | |
| 1425 dwFlag |= ANNOTFLAG_PRINT; | |
| 1426 break; | |
| 1427 case 1: | |
| 1428 dwFlag &= (~ANNOTFLAG_INVISIBLE); | |
| 1429 dwFlag &= (~ANNOTFLAG_NOVIEW); | |
| 1430 dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); | |
| 1431 break; | |
| 1432 case 2: | |
| 1433 dwFlag &= (~ANNOTFLAG_INVISIBLE); | |
| 1434 dwFlag &= (~ANNOTFLAG_PRINT); | |
| 1435 dwFlag &= (~ANNOTFLAG_HIDDEN); | |
| 1436 dwFlag &= (~ANNOTFLAG_NOVIEW); | |
| 1437 break; | |
| 1438 case 3: | |
| 1439 dwFlag |= ANNOTFLAG_NOVIEW; | |
| 1440 dwFlag |= ANNOTFLAG_PRINT; | |
| 1441 dwFlag &= (~ANNOTFLAG_HIDDEN); | |
| 1442 break; | |
| 1443 } | |
| 1444 | |
| 1445 if (dwFlag != pWidget->GetFlags()) | |
| 1446 { | |
| 1447 pWidget->SetFlags(dwFlag); | |
| 1448 bSet = TRUE; | |
| 1449 } | |
| 1450 } | |
| 1451 } | |
| 1452 | |
| 1453 if (bSet) UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); | |
| 1454 } | |
| 1455 else | |
| 1456 { | |
| 1457 if(nControlIndex >= pFormField->CountControls()) return; | |
| 1458 if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControl
Index)) | |
| 1459 { | |
| 1460 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl
)) | |
| 1461 { | |
| 1462 | |
| 1463 FX_DWORD dwFlag = pWidget->GetFlags(); | |
| 1464 switch (number) | |
| 1465 { | |
| 1466 case 0: | |
| 1467 dwFlag &= (~ANNOTFLAG_INVISIBLE); | |
| 1468 dwFlag &= (~ANNOTFLAG_HIDDEN); | |
| 1469 dwFlag &= (~ANNOTFLAG_NOVIEW); | |
| 1470 dwFlag |= ANNOTFLAG_PRINT; | |
| 1471 break; | |
| 1472 case 1: | |
| 1473 dwFlag &= (~ANNOTFLAG_INVISIBLE); | |
| 1474 dwFlag &= (~ANNOTFLAG_NOVIEW); | |
| 1475 dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); | |
| 1476 break; | |
| 1477 case 2: | |
| 1478 dwFlag &= (~ANNOTFLAG_INVISIBLE); | |
| 1479 dwFlag &= (~ANNOTFLAG_PRINT); | |
| 1480 dwFlag &= (~ANNOTFLAG_HIDDEN); | |
| 1481 dwFlag &= (~ANNOTFLAG_NOVIEW); | |
| 1482 break; | |
| 1483 case 3: | |
| 1484 dwFlag |= ANNOTFLAG_NOVIEW; | |
| 1485 dwFlag |= ANNOTFLAG_PRINT; | |
| 1486 dwFlag &= (~ANNOTFLAG_HIDDEN); | |
| 1487 break; | |
| 1488 } | |
| 1489 if (dwFlag != pWidget->GetFlags()) | |
| 1490 { | |
| 1491 pWidget->SetFlags(dwFlag); | |
| 1492 UpdateFormControl(pDocument, pFormControl, TRUE, FALSE,
TRUE); | |
| 1493 } | |
| 1494 } | |
| 1495 } | |
| 1496 } | |
| 1497 } | |
| 1498 } | |
| 1499 | |
| 1500 FX_BOOL Field::doc(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) | |
| 1501 { | |
| 1502 if (!vp.IsGetting()) { | |
| 1503 return FALSE; | |
| 1504 } | |
| 1505 vp << m_pJSDoc->GetCJSDoc(); | |
| 1506 return TRUE; | |
| 1507 } | |
| 1508 | |
| 1509 FX_BOOL Field::editable(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | |
| 1510 { | |
| 1511 ASSERT(m_pDocument != NULL); | |
| 1512 if (vp.IsSetting()) | |
| 1513 { | |
| 1514 if (!m_bCanSet) return FALSE; | |
| 1515 | |
| 1516 bool bVP; | |
| 1517 vp >> bVP; | |
| 1518 } | |
| 1519 else | |
| 1520 { | |
| 1521 CFX_PtrArray FieldArray; | |
| 1522 GetFormFields(m_FieldName, FieldArray); | |
| 1523 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1524 | |
| 1525 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1526 ASSERT(pFormField != NULL); | |
| 1527 | |
| 1528 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) | |
| 1529 return FALSE; | |
| 1530 | |
| 1531 if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT) | |
| 1532 vp << true; | |
| 1533 else | |
| 1534 vp << false; | |
| 1535 } | |
| 1536 | |
| 1537 return TRUE; | |
| 1538 } | |
| 1539 | |
| 1540 FX_BOOL Field::exportValues(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | |
| 1541 { | |
| 1542 ASSERT(m_pDocument != NULL); | |
| 1543 | |
| 1544 CFX_PtrArray FieldArray; | |
| 1545 GetFormFields(m_FieldName,FieldArray); | |
| 1546 if (FieldArray.GetSize() <= 0) | |
| 1547 return FALSE; | |
| 1548 | |
| 1549 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1550 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && | |
| 1551 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) | |
| 1552 return FALSE; | |
| 1553 | |
| 1554 if (vp.IsSetting()) | |
| 1555 { | |
| 1556 if (!m_bCanSet) | |
| 1557 return FALSE; | |
| 1558 | |
| 1559 if (!vp.IsArrayObject()) | |
| 1560 return FALSE; | |
| 1561 } | |
| 1562 else | |
| 1563 { | |
| 1564 CJS_Array ExportValusArray(m_isolate); | |
| 1565 if (m_nFormControlIndex < 0) | |
| 1566 { | |
| 1567 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) | |
| 1568 { | |
| 1569 CPDF_FormControl* pFormControl = pFormField->GetControl(i); | |
| 1570 ExportValusArray.SetElement(i, CJS_Value(m_isolate,pFormControl-
>GetExportValue().c_str())); | |
| 1571 } | |
| 1572 } | |
| 1573 else | |
| 1574 { | |
| 1575 if (m_nFormControlIndex >= pFormField->CountControls()) | |
| 1576 return FALSE; | |
| 1577 | |
| 1578 CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormContr
olIndex); | |
| 1579 if (!pFormControl) | |
| 1580 return FALSE; | |
| 1581 | |
| 1582 ExportValusArray.SetElement(0, CJS_Value(m_isolate,pFormControl->Get
ExportValue().c_str())); | |
| 1583 } | |
| 1584 vp << ExportValusArray; | |
| 1585 } | |
| 1586 return TRUE; | |
| 1587 } | |
| 1588 | |
| 1589 FX_BOOL Field::fileSelect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | |
| 1590 { | |
| 1591 ASSERT(m_pDocument != NULL); | |
| 1592 | |
| 1593 CFX_PtrArray FieldArray; | 379 CFX_PtrArray FieldArray; |
| 1594 GetFormFields(m_FieldName, FieldArray); | 380 GetFormFields(m_FieldName, FieldArray); |
| 1595 if (FieldArray.GetSize() <= 0) | 381 if (FieldArray.GetSize() <= 0) |
| 1596 return FALSE; | 382 return FALSE; |
| 1597 | 383 |
| 1598 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 384 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 385 ASSERT(pFormField != NULL); |
| 386 |
| 1599 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 387 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
| 1600 return FALSE; | 388 return FALSE; |
| 1601 | 389 |
| 1602 if (vp.IsSetting()) | 390 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 1603 { | 391 if (!pFormControl) |
| 1604 if (!m_bCanSet) | 392 return FALSE; |
| 1605 return FALSE; | 393 |
| 1606 | 394 switch (pFormControl->GetControlAlignment()) { |
| 1607 bool bVP; | 395 case 1: |
| 1608 vp >> bVP; | 396 vp << L"center"; |
| 1609 } | 397 break; |
| 1610 else | 398 case 0: |
| 1611 { | 399 vp << L"left"; |
| 1612 if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) | 400 break; |
| 1613 vp << true; | 401 case 2: |
| 1614 else | 402 vp << L"right"; |
| 1615 vp << false; | 403 break; |
| 1616 } | 404 default: |
| 1617 return TRUE; | 405 vp << L""; |
| 1618 } | 406 } |
| 1619 | 407 } |
| 1620 FX_BOOL Field::fillColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 408 |
| 1621 { | 409 return TRUE; |
| 1622 ASSERT(m_pDocument != NULL); | 410 } |
| 1623 | 411 |
| 1624 CJS_Array crArray(m_isolate); | 412 void Field::SetAlignment(CPDFSDK_Document* pDocument, |
| 1625 | 413 const CFX_WideString& swFieldName, |
| 414 int nControlIndex, |
| 415 const CFX_ByteString& string) { |
| 416 // Not supported. |
| 417 } |
| 418 |
| 419 FX_BOOL Field::borderStyle(IFXJS_Context* cc, |
| 420 CJS_PropValue& vp, |
| 421 CFX_WideString& sError) { |
| 422 ASSERT(m_pDocument != NULL); |
| 423 |
| 424 if (vp.IsSetting()) { |
| 425 if (!m_bCanSet) |
| 426 return FALSE; |
| 427 |
| 428 CFX_ByteString strType = ""; |
| 429 vp >> strType; |
| 430 |
| 431 if (m_bDelay) { |
| 432 AddDelay_String(FP_BORDERSTYLE, strType); |
| 433 } else { |
| 434 Field::SetBorderStyle(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 435 strType); |
| 436 } |
| 437 } else { |
| 1626 CFX_PtrArray FieldArray; | 438 CFX_PtrArray FieldArray; |
| 1627 GetFormFields(m_FieldName, FieldArray); | 439 GetFormFields(m_FieldName, FieldArray); |
| 1628 if (FieldArray.GetSize() <= 0) | 440 if (FieldArray.GetSize() <= 0) |
| 1629 return FALSE; | 441 return FALSE; |
| 1630 | 442 |
| 1631 if (vp.IsSetting()) | 443 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1632 { | 444 if (!pFormField) |
| 1633 if (!m_bCanSet) | 445 return FALSE; |
| 1634 return FALSE; | 446 |
| 1635 | 447 CPDFSDK_Widget* pWidget = |
| 1636 if (!vp.IsArrayObject()) | 448 GetWidget(m_pDocument, GetSmartFieldControl(pFormField)); |
| 1637 return FALSE; | 449 if (!pWidget) |
| 1638 | 450 return FALSE; |
| 1639 vp >> crArray; | 451 |
| 1640 | 452 int nBorderstyle = pWidget->GetBorderStyle(); |
| 1641 CPWL_Color color; | 453 |
| 1642 color::ConvertArrayToPWLColor(crArray, color); | 454 switch (nBorderstyle) { |
| 1643 if (m_bDelay) | 455 case BBS_SOLID: |
| 1644 { | 456 vp << L"solid"; |
| 1645 AddDelay_Color(FP_FILLCOLOR, color); | 457 break; |
| 458 case BBS_DASH: |
| 459 vp << L"dashed"; |
| 460 break; |
| 461 case BBS_BEVELED: |
| 462 vp << L"beveled"; |
| 463 break; |
| 464 case BBS_INSET: |
| 465 vp << L"inset"; |
| 466 break; |
| 467 case BBS_UNDERLINE: |
| 468 vp << L"underline"; |
| 469 break; |
| 470 default: |
| 471 vp << L""; |
| 472 break; |
| 473 } |
| 474 } |
| 475 |
| 476 return TRUE; |
| 477 } |
| 478 |
| 479 void Field::SetBorderStyle(CPDFSDK_Document* pDocument, |
| 480 const CFX_WideString& swFieldName, |
| 481 int nControlIndex, |
| 482 const CFX_ByteString& string) { |
| 483 ASSERT(pDocument != NULL); |
| 484 |
| 485 int nBorderStyle = 0; |
| 486 |
| 487 if (string == "solid") |
| 488 nBorderStyle = BBS_SOLID; |
| 489 else if (string == "beveled") |
| 490 nBorderStyle = BBS_BEVELED; |
| 491 else if (string == "dashed") |
| 492 nBorderStyle = BBS_DASH; |
| 493 else if (string == "inset") |
| 494 nBorderStyle = BBS_INSET; |
| 495 else if (string == "underline") |
| 496 nBorderStyle = BBS_UNDERLINE; |
| 497 else |
| 498 return; |
| 499 |
| 500 CFX_PtrArray FieldArray; |
| 501 GetFormFields(pDocument, swFieldName, FieldArray); |
| 502 |
| 503 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { |
| 504 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); |
| 505 ASSERT(pFormField != NULL); |
| 506 |
| 507 if (nControlIndex < 0) { |
| 508 FX_BOOL bSet = FALSE; |
| 509 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { |
| 510 if (CPDFSDK_Widget* pWidget = |
| 511 GetWidget(pDocument, pFormField->GetControl(j))) { |
| 512 if (pWidget->GetBorderStyle() != nBorderStyle) { |
| 513 pWidget->SetBorderStyle(nBorderStyle); |
| 514 bSet = TRUE; |
| 515 } |
| 1646 } | 516 } |
| 1647 else | 517 } |
| 1648 { | 518 if (bSet) |
| 1649 Field::SetFillColor(m_pDocument, m_FieldName, m_nFormControlIndex, c
olor); | 519 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); |
| 520 } else { |
| 521 if (nControlIndex >= pFormField->CountControls()) |
| 522 return; |
| 523 if (CPDF_FormControl* pFormControl = |
| 524 pFormField->GetControl(nControlIndex)) { |
| 525 if (CPDFSDK_Widget* pWidget = GetWidget(pDocument, pFormControl)) { |
| 526 if (pWidget->GetBorderStyle() != nBorderStyle) { |
| 527 pWidget->SetBorderStyle(nBorderStyle); |
| 528 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); |
| 529 } |
| 1650 } | 530 } |
| 1651 } | 531 } |
| 1652 else | 532 } |
| 1653 { | 533 } |
| 1654 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 534 } |
| 1655 ASSERT(pFormField != NULL); | 535 |
| 1656 | 536 FX_BOOL Field::buttonAlignX(IFXJS_Context* cc, |
| 1657 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 537 CJS_PropValue& vp, |
| 1658 if (!pFormControl) | 538 CFX_WideString& sError) { |
| 1659 return FALSE; | 539 ASSERT(m_pDocument != NULL); |
| 1660 | 540 |
| 1661 int iColorType; | 541 if (vp.IsSetting()) { |
| 1662 pFormControl->GetBackgroundColor(iColorType); | 542 if (!m_bCanSet) |
| 1663 | 543 return FALSE; |
| 1664 CPWL_Color color; | 544 |
| 1665 if (iColorType == COLORTYPE_TRANSPARENT) | 545 int nVP; |
| 1666 { | 546 vp >> nVP; |
| 1667 color = CPWL_Color(COLORTYPE_TRANSPARENT); | 547 |
| 1668 } | 548 if (m_bDelay) { |
| 1669 else if (iColorType == COLORTYPE_GRAY) | 549 AddDelay_Int(FP_BUTTONALIGNX, nVP); |
| 1670 { | 550 } else { |
| 1671 color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBackgrou
ndColor(0)); | 551 Field::SetButtonAlignX(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 1672 } | 552 nVP); |
| 1673 else if (iColorType == COLORTYPE_RGB) | 553 } |
| 1674 { | 554 } else { |
| 1675 color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroun
dColor(0), | |
| 1676 pFormControl->GetOriginalBackgroundColor(1), | |
| 1677 pFormControl->GetOriginalBackgroundColor(2)); | |
| 1678 } | |
| 1679 else if (iColorType == COLORTYPE_CMYK) | |
| 1680 { | |
| 1681 color = CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBackgrou
ndColor(0), | |
| 1682 pFormControl->GetOriginalBackgroundColor(1), | |
| 1683 pFormControl->GetOriginalBackgroundColor(2), | |
| 1684 pFormControl->GetOriginalBackgroundColor(3)); | |
| 1685 } | |
| 1686 else | |
| 1687 return FALSE; | |
| 1688 | |
| 1689 color::ConvertPWLColorToArray(color, crArray); | |
| 1690 vp << crArray; | |
| 1691 } | |
| 1692 | |
| 1693 return TRUE; | |
| 1694 } | |
| 1695 | |
| 1696 void Field::SetFillColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFi
eldName, int nControlIndex, const CPWL_Color& color) | |
| 1697 { | |
| 1698 //Not supported. | |
| 1699 } | |
| 1700 | |
| 1701 FX_BOOL Field::hidden(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) | |
| 1702 { | |
| 1703 ASSERT(m_pDocument != NULL); | |
| 1704 | |
| 1705 if (vp.IsSetting()) | |
| 1706 { | |
| 1707 if (!m_bCanSet) return FALSE; | |
| 1708 | |
| 1709 bool bVP; | |
| 1710 vp >> bVP; | |
| 1711 | |
| 1712 if (m_bDelay) | |
| 1713 { | |
| 1714 AddDelay_Bool(FP_HIDDEN, bVP); | |
| 1715 } | |
| 1716 else | |
| 1717 { | |
| 1718 Field::SetHidden(m_pDocument, m_FieldName, m_nFormControlIndex, bVP)
; | |
| 1719 } | |
| 1720 } | |
| 1721 else | |
| 1722 { | |
| 1723 CFX_PtrArray FieldArray; | |
| 1724 GetFormFields(m_FieldName,FieldArray); | |
| 1725 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1726 | |
| 1727 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1728 ASSERT(pFormField != NULL); | |
| 1729 | |
| 1730 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | |
| 1731 ASSERT(pInterForm != NULL); | |
| 1732 | |
| 1733 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFo
rmField)); | |
| 1734 if (!pWidget) return FALSE; | |
| 1735 | |
| 1736 FX_DWORD dwFlags = pWidget->GetFlags(); | |
| 1737 | |
| 1738 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) | |
| 1739 { | |
| 1740 vp << true; | |
| 1741 } | |
| 1742 else | |
| 1743 vp << false; | |
| 1744 } | |
| 1745 | |
| 1746 return TRUE; | |
| 1747 } | |
| 1748 | |
| 1749 void Field::SetHidden(CPDFSDK_Document* pDocument, const CFX_WideString& swField
Name, int nControlIndex, bool b) | |
| 1750 { | |
| 1751 ASSERT(pDocument != NULL); | |
| 1752 | |
| 1753 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(
); | |
| 1754 ASSERT(pInterForm != NULL); | |
| 1755 | |
| 1756 CFX_PtrArray FieldArray; | |
| 1757 GetFormFields(pDocument, swFieldName, FieldArray); | |
| 1758 | |
| 1759 for (int i=0,isz=FieldArray.GetSize(); i<isz; i++) | |
| 1760 { | |
| 1761 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
| 1762 ASSERT(pFormField != NULL); | |
| 1763 | |
| 1764 if (nControlIndex < 0) | |
| 1765 { | |
| 1766 FX_BOOL bSet = FALSE; | |
| 1767 for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++) | |
| 1768 { | |
| 1769 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->
GetControl(j))) | |
| 1770 { | |
| 1771 FX_DWORD dwFlags = pWidget->GetFlags(); | |
| 1772 | |
| 1773 if (b) | |
| 1774 { | |
| 1775 dwFlags &= (~ANNOTFLAG_INVISIBLE); | |
| 1776 dwFlags &= (~ANNOTFLAG_NOVIEW); | |
| 1777 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); | |
| 1778 } | |
| 1779 else | |
| 1780 { | |
| 1781 dwFlags &= (~ANNOTFLAG_INVISIBLE); | |
| 1782 dwFlags &= (~ANNOTFLAG_HIDDEN); | |
| 1783 dwFlags &= (~ANNOTFLAG_NOVIEW); | |
| 1784 dwFlags |= ANNOTFLAG_PRINT; | |
| 1785 } | |
| 1786 | |
| 1787 if (dwFlags != pWidget->GetFlags()) | |
| 1788 { | |
| 1789 pWidget->SetFlags(dwFlags); | |
| 1790 bSet = TRUE; | |
| 1791 } | |
| 1792 } | |
| 1793 } | |
| 1794 | |
| 1795 if (bSet) | |
| 1796 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); | |
| 1797 } | |
| 1798 else | |
| 1799 { | |
| 1800 if(nControlIndex >= pFormField->CountControls()) return; | |
| 1801 if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControl
Index)) | |
| 1802 { | |
| 1803 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl
)) | |
| 1804 { | |
| 1805 FX_DWORD dwFlags = pWidget->GetFlags(); | |
| 1806 | |
| 1807 if (b) | |
| 1808 { | |
| 1809 dwFlags &= (~ANNOTFLAG_INVISIBLE); | |
| 1810 dwFlags &= (~ANNOTFLAG_NOVIEW); | |
| 1811 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); | |
| 1812 } | |
| 1813 else | |
| 1814 { | |
| 1815 dwFlags &= (~ANNOTFLAG_INVISIBLE); | |
| 1816 dwFlags &= (~ANNOTFLAG_HIDDEN); | |
| 1817 dwFlags &= (~ANNOTFLAG_NOVIEW); | |
| 1818 dwFlags |= ANNOTFLAG_PRINT; | |
| 1819 } | |
| 1820 | |
| 1821 if (dwFlags != pWidget->GetFlags()) | |
| 1822 { | |
| 1823 pWidget->SetFlags(dwFlags); | |
| 1824 UpdateFormControl(pDocument, pFormControl, TRUE, FALSE,
TRUE); | |
| 1825 } | |
| 1826 } | |
| 1827 } | |
| 1828 } | |
| 1829 } | |
| 1830 } | |
| 1831 | |
| 1832 FX_BOOL Field::highlight(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | |
| 1833 { | |
| 1834 ASSERT(m_pDocument != NULL); | |
| 1835 | |
| 1836 if (vp.IsSetting()) | |
| 1837 { | |
| 1838 if (!m_bCanSet) return FALSE; | |
| 1839 | |
| 1840 CFX_ByteString strMode; | |
| 1841 vp >> strMode; | |
| 1842 | |
| 1843 if (m_bDelay) | |
| 1844 { | |
| 1845 AddDelay_String(FP_HIGHLIGHT, strMode); | |
| 1846 } | |
| 1847 else | |
| 1848 { | |
| 1849 Field::SetHighlight(m_pDocument, m_FieldName, m_nFormControlIndex, s
trMode); | |
| 1850 } | |
| 1851 } | |
| 1852 else | |
| 1853 { | |
| 1854 CFX_PtrArray FieldArray; | |
| 1855 GetFormFields(m_FieldName,FieldArray); | |
| 1856 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1857 | |
| 1858 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1859 ASSERT(pFormField != NULL); | |
| 1860 | |
| 1861 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | |
| 1862 return FALSE; | |
| 1863 | |
| 1864 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 1865 if (!pFormControl) return FALSE; | |
| 1866 | |
| 1867 int eHM = pFormControl->GetHighlightingMode(); | |
| 1868 switch (eHM) | |
| 1869 { | |
| 1870 case CPDF_FormControl::None: | |
| 1871 vp << L"none"; | |
| 1872 break; | |
| 1873 case CPDF_FormControl::Push: | |
| 1874 vp << L"push"; | |
| 1875 break; | |
| 1876 case CPDF_FormControl::Invert: | |
| 1877 vp << L"invert"; | |
| 1878 break; | |
| 1879 case CPDF_FormControl::Outline: | |
| 1880 vp << L"outline"; | |
| 1881 break; | |
| 1882 case CPDF_FormControl::Toggle: | |
| 1883 vp << L"toggle"; | |
| 1884 break; | |
| 1885 } | |
| 1886 } | |
| 1887 | |
| 1888 return TRUE; | |
| 1889 } | |
| 1890 | |
| 1891 void Field::SetHighlight(CPDFSDK_Document* pDocument, const CFX_WideString& swFi
eldName, int nControlIndex, const CFX_ByteString& string) | |
| 1892 { | |
| 1893 //Not supported. | |
| 1894 } | |
| 1895 | |
| 1896 FX_BOOL Field::lineWidth(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | |
| 1897 { | |
| 1898 ASSERT(m_pDocument != NULL); | |
| 1899 | |
| 1900 if (vp.IsSetting()) | |
| 1901 { | |
| 1902 if (!m_bCanSet) return FALSE; | |
| 1903 | |
| 1904 int iWidth; | |
| 1905 vp >> iWidth; | |
| 1906 | |
| 1907 if (m_bDelay) | |
| 1908 { | |
| 1909 AddDelay_Int(FP_LINEWIDTH, iWidth); | |
| 1910 } | |
| 1911 else | |
| 1912 { | |
| 1913 Field::SetLineWidth(m_pDocument, m_FieldName, m_nFormControlIndex, i
Width); | |
| 1914 } | |
| 1915 } | |
| 1916 else | |
| 1917 { | |
| 1918 CFX_PtrArray FieldArray; | |
| 1919 GetFormFields(m_FieldName,FieldArray); | |
| 1920 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 1921 | |
| 1922 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 1923 ASSERT(pFormField != NULL); | |
| 1924 | |
| 1925 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 1926 if (!pFormControl) return FALSE; | |
| 1927 | |
| 1928 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | |
| 1929 ASSERT(pInterForm != NULL); | |
| 1930 | |
| 1931 if(!pFormField->CountControls()) return FALSE; | |
| 1932 | |
| 1933 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0
)); | |
| 1934 if (!pWidget) return FALSE; | |
| 1935 | |
| 1936 vp << (int32_t)pWidget->GetBorderWidth(); | |
| 1937 } | |
| 1938 | |
| 1939 return TRUE; | |
| 1940 } | |
| 1941 | |
| 1942 void Field::SetLineWidth(CPDFSDK_Document* pDocument, const CFX_WideString& swFi
eldName, int nControlIndex, int number) | |
| 1943 { | |
| 1944 ASSERT(pDocument != NULL); | |
| 1945 | |
| 1946 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(
); | |
| 1947 ASSERT(pInterForm != NULL); | |
| 1948 | |
| 1949 CFX_PtrArray FieldArray; | |
| 1950 GetFormFields(pDocument, swFieldName, FieldArray); | |
| 1951 | |
| 1952 for (int i=0,isz=FieldArray.GetSize(); i<isz; i++) | |
| 1953 { | |
| 1954 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
| 1955 ASSERT(pFormField != NULL); | |
| 1956 | |
| 1957 if (nControlIndex < 0) | |
| 1958 { | |
| 1959 FX_BOOL bSet = FALSE; | |
| 1960 for (int j=0,jsz=pFormField->CountControls(); j<jsz; j++) | |
| 1961 { | |
| 1962 CPDF_FormControl* pFormControl = pFormField->GetControl(j); | |
| 1963 ASSERT(pFormControl != NULL); | |
| 1964 | |
| 1965 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl
)) | |
| 1966 { | |
| 1967 if (number != pWidget->GetBorderWidth()) | |
| 1968 { | |
| 1969 pWidget->SetBorderWidth(number); | |
| 1970 bSet = TRUE; | |
| 1971 } | |
| 1972 } | |
| 1973 } | |
| 1974 if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); | |
| 1975 } | |
| 1976 else | |
| 1977 { | |
| 1978 if(nControlIndex >= pFormField->CountControls()) return; | |
| 1979 if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControl
Index)) | |
| 1980 { | |
| 1981 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl
)) | |
| 1982 { | |
| 1983 if (number != pWidget->GetBorderWidth()) | |
| 1984 { | |
| 1985 pWidget->SetBorderWidth(number); | |
| 1986 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, T
RUE); | |
| 1987 } | |
| 1988 } | |
| 1989 } | |
| 1990 } | |
| 1991 } | |
| 1992 } | |
| 1993 | |
| 1994 FX_BOOL Field::multiline(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | |
| 1995 { | |
| 1996 ASSERT(m_pDocument != NULL); | |
| 1997 | |
| 1998 if (vp.IsSetting()) | |
| 1999 { | |
| 2000 if (!m_bCanSet) return FALSE; | |
| 2001 | |
| 2002 bool bVP; | |
| 2003 vp >> bVP; | |
| 2004 | |
| 2005 if (m_bDelay) | |
| 2006 { | |
| 2007 AddDelay_Bool(FP_MULTILINE, bVP); | |
| 2008 } | |
| 2009 else | |
| 2010 { | |
| 2011 Field::SetMultiline(m_pDocument, m_FieldName, m_nFormControlIndex, b
VP); | |
| 2012 } | |
| 2013 } | |
| 2014 else | |
| 2015 { | |
| 2016 CFX_PtrArray FieldArray; | |
| 2017 GetFormFields(m_FieldName, FieldArray); | |
| 2018 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2019 | |
| 2020 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2021 ASSERT(pFormField != NULL); | |
| 2022 | |
| 2023 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | |
| 2024 return FALSE; | |
| 2025 | |
| 2026 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE) | |
| 2027 vp << true; | |
| 2028 else | |
| 2029 vp << false; | |
| 2030 } | |
| 2031 | |
| 2032 return TRUE; | |
| 2033 } | |
| 2034 | |
| 2035 void Field::SetMultiline(CPDFSDK_Document* pDocument, const CFX_WideString& swFi
eldName, int nControlIndex, bool b) | |
| 2036 { | |
| 2037 //Not supported. | |
| 2038 } | |
| 2039 | |
| 2040 FX_BOOL Field::multipleSelection(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideS
tring& sError) | |
| 2041 { | |
| 2042 ASSERT(m_pDocument != NULL); | |
| 2043 | |
| 2044 if (vp.IsSetting()) | |
| 2045 { | |
| 2046 if (!m_bCanSet) return FALSE; | |
| 2047 | |
| 2048 bool bVP; | |
| 2049 vp >> bVP; | |
| 2050 | |
| 2051 if (m_bDelay) | |
| 2052 { | |
| 2053 AddDelay_Bool(FP_MULTIPLESELECTION, bVP); | |
| 2054 } | |
| 2055 else | |
| 2056 { | |
| 2057 Field::SetMultipleSelection(m_pDocument, m_FieldName, m_nFormControl
Index, bVP); | |
| 2058 } | |
| 2059 } | |
| 2060 else | |
| 2061 { | |
| 2062 CFX_PtrArray FieldArray; | |
| 2063 GetFormFields(m_FieldName,FieldArray); | |
| 2064 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2065 | |
| 2066 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2067 ASSERT(pFormField != NULL); | |
| 2068 | |
| 2069 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) | |
| 2070 return FALSE; | |
| 2071 | |
| 2072 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT) | |
| 2073 vp << true; | |
| 2074 else | |
| 2075 vp << false; | |
| 2076 } | |
| 2077 | |
| 2078 return TRUE; | |
| 2079 } | |
| 2080 | |
| 2081 void Field::SetMultipleSelection(CPDFSDK_Document* pDocument, const CFX_WideStri
ng& swFieldName, int nControlIndex, bool b) | |
| 2082 { | |
| 2083 //Not supported. | |
| 2084 } | |
| 2085 | |
| 2086 FX_BOOL Field::name(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) | |
| 2087 { | |
| 2088 if (!vp.IsGetting()) return FALSE; | |
| 2089 | |
| 2090 CFX_PtrArray FieldArray; | 555 CFX_PtrArray FieldArray; |
| 2091 GetFormFields(m_FieldName, FieldArray); | 556 GetFormFields(m_FieldName, FieldArray); |
| 2092 if (FieldArray.GetSize() <= 0) return FALSE; | 557 if (FieldArray.GetSize() <= 0) |
| 2093 | 558 return FALSE; |
| 2094 vp << m_FieldName; | 559 |
| 2095 | 560 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2096 return TRUE; | 561 ASSERT(pFormField != NULL); |
| 2097 } | 562 |
| 2098 | 563 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 2099 FX_BOOL Field::numItems(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 564 return FALSE; |
| 2100 { | 565 |
| 566 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 567 if (!pFormControl) |
| 568 return FALSE; |
| 569 |
| 570 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
| 571 |
| 572 FX_FLOAT fLeft, fBottom; |
| 573 IconFit.GetIconPosition(fLeft, fBottom); |
| 574 |
| 575 vp << (int32_t)fLeft; |
| 576 } |
| 577 |
| 578 return TRUE; |
| 579 } |
| 580 |
| 581 void Field::SetButtonAlignX(CPDFSDK_Document* pDocument, |
| 582 const CFX_WideString& swFieldName, |
| 583 int nControlIndex, |
| 584 int number) { |
| 585 // Not supported. |
| 586 } |
| 587 |
| 588 FX_BOOL Field::buttonAlignY(IFXJS_Context* cc, |
| 589 CJS_PropValue& vp, |
| 590 CFX_WideString& sError) { |
| 591 ASSERT(m_pDocument != NULL); |
| 592 |
| 593 if (vp.IsSetting()) { |
| 594 if (!m_bCanSet) |
| 595 return FALSE; |
| 596 |
| 597 int nVP; |
| 598 vp >> nVP; |
| 599 |
| 600 if (m_bDelay) { |
| 601 AddDelay_Int(FP_BUTTONALIGNY, nVP); |
| 602 } else { |
| 603 Field::SetButtonAlignY(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 604 nVP); |
| 605 } |
| 606 } else { |
| 2101 CFX_PtrArray FieldArray; | 607 CFX_PtrArray FieldArray; |
| 2102 GetFormFields(m_FieldName, FieldArray); | 608 GetFormFields(m_FieldName, FieldArray); |
| 2103 if (FieldArray.GetSize() <= 0) return FALSE; | 609 if (FieldArray.GetSize() <= 0) |
| 610 return FALSE; |
| 611 |
| 612 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 613 ASSERT(pFormField != NULL); |
| 614 |
| 615 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 616 return FALSE; |
| 617 |
| 618 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 619 if (!pFormControl) |
| 620 return FALSE; |
| 621 |
| 622 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
| 623 |
| 624 FX_FLOAT fLeft, fBottom; |
| 625 IconFit.GetIconPosition(fLeft, fBottom); |
| 626 |
| 627 vp << (int32_t)fBottom; |
| 628 } |
| 629 |
| 630 return TRUE; |
| 631 } |
| 632 |
| 633 void Field::SetButtonAlignY(CPDFSDK_Document* pDocument, |
| 634 const CFX_WideString& swFieldName, |
| 635 int nControlIndex, |
| 636 int number) { |
| 637 // Not supported. |
| 638 } |
| 639 |
| 640 FX_BOOL Field::buttonFitBounds(IFXJS_Context* cc, |
| 641 CJS_PropValue& vp, |
| 642 CFX_WideString& sError) { |
| 643 ASSERT(m_pDocument != NULL); |
| 644 |
| 645 if (vp.IsSetting()) { |
| 646 if (!m_bCanSet) |
| 647 return FALSE; |
| 648 |
| 649 bool bVP; |
| 650 vp >> bVP; |
| 651 |
| 652 if (m_bDelay) { |
| 653 AddDelay_Bool(FP_BUTTONFITBOUNDS, bVP); |
| 654 } else { |
| 655 Field::SetButtonFitBounds(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 656 bVP); |
| 657 } |
| 658 } else { |
| 659 CFX_PtrArray FieldArray; |
| 660 GetFormFields(m_FieldName, FieldArray); |
| 661 if (FieldArray.GetSize() <= 0) |
| 662 return FALSE; |
| 663 |
| 664 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 665 ASSERT(pFormField != NULL); |
| 666 |
| 667 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 668 return FALSE; |
| 669 |
| 670 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 671 if (!pFormControl) |
| 672 return FALSE; |
| 673 |
| 674 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
| 675 vp << IconFit.GetFittingBounds(); |
| 676 } |
| 677 |
| 678 return TRUE; |
| 679 } |
| 680 |
| 681 void Field::SetButtonFitBounds(CPDFSDK_Document* pDocument, |
| 682 const CFX_WideString& swFieldName, |
| 683 int nControlIndex, |
| 684 bool b) { |
| 685 // Not supported. |
| 686 } |
| 687 |
| 688 FX_BOOL Field::buttonPosition(IFXJS_Context* cc, |
| 689 CJS_PropValue& vp, |
| 690 CFX_WideString& sError) { |
| 691 ASSERT(m_pDocument != NULL); |
| 692 |
| 693 if (vp.IsSetting()) { |
| 694 if (!m_bCanSet) |
| 695 return FALSE; |
| 696 |
| 697 int nVP; |
| 698 vp >> nVP; |
| 699 |
| 700 if (m_bDelay) { |
| 701 AddDelay_Int(FP_BUTTONPOSITION, nVP); |
| 702 } else { |
| 703 Field::SetButtonPosition(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 704 nVP); |
| 705 } |
| 706 } else { |
| 707 CFX_PtrArray FieldArray; |
| 708 GetFormFields(m_FieldName, FieldArray); |
| 709 if (FieldArray.GetSize() <= 0) |
| 710 return FALSE; |
| 711 |
| 712 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 713 ASSERT(pFormField != NULL); |
| 714 |
| 715 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 716 return FALSE; |
| 717 |
| 718 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 719 if (!pFormControl) |
| 720 return FALSE; |
| 721 |
| 722 vp << pFormControl->GetTextPosition(); |
| 723 } |
| 724 return TRUE; |
| 725 } |
| 726 |
| 727 void Field::SetButtonPosition(CPDFSDK_Document* pDocument, |
| 728 const CFX_WideString& swFieldName, |
| 729 int nControlIndex, |
| 730 int number) { |
| 731 // Not supported. |
| 732 } |
| 733 |
| 734 FX_BOOL Field::buttonScaleHow(IFXJS_Context* cc, |
| 735 CJS_PropValue& vp, |
| 736 CFX_WideString& sError) { |
| 737 ASSERT(m_pDocument != NULL); |
| 738 |
| 739 if (vp.IsSetting()) { |
| 740 if (!m_bCanSet) |
| 741 return FALSE; |
| 742 |
| 743 int nVP; |
| 744 vp >> nVP; |
| 745 |
| 746 if (m_bDelay) { |
| 747 AddDelay_Int(FP_BUTTONSCALEHOW, nVP); |
| 748 } else { |
| 749 Field::SetButtonScaleHow(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 750 nVP); |
| 751 } |
| 752 } else { |
| 753 CFX_PtrArray FieldArray; |
| 754 GetFormFields(m_FieldName, FieldArray); |
| 755 if (FieldArray.GetSize() <= 0) |
| 756 return FALSE; |
| 757 |
| 758 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 759 ASSERT(pFormField != NULL); |
| 760 |
| 761 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 762 return FALSE; |
| 763 |
| 764 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 765 if (!pFormControl) |
| 766 return FALSE; |
| 767 |
| 768 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
| 769 if (IconFit.IsProportionalScale()) |
| 770 vp << (int32_t)0; |
| 771 else |
| 772 vp << (int32_t)1; |
| 773 } |
| 774 |
| 775 return TRUE; |
| 776 } |
| 777 |
| 778 void Field::SetButtonScaleHow(CPDFSDK_Document* pDocument, |
| 779 const CFX_WideString& swFieldName, |
| 780 int nControlIndex, |
| 781 int number) { |
| 782 // Not supported. |
| 783 } |
| 784 |
| 785 FX_BOOL Field::buttonScaleWhen(IFXJS_Context* cc, |
| 786 CJS_PropValue& vp, |
| 787 CFX_WideString& sError) { |
| 788 ASSERT(m_pDocument != NULL); |
| 789 |
| 790 if (vp.IsSetting()) { |
| 791 if (!m_bCanSet) |
| 792 return FALSE; |
| 793 |
| 794 int nVP; |
| 795 vp >> nVP; |
| 796 |
| 797 if (m_bDelay) { |
| 798 AddDelay_Int(FP_BUTTONSCALEWHEN, nVP); |
| 799 } else { |
| 800 Field::SetButtonScaleWhen(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 801 nVP); |
| 802 } |
| 803 } else { |
| 804 CFX_PtrArray FieldArray; |
| 805 GetFormFields(m_FieldName, FieldArray); |
| 806 if (FieldArray.GetSize() <= 0) |
| 807 return FALSE; |
| 808 |
| 809 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 810 ASSERT(pFormField != NULL); |
| 811 |
| 812 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 813 return FALSE; |
| 814 |
| 815 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 816 if (!pFormControl) |
| 817 return FALSE; |
| 818 |
| 819 CPDF_IconFit IconFit = pFormControl->GetIconFit(); |
| 820 int ScaleM = IconFit.GetScaleMethod(); |
| 821 switch (ScaleM) { |
| 822 case CPDF_IconFit::Always: |
| 823 vp << (int32_t)CPDF_IconFit::Always; |
| 824 break; |
| 825 case CPDF_IconFit::Bigger: |
| 826 vp << (int32_t)CPDF_IconFit::Bigger; |
| 827 break; |
| 828 case CPDF_IconFit::Never: |
| 829 vp << (int32_t)CPDF_IconFit::Never; |
| 830 break; |
| 831 case CPDF_IconFit::Smaller: |
| 832 vp << (int32_t)CPDF_IconFit::Smaller; |
| 833 break; |
| 834 } |
| 835 } |
| 836 |
| 837 return TRUE; |
| 838 } |
| 839 |
| 840 void Field::SetButtonScaleWhen(CPDFSDK_Document* pDocument, |
| 841 const CFX_WideString& swFieldName, |
| 842 int nControlIndex, |
| 843 int number) { |
| 844 // Not supported. |
| 845 } |
| 846 |
| 847 FX_BOOL Field::calcOrderIndex(IFXJS_Context* cc, |
| 848 CJS_PropValue& vp, |
| 849 CFX_WideString& sError) { |
| 850 ASSERT(m_pDocument != NULL); |
| 851 |
| 852 if (vp.IsSetting()) { |
| 853 if (!m_bCanSet) |
| 854 return FALSE; |
| 855 |
| 856 int nVP; |
| 857 vp >> nVP; |
| 858 |
| 859 if (m_bDelay) { |
| 860 AddDelay_Int(FP_CALCORDERINDEX, nVP); |
| 861 } else { |
| 862 Field::SetCalcOrderIndex(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 863 nVP); |
| 864 } |
| 865 } else { |
| 866 CFX_PtrArray FieldArray; |
| 867 GetFormFields(m_FieldName, FieldArray); |
| 868 if (FieldArray.GetSize() <= 0) |
| 869 return FALSE; |
| 870 |
| 871 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 872 ASSERT(pFormField != NULL); |
| 873 |
| 874 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && |
| 875 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
| 876 return FALSE; |
| 877 |
| 878 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); |
| 879 ASSERT(pRDInterForm != NULL); |
| 880 |
| 881 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); |
| 882 ASSERT(pInterForm != NULL); |
| 883 |
| 884 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); |
| 885 } |
| 886 |
| 887 return TRUE; |
| 888 } |
| 889 |
| 890 void Field::SetCalcOrderIndex(CPDFSDK_Document* pDocument, |
| 891 const CFX_WideString& swFieldName, |
| 892 int nControlIndex, |
| 893 int number) { |
| 894 // Not supported. |
| 895 } |
| 896 |
| 897 FX_BOOL Field::charLimit(IFXJS_Context* cc, |
| 898 CJS_PropValue& vp, |
| 899 CFX_WideString& sError) { |
| 900 ASSERT(m_pDocument != NULL); |
| 901 |
| 902 if (vp.IsSetting()) { |
| 903 if (!m_bCanSet) |
| 904 return FALSE; |
| 905 |
| 906 int nVP; |
| 907 vp >> nVP; |
| 908 |
| 909 if (m_bDelay) { |
| 910 AddDelay_Int(FP_CHARLIMIT, nVP); |
| 911 } else { |
| 912 Field::SetCharLimit(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); |
| 913 } |
| 914 } else { |
| 915 CFX_PtrArray FieldArray; |
| 916 GetFormFields(m_FieldName, FieldArray); |
| 917 if (FieldArray.GetSize() <= 0) |
| 918 return FALSE; |
| 919 |
| 920 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 921 ASSERT(pFormField != NULL); |
| 922 |
| 923 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
| 924 return FALSE; |
| 925 |
| 926 vp << (int32_t)pFormField->GetMaxLen(); |
| 927 } |
| 928 return TRUE; |
| 929 } |
| 930 |
| 931 void Field::SetCharLimit(CPDFSDK_Document* pDocument, |
| 932 const CFX_WideString& swFieldName, |
| 933 int nControlIndex, |
| 934 int number) { |
| 935 // Not supported. |
| 936 } |
| 937 |
| 938 FX_BOOL Field::comb(IFXJS_Context* cc, |
| 939 CJS_PropValue& vp, |
| 940 CFX_WideString& sError) { |
| 941 ASSERT(m_pDocument != NULL); |
| 942 |
| 943 if (vp.IsSetting()) { |
| 944 if (!m_bCanSet) |
| 945 return FALSE; |
| 946 |
| 947 bool bVP; |
| 948 vp >> bVP; |
| 949 |
| 950 if (m_bDelay) { |
| 951 AddDelay_Bool(FP_COMB, bVP); |
| 952 } else { |
| 953 Field::SetComb(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
| 954 } |
| 955 } else { |
| 956 CFX_PtrArray FieldArray; |
| 957 GetFormFields(m_FieldName, FieldArray); |
| 958 if (FieldArray.GetSize() <= 0) |
| 959 return FALSE; |
| 960 |
| 961 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 962 ASSERT(pFormField != NULL); |
| 963 |
| 964 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
| 965 return FALSE; |
| 966 |
| 967 if (pFormField->GetFieldFlags() & FIELDFLAG_COMB) |
| 968 vp << true; |
| 969 else |
| 970 vp << false; |
| 971 } |
| 972 |
| 973 return TRUE; |
| 974 } |
| 975 |
| 976 void Field::SetComb(CPDFSDK_Document* pDocument, |
| 977 const CFX_WideString& swFieldName, |
| 978 int nControlIndex, |
| 979 bool b) { |
| 980 // Not supported. |
| 981 } |
| 982 |
| 983 FX_BOOL Field::commitOnSelChange(IFXJS_Context* cc, |
| 984 CJS_PropValue& vp, |
| 985 CFX_WideString& sError) { |
| 986 ASSERT(m_pDocument != NULL); |
| 987 |
| 988 if (vp.IsSetting()) { |
| 989 if (!m_bCanSet) |
| 990 return FALSE; |
| 991 |
| 992 bool bVP; |
| 993 vp >> bVP; |
| 994 |
| 995 if (m_bDelay) { |
| 996 AddDelay_Bool(FP_COMMITONSELCHANGE, bVP); |
| 997 } else { |
| 998 Field::SetCommitOnSelChange(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 999 bVP); |
| 1000 } |
| 1001 } else { |
| 1002 CFX_PtrArray FieldArray; |
| 1003 GetFormFields(m_FieldName, FieldArray); |
| 1004 if (FieldArray.GetSize() <= 0) |
| 1005 return FALSE; |
| 2104 | 1006 |
| 2105 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1007 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2106 ASSERT(pFormField != NULL); | 1008 ASSERT(pFormField != NULL); |
| 2107 | 1009 |
| 2108 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && | 1010 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && |
| 2109 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) | 1011 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) |
| 2110 return FALSE; | 1012 return FALSE; |
| 2111 | 1013 |
| 2112 if (!vp.IsGetting()) return FALSE; | 1014 if (pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE) |
| 2113 | 1015 vp << true; |
| 2114 vp << (int32_t)pFormField->CountOptions(); | 1016 else |
| 2115 | 1017 vp << false; |
| 2116 return TRUE; | 1018 } |
| 2117 } | 1019 |
| 2118 | 1020 return TRUE; |
| 2119 FX_BOOL Field::page(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) | 1021 } |
| 2120 { | 1022 |
| 2121 if (!vp.IsGetting()) return FALSE; | 1023 void Field::SetCommitOnSelChange(CPDFSDK_Document* pDocument, |
| 2122 | 1024 const CFX_WideString& swFieldName, |
| 1025 int nControlIndex, |
| 1026 bool b) { |
| 1027 // Not supported. |
| 1028 } |
| 1029 |
| 1030 FX_BOOL Field::currentValueIndices(IFXJS_Context* cc, |
| 1031 CJS_PropValue& vp, |
| 1032 CFX_WideString& sError) { |
| 1033 ASSERT(m_pDocument != NULL); |
| 1034 |
| 1035 if (vp.IsSetting()) { |
| 1036 if (!m_bCanSet) |
| 1037 return FALSE; |
| 1038 |
| 1039 CFX_DWordArray array; |
| 1040 |
| 1041 if (vp.GetType() == VT_number) { |
| 1042 int iSelecting = 0; |
| 1043 vp >> iSelecting; |
| 1044 array.Add(iSelecting); |
| 1045 } else if (vp.IsArrayObject()) { |
| 1046 CJS_Array SelArray(m_isolate); |
| 1047 CJS_Value SelValue(m_isolate); |
| 1048 int iSelecting; |
| 1049 vp >> SelArray; |
| 1050 for (int i = 0, sz = SelArray.GetLength(); i < sz; i++) { |
| 1051 SelArray.GetElement(i, SelValue); |
| 1052 iSelecting = SelValue.ToInt(); |
| 1053 array.Add(iSelecting); |
| 1054 } |
| 1055 } |
| 1056 |
| 1057 if (m_bDelay) { |
| 1058 AddDelay_WordArray(FP_CURRENTVALUEINDICES, array); |
| 1059 } else { |
| 1060 Field::SetCurrentValueIndices(m_pDocument, m_FieldName, |
| 1061 m_nFormControlIndex, array); |
| 1062 } |
| 1063 } else { |
| 2123 CFX_PtrArray FieldArray; | 1064 CFX_PtrArray FieldArray; |
| 2124 GetFormFields(m_FieldName, FieldArray); | 1065 GetFormFields(m_FieldName, FieldArray); |
| 2125 if (FieldArray.GetSize() <= 0) return FALSE; | 1066 if (FieldArray.GetSize() <= 0) |
| 2126 | 1067 return FALSE; |
| 2127 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1068 |
| 2128 if (!pFormField) return FALSE; | 1069 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2129 | 1070 ASSERT(pFormField != NULL); |
| 2130 ASSERT(m_pDocument != NULL); | 1071 |
| 2131 | 1072 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && |
| 2132 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | 1073 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) |
| 2133 ASSERT(pInterForm != NULL); | 1074 return FALSE; |
| 2134 | 1075 |
| 2135 CFX_PtrArray widgetArray; | 1076 if (pFormField->CountSelectedItems() == 1) |
| 2136 pInterForm->GetWidgets(pFormField, widgetArray); | 1077 vp << pFormField->GetSelectedIndex(0); |
| 2137 | 1078 else if (pFormField->CountSelectedItems() > 1) { |
| 2138 if (widgetArray.GetSize() > 0) | 1079 CJS_Array SelArray(m_isolate); |
| 2139 { | 1080 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { |
| 2140 CJS_Array PageArray(m_isolate); | 1081 SelArray.SetElement( |
| 2141 | 1082 i, CJS_Value(m_isolate, pFormField->GetSelectedIndex(i))); |
| 2142 for (int i=0,sz=widgetArray.GetSize(); i<sz; i++) | 1083 } |
| 2143 { | 1084 vp << SelArray; |
| 2144 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgetArray.GetAt(i); | 1085 } else |
| 2145 ASSERT(pWidget != NULL); | 1086 vp << -1; |
| 2146 | 1087 } |
| 2147 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); | 1088 |
| 2148 if(!pPageView) | 1089 return TRUE; |
| 2149 return FALSE; | 1090 } |
| 2150 | 1091 |
| 2151 PageArray.SetElement(i, CJS_Value(m_isolate,(int32_t)pPageView->GetP
ageIndex())); | 1092 void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument, |
| 1093 const CFX_WideString& swFieldName, |
| 1094 int nControlIndex, |
| 1095 const CFX_DWordArray& array) { |
| 1096 ASSERT(pDocument != NULL); |
| 1097 |
| 1098 CFX_PtrArray FieldArray; |
| 1099 GetFormFields(pDocument, swFieldName, FieldArray); |
| 1100 |
| 1101 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { |
| 1102 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); |
| 1103 ASSERT(pFormField != NULL); |
| 1104 |
| 1105 int nFieldType = pFormField->GetFieldType(); |
| 1106 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX) { |
| 1107 FX_DWORD dwFieldFlags = pFormField->GetFieldFlags(); |
| 1108 pFormField->ClearSelection(TRUE); |
| 1109 |
| 1110 for (int i = 0, sz = array.GetSize(); i < sz; i++) { |
| 1111 if (i > 0 && !(dwFieldFlags & (1 << 21))) { |
| 1112 break; |
| 2152 } | 1113 } |
| 2153 | 1114 |
| 2154 vp << PageArray; | 1115 int iSelecting = (int32_t)array.GetAt(i); |
| 2155 } | 1116 if (iSelecting < pFormField->CountOptions() && |
| 2156 else | 1117 !pFormField->IsItemSelected(iSelecting)) |
| 2157 { | 1118 pFormField->SetItemSelection(iSelecting, TRUE); |
| 2158 vp << (int32_t) -1; | 1119 } |
| 2159 } | 1120 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); |
| 2160 | 1121 } |
| 2161 return TRUE; | 1122 } |
| 2162 } | 1123 } |
| 2163 | 1124 |
| 2164 FX_BOOL Field::password(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1125 FX_BOOL Field::defaultStyle(IFXJS_Context* cc, |
| 2165 { | 1126 CJS_PropValue& vp, |
| 2166 ASSERT(m_pDocument != NULL); | 1127 CFX_WideString& sError) { |
| 2167 | 1128 // MQG sError = JSGetStringFromID(IDS_STRING_NOTSUPPORT); |
| 2168 if (vp.IsSetting()) | 1129 return FALSE; |
| 2169 { | 1130 |
| 2170 if (!m_bCanSet) return FALSE; | 1131 if (vp.IsSetting()) { |
| 2171 | 1132 if (!m_bCanSet) |
| 2172 bool bVP; | 1133 return FALSE; |
| 2173 vp >> bVP; | 1134 |
| 2174 | 1135 ; |
| 2175 if (m_bDelay) | 1136 } else { |
| 2176 { | 1137 ; |
| 2177 AddDelay_Bool(FP_PASSWORD, bVP); | 1138 } |
| 2178 } | 1139 return TRUE; |
| 2179 else | 1140 } |
| 2180 { | 1141 |
| 2181 Field::SetPassword(m_pDocument, m_FieldName, m_nFormControlIndex, bV
P); | 1142 void Field::SetDefaultStyle(CPDFSDK_Document* pDocument, |
| 2182 } | 1143 const CFX_WideString& swFieldName, |
| 2183 } | 1144 int nControlIndex) { |
| 2184 else | 1145 // Not supported. |
| 2185 { | 1146 } |
| 2186 CFX_PtrArray FieldArray; | 1147 |
| 2187 GetFormFields(m_FieldName,FieldArray); | 1148 FX_BOOL Field::defaultValue(IFXJS_Context* cc, |
| 2188 if (FieldArray.GetSize() <= 0) return FALSE; | 1149 CJS_PropValue& vp, |
| 2189 | 1150 CFX_WideString& sError) { |
| 2190 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1151 ASSERT(m_pDocument != NULL); |
| 2191 ASSERT(pFormField != NULL); | 1152 |
| 2192 | 1153 if (vp.IsSetting()) { |
| 2193 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 1154 if (!m_bCanSet) |
| 2194 return FALSE; | 1155 return FALSE; |
| 2195 | 1156 |
| 2196 if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD) | 1157 CFX_WideString WideStr; |
| 2197 vp << true; | 1158 vp >> WideStr; |
| 2198 else | 1159 |
| 2199 vp << false; | 1160 if (m_bDelay) { |
| 2200 } | 1161 AddDelay_WideString(FP_DEFAULTVALUE, WideStr); |
| 2201 | 1162 } else { |
| 2202 return TRUE; | 1163 Field::SetDefaultValue(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 2203 } | 1164 WideStr); |
| 2204 | 1165 } |
| 2205 void Field::SetPassword(CPDFSDK_Document* pDocument, const CFX_WideString& swFie
ldName, int nControlIndex, bool b) | 1166 } else { |
| 2206 { | |
| 2207 //Not supported. | |
| 2208 } | |
| 2209 | |
| 2210 FX_BOOL Field::print(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) | |
| 2211 { | |
| 2212 ASSERT(m_pDocument != NULL); | |
| 2213 | |
| 2214 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | |
| 2215 ASSERT(pInterForm != NULL); | |
| 2216 | |
| 2217 CFX_PtrArray FieldArray; | 1167 CFX_PtrArray FieldArray; |
| 2218 GetFormFields(m_FieldName, FieldArray); | 1168 GetFormFields(m_FieldName, FieldArray); |
| 2219 if (FieldArray.GetSize() <= 0) return FALSE; | 1169 if (FieldArray.GetSize() <= 0) |
| 2220 | 1170 return FALSE; |
| 2221 if (vp.IsSetting()) | 1171 |
| 2222 { | 1172 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2223 if (!m_bCanSet) return FALSE; | 1173 ASSERT(pFormField != NULL); |
| 2224 | 1174 |
| 2225 bool bVP; | 1175 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON || |
| 2226 vp >> bVP; | 1176 pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) |
| 2227 | 1177 return FALSE; |
| 2228 for (int i=0,isz=FieldArray.GetSize(); i<isz; i++) | 1178 |
| 2229 { | 1179 vp << pFormField->GetDefaultValue(); |
| 2230 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i
); | 1180 } |
| 2231 ASSERT(pFormField != NULL); | 1181 return TRUE; |
| 2232 | 1182 } |
| 2233 if (m_nFormControlIndex < 0) | 1183 |
| 2234 { | 1184 void Field::SetDefaultValue(CPDFSDK_Document* pDocument, |
| 2235 FX_BOOL bSet = FALSE; | 1185 const CFX_WideString& swFieldName, |
| 2236 for (int j=0,jsz = pFormField->CountControls(); j<jsz; j++) | 1186 int nControlIndex, |
| 2237 { | 1187 const CFX_WideString& string) { |
| 2238 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormFie
ld->GetControl(j))) | 1188 // Not supported. |
| 2239 { | 1189 } |
| 2240 FX_DWORD dwFlags = pWidget->GetFlags(); | 1190 |
| 2241 if (bVP) | 1191 FX_BOOL Field::doNotScroll(IFXJS_Context* cc, |
| 2242 dwFlags |= ANNOTFLAG_PRINT; | 1192 CJS_PropValue& vp, |
| 2243 else | 1193 CFX_WideString& sError) { |
| 2244 dwFlags &= ~ANNOTFLAG_PRINT; | 1194 ASSERT(m_pDocument != NULL); |
| 2245 | 1195 |
| 2246 if (dwFlags != pWidget->GetFlags()) | 1196 if (vp.IsSetting()) { |
| 2247 { | 1197 if (!m_bCanSet) |
| 2248 pWidget->SetFlags(dwFlags); | 1198 return FALSE; |
| 2249 bSet = TRUE; | 1199 |
| 2250 } | 1200 bool bVP; |
| 2251 } | 1201 vp >> bVP; |
| 2252 } | 1202 |
| 2253 | 1203 if (m_bDelay) { |
| 2254 if (bSet) | 1204 AddDelay_Bool(FP_DONOTSCROLL, bVP); |
| 2255 UpdateFormField(m_pDocument, pFormField, TRUE, FALSE, TRUE); | 1205 } else { |
| 2256 } | 1206 Field::SetDoNotScroll(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
| 2257 else | 1207 } |
| 2258 { | 1208 } else { |
| 2259 if(m_nFormControlIndex >= pFormField->CountControls()) return FA
LSE; | |
| 2260 if (CPDF_FormControl* pFormControl = pFormField->GetControl(m_nF
ormControlIndex)) | |
| 2261 { | |
| 2262 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormCon
trol)) | |
| 2263 { | |
| 2264 FX_DWORD dwFlags = pWidget->GetFlags(); | |
| 2265 if (bVP) | |
| 2266 dwFlags |= ANNOTFLAG_PRINT; | |
| 2267 else | |
| 2268 dwFlags &= ~ANNOTFLAG_PRINT; | |
| 2269 | |
| 2270 if (dwFlags != pWidget->GetFlags()) | |
| 2271 { | |
| 2272 pWidget->SetFlags(dwFlags); | |
| 2273 UpdateFormControl(m_pDocument, pFormField->GetContro
l(m_nFormControlIndex), TRUE, FALSE, TRUE); | |
| 2274 } | |
| 2275 } | |
| 2276 } | |
| 2277 } | |
| 2278 } | |
| 2279 } | |
| 2280 else | |
| 2281 { | |
| 2282 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2283 ASSERT(pFormField != NULL); | |
| 2284 | |
| 2285 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFo
rmField)); | |
| 2286 if (!pWidget) return FALSE; | |
| 2287 | |
| 2288 if (pWidget->GetFlags() & ANNOTFLAG_PRINT) | |
| 2289 vp << true; | |
| 2290 else | |
| 2291 vp << false; | |
| 2292 } | |
| 2293 | |
| 2294 return TRUE; | |
| 2295 } | |
| 2296 | |
| 2297 FX_BOOL Field::radiosInUnison(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStri
ng& sError) | |
| 2298 { | |
| 2299 ASSERT(m_pDocument != NULL); | |
| 2300 | |
| 2301 CFX_PtrArray FieldArray; | |
| 2302 GetFormFields(m_FieldName,FieldArray); | |
| 2303 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2304 | |
| 2305 if (vp.IsSetting()) | |
| 2306 { | |
| 2307 if (!m_bCanSet) return FALSE; | |
| 2308 | |
| 2309 bool bVP; | |
| 2310 vp >> bVP; | |
| 2311 | |
| 2312 } | |
| 2313 else | |
| 2314 { | |
| 2315 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2316 ASSERT(pFormField != NULL); | |
| 2317 | |
| 2318 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) | |
| 2319 return FALSE; | |
| 2320 | |
| 2321 if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON) | |
| 2322 vp << true; | |
| 2323 else | |
| 2324 vp << false; | |
| 2325 } | |
| 2326 | |
| 2327 return TRUE; | |
| 2328 } | |
| 2329 | |
| 2330 FX_BOOL Field::readonly(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | |
| 2331 { | |
| 2332 ASSERT(m_pDocument != NULL); | |
| 2333 | |
| 2334 CFX_PtrArray FieldArray; | |
| 2335 GetFormFields(m_FieldName,FieldArray); | |
| 2336 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2337 | |
| 2338 if (vp.IsSetting()) | |
| 2339 { | |
| 2340 if (!m_bCanSet) return FALSE; | |
| 2341 | |
| 2342 bool bVP; | |
| 2343 vp >> bVP; | |
| 2344 | |
| 2345 } | |
| 2346 else | |
| 2347 { | |
| 2348 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2349 ASSERT(pFormField != NULL); | |
| 2350 | |
| 2351 if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY) | |
| 2352 vp << true; | |
| 2353 else | |
| 2354 vp << false; | |
| 2355 } | |
| 2356 | |
| 2357 return TRUE; | |
| 2358 } | |
| 2359 | |
| 2360 FX_BOOL Field::rect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) | |
| 2361 { | |
| 2362 ASSERT(m_pDocument != NULL); | |
| 2363 | |
| 2364 if (vp.IsSetting()) | |
| 2365 { | |
| 2366 if (!m_bCanSet) return FALSE; | |
| 2367 if (!vp.IsArrayObject())return FALSE; | |
| 2368 | |
| 2369 CJS_Array rcArray(m_isolate); | |
| 2370 vp >> rcArray; | |
| 2371 CJS_Value Upper_Leftx(m_isolate), Upper_Lefty(m_isolate), Lower_Rightx(m
_isolate), Lower_Righty(m_isolate); | |
| 2372 rcArray.GetElement(0, Upper_Leftx); | |
| 2373 rcArray.GetElement(1, Upper_Lefty); | |
| 2374 rcArray.GetElement(2, Lower_Rightx); | |
| 2375 rcArray.GetElement(3, Lower_Righty); | |
| 2376 | |
| 2377 FX_FLOAT pArray[4] = {0.0f,0.0f,0.0f,0.0f}; | |
| 2378 pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt(); | |
| 2379 pArray[1] = (FX_FLOAT)Lower_Righty.ToInt(); | |
| 2380 pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(); | |
| 2381 pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(); | |
| 2382 | |
| 2383 CPDF_Rect crRect(pArray); | |
| 2384 | |
| 2385 if (m_bDelay) | |
| 2386 { | |
| 2387 AddDelay_Rect(FP_RECT, crRect); | |
| 2388 } | |
| 2389 else | |
| 2390 { | |
| 2391 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect
); | |
| 2392 } | |
| 2393 } | |
| 2394 else | |
| 2395 { | |
| 2396 CFX_PtrArray FieldArray; | |
| 2397 GetFormFields(m_FieldName,FieldArray); | |
| 2398 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2399 | |
| 2400 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2401 ASSERT(pFormField != NULL); | |
| 2402 | |
| 2403 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | |
| 2404 ASSERT(pInterForm != NULL); | |
| 2405 | |
| 2406 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFo
rmField)); | |
| 2407 if (!pWidget) return FALSE; | |
| 2408 | |
| 2409 CFX_FloatRect crRect = pWidget->GetRect(); | |
| 2410 CJS_Value Upper_Leftx(m_isolate),Upper_Lefty(m_isolate),Lower_Rightx(m_i
solate),Lower_Righty(m_isolate); | |
| 2411 Upper_Leftx = (int32_t)crRect.left; | |
| 2412 Upper_Lefty = (int32_t)crRect.top; | |
| 2413 Lower_Rightx = (int32_t)crRect.right; | |
| 2414 Lower_Righty = (int32_t)crRect.bottom; | |
| 2415 | |
| 2416 CJS_Array rcArray(m_isolate); | |
| 2417 rcArray.SetElement(0,Upper_Leftx); | |
| 2418 rcArray.SetElement(1,Upper_Lefty); | |
| 2419 rcArray.SetElement(2,Lower_Rightx); | |
| 2420 rcArray.SetElement(3,Lower_Righty); | |
| 2421 | |
| 2422 vp << rcArray; | |
| 2423 } | |
| 2424 | |
| 2425 return TRUE; | |
| 2426 } | |
| 2427 | |
| 2428 void Field::SetRect(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldNa
me, int nControlIndex, const CPDF_Rect& rect) | |
| 2429 { | |
| 2430 ASSERT(pDocument != NULL); | |
| 2431 | |
| 2432 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(
); | |
| 2433 ASSERT(pInterForm != NULL); | |
| 2434 | |
| 2435 CFX_PtrArray FieldArray; | |
| 2436 GetFormFields(pDocument, swFieldName, FieldArray); | |
| 2437 | |
| 2438 for (int i=0,isz=FieldArray.GetSize(); i<isz; i++) | |
| 2439 { | |
| 2440 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
| 2441 ASSERT(pFormField != NULL); | |
| 2442 | |
| 2443 if (nControlIndex < 0) | |
| 2444 { | |
| 2445 FX_BOOL bSet = FALSE; | |
| 2446 for (int i=0, sz=pFormField->CountControls(); i<sz; i++) | |
| 2447 { | |
| 2448 CPDF_FormControl* pFormControl = pFormField->GetControl(i); | |
| 2449 ASSERT(pFormControl != NULL); | |
| 2450 | |
| 2451 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl
)) | |
| 2452 { | |
| 2453 CPDF_Rect crRect = rect; | |
| 2454 | |
| 2455 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); | |
| 2456 ASSERT(pPDFPage != NULL); | |
| 2457 | |
| 2458 // CPDF_Page* pPDFPage = pPage->GetPage(); | |
| 2459 // ASSERT(pPDFPage != NULL); | |
| 2460 | |
| 2461 crRect.Intersect(pPDFPage->GetPageBBox()); | |
| 2462 | |
| 2463 if (!crRect.IsEmpty()) | |
| 2464 { | |
| 2465 CPDF_Rect rcOld = pWidget->GetRect(); | |
| 2466 if (crRect.left != rcOld.left || | |
| 2467 crRect.right != rcOld.right || | |
| 2468 crRect.top != rcOld.top || | |
| 2469 crRect.bottom != rcOld.bottom) | |
| 2470 { | |
| 2471 pWidget->SetRect(crRect); | |
| 2472 bSet = TRUE; | |
| 2473 } | |
| 2474 } | |
| 2475 } | |
| 2476 } | |
| 2477 | |
| 2478 if (bSet) UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); | |
| 2479 } | |
| 2480 else | |
| 2481 { | |
| 2482 if(nControlIndex >= pFormField->CountControls()) return; | |
| 2483 if (CPDF_FormControl* pFormControl = pFormField->GetControl(nControl
Index)) | |
| 2484 { | |
| 2485 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl
)) | |
| 2486 { | |
| 2487 CPDF_Rect crRect = rect; | |
| 2488 | |
| 2489 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); | |
| 2490 ASSERT(pPDFPage != NULL); | |
| 2491 | |
| 2492 // CPDF_Page* pPDFPage = pPage->GetPage(); | |
| 2493 // ASSERT(pPDFPage != NULL); | |
| 2494 | |
| 2495 crRect.Intersect(pPDFPage->GetPageBBox()); | |
| 2496 | |
| 2497 if (!crRect.IsEmpty()) | |
| 2498 { | |
| 2499 CPDF_Rect rcOld = pWidget->GetRect(); | |
| 2500 if (crRect.left != rcOld.left || | |
| 2501 crRect.right != rcOld.right || | |
| 2502 crRect.top != rcOld.top || | |
| 2503 crRect.bottom != rcOld.bottom) | |
| 2504 { | |
| 2505 pWidget->SetRect(crRect); | |
| 2506 UpdateFormControl(pDocument, pFormControl, TRUE, TRU
E, TRUE); | |
| 2507 } | |
| 2508 } | |
| 2509 } | |
| 2510 } | |
| 2511 } | |
| 2512 } | |
| 2513 } | |
| 2514 | |
| 2515 FX_BOOL Field::required(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | |
| 2516 { | |
| 2517 ASSERT(m_pDocument != NULL); | |
| 2518 | |
| 2519 CFX_PtrArray FieldArray; | |
| 2520 GetFormFields(m_FieldName,FieldArray); | |
| 2521 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2522 | |
| 2523 if (vp.IsSetting()) | |
| 2524 { | |
| 2525 if (!m_bCanSet) return FALSE; | |
| 2526 | |
| 2527 | |
| 2528 bool bVP; | |
| 2529 vp >> bVP; | |
| 2530 | |
| 2531 } | |
| 2532 else | |
| 2533 { | |
| 2534 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2535 ASSERT(pFormField != NULL); | |
| 2536 | |
| 2537 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) | |
| 2538 return FALSE; | |
| 2539 | |
| 2540 if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED) | |
| 2541 vp << true; | |
| 2542 else | |
| 2543 vp << false; | |
| 2544 } | |
| 2545 | |
| 2546 return TRUE; | |
| 2547 } | |
| 2548 | |
| 2549 FX_BOOL Field::richText(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | |
| 2550 { | |
| 2551 ASSERT(m_pDocument != NULL); | |
| 2552 | |
| 2553 if (vp.IsSetting()) | |
| 2554 { | |
| 2555 if (!m_bCanSet) return FALSE; | |
| 2556 | |
| 2557 bool bVP; | |
| 2558 vp >> bVP; | |
| 2559 | |
| 2560 if (m_bDelay) | |
| 2561 { | |
| 2562 AddDelay_Bool(FP_RICHTEXT, bVP); | |
| 2563 } | |
| 2564 else | |
| 2565 { | |
| 2566 Field::SetRichText(m_pDocument, m_FieldName, m_nFormControlIndex, bV
P); | |
| 2567 } | |
| 2568 } | |
| 2569 else | |
| 2570 { | |
| 2571 CFX_PtrArray FieldArray; | |
| 2572 GetFormFields(m_FieldName,FieldArray); | |
| 2573 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2574 | |
| 2575 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2576 ASSERT(pFormField != NULL); | |
| 2577 | |
| 2578 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | |
| 2579 return FALSE; | |
| 2580 | |
| 2581 if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT) | |
| 2582 vp << true; | |
| 2583 else | |
| 2584 vp << false; | |
| 2585 } | |
| 2586 | |
| 2587 return TRUE; | |
| 2588 } | |
| 2589 | |
| 2590 void Field::SetRichText(CPDFSDK_Document* pDocument, const CFX_WideString& swFie
ldName, int nControlIndex, bool b) | |
| 2591 { | |
| 2592 //Not supported. | |
| 2593 } | |
| 2594 | |
| 2595 FX_BOOL Field::richValue(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | |
| 2596 { | |
| 2597 return TRUE; | |
| 2598 if (vp.IsSetting()) | |
| 2599 { | |
| 2600 if (!m_bCanSet) return FALSE; | |
| 2601 ; | |
| 2602 } | |
| 2603 else | |
| 2604 { | |
| 2605 ; | |
| 2606 } | |
| 2607 return TRUE; | |
| 2608 } | |
| 2609 | |
| 2610 void Field::SetRichValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFi
eldName, int nControlIndex) | |
| 2611 { | |
| 2612 //Not supported. | |
| 2613 } | |
| 2614 | |
| 2615 FX_BOOL Field::rotation(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | |
| 2616 { | |
| 2617 ASSERT(m_pDocument != NULL); | |
| 2618 | |
| 2619 if (vp.IsSetting()) | |
| 2620 { | |
| 2621 if (!m_bCanSet) return FALSE; | |
| 2622 | |
| 2623 int nVP; | |
| 2624 vp >> nVP; | |
| 2625 | |
| 2626 if (m_bDelay) | |
| 2627 { | |
| 2628 AddDelay_Int(FP_ROTATION, nVP); | |
| 2629 } | |
| 2630 else | |
| 2631 { | |
| 2632 Field::SetRotation(m_pDocument, m_FieldName, m_nFormControlIndex, nV
P); | |
| 2633 } | |
| 2634 } | |
| 2635 else | |
| 2636 { | |
| 2637 CFX_PtrArray FieldArray; | |
| 2638 GetFormFields(m_FieldName,FieldArray); | |
| 2639 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2640 | |
| 2641 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2642 ASSERT(pFormField != NULL); | |
| 2643 | |
| 2644 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 2645 if (!pFormControl)return FALSE; | |
| 2646 | |
| 2647 vp << (int32_t)pFormControl->GetRotation(); | |
| 2648 } | |
| 2649 | |
| 2650 return TRUE; | |
| 2651 } | |
| 2652 | |
| 2653 void Field::SetRotation(CPDFSDK_Document* pDocument, const CFX_WideString& swFie
ldName, int nControlIndex, int number) | |
| 2654 { | |
| 2655 //Not supported. | |
| 2656 } | |
| 2657 | |
| 2658 FX_BOOL Field::strokeColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | |
| 2659 { | |
| 2660 ASSERT(m_pDocument != NULL); | |
| 2661 | |
| 2662 if (vp.IsSetting()) | |
| 2663 { | |
| 2664 if (!m_bCanSet) return FALSE; | |
| 2665 | |
| 2666 if (!vp.IsArrayObject())return FALSE; | |
| 2667 | |
| 2668 CJS_Array crArray(m_isolate); | |
| 2669 vp >> crArray; | |
| 2670 | |
| 2671 CPWL_Color color; | |
| 2672 color::ConvertArrayToPWLColor(crArray, color); | |
| 2673 | |
| 2674 if (m_bDelay) | |
| 2675 { | |
| 2676 AddDelay_Color(FP_STROKECOLOR, color); | |
| 2677 } | |
| 2678 else | |
| 2679 { | |
| 2680 Field::SetStrokeColor(m_pDocument, m_FieldName, m_nFormControlIndex,
color); | |
| 2681 } | |
| 2682 } | |
| 2683 else | |
| 2684 { | |
| 2685 CFX_PtrArray FieldArray; | |
| 2686 GetFormFields(m_FieldName,FieldArray); | |
| 2687 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2688 | |
| 2689 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2690 ASSERT(pFormField != NULL); | |
| 2691 | |
| 2692 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 2693 if (!pFormControl)return FALSE; | |
| 2694 | |
| 2695 int iColorType; | |
| 2696 pFormControl->GetBorderColor(iColorType); | |
| 2697 | |
| 2698 CPWL_Color color; | |
| 2699 | |
| 2700 if (iColorType == COLORTYPE_TRANSPARENT) | |
| 2701 { | |
| 2702 color = CPWL_Color(COLORTYPE_TRANSPARENT); | |
| 2703 } | |
| 2704 else if (iColorType == COLORTYPE_GRAY) | |
| 2705 { | |
| 2706 color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderCo
lor(0)); | |
| 2707 } | |
| 2708 else if (iColorType == COLORTYPE_RGB) | |
| 2709 { | |
| 2710 color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderCol
or(0), | |
| 2711 pFormControl->GetOriginalBorderColor(1), | |
| 2712 pFormControl->GetOriginalBorderColor(2)); | |
| 2713 } | |
| 2714 else if (iColorType == COLORTYPE_CMYK) | |
| 2715 { | |
| 2716 color = CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderCo
lor(0), | |
| 2717 pFormControl->GetOriginalBorderColor(1), | |
| 2718 pFormControl->GetOriginalBorderColor(2), | |
| 2719 pFormControl->GetOriginalBorderColor(3)); | |
| 2720 } | |
| 2721 else | |
| 2722 return FALSE; | |
| 2723 | |
| 2724 CJS_Array crArray(m_isolate); | |
| 2725 color::ConvertPWLColorToArray(color, crArray); | |
| 2726 vp << crArray; | |
| 2727 } | |
| 2728 | |
| 2729 return TRUE; | |
| 2730 } | |
| 2731 | |
| 2732 void Field::SetStrokeColor(CPDFSDK_Document* pDocument, const CFX_WideString& sw
FieldName, int nControlIndex, const CPWL_Color& color) | |
| 2733 { | |
| 2734 //Not supported. | |
| 2735 } | |
| 2736 | |
| 2737 FX_BOOL Field::style(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) | |
| 2738 { | |
| 2739 ASSERT(m_pDocument != NULL); | |
| 2740 | |
| 2741 if (vp.IsSetting()) | |
| 2742 { | |
| 2743 if (!m_bCanSet) return FALSE; | |
| 2744 | |
| 2745 CFX_ByteString csBCaption; | |
| 2746 vp >> csBCaption; | |
| 2747 | |
| 2748 if (m_bDelay) | |
| 2749 { | |
| 2750 AddDelay_String(FP_STYLE, csBCaption); | |
| 2751 } | |
| 2752 else | |
| 2753 { | |
| 2754 Field::SetStyle(m_pDocument, m_FieldName, m_nFormControlIndex, csBCa
ption); | |
| 2755 } | |
| 2756 } | |
| 2757 else | |
| 2758 { | |
| 2759 CFX_PtrArray FieldArray; | |
| 2760 GetFormFields(m_FieldName,FieldArray); | |
| 2761 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2762 | |
| 2763 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2764 ASSERT(pFormField != NULL); | |
| 2765 | |
| 2766 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON && | |
| 2767 pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) | |
| 2768 return FALSE; | |
| 2769 | |
| 2770 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 2771 if (!pFormControl) return FALSE; | |
| 2772 | |
| 2773 CFX_WideString csWCaption = pFormControl->GetNormalCaption(); | |
| 2774 CFX_ByteString csBCaption; | |
| 2775 | |
| 2776 switch (csWCaption[0]) | |
| 2777 { | |
| 2778 case L'l': | |
| 2779 csBCaption = "circle"; | |
| 2780 break; | |
| 2781 case L'8': | |
| 2782 csBCaption = "cross"; | |
| 2783 break; | |
| 2784 case L'u': | |
| 2785 csBCaption = "diamond"; | |
| 2786 break; | |
| 2787 case L'n': | |
| 2788 csBCaption = "square"; | |
| 2789 break; | |
| 2790 case L'H': | |
| 2791 csBCaption = "star"; | |
| 2792 break; | |
| 2793 default: //L'4' | |
| 2794 csBCaption = "check"; | |
| 2795 break; | |
| 2796 } | |
| 2797 vp << csBCaption; | |
| 2798 } | |
| 2799 | |
| 2800 return TRUE; | |
| 2801 } | |
| 2802 | |
| 2803 void Field::SetStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldN
ame, int nControlIndex, | |
| 2804 const CFX_ByteString& string) | |
| 2805 { | |
| 2806 //Not supported. | |
| 2807 } | |
| 2808 | |
| 2809 FX_BOOL Field::submitName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | |
| 2810 { | |
| 2811 return TRUE; | |
| 2812 } | |
| 2813 | |
| 2814 FX_BOOL Field::textColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | |
| 2815 { | |
| 2816 ASSERT(m_pDocument != NULL); | |
| 2817 | |
| 2818 if (vp.IsSetting()) | |
| 2819 { | |
| 2820 if (!m_bCanSet) return FALSE; | |
| 2821 | |
| 2822 CJS_Array crArray(m_isolate); | |
| 2823 if (!vp.IsArrayObject())return FALSE; | |
| 2824 vp >> crArray; | |
| 2825 | |
| 2826 CPWL_Color color; | |
| 2827 color::ConvertArrayToPWLColor(crArray, color); | |
| 2828 | |
| 2829 if (m_bDelay) | |
| 2830 { | |
| 2831 AddDelay_Color(FP_TEXTCOLOR, color); | |
| 2832 } | |
| 2833 else | |
| 2834 { | |
| 2835 Field::SetTextColor(m_pDocument, m_FieldName, m_nFormControlIndex, c
olor); | |
| 2836 } | |
| 2837 } | |
| 2838 else | |
| 2839 { | |
| 2840 CFX_PtrArray FieldArray; | |
| 2841 GetFormFields(m_FieldName,FieldArray); | |
| 2842 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2843 | |
| 2844 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2845 ASSERT(pFormField != NULL); | |
| 2846 | |
| 2847 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 2848 if (!pFormControl)return FALSE; | |
| 2849 | |
| 2850 int iColorType; | |
| 2851 FX_ARGB color; | |
| 2852 CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppeara
nce(); | |
| 2853 FieldAppearance.GetColor(color, iColorType); | |
| 2854 int32_t a,r,g,b; | |
| 2855 ArgbDecode(color, a, r, g, b); | |
| 2856 | |
| 2857 CPWL_Color crRet = CPWL_Color(COLORTYPE_RGB, r / 255.0f, | |
| 2858 g / 255.0f, | |
| 2859 b / 255.0f); | |
| 2860 | |
| 2861 if (iColorType == COLORTYPE_TRANSPARENT) | |
| 2862 crRet = CPWL_Color(COLORTYPE_TRANSPARENT); | |
| 2863 | |
| 2864 CJS_Array crArray(m_isolate); | |
| 2865 color::ConvertPWLColorToArray(crRet, crArray); | |
| 2866 vp << crArray; | |
| 2867 } | |
| 2868 | |
| 2869 return TRUE; | |
| 2870 } | |
| 2871 | |
| 2872 void Field::SetTextColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFi
eldName, int nControlIndex, const CPWL_Color& color) | |
| 2873 { | |
| 2874 //Not supported. | |
| 2875 } | |
| 2876 | |
| 2877 FX_BOOL Field::textFont(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | |
| 2878 { | |
| 2879 ASSERT(m_pDocument != NULL); | |
| 2880 | |
| 2881 if (vp.IsSetting()) | |
| 2882 { | |
| 2883 if (!m_bCanSet) return FALSE; | |
| 2884 | |
| 2885 CFX_ByteString csFontName; | |
| 2886 vp >> csFontName; | |
| 2887 if (csFontName.IsEmpty()) return FALSE; | |
| 2888 | |
| 2889 if (m_bDelay) | |
| 2890 { | |
| 2891 AddDelay_String(FP_TEXTFONT, csFontName); | |
| 2892 } | |
| 2893 else | |
| 2894 { | |
| 2895 Field::SetTextFont(m_pDocument, m_FieldName, m_nFormControlIndex, cs
FontName); | |
| 2896 } | |
| 2897 } | |
| 2898 else | |
| 2899 { | |
| 2900 CFX_PtrArray FieldArray; | |
| 2901 GetFormFields(m_FieldName,FieldArray); | |
| 2902 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2903 | |
| 2904 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2905 ASSERT(pFormField != NULL); | |
| 2906 | |
| 2907 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 2908 if (!pFormControl)return FALSE; | |
| 2909 | |
| 2910 int nFieldType = pFormField->GetFieldType(); | |
| 2911 | |
| 2912 if (nFieldType == FIELDTYPE_PUSHBUTTON || | |
| 2913 nFieldType == FIELDTYPE_COMBOBOX || | |
| 2914 nFieldType == FIELDTYPE_LISTBOX || | |
| 2915 nFieldType == FIELDTYPE_TEXTFIELD) | |
| 2916 { | |
| 2917 CPDF_Font * pFont = pFormControl->GetDefaultControlFont(); | |
| 2918 if (!pFont) return FALSE; | |
| 2919 | |
| 2920 vp << pFont->GetBaseFont(); | |
| 2921 } | |
| 2922 else | |
| 2923 return FALSE; | |
| 2924 } | |
| 2925 | |
| 2926 return TRUE; | |
| 2927 } | |
| 2928 | |
| 2929 void Field::SetTextFont(CPDFSDK_Document* pDocument, const CFX_WideString& swFie
ldName, int nControlIndex, const CFX_ByteString& string) | |
| 2930 { | |
| 2931 //Not supported. | |
| 2932 } | |
| 2933 | |
| 2934 FX_BOOL Field::textSize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | |
| 2935 { | |
| 2936 ASSERT(m_pDocument != NULL); | |
| 2937 | |
| 2938 if (vp.IsSetting()) | |
| 2939 { | |
| 2940 if (!m_bCanSet) return FALSE; | |
| 2941 | |
| 2942 int nVP; | |
| 2943 vp >> nVP; | |
| 2944 | |
| 2945 if (m_bDelay) | |
| 2946 { | |
| 2947 AddDelay_Int(FP_TEXTSIZE, nVP); | |
| 2948 } | |
| 2949 else | |
| 2950 { | |
| 2951 Field::SetTextSize(m_pDocument, m_FieldName, m_nFormControlIndex, nV
P); | |
| 2952 } | |
| 2953 } | |
| 2954 else | |
| 2955 { | |
| 2956 CFX_PtrArray FieldArray; | |
| 2957 GetFormFields(m_FieldName,FieldArray); | |
| 2958 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2959 | |
| 2960 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2961 ASSERT(pFormField != NULL); | |
| 2962 | |
| 2963 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | |
| 2964 if (!pFormControl)return FALSE; | |
| 2965 | |
| 2966 CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppeara
nce(); | |
| 2967 | |
| 2968 CFX_ByteString csFontNameTag; | |
| 2969 FX_FLOAT fFontSize; | |
| 2970 FieldAppearance.GetFont(csFontNameTag,fFontSize); | |
| 2971 | |
| 2972 vp << (int)fFontSize; | |
| 2973 } | |
| 2974 | |
| 2975 return TRUE; | |
| 2976 } | |
| 2977 | |
| 2978 void Field::SetTextSize(CPDFSDK_Document* pDocument, const CFX_WideString& swFie
ldName, int nControlIndex, int number) | |
| 2979 { | |
| 2980 //Not supported. | |
| 2981 } | |
| 2982 | |
| 2983 FX_BOOL Field::type(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) | |
| 2984 { | |
| 2985 ASSERT(m_pDocument != NULL); | |
| 2986 | |
| 2987 if (!vp.IsGetting()) return FALSE; | |
| 2988 | |
| 2989 CFX_PtrArray FieldArray; | |
| 2990 GetFormFields(m_FieldName,FieldArray); | |
| 2991 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 2992 | |
| 2993 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 2994 ASSERT(pFormField != NULL); | |
| 2995 | |
| 2996 switch (pFormField->GetFieldType()) | |
| 2997 { | |
| 2998 case FIELDTYPE_UNKNOWN: | |
| 2999 vp << L"unknown"; | |
| 3000 break; | |
| 3001 case FIELDTYPE_PUSHBUTTON: | |
| 3002 vp << L"button"; | |
| 3003 break; | |
| 3004 case FIELDTYPE_CHECKBOX: | |
| 3005 vp << L"checkbox"; | |
| 3006 break; | |
| 3007 case FIELDTYPE_RADIOBUTTON: | |
| 3008 vp << L"radiobutton"; | |
| 3009 break; | |
| 3010 case FIELDTYPE_COMBOBOX: | |
| 3011 vp << L"combobox"; | |
| 3012 break; | |
| 3013 case FIELDTYPE_LISTBOX: | |
| 3014 vp << L"listbox"; | |
| 3015 break; | |
| 3016 case FIELDTYPE_TEXTFIELD: | |
| 3017 vp << L"text"; | |
| 3018 break; | |
| 3019 case FIELDTYPE_SIGNATURE: | |
| 3020 vp << L"signature"; | |
| 3021 break; | |
| 3022 default : | |
| 3023 vp << L"unknown"; | |
| 3024 break; | |
| 3025 } | |
| 3026 | |
| 3027 return TRUE; | |
| 3028 } | |
| 3029 | |
| 3030 FX_BOOL Field::userName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | |
| 3031 { | |
| 3032 ASSERT(m_pDocument != NULL); | |
| 3033 | |
| 3034 if (vp.IsSetting()) | |
| 3035 { | |
| 3036 if (!m_bCanSet) return FALSE; | |
| 3037 | |
| 3038 CFX_WideString swName; | |
| 3039 vp >> swName; | |
| 3040 | |
| 3041 if (m_bDelay) | |
| 3042 { | |
| 3043 AddDelay_WideString(FP_USERNAME, swName); | |
| 3044 } | |
| 3045 else | |
| 3046 { | |
| 3047 Field::SetUserName(m_pDocument, m_FieldName, m_nFormControlIndex, sw
Name); | |
| 3048 } | |
| 3049 } | |
| 3050 else | |
| 3051 { | |
| 3052 CFX_PtrArray FieldArray; | |
| 3053 GetFormFields(m_FieldName,FieldArray); | |
| 3054 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 3055 | |
| 3056 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 3057 ASSERT(pFormField != NULL); | |
| 3058 | |
| 3059 vp << (CFX_WideString)pFormField->GetAlternateName(); | |
| 3060 } | |
| 3061 | |
| 3062 return TRUE; | |
| 3063 } | |
| 3064 | |
| 3065 void Field::SetUserName(CPDFSDK_Document* pDocument, const CFX_WideString& swFie
ldName, int nControlIndex, const CFX_WideString& string) | |
| 3066 { | |
| 3067 //Not supported. | |
| 3068 } | |
| 3069 | |
| 3070 FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) | |
| 3071 { | |
| 3072 ASSERT(m_pDocument != NULL); | |
| 3073 | |
| 3074 if (vp.IsSetting()) | |
| 3075 { | |
| 3076 if (!m_bCanSet) return FALSE; | |
| 3077 | |
| 3078 CJS_WideStringArray strArray; | |
| 3079 | |
| 3080 if (vp.IsArrayObject()) | |
| 3081 { | |
| 3082 CJS_Array ValueArray(m_isolate); | |
| 3083 vp.ConvertToArray(ValueArray); | |
| 3084 for (int i = 0,sz = ValueArray.GetLength(); i < sz; i++) | |
| 3085 { | |
| 3086 CJS_Value ElementValue(m_isolate); | |
| 3087 ValueArray.GetElement(i, ElementValue); | |
| 3088 strArray.Add(ElementValue.ToCFXWideString()); | |
| 3089 } | |
| 3090 } | |
| 3091 else | |
| 3092 { | |
| 3093 CFX_WideString swValue; | |
| 3094 vp >> swValue; | |
| 3095 | |
| 3096 strArray.Add(swValue); | |
| 3097 } | |
| 3098 | |
| 3099 if (m_bDelay) | |
| 3100 { | |
| 3101 AddDelay_WideStringArray(FP_VALUE, strArray); | |
| 3102 } | |
| 3103 else | |
| 3104 { | |
| 3105 Field::SetValue(m_pDocument, m_FieldName, m_nFormControlIndex, strAr
ray); | |
| 3106 } | |
| 3107 } | |
| 3108 else | |
| 3109 { | |
| 3110 CFX_PtrArray FieldArray; | |
| 3111 GetFormFields(m_FieldName,FieldArray); | |
| 3112 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 3113 | |
| 3114 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 3115 ASSERT(pFormField != NULL); | |
| 3116 | |
| 3117 | |
| 3118 | |
| 3119 switch (pFormField->GetFieldType()) | |
| 3120 { | |
| 3121 case FIELDTYPE_PUSHBUTTON: | |
| 3122 return FALSE; | |
| 3123 case FIELDTYPE_COMBOBOX: | |
| 3124 case FIELDTYPE_TEXTFIELD: | |
| 3125 { | |
| 3126 CFX_WideString swValue = pFormField->GetValue(); | |
| 3127 | |
| 3128 double dRet; | |
| 3129 FX_BOOL bDot; | |
| 3130 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dR
et, bDot)) | |
| 3131 { | |
| 3132 if (bDot) | |
| 3133 vp << dRet; | |
| 3134 else | |
| 3135 vp << dRet; | |
| 3136 } | |
| 3137 else | |
| 3138 vp << swValue; | |
| 3139 } | |
| 3140 break; | |
| 3141 case FIELDTYPE_LISTBOX: | |
| 3142 { | |
| 3143 if (pFormField->CountSelectedItems() > 1) | |
| 3144 { | |
| 3145 CJS_Array ValueArray(m_isolate); | |
| 3146 CJS_Value ElementValue(m_isolate); | |
| 3147 int iIndex; | |
| 3148 for (int i = 0, sz = pFormField->CountSelectedItems(); i < s
z; i++) | |
| 3149 { | |
| 3150 iIndex = pFormField->GetSelectedIndex(i); | |
| 3151 ElementValue = pFormField->GetOptionValue(iIndex).c_str(
); | |
| 3152 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str())
== 0) | |
| 3153 ElementValue = pFormField->GetOptionLabel(iIndex).c_
str(); | |
| 3154 ValueArray.SetElement(i, ElementValue); | |
| 3155 } | |
| 3156 vp << ValueArray; | |
| 3157 } | |
| 3158 else | |
| 3159 { | |
| 3160 CFX_WideString swValue = pFormField->GetValue(); | |
| 3161 | |
| 3162 double dRet; | |
| 3163 FX_BOOL bDot; | |
| 3164 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str()
, dRet, bDot)) | |
| 3165 { | |
| 3166 if (bDot) | |
| 3167 vp << dRet; | |
| 3168 else | |
| 3169 vp << dRet; | |
| 3170 } | |
| 3171 else | |
| 3172 vp << swValue; | |
| 3173 } | |
| 3174 } | |
| 3175 break; | |
| 3176 case FIELDTYPE_CHECKBOX: | |
| 3177 case FIELDTYPE_RADIOBUTTON: | |
| 3178 { | |
| 3179 FX_BOOL bFind = FALSE; | |
| 3180 for (int i = 0 , sz = pFormField->CountControls(); i < sz; i++) | |
| 3181 { | |
| 3182 if (pFormField->GetControl(i)->IsChecked()) | |
| 3183 { | |
| 3184 CFX_WideString swValue = pFormField->GetControl(i)->GetE
xportValue(); | |
| 3185 double dRet; | |
| 3186 FX_BOOL bDot; | |
| 3187 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_s
tr(), dRet, bDot)) | |
| 3188 { | |
| 3189 if (bDot) | |
| 3190 vp << dRet; | |
| 3191 else | |
| 3192 vp << dRet; | |
| 3193 } | |
| 3194 else | |
| 3195 vp << swValue; | |
| 3196 | |
| 3197 bFind = TRUE; | |
| 3198 break; | |
| 3199 } | |
| 3200 else | |
| 3201 continue; | |
| 3202 } | |
| 3203 if (!bFind) | |
| 3204 vp << L"Off"; | |
| 3205 } | |
| 3206 break; | |
| 3207 default: | |
| 3208 vp << pFormField->GetValue(); | |
| 3209 break; | |
| 3210 } | |
| 3211 } | |
| 3212 | |
| 3213 return TRUE; | |
| 3214 } | |
| 3215 | |
| 3216 void Field::SetValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldN
ame, | |
| 3217 int nControlIndex, const CJS_WideStringArray& strArray) | |
| 3218 { | |
| 3219 ASSERT(pDocument != NULL); | |
| 3220 | |
| 3221 if (strArray.GetSize() < 1) return; | |
| 3222 | |
| 3223 CFX_PtrArray FieldArray; | |
| 3224 GetFormFields(pDocument, swFieldName, FieldArray); | |
| 3225 | |
| 3226 for (int i=0,isz=FieldArray.GetSize(); i<isz; i++) | |
| 3227 { | |
| 3228 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | |
| 3229 ASSERT(pFormField != NULL); | |
| 3230 | |
| 3231 if (pFormField->GetFullName().Compare(swFieldName) != 0) | |
| 3232 continue; | |
| 3233 | |
| 3234 switch (pFormField->GetFieldType()) | |
| 3235 { | |
| 3236 case FIELDTYPE_TEXTFIELD: | |
| 3237 case FIELDTYPE_COMBOBOX: | |
| 3238 if (pFormField->GetValue() != strArray.GetAt(0)) | |
| 3239 { | |
| 3240 CFX_WideString WideString = strArray.GetAt(0); | |
| 3241 pFormField->SetValue(strArray.GetAt(0), TRUE); | |
| 3242 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); | |
| 3243 } | |
| 3244 break; | |
| 3245 case FIELDTYPE_CHECKBOX: //mantis: 0004493 | |
| 3246 case FIELDTYPE_RADIOBUTTON: | |
| 3247 { | |
| 3248 if (pFormField->GetValue() != strArray.GetAt(0)) | |
| 3249 { | |
| 3250 pFormField->SetValue(strArray.GetAt(0), TRUE); | |
| 3251 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); | |
| 3252 } | |
| 3253 } | |
| 3254 break; | |
| 3255 case FIELDTYPE_LISTBOX: | |
| 3256 { | |
| 3257 FX_BOOL bModified = FALSE; | |
| 3258 | |
| 3259 for (int i=0,sz=strArray.GetSize(); i<sz; i++) | |
| 3260 { | |
| 3261 int iIndex = pFormField->FindOption(strArray.GetAt(i)); | |
| 3262 | |
| 3263 if (!pFormField->IsItemSelected(iIndex)) | |
| 3264 { | |
| 3265 bModified = TRUE; | |
| 3266 break; | |
| 3267 } | |
| 3268 } | |
| 3269 | |
| 3270 if (bModified) | |
| 3271 { | |
| 3272 pFormField->ClearSelection(TRUE); | |
| 3273 for (int i=0,sz=strArray.GetSize(); i<sz; i++) | |
| 3274 { | |
| 3275 int iIndex = pFormField->FindOption(strArray.GetAt(i)); | |
| 3276 pFormField->SetItemSelection(iIndex, TRUE, TRUE); | |
| 3277 } | |
| 3278 | |
| 3279 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); | |
| 3280 } | |
| 3281 } | |
| 3282 break; | |
| 3283 default: | |
| 3284 break; | |
| 3285 } | |
| 3286 } | |
| 3287 } | |
| 3288 | |
| 3289 FX_BOOL Field::valueAsString(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStrin
g& sError) | |
| 3290 { | |
| 3291 ASSERT(m_pDocument != NULL); | |
| 3292 | |
| 3293 if (!vp.IsGetting()) return FALSE; | |
| 3294 | |
| 3295 CFX_PtrArray FieldArray; | |
| 3296 GetFormFields(m_FieldName,FieldArray); | |
| 3297 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 3298 | |
| 3299 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 3300 ASSERT(pFormField != NULL); | |
| 3301 | |
| 3302 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) | |
| 3303 return FALSE; | |
| 3304 | |
| 3305 if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) | |
| 3306 { | |
| 3307 if(!pFormField->CountControls()) return FALSE; | |
| 3308 | |
| 3309 if (pFormField->GetControl(0)->IsChecked()) | |
| 3310 vp << L"Yes"; | |
| 3311 else | |
| 3312 vp << L"Off"; | |
| 3313 } | |
| 3314 else if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON && !(pFormField
->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) | |
| 3315 { | |
| 3316 for (int i=0, sz=pFormField->CountControls(); i<sz; i++) | |
| 3317 { | |
| 3318 if (pFormField->GetControl(i)->IsChecked()) | |
| 3319 { | |
| 3320 vp << pFormField->GetControl(i)->GetExportValue().c_str(); | |
| 3321 break; | |
| 3322 } | |
| 3323 else | |
| 3324 vp << L"Off"; | |
| 3325 } | |
| 3326 } | |
| 3327 else if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX && (pFormField->Cou
ntSelectedItems() > 1)) | |
| 3328 { | |
| 3329 vp << L""; | |
| 3330 } | |
| 3331 else | |
| 3332 vp << pFormField->GetValue().c_str(); | |
| 3333 | |
| 3334 return TRUE; | |
| 3335 } | |
| 3336 | |
| 3337 /* --------------------------------- methods --------------------------------- *
/ | |
| 3338 | |
| 3339 FX_BOOL Field::browseForFileToSubmit(IFXJS_Context* cc, const CJS_Parameters& pa
rams, CJS_Value& vRet, CFX_WideString& sError) | |
| 3340 { | |
| 3341 ASSERT(m_pDocument != NULL); | |
| 3342 | |
| 3343 CFX_PtrArray FieldArray; | 1209 CFX_PtrArray FieldArray; |
| 3344 GetFormFields(m_FieldName, FieldArray); | 1210 GetFormFields(m_FieldName, FieldArray); |
| 3345 if (FieldArray.GetSize() <= 0) return FALSE; | 1211 if (FieldArray.GetSize() <= 0) |
| 3346 | 1212 return FALSE; |
| 3347 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1213 |
| 3348 ASSERT(pFormField != NULL); | 1214 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3349 | 1215 ASSERT(pFormField != NULL); |
| 3350 CPDFDoc_Environment* pApp = m_pDocument->GetEnv(); | 1216 |
| 3351 ASSERT(pApp != NULL); | 1217 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
| 3352 | 1218 return FALSE; |
| 3353 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && | 1219 |
| 3354 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) | 1220 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL) |
| 3355 { | 1221 vp << true; |
| 3356 CFX_WideString wsFileName = pApp->JS_fieldBrowse(); | |
| 3357 if(!wsFileName.IsEmpty()) | |
| 3358 { | |
| 3359 pFormField->SetValue(wsFileName); | |
| 3360 UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE); | |
| 3361 } | |
| 3362 } | |
| 3363 else | 1222 else |
| 1223 vp << false; |
| 1224 } |
| 1225 |
| 1226 return TRUE; |
| 1227 } |
| 1228 |
| 1229 void Field::SetDoNotScroll(CPDFSDK_Document* pDocument, |
| 1230 const CFX_WideString& swFieldName, |
| 1231 int nControlIndex, |
| 1232 bool b) { |
| 1233 // Not supported. |
| 1234 } |
| 1235 |
| 1236 FX_BOOL Field::doNotSpellCheck(IFXJS_Context* cc, |
| 1237 CJS_PropValue& vp, |
| 1238 CFX_WideString& sError) { |
| 1239 ASSERT(m_pDocument != NULL); |
| 1240 |
| 1241 if (vp.IsSetting()) { |
| 1242 if (!m_bCanSet) |
| 1243 return FALSE; |
| 1244 |
| 1245 bool bVP; |
| 1246 vp >> bVP; |
| 1247 } else { |
| 1248 CFX_PtrArray FieldArray; |
| 1249 GetFormFields(m_FieldName, FieldArray); |
| 1250 if (FieldArray.GetSize() <= 0) |
| 1251 return FALSE; |
| 1252 |
| 1253 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1254 ASSERT(pFormField != NULL); |
| 1255 |
| 1256 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD && |
| 1257 pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) |
| 1258 return FALSE; |
| 1259 |
| 1260 if (pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK) |
| 1261 vp << true; |
| 1262 else |
| 1263 vp << false; |
| 1264 } |
| 1265 |
| 1266 return TRUE; |
| 1267 } |
| 1268 |
| 1269 void Field::SetDelay(FX_BOOL bDelay) { |
| 1270 m_bDelay = bDelay; |
| 1271 |
| 1272 if (!m_bDelay) { |
| 1273 if (m_pJSDoc) |
| 1274 m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex); |
| 1275 } |
| 1276 } |
| 1277 |
| 1278 FX_BOOL Field::delay(IFXJS_Context* cc, |
| 1279 CJS_PropValue& vp, |
| 1280 CFX_WideString& sError) { |
| 1281 if (vp.IsSetting()) { |
| 1282 if (!m_bCanSet) |
| 1283 return FALSE; |
| 1284 |
| 1285 bool bVP; |
| 1286 vp >> bVP; |
| 1287 |
| 1288 SetDelay(bVP); |
| 1289 } else { |
| 1290 vp << m_bDelay; |
| 1291 } |
| 1292 return TRUE; |
| 1293 } |
| 1294 |
| 1295 FX_BOOL Field::display(IFXJS_Context* cc, |
| 1296 CJS_PropValue& vp, |
| 1297 CFX_WideString& sError) { |
| 1298 ASSERT(m_pDocument != NULL); |
| 1299 |
| 1300 if (vp.IsSetting()) { |
| 1301 if (!m_bCanSet) |
| 1302 return FALSE; |
| 1303 |
| 1304 int nVP; |
| 1305 vp >> nVP; |
| 1306 |
| 1307 if (m_bDelay) { |
| 1308 AddDelay_Int(FP_DISPLAY, nVP); |
| 1309 } else { |
| 1310 Field::SetDisplay(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); |
| 1311 } |
| 1312 } else { |
| 1313 CFX_PtrArray FieldArray; |
| 1314 GetFormFields(m_FieldName, FieldArray); |
| 1315 if (FieldArray.GetSize() <= 0) |
| 1316 return FALSE; |
| 1317 |
| 1318 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1319 ASSERT(pFormField != NULL); |
| 1320 |
| 1321 CPDFSDK_InterForm* pInterForm = |
| 1322 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
| 1323 ASSERT(pInterForm != NULL); |
| 1324 |
| 1325 CPDFSDK_Widget* pWidget = |
| 1326 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
| 1327 if (!pWidget) |
| 1328 return FALSE; |
| 1329 |
| 1330 FX_DWORD dwFlag = pWidget->GetFlags(); |
| 1331 |
| 1332 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { |
| 1333 vp << (int32_t)1; |
| 1334 } else { |
| 1335 if (ANNOTFLAG_PRINT & dwFlag) { |
| 1336 if (ANNOTFLAG_NOVIEW & dwFlag) { |
| 1337 vp << (int32_t)3; |
| 1338 } else { |
| 1339 vp << (int32_t)0; |
| 1340 } |
| 1341 } else { |
| 1342 vp << (int32_t)2; |
| 1343 } |
| 1344 } |
| 1345 } |
| 1346 |
| 1347 return TRUE; |
| 1348 } |
| 1349 |
| 1350 void Field::SetDisplay(CPDFSDK_Document* pDocument, |
| 1351 const CFX_WideString& swFieldName, |
| 1352 int nControlIndex, |
| 1353 int number) { |
| 1354 ASSERT(pDocument != NULL); |
| 1355 |
| 1356 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 1357 ASSERT(pInterForm != NULL); |
| 1358 |
| 1359 CFX_PtrArray FieldArray; |
| 1360 GetFormFields(pDocument, swFieldName, FieldArray); |
| 1361 |
| 1362 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { |
| 1363 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); |
| 1364 ASSERT(pFormField != NULL); |
| 1365 |
| 1366 if (nControlIndex < 0) { |
| 1367 FX_BOOL bSet = FALSE; |
| 1368 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { |
| 1369 CPDF_FormControl* pFormControl = pFormField->GetControl(j); |
| 1370 ASSERT(pFormControl != NULL); |
| 1371 |
| 1372 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
| 1373 FX_DWORD dwFlag = pWidget->GetFlags(); |
| 1374 switch (number) { |
| 1375 case 0: |
| 1376 dwFlag &= (~ANNOTFLAG_INVISIBLE); |
| 1377 dwFlag &= (~ANNOTFLAG_HIDDEN); |
| 1378 dwFlag &= (~ANNOTFLAG_NOVIEW); |
| 1379 dwFlag |= ANNOTFLAG_PRINT; |
| 1380 break; |
| 1381 case 1: |
| 1382 dwFlag &= (~ANNOTFLAG_INVISIBLE); |
| 1383 dwFlag &= (~ANNOTFLAG_NOVIEW); |
| 1384 dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); |
| 1385 break; |
| 1386 case 2: |
| 1387 dwFlag &= (~ANNOTFLAG_INVISIBLE); |
| 1388 dwFlag &= (~ANNOTFLAG_PRINT); |
| 1389 dwFlag &= (~ANNOTFLAG_HIDDEN); |
| 1390 dwFlag &= (~ANNOTFLAG_NOVIEW); |
| 1391 break; |
| 1392 case 3: |
| 1393 dwFlag |= ANNOTFLAG_NOVIEW; |
| 1394 dwFlag |= ANNOTFLAG_PRINT; |
| 1395 dwFlag &= (~ANNOTFLAG_HIDDEN); |
| 1396 break; |
| 1397 } |
| 1398 |
| 1399 if (dwFlag != pWidget->GetFlags()) { |
| 1400 pWidget->SetFlags(dwFlag); |
| 1401 bSet = TRUE; |
| 1402 } |
| 1403 } |
| 1404 } |
| 1405 |
| 1406 if (bSet) |
| 1407 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); |
| 1408 } else { |
| 1409 if (nControlIndex >= pFormField->CountControls()) |
| 1410 return; |
| 1411 if (CPDF_FormControl* pFormControl = |
| 1412 pFormField->GetControl(nControlIndex)) { |
| 1413 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
| 1414 FX_DWORD dwFlag = pWidget->GetFlags(); |
| 1415 switch (number) { |
| 1416 case 0: |
| 1417 dwFlag &= (~ANNOTFLAG_INVISIBLE); |
| 1418 dwFlag &= (~ANNOTFLAG_HIDDEN); |
| 1419 dwFlag &= (~ANNOTFLAG_NOVIEW); |
| 1420 dwFlag |= ANNOTFLAG_PRINT; |
| 1421 break; |
| 1422 case 1: |
| 1423 dwFlag &= (~ANNOTFLAG_INVISIBLE); |
| 1424 dwFlag &= (~ANNOTFLAG_NOVIEW); |
| 1425 dwFlag |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); |
| 1426 break; |
| 1427 case 2: |
| 1428 dwFlag &= (~ANNOTFLAG_INVISIBLE); |
| 1429 dwFlag &= (~ANNOTFLAG_PRINT); |
| 1430 dwFlag &= (~ANNOTFLAG_HIDDEN); |
| 1431 dwFlag &= (~ANNOTFLAG_NOVIEW); |
| 1432 break; |
| 1433 case 3: |
| 1434 dwFlag |= ANNOTFLAG_NOVIEW; |
| 1435 dwFlag |= ANNOTFLAG_PRINT; |
| 1436 dwFlag &= (~ANNOTFLAG_HIDDEN); |
| 1437 break; |
| 1438 } |
| 1439 if (dwFlag != pWidget->GetFlags()) { |
| 1440 pWidget->SetFlags(dwFlag); |
| 1441 UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE); |
| 1442 } |
| 1443 } |
| 1444 } |
| 1445 } |
| 1446 } |
| 1447 } |
| 1448 |
| 1449 FX_BOOL Field::doc(IFXJS_Context* cc, |
| 1450 CJS_PropValue& vp, |
| 1451 CFX_WideString& sError) { |
| 1452 if (!vp.IsGetting()) { |
| 1453 return FALSE; |
| 1454 } |
| 1455 vp << m_pJSDoc->GetCJSDoc(); |
| 1456 return TRUE; |
| 1457 } |
| 1458 |
| 1459 FX_BOOL Field::editable(IFXJS_Context* cc, |
| 1460 CJS_PropValue& vp, |
| 1461 CFX_WideString& sError) { |
| 1462 ASSERT(m_pDocument != NULL); |
| 1463 if (vp.IsSetting()) { |
| 1464 if (!m_bCanSet) |
| 1465 return FALSE; |
| 1466 |
| 1467 bool bVP; |
| 1468 vp >> bVP; |
| 1469 } else { |
| 1470 CFX_PtrArray FieldArray; |
| 1471 GetFormFields(m_FieldName, FieldArray); |
| 1472 if (FieldArray.GetSize() <= 0) |
| 1473 return FALSE; |
| 1474 |
| 1475 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1476 ASSERT(pFormField != NULL); |
| 1477 |
| 1478 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) |
| 1479 return FALSE; |
| 1480 |
| 1481 if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT) |
| 1482 vp << true; |
| 1483 else |
| 1484 vp << false; |
| 1485 } |
| 1486 |
| 1487 return TRUE; |
| 1488 } |
| 1489 |
| 1490 FX_BOOL Field::exportValues(IFXJS_Context* cc, |
| 1491 CJS_PropValue& vp, |
| 1492 CFX_WideString& sError) { |
| 1493 ASSERT(m_pDocument != NULL); |
| 1494 |
| 1495 CFX_PtrArray FieldArray; |
| 1496 GetFormFields(m_FieldName, FieldArray); |
| 1497 if (FieldArray.GetSize() <= 0) |
| 1498 return FALSE; |
| 1499 |
| 1500 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1501 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && |
| 1502 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) |
| 1503 return FALSE; |
| 1504 |
| 1505 if (vp.IsSetting()) { |
| 1506 if (!m_bCanSet) |
| 1507 return FALSE; |
| 1508 |
| 1509 if (!vp.IsArrayObject()) |
| 1510 return FALSE; |
| 1511 } else { |
| 1512 CJS_Array ExportValusArray(m_isolate); |
| 1513 if (m_nFormControlIndex < 0) { |
| 1514 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
| 1515 CPDF_FormControl* pFormControl = pFormField->GetControl(i); |
| 1516 ExportValusArray.SetElement( |
| 1517 i, CJS_Value(m_isolate, pFormControl->GetExportValue().c_str())); |
| 1518 } |
| 1519 } else { |
| 1520 if (m_nFormControlIndex >= pFormField->CountControls()) |
| 3364 return FALSE; | 1521 return FALSE; |
| 3365 | 1522 |
| 3366 return TRUE; | 1523 CPDF_FormControl* pFormControl = |
| 3367 } | 1524 pFormField->GetControl(m_nFormControlIndex); |
| 3368 | 1525 if (!pFormControl) |
| 3369 | 1526 return FALSE; |
| 3370 FX_BOOL Field::buttonGetCaption(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 1527 |
| 3371 { | 1528 ExportValusArray.SetElement( |
| 3372 ASSERT(m_pDocument != NULL); | 1529 0, CJS_Value(m_isolate, pFormControl->GetExportValue().c_str())); |
| 3373 | 1530 } |
| 3374 int nface = 0; | 1531 vp << ExportValusArray; |
| 3375 int iSize = params.size(); | 1532 } |
| 3376 if (iSize >= 1) | 1533 return TRUE; |
| 3377 nface = params[0].ToInt(); | 1534 } |
| 3378 | 1535 |
| 1536 FX_BOOL Field::fileSelect(IFXJS_Context* cc, |
| 1537 CJS_PropValue& vp, |
| 1538 CFX_WideString& sError) { |
| 1539 ASSERT(m_pDocument != NULL); |
| 1540 |
| 1541 CFX_PtrArray FieldArray; |
| 1542 GetFormFields(m_FieldName, FieldArray); |
| 1543 if (FieldArray.GetSize() <= 0) |
| 1544 return FALSE; |
| 1545 |
| 1546 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1547 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
| 1548 return FALSE; |
| 1549 |
| 1550 if (vp.IsSetting()) { |
| 1551 if (!m_bCanSet) |
| 1552 return FALSE; |
| 1553 |
| 1554 bool bVP; |
| 1555 vp >> bVP; |
| 1556 } else { |
| 1557 if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) |
| 1558 vp << true; |
| 1559 else |
| 1560 vp << false; |
| 1561 } |
| 1562 return TRUE; |
| 1563 } |
| 1564 |
| 1565 FX_BOOL Field::fillColor(IFXJS_Context* cc, |
| 1566 CJS_PropValue& vp, |
| 1567 CFX_WideString& sError) { |
| 1568 ASSERT(m_pDocument != NULL); |
| 1569 |
| 1570 CJS_Array crArray(m_isolate); |
| 1571 |
| 1572 CFX_PtrArray FieldArray; |
| 1573 GetFormFields(m_FieldName, FieldArray); |
| 1574 if (FieldArray.GetSize() <= 0) |
| 1575 return FALSE; |
| 1576 |
| 1577 if (vp.IsSetting()) { |
| 1578 if (!m_bCanSet) |
| 1579 return FALSE; |
| 1580 |
| 1581 if (!vp.IsArrayObject()) |
| 1582 return FALSE; |
| 1583 |
| 1584 vp >> crArray; |
| 1585 |
| 1586 CPWL_Color color; |
| 1587 color::ConvertArrayToPWLColor(crArray, color); |
| 1588 if (m_bDelay) { |
| 1589 AddDelay_Color(FP_FILLCOLOR, color); |
| 1590 } else { |
| 1591 Field::SetFillColor(m_pDocument, m_FieldName, m_nFormControlIndex, color); |
| 1592 } |
| 1593 } else { |
| 1594 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1595 ASSERT(pFormField != NULL); |
| 1596 |
| 1597 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 1598 if (!pFormControl) |
| 1599 return FALSE; |
| 1600 |
| 1601 int iColorType; |
| 1602 pFormControl->GetBackgroundColor(iColorType); |
| 1603 |
| 1604 CPWL_Color color; |
| 1605 if (iColorType == COLORTYPE_TRANSPARENT) { |
| 1606 color = CPWL_Color(COLORTYPE_TRANSPARENT); |
| 1607 } else if (iColorType == COLORTYPE_GRAY) { |
| 1608 color = CPWL_Color(COLORTYPE_GRAY, |
| 1609 pFormControl->GetOriginalBackgroundColor(0)); |
| 1610 } else if (iColorType == COLORTYPE_RGB) { |
| 1611 color = |
| 1612 CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0), |
| 1613 pFormControl->GetOriginalBackgroundColor(1), |
| 1614 pFormControl->GetOriginalBackgroundColor(2)); |
| 1615 } else if (iColorType == COLORTYPE_CMYK) { |
| 1616 color = CPWL_Color(COLORTYPE_CMYK, |
| 1617 pFormControl->GetOriginalBackgroundColor(0), |
| 1618 pFormControl->GetOriginalBackgroundColor(1), |
| 1619 pFormControl->GetOriginalBackgroundColor(2), |
| 1620 pFormControl->GetOriginalBackgroundColor(3)); |
| 1621 } else |
| 1622 return FALSE; |
| 1623 |
| 1624 color::ConvertPWLColorToArray(color, crArray); |
| 1625 vp << crArray; |
| 1626 } |
| 1627 |
| 1628 return TRUE; |
| 1629 } |
| 1630 |
| 1631 void Field::SetFillColor(CPDFSDK_Document* pDocument, |
| 1632 const CFX_WideString& swFieldName, |
| 1633 int nControlIndex, |
| 1634 const CPWL_Color& color) { |
| 1635 // Not supported. |
| 1636 } |
| 1637 |
| 1638 FX_BOOL Field::hidden(IFXJS_Context* cc, |
| 1639 CJS_PropValue& vp, |
| 1640 CFX_WideString& sError) { |
| 1641 ASSERT(m_pDocument != NULL); |
| 1642 |
| 1643 if (vp.IsSetting()) { |
| 1644 if (!m_bCanSet) |
| 1645 return FALSE; |
| 1646 |
| 1647 bool bVP; |
| 1648 vp >> bVP; |
| 1649 |
| 1650 if (m_bDelay) { |
| 1651 AddDelay_Bool(FP_HIDDEN, bVP); |
| 1652 } else { |
| 1653 Field::SetHidden(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
| 1654 } |
| 1655 } else { |
| 3379 CFX_PtrArray FieldArray; | 1656 CFX_PtrArray FieldArray; |
| 3380 GetFormFields(m_FieldName,FieldArray); | 1657 GetFormFields(m_FieldName, FieldArray); |
| 3381 if (FieldArray.GetSize() <= 0) return FALSE; | 1658 if (FieldArray.GetSize() <= 0) |
| 1659 return FALSE; |
| 1660 |
| 1661 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1662 ASSERT(pFormField != NULL); |
| 1663 |
| 1664 CPDFSDK_InterForm* pInterForm = |
| 1665 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
| 1666 ASSERT(pInterForm != NULL); |
| 1667 |
| 1668 CPDFSDK_Widget* pWidget = |
| 1669 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
| 1670 if (!pWidget) |
| 1671 return FALSE; |
| 1672 |
| 1673 FX_DWORD dwFlags = pWidget->GetFlags(); |
| 1674 |
| 1675 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) { |
| 1676 vp << true; |
| 1677 } else |
| 1678 vp << false; |
| 1679 } |
| 1680 |
| 1681 return TRUE; |
| 1682 } |
| 1683 |
| 1684 void Field::SetHidden(CPDFSDK_Document* pDocument, |
| 1685 const CFX_WideString& swFieldName, |
| 1686 int nControlIndex, |
| 1687 bool b) { |
| 1688 ASSERT(pDocument != NULL); |
| 1689 |
| 1690 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 1691 ASSERT(pInterForm != NULL); |
| 1692 |
| 1693 CFX_PtrArray FieldArray; |
| 1694 GetFormFields(pDocument, swFieldName, FieldArray); |
| 1695 |
| 1696 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { |
| 1697 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); |
| 1698 ASSERT(pFormField != NULL); |
| 1699 |
| 1700 if (nControlIndex < 0) { |
| 1701 FX_BOOL bSet = FALSE; |
| 1702 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { |
| 1703 if (CPDFSDK_Widget* pWidget = |
| 1704 pInterForm->GetWidget(pFormField->GetControl(j))) { |
| 1705 FX_DWORD dwFlags = pWidget->GetFlags(); |
| 1706 |
| 1707 if (b) { |
| 1708 dwFlags &= (~ANNOTFLAG_INVISIBLE); |
| 1709 dwFlags &= (~ANNOTFLAG_NOVIEW); |
| 1710 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); |
| 1711 } else { |
| 1712 dwFlags &= (~ANNOTFLAG_INVISIBLE); |
| 1713 dwFlags &= (~ANNOTFLAG_HIDDEN); |
| 1714 dwFlags &= (~ANNOTFLAG_NOVIEW); |
| 1715 dwFlags |= ANNOTFLAG_PRINT; |
| 1716 } |
| 1717 |
| 1718 if (dwFlags != pWidget->GetFlags()) { |
| 1719 pWidget->SetFlags(dwFlags); |
| 1720 bSet = TRUE; |
| 1721 } |
| 1722 } |
| 1723 } |
| 1724 |
| 1725 if (bSet) |
| 1726 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); |
| 1727 } else { |
| 1728 if (nControlIndex >= pFormField->CountControls()) |
| 1729 return; |
| 1730 if (CPDF_FormControl* pFormControl = |
| 1731 pFormField->GetControl(nControlIndex)) { |
| 1732 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
| 1733 FX_DWORD dwFlags = pWidget->GetFlags(); |
| 1734 |
| 1735 if (b) { |
| 1736 dwFlags &= (~ANNOTFLAG_INVISIBLE); |
| 1737 dwFlags &= (~ANNOTFLAG_NOVIEW); |
| 1738 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); |
| 1739 } else { |
| 1740 dwFlags &= (~ANNOTFLAG_INVISIBLE); |
| 1741 dwFlags &= (~ANNOTFLAG_HIDDEN); |
| 1742 dwFlags &= (~ANNOTFLAG_NOVIEW); |
| 1743 dwFlags |= ANNOTFLAG_PRINT; |
| 1744 } |
| 1745 |
| 1746 if (dwFlags != pWidget->GetFlags()) { |
| 1747 pWidget->SetFlags(dwFlags); |
| 1748 UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE); |
| 1749 } |
| 1750 } |
| 1751 } |
| 1752 } |
| 1753 } |
| 1754 } |
| 1755 |
| 1756 FX_BOOL Field::highlight(IFXJS_Context* cc, |
| 1757 CJS_PropValue& vp, |
| 1758 CFX_WideString& sError) { |
| 1759 ASSERT(m_pDocument != NULL); |
| 1760 |
| 1761 if (vp.IsSetting()) { |
| 1762 if (!m_bCanSet) |
| 1763 return FALSE; |
| 1764 |
| 1765 CFX_ByteString strMode; |
| 1766 vp >> strMode; |
| 1767 |
| 1768 if (m_bDelay) { |
| 1769 AddDelay_String(FP_HIGHLIGHT, strMode); |
| 1770 } else { |
| 1771 Field::SetHighlight(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 1772 strMode); |
| 1773 } |
| 1774 } else { |
| 1775 CFX_PtrArray FieldArray; |
| 1776 GetFormFields(m_FieldName, FieldArray); |
| 1777 if (FieldArray.GetSize() <= 0) |
| 1778 return FALSE; |
| 3382 | 1779 |
| 3383 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1780 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3384 ASSERT(pFormField != NULL); | 1781 ASSERT(pFormField != NULL); |
| 3385 | 1782 |
| 3386 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 1783 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 1784 return FALSE; |
| 1785 |
| 1786 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 1787 if (!pFormControl) |
| 1788 return FALSE; |
| 1789 |
| 1790 int eHM = pFormControl->GetHighlightingMode(); |
| 1791 switch (eHM) { |
| 1792 case CPDF_FormControl::None: |
| 1793 vp << L"none"; |
| 1794 break; |
| 1795 case CPDF_FormControl::Push: |
| 1796 vp << L"push"; |
| 1797 break; |
| 1798 case CPDF_FormControl::Invert: |
| 1799 vp << L"invert"; |
| 1800 break; |
| 1801 case CPDF_FormControl::Outline: |
| 1802 vp << L"outline"; |
| 1803 break; |
| 1804 case CPDF_FormControl::Toggle: |
| 1805 vp << L"toggle"; |
| 1806 break; |
| 1807 } |
| 1808 } |
| 1809 |
| 1810 return TRUE; |
| 1811 } |
| 1812 |
| 1813 void Field::SetHighlight(CPDFSDK_Document* pDocument, |
| 1814 const CFX_WideString& swFieldName, |
| 1815 int nControlIndex, |
| 1816 const CFX_ByteString& string) { |
| 1817 // Not supported. |
| 1818 } |
| 1819 |
| 1820 FX_BOOL Field::lineWidth(IFXJS_Context* cc, |
| 1821 CJS_PropValue& vp, |
| 1822 CFX_WideString& sError) { |
| 1823 ASSERT(m_pDocument != NULL); |
| 1824 |
| 1825 if (vp.IsSetting()) { |
| 1826 if (!m_bCanSet) |
| 1827 return FALSE; |
| 1828 |
| 1829 int iWidth; |
| 1830 vp >> iWidth; |
| 1831 |
| 1832 if (m_bDelay) { |
| 1833 AddDelay_Int(FP_LINEWIDTH, iWidth); |
| 1834 } else { |
| 1835 Field::SetLineWidth(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 1836 iWidth); |
| 1837 } |
| 1838 } else { |
| 1839 CFX_PtrArray FieldArray; |
| 1840 GetFormFields(m_FieldName, FieldArray); |
| 1841 if (FieldArray.GetSize() <= 0) |
| 1842 return FALSE; |
| 1843 |
| 1844 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1845 ASSERT(pFormField != NULL); |
| 1846 |
| 1847 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 1848 if (!pFormControl) |
| 1849 return FALSE; |
| 1850 |
| 1851 CPDFSDK_InterForm* pInterForm = |
| 1852 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
| 1853 ASSERT(pInterForm != NULL); |
| 1854 |
| 1855 if (!pFormField->CountControls()) |
| 1856 return FALSE; |
| 1857 |
| 1858 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); |
| 1859 if (!pWidget) |
| 1860 return FALSE; |
| 1861 |
| 1862 vp << (int32_t)pWidget->GetBorderWidth(); |
| 1863 } |
| 1864 |
| 1865 return TRUE; |
| 1866 } |
| 1867 |
| 1868 void Field::SetLineWidth(CPDFSDK_Document* pDocument, |
| 1869 const CFX_WideString& swFieldName, |
| 1870 int nControlIndex, |
| 1871 int number) { |
| 1872 ASSERT(pDocument != NULL); |
| 1873 |
| 1874 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 1875 ASSERT(pInterForm != NULL); |
| 1876 |
| 1877 CFX_PtrArray FieldArray; |
| 1878 GetFormFields(pDocument, swFieldName, FieldArray); |
| 1879 |
| 1880 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { |
| 1881 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); |
| 1882 ASSERT(pFormField != NULL); |
| 1883 |
| 1884 if (nControlIndex < 0) { |
| 1885 FX_BOOL bSet = FALSE; |
| 1886 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { |
| 1887 CPDF_FormControl* pFormControl = pFormField->GetControl(j); |
| 1888 ASSERT(pFormControl != NULL); |
| 1889 |
| 1890 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
| 1891 if (number != pWidget->GetBorderWidth()) { |
| 1892 pWidget->SetBorderWidth(number); |
| 1893 bSet = TRUE; |
| 1894 } |
| 1895 } |
| 1896 } |
| 1897 if (bSet) |
| 1898 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); |
| 1899 } else { |
| 1900 if (nControlIndex >= pFormField->CountControls()) |
| 1901 return; |
| 1902 if (CPDF_FormControl* pFormControl = |
| 1903 pFormField->GetControl(nControlIndex)) { |
| 1904 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
| 1905 if (number != pWidget->GetBorderWidth()) { |
| 1906 pWidget->SetBorderWidth(number); |
| 1907 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); |
| 1908 } |
| 1909 } |
| 1910 } |
| 1911 } |
| 1912 } |
| 1913 } |
| 1914 |
| 1915 FX_BOOL Field::multiline(IFXJS_Context* cc, |
| 1916 CJS_PropValue& vp, |
| 1917 CFX_WideString& sError) { |
| 1918 ASSERT(m_pDocument != NULL); |
| 1919 |
| 1920 if (vp.IsSetting()) { |
| 1921 if (!m_bCanSet) |
| 1922 return FALSE; |
| 1923 |
| 1924 bool bVP; |
| 1925 vp >> bVP; |
| 1926 |
| 1927 if (m_bDelay) { |
| 1928 AddDelay_Bool(FP_MULTILINE, bVP); |
| 1929 } else { |
| 1930 Field::SetMultiline(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
| 1931 } |
| 1932 } else { |
| 1933 CFX_PtrArray FieldArray; |
| 1934 GetFormFields(m_FieldName, FieldArray); |
| 1935 if (FieldArray.GetSize() <= 0) |
| 1936 return FALSE; |
| 1937 |
| 1938 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1939 ASSERT(pFormField != NULL); |
| 1940 |
| 1941 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
| 1942 return FALSE; |
| 1943 |
| 1944 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE) |
| 1945 vp << true; |
| 1946 else |
| 1947 vp << false; |
| 1948 } |
| 1949 |
| 1950 return TRUE; |
| 1951 } |
| 1952 |
| 1953 void Field::SetMultiline(CPDFSDK_Document* pDocument, |
| 1954 const CFX_WideString& swFieldName, |
| 1955 int nControlIndex, |
| 1956 bool b) { |
| 1957 // Not supported. |
| 1958 } |
| 1959 |
| 1960 FX_BOOL Field::multipleSelection(IFXJS_Context* cc, |
| 1961 CJS_PropValue& vp, |
| 1962 CFX_WideString& sError) { |
| 1963 ASSERT(m_pDocument != NULL); |
| 1964 |
| 1965 if (vp.IsSetting()) { |
| 1966 if (!m_bCanSet) |
| 1967 return FALSE; |
| 1968 |
| 1969 bool bVP; |
| 1970 vp >> bVP; |
| 1971 |
| 1972 if (m_bDelay) { |
| 1973 AddDelay_Bool(FP_MULTIPLESELECTION, bVP); |
| 1974 } else { |
| 1975 Field::SetMultipleSelection(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 1976 bVP); |
| 1977 } |
| 1978 } else { |
| 1979 CFX_PtrArray FieldArray; |
| 1980 GetFormFields(m_FieldName, FieldArray); |
| 1981 if (FieldArray.GetSize() <= 0) |
| 1982 return FALSE; |
| 1983 |
| 1984 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 1985 ASSERT(pFormField != NULL); |
| 1986 |
| 1987 if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) |
| 1988 return FALSE; |
| 1989 |
| 1990 if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT) |
| 1991 vp << true; |
| 1992 else |
| 1993 vp << false; |
| 1994 } |
| 1995 |
| 1996 return TRUE; |
| 1997 } |
| 1998 |
| 1999 void Field::SetMultipleSelection(CPDFSDK_Document* pDocument, |
| 2000 const CFX_WideString& swFieldName, |
| 2001 int nControlIndex, |
| 2002 bool b) { |
| 2003 // Not supported. |
| 2004 } |
| 2005 |
| 2006 FX_BOOL Field::name(IFXJS_Context* cc, |
| 2007 CJS_PropValue& vp, |
| 2008 CFX_WideString& sError) { |
| 2009 if (!vp.IsGetting()) |
| 2010 return FALSE; |
| 2011 |
| 2012 CFX_PtrArray FieldArray; |
| 2013 GetFormFields(m_FieldName, FieldArray); |
| 2014 if (FieldArray.GetSize() <= 0) |
| 2015 return FALSE; |
| 2016 |
| 2017 vp << m_FieldName; |
| 2018 |
| 2019 return TRUE; |
| 2020 } |
| 2021 |
| 2022 FX_BOOL Field::numItems(IFXJS_Context* cc, |
| 2023 CJS_PropValue& vp, |
| 2024 CFX_WideString& sError) { |
| 2025 CFX_PtrArray FieldArray; |
| 2026 GetFormFields(m_FieldName, FieldArray); |
| 2027 if (FieldArray.GetSize() <= 0) |
| 2028 return FALSE; |
| 2029 |
| 2030 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2031 ASSERT(pFormField != NULL); |
| 2032 |
| 2033 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && |
| 2034 pFormField->GetFieldType() != FIELDTYPE_LISTBOX) |
| 2035 return FALSE; |
| 2036 |
| 2037 if (!vp.IsGetting()) |
| 2038 return FALSE; |
| 2039 |
| 2040 vp << (int32_t)pFormField->CountOptions(); |
| 2041 |
| 2042 return TRUE; |
| 2043 } |
| 2044 |
| 2045 FX_BOOL Field::page(IFXJS_Context* cc, |
| 2046 CJS_PropValue& vp, |
| 2047 CFX_WideString& sError) { |
| 2048 if (!vp.IsGetting()) |
| 2049 return FALSE; |
| 2050 |
| 2051 CFX_PtrArray FieldArray; |
| 2052 GetFormFields(m_FieldName, FieldArray); |
| 2053 if (FieldArray.GetSize() <= 0) |
| 2054 return FALSE; |
| 2055 |
| 2056 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2057 if (!pFormField) |
| 2058 return FALSE; |
| 2059 |
| 2060 ASSERT(m_pDocument != NULL); |
| 2061 |
| 2062 CPDFSDK_InterForm* pInterForm = |
| 2063 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
| 2064 ASSERT(pInterForm != NULL); |
| 2065 |
| 2066 CFX_PtrArray widgetArray; |
| 2067 pInterForm->GetWidgets(pFormField, widgetArray); |
| 2068 |
| 2069 if (widgetArray.GetSize() > 0) { |
| 2070 CJS_Array PageArray(m_isolate); |
| 2071 |
| 2072 for (int i = 0, sz = widgetArray.GetSize(); i < sz; i++) { |
| 2073 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgetArray.GetAt(i); |
| 2074 ASSERT(pWidget != NULL); |
| 2075 |
| 2076 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); |
| 2077 if (!pPageView) |
| 3387 return FALSE; | 2078 return FALSE; |
| 3388 | 2079 |
| 2080 PageArray.SetElement( |
| 2081 i, CJS_Value(m_isolate, (int32_t)pPageView->GetPageIndex())); |
| 2082 } |
| 2083 |
| 2084 vp << PageArray; |
| 2085 } else { |
| 2086 vp << (int32_t)-1; |
| 2087 } |
| 2088 |
| 2089 return TRUE; |
| 2090 } |
| 2091 |
| 2092 FX_BOOL Field::password(IFXJS_Context* cc, |
| 2093 CJS_PropValue& vp, |
| 2094 CFX_WideString& sError) { |
| 2095 ASSERT(m_pDocument != NULL); |
| 2096 |
| 2097 if (vp.IsSetting()) { |
| 2098 if (!m_bCanSet) |
| 2099 return FALSE; |
| 2100 |
| 2101 bool bVP; |
| 2102 vp >> bVP; |
| 2103 |
| 2104 if (m_bDelay) { |
| 2105 AddDelay_Bool(FP_PASSWORD, bVP); |
| 2106 } else { |
| 2107 Field::SetPassword(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
| 2108 } |
| 2109 } else { |
| 2110 CFX_PtrArray FieldArray; |
| 2111 GetFormFields(m_FieldName, FieldArray); |
| 2112 if (FieldArray.GetSize() <= 0) |
| 2113 return FALSE; |
| 2114 |
| 2115 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2116 ASSERT(pFormField != NULL); |
| 2117 |
| 2118 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
| 2119 return FALSE; |
| 2120 |
| 2121 if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD) |
| 2122 vp << true; |
| 2123 else |
| 2124 vp << false; |
| 2125 } |
| 2126 |
| 2127 return TRUE; |
| 2128 } |
| 2129 |
| 2130 void Field::SetPassword(CPDFSDK_Document* pDocument, |
| 2131 const CFX_WideString& swFieldName, |
| 2132 int nControlIndex, |
| 2133 bool b) { |
| 2134 // Not supported. |
| 2135 } |
| 2136 |
| 2137 FX_BOOL Field::print(IFXJS_Context* cc, |
| 2138 CJS_PropValue& vp, |
| 2139 CFX_WideString& sError) { |
| 2140 ASSERT(m_pDocument != NULL); |
| 2141 |
| 2142 CPDFSDK_InterForm* pInterForm = |
| 2143 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
| 2144 ASSERT(pInterForm != NULL); |
| 2145 |
| 2146 CFX_PtrArray FieldArray; |
| 2147 GetFormFields(m_FieldName, FieldArray); |
| 2148 if (FieldArray.GetSize() <= 0) |
| 2149 return FALSE; |
| 2150 |
| 2151 if (vp.IsSetting()) { |
| 2152 if (!m_bCanSet) |
| 2153 return FALSE; |
| 2154 |
| 2155 bool bVP; |
| 2156 vp >> bVP; |
| 2157 |
| 2158 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { |
| 2159 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); |
| 2160 ASSERT(pFormField != NULL); |
| 2161 |
| 2162 if (m_nFormControlIndex < 0) { |
| 2163 FX_BOOL bSet = FALSE; |
| 2164 for (int j = 0, jsz = pFormField->CountControls(); j < jsz; j++) { |
| 2165 if (CPDFSDK_Widget* pWidget = |
| 2166 pInterForm->GetWidget(pFormField->GetControl(j))) { |
| 2167 FX_DWORD dwFlags = pWidget->GetFlags(); |
| 2168 if (bVP) |
| 2169 dwFlags |= ANNOTFLAG_PRINT; |
| 2170 else |
| 2171 dwFlags &= ~ANNOTFLAG_PRINT; |
| 2172 |
| 2173 if (dwFlags != pWidget->GetFlags()) { |
| 2174 pWidget->SetFlags(dwFlags); |
| 2175 bSet = TRUE; |
| 2176 } |
| 2177 } |
| 2178 } |
| 2179 |
| 2180 if (bSet) |
| 2181 UpdateFormField(m_pDocument, pFormField, TRUE, FALSE, TRUE); |
| 2182 } else { |
| 2183 if (m_nFormControlIndex >= pFormField->CountControls()) |
| 2184 return FALSE; |
| 2185 if (CPDF_FormControl* pFormControl = |
| 2186 pFormField->GetControl(m_nFormControlIndex)) { |
| 2187 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
| 2188 FX_DWORD dwFlags = pWidget->GetFlags(); |
| 2189 if (bVP) |
| 2190 dwFlags |= ANNOTFLAG_PRINT; |
| 2191 else |
| 2192 dwFlags &= ~ANNOTFLAG_PRINT; |
| 2193 |
| 2194 if (dwFlags != pWidget->GetFlags()) { |
| 2195 pWidget->SetFlags(dwFlags); |
| 2196 UpdateFormControl(m_pDocument, |
| 2197 pFormField->GetControl(m_nFormControlIndex), |
| 2198 TRUE, FALSE, TRUE); |
| 2199 } |
| 2200 } |
| 2201 } |
| 2202 } |
| 2203 } |
| 2204 } else { |
| 2205 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2206 ASSERT(pFormField != NULL); |
| 2207 |
| 2208 CPDFSDK_Widget* pWidget = |
| 2209 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
| 2210 if (!pWidget) |
| 2211 return FALSE; |
| 2212 |
| 2213 if (pWidget->GetFlags() & ANNOTFLAG_PRINT) |
| 2214 vp << true; |
| 2215 else |
| 2216 vp << false; |
| 2217 } |
| 2218 |
| 2219 return TRUE; |
| 2220 } |
| 2221 |
| 2222 FX_BOOL Field::radiosInUnison(IFXJS_Context* cc, |
| 2223 CJS_PropValue& vp, |
| 2224 CFX_WideString& sError) { |
| 2225 ASSERT(m_pDocument != NULL); |
| 2226 |
| 2227 CFX_PtrArray FieldArray; |
| 2228 GetFormFields(m_FieldName, FieldArray); |
| 2229 if (FieldArray.GetSize() <= 0) |
| 2230 return FALSE; |
| 2231 |
| 2232 if (vp.IsSetting()) { |
| 2233 if (!m_bCanSet) |
| 2234 return FALSE; |
| 2235 |
| 2236 bool bVP; |
| 2237 vp >> bVP; |
| 2238 |
| 2239 } else { |
| 2240 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2241 ASSERT(pFormField != NULL); |
| 2242 |
| 2243 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) |
| 2244 return FALSE; |
| 2245 |
| 2246 if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON) |
| 2247 vp << true; |
| 2248 else |
| 2249 vp << false; |
| 2250 } |
| 2251 |
| 2252 return TRUE; |
| 2253 } |
| 2254 |
| 2255 FX_BOOL Field::readonly(IFXJS_Context* cc, |
| 2256 CJS_PropValue& vp, |
| 2257 CFX_WideString& sError) { |
| 2258 ASSERT(m_pDocument != NULL); |
| 2259 |
| 2260 CFX_PtrArray FieldArray; |
| 2261 GetFormFields(m_FieldName, FieldArray); |
| 2262 if (FieldArray.GetSize() <= 0) |
| 2263 return FALSE; |
| 2264 |
| 2265 if (vp.IsSetting()) { |
| 2266 if (!m_bCanSet) |
| 2267 return FALSE; |
| 2268 |
| 2269 bool bVP; |
| 2270 vp >> bVP; |
| 2271 |
| 2272 } else { |
| 2273 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2274 ASSERT(pFormField != NULL); |
| 2275 |
| 2276 if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY) |
| 2277 vp << true; |
| 2278 else |
| 2279 vp << false; |
| 2280 } |
| 2281 |
| 2282 return TRUE; |
| 2283 } |
| 2284 |
| 2285 FX_BOOL Field::rect(IFXJS_Context* cc, |
| 2286 CJS_PropValue& vp, |
| 2287 CFX_WideString& sError) { |
| 2288 ASSERT(m_pDocument != NULL); |
| 2289 |
| 2290 if (vp.IsSetting()) { |
| 2291 if (!m_bCanSet) |
| 2292 return FALSE; |
| 2293 if (!vp.IsArrayObject()) |
| 2294 return FALSE; |
| 2295 |
| 2296 CJS_Array rcArray(m_isolate); |
| 2297 vp >> rcArray; |
| 2298 CJS_Value Upper_Leftx(m_isolate), Upper_Lefty(m_isolate), |
| 2299 Lower_Rightx(m_isolate), Lower_Righty(m_isolate); |
| 2300 rcArray.GetElement(0, Upper_Leftx); |
| 2301 rcArray.GetElement(1, Upper_Lefty); |
| 2302 rcArray.GetElement(2, Lower_Rightx); |
| 2303 rcArray.GetElement(3, Lower_Righty); |
| 2304 |
| 2305 FX_FLOAT pArray[4] = {0.0f, 0.0f, 0.0f, 0.0f}; |
| 2306 pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt(); |
| 2307 pArray[1] = (FX_FLOAT)Lower_Righty.ToInt(); |
| 2308 pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt(); |
| 2309 pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt(); |
| 2310 |
| 2311 CPDF_Rect crRect(pArray); |
| 2312 |
| 2313 if (m_bDelay) { |
| 2314 AddDelay_Rect(FP_RECT, crRect); |
| 2315 } else { |
| 2316 Field::SetRect(m_pDocument, m_FieldName, m_nFormControlIndex, crRect); |
| 2317 } |
| 2318 } else { |
| 2319 CFX_PtrArray FieldArray; |
| 2320 GetFormFields(m_FieldName, FieldArray); |
| 2321 if (FieldArray.GetSize() <= 0) |
| 2322 return FALSE; |
| 2323 |
| 2324 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2325 ASSERT(pFormField != NULL); |
| 2326 |
| 2327 CPDFSDK_InterForm* pInterForm = |
| 2328 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
| 2329 ASSERT(pInterForm != NULL); |
| 2330 |
| 2331 CPDFSDK_Widget* pWidget = |
| 2332 pInterForm->GetWidget(GetSmartFieldControl(pFormField)); |
| 2333 if (!pWidget) |
| 2334 return FALSE; |
| 2335 |
| 2336 CFX_FloatRect crRect = pWidget->GetRect(); |
| 2337 CJS_Value Upper_Leftx(m_isolate), Upper_Lefty(m_isolate), |
| 2338 Lower_Rightx(m_isolate), Lower_Righty(m_isolate); |
| 2339 Upper_Leftx = (int32_t)crRect.left; |
| 2340 Upper_Lefty = (int32_t)crRect.top; |
| 2341 Lower_Rightx = (int32_t)crRect.right; |
| 2342 Lower_Righty = (int32_t)crRect.bottom; |
| 2343 |
| 2344 CJS_Array rcArray(m_isolate); |
| 2345 rcArray.SetElement(0, Upper_Leftx); |
| 2346 rcArray.SetElement(1, Upper_Lefty); |
| 2347 rcArray.SetElement(2, Lower_Rightx); |
| 2348 rcArray.SetElement(3, Lower_Righty); |
| 2349 |
| 2350 vp << rcArray; |
| 2351 } |
| 2352 |
| 2353 return TRUE; |
| 2354 } |
| 2355 |
| 2356 void Field::SetRect(CPDFSDK_Document* pDocument, |
| 2357 const CFX_WideString& swFieldName, |
| 2358 int nControlIndex, |
| 2359 const CPDF_Rect& rect) { |
| 2360 ASSERT(pDocument != NULL); |
| 2361 |
| 2362 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 2363 ASSERT(pInterForm != NULL); |
| 2364 |
| 2365 CFX_PtrArray FieldArray; |
| 2366 GetFormFields(pDocument, swFieldName, FieldArray); |
| 2367 |
| 2368 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { |
| 2369 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); |
| 2370 ASSERT(pFormField != NULL); |
| 2371 |
| 2372 if (nControlIndex < 0) { |
| 2373 FX_BOOL bSet = FALSE; |
| 2374 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
| 2375 CPDF_FormControl* pFormControl = pFormField->GetControl(i); |
| 2376 ASSERT(pFormControl != NULL); |
| 2377 |
| 2378 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
| 2379 CPDF_Rect crRect = rect; |
| 2380 |
| 2381 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); |
| 2382 ASSERT(pPDFPage != NULL); |
| 2383 |
| 2384 // CPDF_Page* pPDFPage = pPage->GetPage(); |
| 2385 // ASSERT(pPDFPage != NULL); |
| 2386 |
| 2387 crRect.Intersect(pPDFPage->GetPageBBox()); |
| 2388 |
| 2389 if (!crRect.IsEmpty()) { |
| 2390 CPDF_Rect rcOld = pWidget->GetRect(); |
| 2391 if (crRect.left != rcOld.left || crRect.right != rcOld.right || |
| 2392 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { |
| 2393 pWidget->SetRect(crRect); |
| 2394 bSet = TRUE; |
| 2395 } |
| 2396 } |
| 2397 } |
| 2398 } |
| 2399 |
| 2400 if (bSet) |
| 2401 UpdateFormField(pDocument, pFormField, TRUE, TRUE, TRUE); |
| 2402 } else { |
| 2403 if (nControlIndex >= pFormField->CountControls()) |
| 2404 return; |
| 2405 if (CPDF_FormControl* pFormControl = |
| 2406 pFormField->GetControl(nControlIndex)) { |
| 2407 if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { |
| 2408 CPDF_Rect crRect = rect; |
| 2409 |
| 2410 CPDF_Page* pPDFPage = pWidget->GetPDFPage(); |
| 2411 ASSERT(pPDFPage != NULL); |
| 2412 |
| 2413 // CPDF_Page* pPDFPage = pPage->GetPage(); |
| 2414 // ASSERT(pPDFPage != NULL); |
| 2415 |
| 2416 crRect.Intersect(pPDFPage->GetPageBBox()); |
| 2417 |
| 2418 if (!crRect.IsEmpty()) { |
| 2419 CPDF_Rect rcOld = pWidget->GetRect(); |
| 2420 if (crRect.left != rcOld.left || crRect.right != rcOld.right || |
| 2421 crRect.top != rcOld.top || crRect.bottom != rcOld.bottom) { |
| 2422 pWidget->SetRect(crRect); |
| 2423 UpdateFormControl(pDocument, pFormControl, TRUE, TRUE, TRUE); |
| 2424 } |
| 2425 } |
| 2426 } |
| 2427 } |
| 2428 } |
| 2429 } |
| 2430 } |
| 2431 |
| 2432 FX_BOOL Field::required(IFXJS_Context* cc, |
| 2433 CJS_PropValue& vp, |
| 2434 CFX_WideString& sError) { |
| 2435 ASSERT(m_pDocument != NULL); |
| 2436 |
| 2437 CFX_PtrArray FieldArray; |
| 2438 GetFormFields(m_FieldName, FieldArray); |
| 2439 if (FieldArray.GetSize() <= 0) |
| 2440 return FALSE; |
| 2441 |
| 2442 if (vp.IsSetting()) { |
| 2443 if (!m_bCanSet) |
| 2444 return FALSE; |
| 2445 |
| 2446 bool bVP; |
| 2447 vp >> bVP; |
| 2448 |
| 2449 } else { |
| 2450 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2451 ASSERT(pFormField != NULL); |
| 2452 |
| 2453 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
| 2454 return FALSE; |
| 2455 |
| 2456 if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED) |
| 2457 vp << true; |
| 2458 else |
| 2459 vp << false; |
| 2460 } |
| 2461 |
| 2462 return TRUE; |
| 2463 } |
| 2464 |
| 2465 FX_BOOL Field::richText(IFXJS_Context* cc, |
| 2466 CJS_PropValue& vp, |
| 2467 CFX_WideString& sError) { |
| 2468 ASSERT(m_pDocument != NULL); |
| 2469 |
| 2470 if (vp.IsSetting()) { |
| 2471 if (!m_bCanSet) |
| 2472 return FALSE; |
| 2473 |
| 2474 bool bVP; |
| 2475 vp >> bVP; |
| 2476 |
| 2477 if (m_bDelay) { |
| 2478 AddDelay_Bool(FP_RICHTEXT, bVP); |
| 2479 } else { |
| 2480 Field::SetRichText(m_pDocument, m_FieldName, m_nFormControlIndex, bVP); |
| 2481 } |
| 2482 } else { |
| 2483 CFX_PtrArray FieldArray; |
| 2484 GetFormFields(m_FieldName, FieldArray); |
| 2485 if (FieldArray.GetSize() <= 0) |
| 2486 return FALSE; |
| 2487 |
| 2488 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2489 ASSERT(pFormField != NULL); |
| 2490 |
| 2491 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
| 2492 return FALSE; |
| 2493 |
| 2494 if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT) |
| 2495 vp << true; |
| 2496 else |
| 2497 vp << false; |
| 2498 } |
| 2499 |
| 2500 return TRUE; |
| 2501 } |
| 2502 |
| 2503 void Field::SetRichText(CPDFSDK_Document* pDocument, |
| 2504 const CFX_WideString& swFieldName, |
| 2505 int nControlIndex, |
| 2506 bool b) { |
| 2507 // Not supported. |
| 2508 } |
| 2509 |
| 2510 FX_BOOL Field::richValue(IFXJS_Context* cc, |
| 2511 CJS_PropValue& vp, |
| 2512 CFX_WideString& sError) { |
| 2513 return TRUE; |
| 2514 if (vp.IsSetting()) { |
| 2515 if (!m_bCanSet) |
| 2516 return FALSE; |
| 2517 ; |
| 2518 } else { |
| 2519 ; |
| 2520 } |
| 2521 return TRUE; |
| 2522 } |
| 2523 |
| 2524 void Field::SetRichValue(CPDFSDK_Document* pDocument, |
| 2525 const CFX_WideString& swFieldName, |
| 2526 int nControlIndex) { |
| 2527 // Not supported. |
| 2528 } |
| 2529 |
| 2530 FX_BOOL Field::rotation(IFXJS_Context* cc, |
| 2531 CJS_PropValue& vp, |
| 2532 CFX_WideString& sError) { |
| 2533 ASSERT(m_pDocument != NULL); |
| 2534 |
| 2535 if (vp.IsSetting()) { |
| 2536 if (!m_bCanSet) |
| 2537 return FALSE; |
| 2538 |
| 2539 int nVP; |
| 2540 vp >> nVP; |
| 2541 |
| 2542 if (m_bDelay) { |
| 2543 AddDelay_Int(FP_ROTATION, nVP); |
| 2544 } else { |
| 2545 Field::SetRotation(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); |
| 2546 } |
| 2547 } else { |
| 2548 CFX_PtrArray FieldArray; |
| 2549 GetFormFields(m_FieldName, FieldArray); |
| 2550 if (FieldArray.GetSize() <= 0) |
| 2551 return FALSE; |
| 2552 |
| 2553 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2554 ASSERT(pFormField != NULL); |
| 2555 |
| 3389 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 2556 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 3390 if (!pFormControl)return FALSE; | 2557 if (!pFormControl) |
| 3391 | 2558 return FALSE; |
| 3392 if (nface == 0) | 2559 |
| 3393 vRet = pFormControl->GetNormalCaption().c_str(); | 2560 vp << (int32_t)pFormControl->GetRotation(); |
| 3394 else if (nface == 1) | 2561 } |
| 3395 vRet = pFormControl->GetDownCaption().c_str(); | 2562 |
| 3396 else if (nface == 2) | 2563 return TRUE; |
| 3397 vRet = pFormControl->GetRolloverCaption().c_str(); | 2564 } |
| 2565 |
| 2566 void Field::SetRotation(CPDFSDK_Document* pDocument, |
| 2567 const CFX_WideString& swFieldName, |
| 2568 int nControlIndex, |
| 2569 int number) { |
| 2570 // Not supported. |
| 2571 } |
| 2572 |
| 2573 FX_BOOL Field::strokeColor(IFXJS_Context* cc, |
| 2574 CJS_PropValue& vp, |
| 2575 CFX_WideString& sError) { |
| 2576 ASSERT(m_pDocument != NULL); |
| 2577 |
| 2578 if (vp.IsSetting()) { |
| 2579 if (!m_bCanSet) |
| 2580 return FALSE; |
| 2581 |
| 2582 if (!vp.IsArrayObject()) |
| 2583 return FALSE; |
| 2584 |
| 2585 CJS_Array crArray(m_isolate); |
| 2586 vp >> crArray; |
| 2587 |
| 2588 CPWL_Color color; |
| 2589 color::ConvertArrayToPWLColor(crArray, color); |
| 2590 |
| 2591 if (m_bDelay) { |
| 2592 AddDelay_Color(FP_STROKECOLOR, color); |
| 2593 } else { |
| 2594 Field::SetStrokeColor(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 2595 color); |
| 2596 } |
| 2597 } else { |
| 2598 CFX_PtrArray FieldArray; |
| 2599 GetFormFields(m_FieldName, FieldArray); |
| 2600 if (FieldArray.GetSize() <= 0) |
| 2601 return FALSE; |
| 2602 |
| 2603 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2604 ASSERT(pFormField != NULL); |
| 2605 |
| 2606 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 2607 if (!pFormControl) |
| 2608 return FALSE; |
| 2609 |
| 2610 int iColorType; |
| 2611 pFormControl->GetBorderColor(iColorType); |
| 2612 |
| 2613 CPWL_Color color; |
| 2614 |
| 2615 if (iColorType == COLORTYPE_TRANSPARENT) { |
| 2616 color = CPWL_Color(COLORTYPE_TRANSPARENT); |
| 2617 } else if (iColorType == COLORTYPE_GRAY) { |
| 2618 color = |
| 2619 CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0)); |
| 2620 } else if (iColorType == COLORTYPE_RGB) { |
| 2621 color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0), |
| 2622 pFormControl->GetOriginalBorderColor(1), |
| 2623 pFormControl->GetOriginalBorderColor(2)); |
| 2624 } else if (iColorType == COLORTYPE_CMYK) { |
| 2625 color = |
| 2626 CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0), |
| 2627 pFormControl->GetOriginalBorderColor(1), |
| 2628 pFormControl->GetOriginalBorderColor(2), |
| 2629 pFormControl->GetOriginalBorderColor(3)); |
| 2630 } else |
| 2631 return FALSE; |
| 2632 |
| 2633 CJS_Array crArray(m_isolate); |
| 2634 color::ConvertPWLColorToArray(color, crArray); |
| 2635 vp << crArray; |
| 2636 } |
| 2637 |
| 2638 return TRUE; |
| 2639 } |
| 2640 |
| 2641 void Field::SetStrokeColor(CPDFSDK_Document* pDocument, |
| 2642 const CFX_WideString& swFieldName, |
| 2643 int nControlIndex, |
| 2644 const CPWL_Color& color) { |
| 2645 // Not supported. |
| 2646 } |
| 2647 |
| 2648 FX_BOOL Field::style(IFXJS_Context* cc, |
| 2649 CJS_PropValue& vp, |
| 2650 CFX_WideString& sError) { |
| 2651 ASSERT(m_pDocument != NULL); |
| 2652 |
| 2653 if (vp.IsSetting()) { |
| 2654 if (!m_bCanSet) |
| 2655 return FALSE; |
| 2656 |
| 2657 CFX_ByteString csBCaption; |
| 2658 vp >> csBCaption; |
| 2659 |
| 2660 if (m_bDelay) { |
| 2661 AddDelay_String(FP_STYLE, csBCaption); |
| 2662 } else { |
| 2663 Field::SetStyle(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 2664 csBCaption); |
| 2665 } |
| 2666 } else { |
| 2667 CFX_PtrArray FieldArray; |
| 2668 GetFormFields(m_FieldName, FieldArray); |
| 2669 if (FieldArray.GetSize() <= 0) |
| 2670 return FALSE; |
| 2671 |
| 2672 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2673 ASSERT(pFormField != NULL); |
| 2674 |
| 2675 if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON && |
| 2676 pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) |
| 2677 return FALSE; |
| 2678 |
| 2679 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 2680 if (!pFormControl) |
| 2681 return FALSE; |
| 2682 |
| 2683 CFX_WideString csWCaption = pFormControl->GetNormalCaption(); |
| 2684 CFX_ByteString csBCaption; |
| 2685 |
| 2686 switch (csWCaption[0]) { |
| 2687 case L'l': |
| 2688 csBCaption = "circle"; |
| 2689 break; |
| 2690 case L'8': |
| 2691 csBCaption = "cross"; |
| 2692 break; |
| 2693 case L'u': |
| 2694 csBCaption = "diamond"; |
| 2695 break; |
| 2696 case L'n': |
| 2697 csBCaption = "square"; |
| 2698 break; |
| 2699 case L'H': |
| 2700 csBCaption = "star"; |
| 2701 break; |
| 2702 default: // L'4' |
| 2703 csBCaption = "check"; |
| 2704 break; |
| 2705 } |
| 2706 vp << csBCaption; |
| 2707 } |
| 2708 |
| 2709 return TRUE; |
| 2710 } |
| 2711 |
| 2712 void Field::SetStyle(CPDFSDK_Document* pDocument, |
| 2713 const CFX_WideString& swFieldName, |
| 2714 int nControlIndex, |
| 2715 const CFX_ByteString& string) { |
| 2716 // Not supported. |
| 2717 } |
| 2718 |
| 2719 FX_BOOL Field::submitName(IFXJS_Context* cc, |
| 2720 CJS_PropValue& vp, |
| 2721 CFX_WideString& sError) { |
| 2722 return TRUE; |
| 2723 } |
| 2724 |
| 2725 FX_BOOL Field::textColor(IFXJS_Context* cc, |
| 2726 CJS_PropValue& vp, |
| 2727 CFX_WideString& sError) { |
| 2728 ASSERT(m_pDocument != NULL); |
| 2729 |
| 2730 if (vp.IsSetting()) { |
| 2731 if (!m_bCanSet) |
| 2732 return FALSE; |
| 2733 |
| 2734 CJS_Array crArray(m_isolate); |
| 2735 if (!vp.IsArrayObject()) |
| 2736 return FALSE; |
| 2737 vp >> crArray; |
| 2738 |
| 2739 CPWL_Color color; |
| 2740 color::ConvertArrayToPWLColor(crArray, color); |
| 2741 |
| 2742 if (m_bDelay) { |
| 2743 AddDelay_Color(FP_TEXTCOLOR, color); |
| 2744 } else { |
| 2745 Field::SetTextColor(m_pDocument, m_FieldName, m_nFormControlIndex, color); |
| 2746 } |
| 2747 } else { |
| 2748 CFX_PtrArray FieldArray; |
| 2749 GetFormFields(m_FieldName, FieldArray); |
| 2750 if (FieldArray.GetSize() <= 0) |
| 2751 return FALSE; |
| 2752 |
| 2753 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2754 ASSERT(pFormField != NULL); |
| 2755 |
| 2756 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 2757 if (!pFormControl) |
| 2758 return FALSE; |
| 2759 |
| 2760 int iColorType; |
| 2761 FX_ARGB color; |
| 2762 CPDF_DefaultAppearance FieldAppearance = |
| 2763 pFormControl->GetDefaultAppearance(); |
| 2764 FieldAppearance.GetColor(color, iColorType); |
| 2765 int32_t a, r, g, b; |
| 2766 ArgbDecode(color, a, r, g, b); |
| 2767 |
| 2768 CPWL_Color crRet = |
| 2769 CPWL_Color(COLORTYPE_RGB, r / 255.0f, g / 255.0f, b / 255.0f); |
| 2770 |
| 2771 if (iColorType == COLORTYPE_TRANSPARENT) |
| 2772 crRet = CPWL_Color(COLORTYPE_TRANSPARENT); |
| 2773 |
| 2774 CJS_Array crArray(m_isolate); |
| 2775 color::ConvertPWLColorToArray(crRet, crArray); |
| 2776 vp << crArray; |
| 2777 } |
| 2778 |
| 2779 return TRUE; |
| 2780 } |
| 2781 |
| 2782 void Field::SetTextColor(CPDFSDK_Document* pDocument, |
| 2783 const CFX_WideString& swFieldName, |
| 2784 int nControlIndex, |
| 2785 const CPWL_Color& color) { |
| 2786 // Not supported. |
| 2787 } |
| 2788 |
| 2789 FX_BOOL Field::textFont(IFXJS_Context* cc, |
| 2790 CJS_PropValue& vp, |
| 2791 CFX_WideString& sError) { |
| 2792 ASSERT(m_pDocument != NULL); |
| 2793 |
| 2794 if (vp.IsSetting()) { |
| 2795 if (!m_bCanSet) |
| 2796 return FALSE; |
| 2797 |
| 2798 CFX_ByteString csFontName; |
| 2799 vp >> csFontName; |
| 2800 if (csFontName.IsEmpty()) |
| 2801 return FALSE; |
| 2802 |
| 2803 if (m_bDelay) { |
| 2804 AddDelay_String(FP_TEXTFONT, csFontName); |
| 2805 } else { |
| 2806 Field::SetTextFont(m_pDocument, m_FieldName, m_nFormControlIndex, |
| 2807 csFontName); |
| 2808 } |
| 2809 } else { |
| 2810 CFX_PtrArray FieldArray; |
| 2811 GetFormFields(m_FieldName, FieldArray); |
| 2812 if (FieldArray.GetSize() <= 0) |
| 2813 return FALSE; |
| 2814 |
| 2815 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2816 ASSERT(pFormField != NULL); |
| 2817 |
| 2818 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 2819 if (!pFormControl) |
| 2820 return FALSE; |
| 2821 |
| 2822 int nFieldType = pFormField->GetFieldType(); |
| 2823 |
| 2824 if (nFieldType == FIELDTYPE_PUSHBUTTON || |
| 2825 nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX || |
| 2826 nFieldType == FIELDTYPE_TEXTFIELD) { |
| 2827 CPDF_Font* pFont = pFormControl->GetDefaultControlFont(); |
| 2828 if (!pFont) |
| 2829 return FALSE; |
| 2830 |
| 2831 vp << pFont->GetBaseFont(); |
| 2832 } else |
| 2833 return FALSE; |
| 2834 } |
| 2835 |
| 2836 return TRUE; |
| 2837 } |
| 2838 |
| 2839 void Field::SetTextFont(CPDFSDK_Document* pDocument, |
| 2840 const CFX_WideString& swFieldName, |
| 2841 int nControlIndex, |
| 2842 const CFX_ByteString& string) { |
| 2843 // Not supported. |
| 2844 } |
| 2845 |
| 2846 FX_BOOL Field::textSize(IFXJS_Context* cc, |
| 2847 CJS_PropValue& vp, |
| 2848 CFX_WideString& sError) { |
| 2849 ASSERT(m_pDocument != NULL); |
| 2850 |
| 2851 if (vp.IsSetting()) { |
| 2852 if (!m_bCanSet) |
| 2853 return FALSE; |
| 2854 |
| 2855 int nVP; |
| 2856 vp >> nVP; |
| 2857 |
| 2858 if (m_bDelay) { |
| 2859 AddDelay_Int(FP_TEXTSIZE, nVP); |
| 2860 } else { |
| 2861 Field::SetTextSize(m_pDocument, m_FieldName, m_nFormControlIndex, nVP); |
| 2862 } |
| 2863 } else { |
| 2864 CFX_PtrArray FieldArray; |
| 2865 GetFormFields(m_FieldName, FieldArray); |
| 2866 if (FieldArray.GetSize() <= 0) |
| 2867 return FALSE; |
| 2868 |
| 2869 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2870 ASSERT(pFormField != NULL); |
| 2871 |
| 2872 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 2873 if (!pFormControl) |
| 2874 return FALSE; |
| 2875 |
| 2876 CPDF_DefaultAppearance FieldAppearance = |
| 2877 pFormControl->GetDefaultAppearance(); |
| 2878 |
| 2879 CFX_ByteString csFontNameTag; |
| 2880 FX_FLOAT fFontSize; |
| 2881 FieldAppearance.GetFont(csFontNameTag, fFontSize); |
| 2882 |
| 2883 vp << (int)fFontSize; |
| 2884 } |
| 2885 |
| 2886 return TRUE; |
| 2887 } |
| 2888 |
| 2889 void Field::SetTextSize(CPDFSDK_Document* pDocument, |
| 2890 const CFX_WideString& swFieldName, |
| 2891 int nControlIndex, |
| 2892 int number) { |
| 2893 // Not supported. |
| 2894 } |
| 2895 |
| 2896 FX_BOOL Field::type(IFXJS_Context* cc, |
| 2897 CJS_PropValue& vp, |
| 2898 CFX_WideString& sError) { |
| 2899 ASSERT(m_pDocument != NULL); |
| 2900 |
| 2901 if (!vp.IsGetting()) |
| 2902 return FALSE; |
| 2903 |
| 2904 CFX_PtrArray FieldArray; |
| 2905 GetFormFields(m_FieldName, FieldArray); |
| 2906 if (FieldArray.GetSize() <= 0) |
| 2907 return FALSE; |
| 2908 |
| 2909 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2910 ASSERT(pFormField != NULL); |
| 2911 |
| 2912 switch (pFormField->GetFieldType()) { |
| 2913 case FIELDTYPE_UNKNOWN: |
| 2914 vp << L"unknown"; |
| 2915 break; |
| 2916 case FIELDTYPE_PUSHBUTTON: |
| 2917 vp << L"button"; |
| 2918 break; |
| 2919 case FIELDTYPE_CHECKBOX: |
| 2920 vp << L"checkbox"; |
| 2921 break; |
| 2922 case FIELDTYPE_RADIOBUTTON: |
| 2923 vp << L"radiobutton"; |
| 2924 break; |
| 2925 case FIELDTYPE_COMBOBOX: |
| 2926 vp << L"combobox"; |
| 2927 break; |
| 2928 case FIELDTYPE_LISTBOX: |
| 2929 vp << L"listbox"; |
| 2930 break; |
| 2931 case FIELDTYPE_TEXTFIELD: |
| 2932 vp << L"text"; |
| 2933 break; |
| 2934 case FIELDTYPE_SIGNATURE: |
| 2935 vp << L"signature"; |
| 2936 break; |
| 2937 default: |
| 2938 vp << L"unknown"; |
| 2939 break; |
| 2940 } |
| 2941 |
| 2942 return TRUE; |
| 2943 } |
| 2944 |
| 2945 FX_BOOL Field::userName(IFXJS_Context* cc, |
| 2946 CJS_PropValue& vp, |
| 2947 CFX_WideString& sError) { |
| 2948 ASSERT(m_pDocument != NULL); |
| 2949 |
| 2950 if (vp.IsSetting()) { |
| 2951 if (!m_bCanSet) |
| 2952 return FALSE; |
| 2953 |
| 2954 CFX_WideString swName; |
| 2955 vp >> swName; |
| 2956 |
| 2957 if (m_bDelay) { |
| 2958 AddDelay_WideString(FP_USERNAME, swName); |
| 2959 } else { |
| 2960 Field::SetUserName(m_pDocument, m_FieldName, m_nFormControlIndex, swName); |
| 2961 } |
| 2962 } else { |
| 2963 CFX_PtrArray FieldArray; |
| 2964 GetFormFields(m_FieldName, FieldArray); |
| 2965 if (FieldArray.GetSize() <= 0) |
| 2966 return FALSE; |
| 2967 |
| 2968 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 2969 ASSERT(pFormField != NULL); |
| 2970 |
| 2971 vp << (CFX_WideString)pFormField->GetAlternateName(); |
| 2972 } |
| 2973 |
| 2974 return TRUE; |
| 2975 } |
| 2976 |
| 2977 void Field::SetUserName(CPDFSDK_Document* pDocument, |
| 2978 const CFX_WideString& swFieldName, |
| 2979 int nControlIndex, |
| 2980 const CFX_WideString& string) { |
| 2981 // Not supported. |
| 2982 } |
| 2983 |
| 2984 FX_BOOL Field::value(IFXJS_Context* cc, |
| 2985 CJS_PropValue& vp, |
| 2986 CFX_WideString& sError) { |
| 2987 ASSERT(m_pDocument != NULL); |
| 2988 |
| 2989 if (vp.IsSetting()) { |
| 2990 if (!m_bCanSet) |
| 2991 return FALSE; |
| 2992 |
| 2993 CJS_WideStringArray strArray; |
| 2994 |
| 2995 if (vp.IsArrayObject()) { |
| 2996 CJS_Array ValueArray(m_isolate); |
| 2997 vp.ConvertToArray(ValueArray); |
| 2998 for (int i = 0, sz = ValueArray.GetLength(); i < sz; i++) { |
| 2999 CJS_Value ElementValue(m_isolate); |
| 3000 ValueArray.GetElement(i, ElementValue); |
| 3001 strArray.Add(ElementValue.ToCFXWideString()); |
| 3002 } |
| 3003 } else { |
| 3004 CFX_WideString swValue; |
| 3005 vp >> swValue; |
| 3006 |
| 3007 strArray.Add(swValue); |
| 3008 } |
| 3009 |
| 3010 if (m_bDelay) { |
| 3011 AddDelay_WideStringArray(FP_VALUE, strArray); |
| 3012 } else { |
| 3013 Field::SetValue(m_pDocument, m_FieldName, m_nFormControlIndex, strArray); |
| 3014 } |
| 3015 } else { |
| 3016 CFX_PtrArray FieldArray; |
| 3017 GetFormFields(m_FieldName, FieldArray); |
| 3018 if (FieldArray.GetSize() <= 0) |
| 3019 return FALSE; |
| 3020 |
| 3021 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3022 ASSERT(pFormField != NULL); |
| 3023 |
| 3024 switch (pFormField->GetFieldType()) { |
| 3025 case FIELDTYPE_PUSHBUTTON: |
| 3026 return FALSE; |
| 3027 case FIELDTYPE_COMBOBOX: |
| 3028 case FIELDTYPE_TEXTFIELD: { |
| 3029 CFX_WideString swValue = pFormField->GetValue(); |
| 3030 |
| 3031 double dRet; |
| 3032 FX_BOOL bDot; |
| 3033 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, |
| 3034 bDot)) { |
| 3035 if (bDot) |
| 3036 vp << dRet; |
| 3037 else |
| 3038 vp << dRet; |
| 3039 } else |
| 3040 vp << swValue; |
| 3041 } break; |
| 3042 case FIELDTYPE_LISTBOX: { |
| 3043 if (pFormField->CountSelectedItems() > 1) { |
| 3044 CJS_Array ValueArray(m_isolate); |
| 3045 CJS_Value ElementValue(m_isolate); |
| 3046 int iIndex; |
| 3047 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { |
| 3048 iIndex = pFormField->GetSelectedIndex(i); |
| 3049 ElementValue = pFormField->GetOptionValue(iIndex).c_str(); |
| 3050 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) |
| 3051 ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); |
| 3052 ValueArray.SetElement(i, ElementValue); |
| 3053 } |
| 3054 vp << ValueArray; |
| 3055 } else { |
| 3056 CFX_WideString swValue = pFormField->GetValue(); |
| 3057 |
| 3058 double dRet; |
| 3059 FX_BOOL bDot; |
| 3060 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, |
| 3061 bDot)) { |
| 3062 if (bDot) |
| 3063 vp << dRet; |
| 3064 else |
| 3065 vp << dRet; |
| 3066 } else |
| 3067 vp << swValue; |
| 3068 } |
| 3069 } break; |
| 3070 case FIELDTYPE_CHECKBOX: |
| 3071 case FIELDTYPE_RADIOBUTTON: { |
| 3072 FX_BOOL bFind = FALSE; |
| 3073 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
| 3074 if (pFormField->GetControl(i)->IsChecked()) { |
| 3075 CFX_WideString swValue = |
| 3076 pFormField->GetControl(i)->GetExportValue(); |
| 3077 double dRet; |
| 3078 FX_BOOL bDot; |
| 3079 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, |
| 3080 bDot)) { |
| 3081 if (bDot) |
| 3082 vp << dRet; |
| 3083 else |
| 3084 vp << dRet; |
| 3085 } else |
| 3086 vp << swValue; |
| 3087 |
| 3088 bFind = TRUE; |
| 3089 break; |
| 3090 } else |
| 3091 continue; |
| 3092 } |
| 3093 if (!bFind) |
| 3094 vp << L"Off"; |
| 3095 } break; |
| 3096 default: |
| 3097 vp << pFormField->GetValue(); |
| 3098 break; |
| 3099 } |
| 3100 } |
| 3101 |
| 3102 return TRUE; |
| 3103 } |
| 3104 |
| 3105 void Field::SetValue(CPDFSDK_Document* pDocument, |
| 3106 const CFX_WideString& swFieldName, |
| 3107 int nControlIndex, |
| 3108 const CJS_WideStringArray& strArray) { |
| 3109 ASSERT(pDocument != NULL); |
| 3110 |
| 3111 if (strArray.GetSize() < 1) |
| 3112 return; |
| 3113 |
| 3114 CFX_PtrArray FieldArray; |
| 3115 GetFormFields(pDocument, swFieldName, FieldArray); |
| 3116 |
| 3117 for (int i = 0, isz = FieldArray.GetSize(); i < isz; i++) { |
| 3118 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); |
| 3119 ASSERT(pFormField != NULL); |
| 3120 |
| 3121 if (pFormField->GetFullName().Compare(swFieldName) != 0) |
| 3122 continue; |
| 3123 |
| 3124 switch (pFormField->GetFieldType()) { |
| 3125 case FIELDTYPE_TEXTFIELD: |
| 3126 case FIELDTYPE_COMBOBOX: |
| 3127 if (pFormField->GetValue() != strArray.GetAt(0)) { |
| 3128 CFX_WideString WideString = strArray.GetAt(0); |
| 3129 pFormField->SetValue(strArray.GetAt(0), TRUE); |
| 3130 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); |
| 3131 } |
| 3132 break; |
| 3133 case FIELDTYPE_CHECKBOX: // mantis: 0004493 |
| 3134 case FIELDTYPE_RADIOBUTTON: { |
| 3135 if (pFormField->GetValue() != strArray.GetAt(0)) { |
| 3136 pFormField->SetValue(strArray.GetAt(0), TRUE); |
| 3137 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); |
| 3138 } |
| 3139 } break; |
| 3140 case FIELDTYPE_LISTBOX: { |
| 3141 FX_BOOL bModified = FALSE; |
| 3142 |
| 3143 for (int i = 0, sz = strArray.GetSize(); i < sz; i++) { |
| 3144 int iIndex = pFormField->FindOption(strArray.GetAt(i)); |
| 3145 |
| 3146 if (!pFormField->IsItemSelected(iIndex)) { |
| 3147 bModified = TRUE; |
| 3148 break; |
| 3149 } |
| 3150 } |
| 3151 |
| 3152 if (bModified) { |
| 3153 pFormField->ClearSelection(TRUE); |
| 3154 for (int i = 0, sz = strArray.GetSize(); i < sz; i++) { |
| 3155 int iIndex = pFormField->FindOption(strArray.GetAt(i)); |
| 3156 pFormField->SetItemSelection(iIndex, TRUE, TRUE); |
| 3157 } |
| 3158 |
| 3159 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); |
| 3160 } |
| 3161 } break; |
| 3162 default: |
| 3163 break; |
| 3164 } |
| 3165 } |
| 3166 } |
| 3167 |
| 3168 FX_BOOL Field::valueAsString(IFXJS_Context* cc, |
| 3169 CJS_PropValue& vp, |
| 3170 CFX_WideString& sError) { |
| 3171 ASSERT(m_pDocument != NULL); |
| 3172 |
| 3173 if (!vp.IsGetting()) |
| 3174 return FALSE; |
| 3175 |
| 3176 CFX_PtrArray FieldArray; |
| 3177 GetFormFields(m_FieldName, FieldArray); |
| 3178 if (FieldArray.GetSize() <= 0) |
| 3179 return FALSE; |
| 3180 |
| 3181 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3182 ASSERT(pFormField != NULL); |
| 3183 |
| 3184 if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
| 3185 return FALSE; |
| 3186 |
| 3187 if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) { |
| 3188 if (!pFormField->CountControls()) |
| 3189 return FALSE; |
| 3190 |
| 3191 if (pFormField->GetControl(0)->IsChecked()) |
| 3192 vp << L"Yes"; |
| 3398 else | 3193 else |
| 3399 return FALSE; | 3194 vp << L"Off"; |
| 3400 | 3195 } else if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON && |
| 3401 return TRUE; | 3196 !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) { |
| 3197 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
| 3198 if (pFormField->GetControl(i)->IsChecked()) { |
| 3199 vp << pFormField->GetControl(i)->GetExportValue().c_str(); |
| 3200 break; |
| 3201 } else |
| 3202 vp << L"Off"; |
| 3203 } |
| 3204 } else if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX && |
| 3205 (pFormField->CountSelectedItems() > 1)) { |
| 3206 vp << L""; |
| 3207 } else |
| 3208 vp << pFormField->GetValue().c_str(); |
| 3209 |
| 3210 return TRUE; |
| 3211 } |
| 3212 |
| 3213 /* --------------------------------- methods --------------------------------- |
| 3214 */ |
| 3215 |
| 3216 FX_BOOL Field::browseForFileToSubmit(IFXJS_Context* cc, |
| 3217 const CJS_Parameters& params, |
| 3218 CJS_Value& vRet, |
| 3219 CFX_WideString& sError) { |
| 3220 ASSERT(m_pDocument != NULL); |
| 3221 |
| 3222 CFX_PtrArray FieldArray; |
| 3223 GetFormFields(m_FieldName, FieldArray); |
| 3224 if (FieldArray.GetSize() <= 0) |
| 3225 return FALSE; |
| 3226 |
| 3227 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3228 ASSERT(pFormField != NULL); |
| 3229 |
| 3230 CPDFDoc_Environment* pApp = m_pDocument->GetEnv(); |
| 3231 ASSERT(pApp != NULL); |
| 3232 |
| 3233 if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && |
| 3234 (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) { |
| 3235 CFX_WideString wsFileName = pApp->JS_fieldBrowse(); |
| 3236 if (!wsFileName.IsEmpty()) { |
| 3237 pFormField->SetValue(wsFileName); |
| 3238 UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE); |
| 3239 } |
| 3240 } else |
| 3241 return FALSE; |
| 3242 |
| 3243 return TRUE; |
| 3244 } |
| 3245 |
| 3246 FX_BOOL Field::buttonGetCaption(IFXJS_Context* cc, |
| 3247 const CJS_Parameters& params, |
| 3248 CJS_Value& vRet, |
| 3249 CFX_WideString& sError) { |
| 3250 ASSERT(m_pDocument != NULL); |
| 3251 |
| 3252 int nface = 0; |
| 3253 int iSize = params.size(); |
| 3254 if (iSize >= 1) |
| 3255 nface = params[0].ToInt(); |
| 3256 |
| 3257 CFX_PtrArray FieldArray; |
| 3258 GetFormFields(m_FieldName, FieldArray); |
| 3259 if (FieldArray.GetSize() <= 0) |
| 3260 return FALSE; |
| 3261 |
| 3262 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3263 ASSERT(pFormField != NULL); |
| 3264 |
| 3265 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 3266 return FALSE; |
| 3267 |
| 3268 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 3269 if (!pFormControl) |
| 3270 return FALSE; |
| 3271 |
| 3272 if (nface == 0) |
| 3273 vRet = pFormControl->GetNormalCaption().c_str(); |
| 3274 else if (nface == 1) |
| 3275 vRet = pFormControl->GetDownCaption().c_str(); |
| 3276 else if (nface == 2) |
| 3277 vRet = pFormControl->GetRolloverCaption().c_str(); |
| 3278 else |
| 3279 return FALSE; |
| 3280 |
| 3281 return TRUE; |
| 3402 } | 3282 } |
| 3403 | 3283 |
| 3404 //#pragma warning(disable: 4800) | 3284 //#pragma warning(disable: 4800) |
| 3405 | 3285 |
| 3406 FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 3286 FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc, |
| 3407 { | 3287 const CJS_Parameters& params, |
| 3408 ASSERT(m_pDocument != NULL); | 3288 CJS_Value& vRet, |
| 3409 | 3289 CFX_WideString& sError) { |
| 3410 int nface = 0; | 3290 ASSERT(m_pDocument != NULL); |
| 3411 int iSize = params.size(); | 3291 |
| 3412 if (iSize >= 1) | 3292 int nface = 0; |
| 3413 nface = params[0].ToInt(); | 3293 int iSize = params.size(); |
| 3414 | 3294 if (iSize >= 1) |
| 3415 CFX_PtrArray FieldArray; | 3295 nface = params[0].ToInt(); |
| 3416 GetFormFields(m_FieldName,FieldArray); | 3296 |
| 3417 if (FieldArray.GetSize() <= 0) return FALSE; | 3297 CFX_PtrArray FieldArray; |
| 3418 | 3298 GetFormFields(m_FieldName, FieldArray); |
| 3419 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3299 if (FieldArray.GetSize() <= 0) |
| 3420 ASSERT(pFormField != NULL); | 3300 return FALSE; |
| 3421 | 3301 |
| 3422 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 3302 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3423 return FALSE; | 3303 ASSERT(pFormField != NULL); |
| 3424 | 3304 |
| 3425 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 3305 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 3426 if (!pFormControl)return FALSE; | 3306 return FALSE; |
| 3427 | 3307 |
| 3428 CJS_Context* pContext = (CJS_Context*)cc; | 3308 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 3429 ASSERT(pContext != NULL); | 3309 if (!pFormControl) |
| 3430 | 3310 return FALSE; |
| 3431 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 3311 |
| 3432 ASSERT(pRuntime != NULL); | 3312 CJS_Context* pContext = (CJS_Context*)cc; |
| 3433 | 3313 ASSERT(pContext != NULL); |
| 3434 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*p
Runtime, L"Icon")); | 3314 |
| 3435 ASSERT(pObj.IsEmpty() == FALSE); | 3315 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 3436 | 3316 ASSERT(pRuntime != NULL); |
| 3437 CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj); | 3317 |
| 3438 ASSERT(pJS_Icon != NULL); | 3318 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, |
| 3439 | 3319 JS_GetObjDefnID(*pRuntime, L"Icon")); |
| 3440 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 3320 ASSERT(pObj.IsEmpty() == FALSE); |
| 3441 ASSERT(pIcon != NULL); | 3321 |
| 3442 | 3322 CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj); |
| 3443 CPDF_Stream* pIconStream = NULL; | 3323 ASSERT(pJS_Icon != NULL); |
| 3444 if (nface == 0) | 3324 |
| 3445 pIconStream = pFormControl->GetNormalIcon(); | 3325 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 3446 else if (nface == 1) | 3326 ASSERT(pIcon != NULL); |
| 3447 pIconStream = pFormControl->GetDownIcon(); | 3327 |
| 3448 else if (nface == 2) | 3328 CPDF_Stream* pIconStream = NULL; |
| 3449 pIconStream = pFormControl->GetRolloverIcon(); | 3329 if (nface == 0) |
| 3450 else | 3330 pIconStream = pFormControl->GetNormalIcon(); |
| 3451 return FALSE; | 3331 else if (nface == 1) |
| 3452 | 3332 pIconStream = pFormControl->GetDownIcon(); |
| 3453 pIcon->SetStream(pIconStream); | 3333 else if (nface == 2) |
| 3454 vRet = pJS_Icon; | 3334 pIconStream = pFormControl->GetRolloverIcon(); |
| 3455 | 3335 else |
| 3456 return TRUE; | 3336 return FALSE; |
| 3337 |
| 3338 pIcon->SetStream(pIconStream); |
| 3339 vRet = pJS_Icon; |
| 3340 |
| 3341 return TRUE; |
| 3457 } | 3342 } |
| 3458 | 3343 |
| 3459 //#pragma warning(default: 4800) | 3344 //#pragma warning(default: 4800) |
| 3460 | 3345 |
| 3461 FX_BOOL Field::buttonImportIcon(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 3346 FX_BOOL Field::buttonImportIcon(IFXJS_Context* cc, |
| 3462 { | 3347 const CJS_Parameters& params, |
| 3348 CJS_Value& vRet, |
| 3349 CFX_WideString& sError) { |
| 3463 #if 0 | 3350 #if 0 |
| 3464 ASSERT(m_pDocument != NULL); | 3351 ASSERT(m_pDocument != NULL); |
| 3465 | 3352 |
| 3466 CFX_PtrArray FieldArray; | 3353 CFX_PtrArray FieldArray; |
| 3467 GetFormFields(m_FieldName,FieldArray); | 3354 GetFormFields(m_FieldName,FieldArray); |
| 3468 if (FieldArray.GetSize() <= 0) return FALSE; | 3355 if (FieldArray.GetSize() <= 0) return FALSE; |
| 3469 | 3356 |
| 3470 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3357 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3471 if (!pFormField)return FALSE; | 3358 if (!pFormField)return FALSE; |
| 3472 | 3359 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3490 return TRUE; | 3377 return TRUE; |
| 3491 } | 3378 } |
| 3492 | 3379 |
| 3493 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 3380 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 3494 if (!pFormControl)return FALSE; | 3381 if (!pFormControl)return FALSE; |
| 3495 | 3382 |
| 3496 pFormControl->SetNormalIcon(pStream); | 3383 pFormControl->SetNormalIcon(pStream); |
| 3497 UpdateFormControl(m_pDocument, pFormControl, TRUE, TRUE, TRUE); | 3384 UpdateFormControl(m_pDocument, pFormControl, TRUE, TRUE, TRUE); |
| 3498 | 3385 |
| 3499 vRet = 0; | 3386 vRet = 0; |
| 3500 #endif // 0 | 3387 #endif // 0 |
| 3501 return TRUE; | 3388 return TRUE; |
| 3502 } | 3389 } |
| 3503 | 3390 |
| 3504 FX_BOOL Field::buttonSetCaption(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 3391 FX_BOOL Field::buttonSetCaption(IFXJS_Context* cc, |
| 3505 { | 3392 const CJS_Parameters& params, |
| 3506 return FALSE; | 3393 CJS_Value& vRet, |
| 3507 } | 3394 CFX_WideString& sError) { |
| 3508 | 3395 return FALSE; |
| 3509 FX_BOOL Field::buttonSetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 3396 } |
| 3510 { | 3397 |
| 3511 return FALSE; | 3398 FX_BOOL Field::buttonSetIcon(IFXJS_Context* cc, |
| 3512 } | 3399 const CJS_Parameters& params, |
| 3513 | 3400 CJS_Value& vRet, |
| 3514 FX_BOOL Field::checkThisBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 3401 CFX_WideString& sError) { |
| 3515 { | 3402 return FALSE; |
| 3516 ASSERT(m_pDocument != NULL); | 3403 } |
| 3517 | 3404 |
| 3518 if (!m_bCanSet) return FALSE; | 3405 FX_BOOL Field::checkThisBox(IFXJS_Context* cc, |
| 3519 | 3406 const CJS_Parameters& params, |
| 3520 int iSize = params.size(); | 3407 CJS_Value& vRet, |
| 3521 if (iSize < 1) | 3408 CFX_WideString& sError) { |
| 3522 return FALSE; | 3409 ASSERT(m_pDocument != NULL); |
| 3523 | 3410 |
| 3524 int nWidget = params[0].ToInt(); | 3411 if (!m_bCanSet) |
| 3525 | 3412 return FALSE; |
| 3526 FX_BOOL bCheckit = TRUE; | 3413 |
| 3527 if (iSize >= 2) | 3414 int iSize = params.size(); |
| 3528 bCheckit = params[1].ToBool(); | 3415 if (iSize < 1) |
| 3529 | 3416 return FALSE; |
| 3530 CFX_PtrArray FieldArray; | 3417 |
| 3531 GetFormFields(m_FieldName,FieldArray); | 3418 int nWidget = params[0].ToInt(); |
| 3532 if (FieldArray.GetSize() <= 0) return FALSE; | 3419 |
| 3533 | 3420 FX_BOOL bCheckit = TRUE; |
| 3534 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3421 if (iSize >= 2) |
| 3422 bCheckit = params[1].ToBool(); |
| 3423 |
| 3424 CFX_PtrArray FieldArray; |
| 3425 GetFormFields(m_FieldName, FieldArray); |
| 3426 if (FieldArray.GetSize() <= 0) |
| 3427 return FALSE; |
| 3428 |
| 3429 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3430 ASSERT(pFormField != NULL); |
| 3431 |
| 3432 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && |
| 3433 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) |
| 3434 return FALSE; |
| 3435 if (nWidget < 0 || nWidget >= pFormField->CountControls()) |
| 3436 return FALSE; |
| 3437 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) |
| 3438 pFormField->CheckControl(nWidget, bCheckit, TRUE); |
| 3439 else |
| 3440 pFormField->CheckControl(nWidget, bCheckit, TRUE); |
| 3441 |
| 3442 UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE); |
| 3443 return TRUE; |
| 3444 } |
| 3445 |
| 3446 FX_BOOL Field::clearItems(IFXJS_Context* cc, |
| 3447 const CJS_Parameters& params, |
| 3448 CJS_Value& vRet, |
| 3449 CFX_WideString& sError) { |
| 3450 return TRUE; |
| 3451 } |
| 3452 |
| 3453 FX_BOOL Field::defaultIsChecked(IFXJS_Context* cc, |
| 3454 const CJS_Parameters& params, |
| 3455 CJS_Value& vRet, |
| 3456 CFX_WideString& sError) { |
| 3457 ASSERT(m_pDocument != NULL); |
| 3458 |
| 3459 if (!m_bCanSet) |
| 3460 return FALSE; |
| 3461 |
| 3462 int iSize = params.size(); |
| 3463 if (iSize < 1) |
| 3464 return FALSE; |
| 3465 |
| 3466 int nWidget = params[0].ToInt(); |
| 3467 |
| 3468 CFX_PtrArray FieldArray; |
| 3469 GetFormFields(m_FieldName, FieldArray); |
| 3470 if (FieldArray.GetSize() <= 0) |
| 3471 return FALSE; |
| 3472 |
| 3473 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3474 ASSERT(pFormField != NULL); |
| 3475 |
| 3476 if (nWidget < 0 || nWidget >= pFormField->CountControls()) { |
| 3477 vRet = FALSE; |
| 3478 return FALSE; |
| 3479 } |
| 3480 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || |
| 3481 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { |
| 3482 vRet = TRUE; |
| 3483 } else |
| 3484 vRet = FALSE; |
| 3485 |
| 3486 return TRUE; |
| 3487 } |
| 3488 |
| 3489 FX_BOOL Field::deleteItemAt(IFXJS_Context* cc, |
| 3490 const CJS_Parameters& params, |
| 3491 CJS_Value& vRet, |
| 3492 CFX_WideString& sError) { |
| 3493 return TRUE; |
| 3494 } |
| 3495 |
| 3496 int JS_COMPARESTRING(CFX_WideString* ps1, CFX_WideString* ps2) { |
| 3497 ASSERT(ps1 != NULL); |
| 3498 ASSERT(ps2 != NULL); |
| 3499 |
| 3500 return ps1->Compare(*ps2); |
| 3501 } |
| 3502 |
| 3503 FX_BOOL Field::getArray(IFXJS_Context* cc, |
| 3504 const CJS_Parameters& params, |
| 3505 CJS_Value& vRet, |
| 3506 CFX_WideString& sError) { |
| 3507 ASSERT(m_pDocument != NULL); |
| 3508 |
| 3509 CFX_PtrArray FieldArray; |
| 3510 GetFormFields(m_FieldName, FieldArray); |
| 3511 if (FieldArray.GetSize() <= 0) |
| 3512 return FALSE; |
| 3513 |
| 3514 CGW_ArrayTemplate<CFX_WideString*> swSort; |
| 3515 |
| 3516 for (int i = 0, sz = FieldArray.GetSize(); i < sz; i++) { |
| 3517 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); |
| 3535 ASSERT(pFormField != NULL); | 3518 ASSERT(pFormField != NULL); |
| 3536 | 3519 |
| 3537 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && pFormField->GetField
Type() != FIELDTYPE_RADIOBUTTON) | 3520 swSort.Add(new CFX_WideString(pFormField->GetFullName())); |
| 3538 return FALSE; | 3521 } |
| 3539 if(nWidget <0 || nWidget >= pFormField->CountControls()) | 3522 swSort.Sort(JS_COMPARESTRING); |
| 3540 return FALSE; | 3523 |
| 3541 if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) | 3524 CJS_Context* pContext = (CJS_Context*)cc; |
| 3542 pFormField->CheckControl(nWidget, bCheckit, TRUE); | 3525 ASSERT(pContext != NULL); |
| 3526 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 3527 ASSERT(pRuntime != NULL); |
| 3528 |
| 3529 CJS_Array FormFieldArray(m_isolate); |
| 3530 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { |
| 3531 CFX_WideString* pStr = swSort.GetAt(j); |
| 3532 |
| 3533 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, |
| 3534 JS_GetObjDefnID(*pRuntime, L"Field")); |
| 3535 ASSERT(pObj.IsEmpty() == FALSE); |
| 3536 |
| 3537 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pObj); |
| 3538 ASSERT(pJSField != NULL); |
| 3539 |
| 3540 Field* pField = (Field*)pJSField->GetEmbedObject(); |
| 3541 ASSERT(pField != NULL); |
| 3542 |
| 3543 pField->AttachField(m_pJSDoc, *pStr); |
| 3544 |
| 3545 CJS_Value FormFieldValue(m_isolate); |
| 3546 FormFieldValue = pJSField; |
| 3547 FormFieldArray.SetElement(j, FormFieldValue); |
| 3548 |
| 3549 delete pStr; |
| 3550 } |
| 3551 |
| 3552 vRet = FormFieldArray; |
| 3553 swSort.RemoveAll(); |
| 3554 return TRUE; |
| 3555 } |
| 3556 |
| 3557 FX_BOOL Field::getItemAt(IFXJS_Context* cc, |
| 3558 const CJS_Parameters& params, |
| 3559 CJS_Value& vRet, |
| 3560 CFX_WideString& sError) { |
| 3561 ASSERT(m_pDocument != NULL); |
| 3562 int iSize = params.size(); |
| 3563 |
| 3564 int nIdx = -1; |
| 3565 if (iSize >= 1) |
| 3566 nIdx = params[0].ToInt(); |
| 3567 |
| 3568 FX_BOOL bExport = TRUE; |
| 3569 if (iSize >= 2) |
| 3570 bExport = params[1].ToBool(); |
| 3571 |
| 3572 CFX_PtrArray FieldArray; |
| 3573 GetFormFields(m_FieldName, FieldArray); |
| 3574 if (FieldArray.GetSize() <= 0) |
| 3575 return FALSE; |
| 3576 |
| 3577 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3578 ASSERT(pFormField != NULL); |
| 3579 |
| 3580 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) || |
| 3581 (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) { |
| 3582 if (nIdx == -1 || nIdx > pFormField->CountOptions()) |
| 3583 nIdx = pFormField->CountOptions() - 1; |
| 3584 if (bExport) { |
| 3585 CFX_WideString strval = pFormField->GetOptionValue(nIdx); |
| 3586 if (strval.IsEmpty()) |
| 3587 vRet = pFormField->GetOptionLabel(nIdx).c_str(); |
| 3588 else |
| 3589 vRet = strval.c_str(); |
| 3590 } else |
| 3591 vRet = pFormField->GetOptionLabel(nIdx).c_str(); |
| 3592 } else |
| 3593 return FALSE; |
| 3594 |
| 3595 return TRUE; |
| 3596 } |
| 3597 |
| 3598 FX_BOOL Field::getLock(IFXJS_Context* cc, |
| 3599 const CJS_Parameters& params, |
| 3600 CJS_Value& vRet, |
| 3601 CFX_WideString& sError) { |
| 3602 return FALSE; |
| 3603 } |
| 3604 |
| 3605 FX_BOOL Field::insertItemAt(IFXJS_Context* cc, |
| 3606 const CJS_Parameters& params, |
| 3607 CJS_Value& vRet, |
| 3608 CFX_WideString& sError) { |
| 3609 return TRUE; |
| 3610 } |
| 3611 |
| 3612 FX_BOOL Field::isBoxChecked(IFXJS_Context* cc, |
| 3613 const CJS_Parameters& params, |
| 3614 CJS_Value& vRet, |
| 3615 CFX_WideString& sError) { |
| 3616 ASSERT(m_pDocument != NULL); |
| 3617 |
| 3618 int nIndex = -1; |
| 3619 if (params.size() >= 1) |
| 3620 nIndex = params[0].ToInt(); |
| 3621 |
| 3622 CFX_PtrArray FieldArray; |
| 3623 GetFormFields(m_FieldName, FieldArray); |
| 3624 if (FieldArray.GetSize() <= 0) |
| 3625 return FALSE; |
| 3626 |
| 3627 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3628 ASSERT(pFormField != NULL); |
| 3629 |
| 3630 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { |
| 3631 vRet = FALSE; |
| 3632 return FALSE; |
| 3633 } |
| 3634 |
| 3635 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || |
| 3636 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { |
| 3637 if (pFormField->GetControl(nIndex)->IsChecked() != 0) |
| 3638 vRet = TRUE; |
| 3543 else | 3639 else |
| 3544 pFormField->CheckControl(nWidget, bCheckit, TRUE); | 3640 vRet = FALSE; |
| 3545 | 3641 } else |
| 3546 UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE); | 3642 vRet = FALSE; |
| 3547 return TRUE; | 3643 |
| 3548 } | 3644 return TRUE; |
| 3549 | 3645 } |
| 3550 FX_BOOL Field::clearItems(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 3646 |
| 3551 { | 3647 FX_BOOL Field::isDefaultChecked(IFXJS_Context* cc, |
| 3552 return TRUE; | 3648 const CJS_Parameters& params, |
| 3553 } | 3649 CJS_Value& vRet, |
| 3554 | 3650 CFX_WideString& sError) { |
| 3555 FX_BOOL Field::defaultIsChecked(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 3651 ASSERT(m_pDocument != NULL); |
| 3556 { | 3652 |
| 3557 ASSERT(m_pDocument != NULL); | 3653 int nIndex = -1; |
| 3558 | 3654 if (params.size() >= 1) |
| 3559 if (!m_bCanSet) return FALSE; | 3655 nIndex = params[0].ToInt(); |
| 3560 | 3656 |
| 3561 int iSize = params.size(); | 3657 CFX_PtrArray FieldArray; |
| 3562 if (iSize < 1) | 3658 GetFormFields(m_FieldName, FieldArray); |
| 3563 return FALSE; | 3659 if (FieldArray.GetSize() <= 0) |
| 3564 | 3660 return FALSE; |
| 3565 int nWidget = params[0].ToInt(); | 3661 |
| 3566 | 3662 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3567 CFX_PtrArray FieldArray; | 3663 ASSERT(pFormField != NULL); |
| 3568 GetFormFields(m_FieldName,FieldArray); | 3664 |
| 3569 if (FieldArray.GetSize() <= 0) return FALSE; | 3665 if (nIndex < 0 || nIndex >= pFormField->CountControls()) { |
| 3570 | 3666 vRet = FALSE; |
| 3571 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3667 return FALSE; |
| 3572 ASSERT(pFormField != NULL); | 3668 } |
| 3573 | 3669 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) || |
| 3574 if(nWidget <0 || nWidget >= pFormField->CountControls()) | 3670 (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) { |
| 3575 { | 3671 if (pFormField->GetControl(nIndex)->IsDefaultChecked() != 0) |
| 3576 vRet = FALSE; | 3672 vRet = TRUE; |
| 3577 return FALSE; | 3673 else |
| 3674 vRet = FALSE; |
| 3675 } else |
| 3676 vRet = FALSE; |
| 3677 |
| 3678 return TRUE; |
| 3679 } |
| 3680 |
| 3681 FX_BOOL Field::setAction(IFXJS_Context* cc, |
| 3682 const CJS_Parameters& params, |
| 3683 CJS_Value& vRet, |
| 3684 CFX_WideString& sError) { |
| 3685 return TRUE; |
| 3686 } |
| 3687 |
| 3688 FX_BOOL Field::setFocus(IFXJS_Context* cc, |
| 3689 const CJS_Parameters& params, |
| 3690 CJS_Value& vRet, |
| 3691 CFX_WideString& sError) { |
| 3692 ASSERT(m_pDocument != NULL); |
| 3693 |
| 3694 CFX_PtrArray FieldArray; |
| 3695 GetFormFields(m_FieldName, FieldArray); |
| 3696 if (FieldArray.GetSize() <= 0) |
| 3697 return FALSE; |
| 3698 |
| 3699 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3700 ASSERT(pFormField != NULL); |
| 3701 |
| 3702 int32_t nCount = pFormField->CountControls(); |
| 3703 |
| 3704 if (nCount < 1) |
| 3705 return FALSE; |
| 3706 |
| 3707 CPDFSDK_InterForm* pInterForm = |
| 3708 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
| 3709 ASSERT(pInterForm != NULL); |
| 3710 |
| 3711 CPDFSDK_Widget* pWidget = NULL; |
| 3712 if (nCount == 1) { |
| 3713 pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); |
| 3714 } else { |
| 3715 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 3716 ASSERT(pEnv); |
| 3717 CPDF_Page* pPage = |
| 3718 (CPDF_Page*)pEnv->FFI_GetCurrentPage(m_pDocument->GetDocument()); |
| 3719 if (!pPage) |
| 3720 return FALSE; |
| 3721 if (CPDFSDK_PageView* pCurPageView = m_pDocument->GetPageView(pPage)) { |
| 3722 for (int32_t i = 0; i < nCount; i++) { |
| 3723 if (CPDFSDK_Widget* pTempWidget = |
| 3724 pInterForm->GetWidget(pFormField->GetControl(i))) { |
| 3725 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) { |
| 3726 pWidget = pTempWidget; |
| 3727 break; |
| 3728 } |
| 3729 } |
| 3730 } |
| 3578 } | 3731 } |
| 3579 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) | 3732 } |
| 3580 || (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) | 3733 |
| 3581 { | 3734 if (pWidget) { |
| 3582 | 3735 m_pDocument->SetFocusAnnot(pWidget); |
| 3583 vRet = TRUE; | 3736 } |
| 3584 } | 3737 |
| 3585 else | 3738 return TRUE; |
| 3586 vRet = FALSE; | 3739 } |
| 3587 | 3740 |
| 3588 return TRUE; | 3741 FX_BOOL Field::setItems(IFXJS_Context* cc, |
| 3589 } | 3742 const CJS_Parameters& params, |
| 3590 | 3743 CJS_Value& vRet, |
| 3591 FX_BOOL Field::deleteItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 3744 CFX_WideString& sError) { |
| 3592 { | 3745 return TRUE; |
| 3593 return TRUE; | 3746 } |
| 3594 } | 3747 |
| 3595 | 3748 FX_BOOL Field::setLock(IFXJS_Context* cc, |
| 3596 int JS_COMPARESTRING(CFX_WideString* ps1, CFX_WideString* ps2) | 3749 const CJS_Parameters& params, |
| 3597 { | 3750 CJS_Value& vRet, |
| 3598 ASSERT(ps1 != NULL); | 3751 CFX_WideString& sError) { |
| 3599 ASSERT(ps2 != NULL); | 3752 return FALSE; |
| 3600 | 3753 } |
| 3601 return ps1->Compare(*ps2); | 3754 |
| 3602 } | 3755 FX_BOOL Field::signatureGetModifications(IFXJS_Context* cc, |
| 3603 | 3756 const CJS_Parameters& params, |
| 3604 | 3757 CJS_Value& vRet, |
| 3605 FX_BOOL Field::getArray(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 3758 CFX_WideString& sError) { |
| 3606 { | 3759 return FALSE; |
| 3607 ASSERT(m_pDocument != NULL); | 3760 } |
| 3608 | 3761 |
| 3609 CFX_PtrArray FieldArray; | 3762 FX_BOOL Field::signatureGetSeedValue(IFXJS_Context* cc, |
| 3610 GetFormFields(m_FieldName,FieldArray); | 3763 const CJS_Parameters& params, |
| 3611 if (FieldArray.GetSize() <= 0) return FALSE; | 3764 CJS_Value& vRet, |
| 3612 | 3765 CFX_WideString& sError) { |
| 3613 CGW_ArrayTemplate<CFX_WideString*> swSort; | 3766 return FALSE; |
| 3614 | 3767 } |
| 3615 for (int i=0,sz=FieldArray.GetSize(); i<sz; i++) | 3768 |
| 3616 { | 3769 FX_BOOL Field::signatureInfo(IFXJS_Context* cc, |
| 3617 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(i); | 3770 const CJS_Parameters& params, |
| 3618 ASSERT(pFormField != NULL); | 3771 CJS_Value& vRet, |
| 3619 | 3772 CFX_WideString& sError) { |
| 3620 swSort.Add(new CFX_WideString(pFormField->GetFullName())); | 3773 return FALSE; |
| 3621 | 3774 } |
| 3622 } | 3775 |
| 3623 swSort.Sort(JS_COMPARESTRING); | 3776 FX_BOOL Field::signatureSetSeedValue(IFXJS_Context* cc, |
| 3624 | 3777 const CJS_Parameters& params, |
| 3625 CJS_Context* pContext = (CJS_Context*)cc; | 3778 CJS_Value& vRet, |
| 3626 ASSERT(pContext != NULL); | 3779 CFX_WideString& sError) { |
| 3627 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 3780 return FALSE; |
| 3628 ASSERT(pRuntime != NULL); | 3781 } |
| 3629 | 3782 |
| 3630 CJS_Array FormFieldArray(m_isolate); | 3783 FX_BOOL Field::signatureSign(IFXJS_Context* cc, |
| 3631 for (int j=0,jsz = swSort.GetSize(); j<jsz; j++) | 3784 const CJS_Parameters& params, |
| 3632 { | 3785 CJS_Value& vRet, |
| 3633 CFX_WideString* pStr = swSort.GetAt(j); | 3786 CFX_WideString& sError) { |
| 3634 | 3787 return FALSE; |
| 3635 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnI
D(*pRuntime, L"Field")); | 3788 } |
| 3636 ASSERT(pObj.IsEmpty() == FALSE); | 3789 |
| 3637 | 3790 FX_BOOL Field::signatureValidate(IFXJS_Context* cc, |
| 3638 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pObj); | 3791 const CJS_Parameters& params, |
| 3639 ASSERT(pJSField != NULL); | 3792 CJS_Value& vRet, |
| 3640 | 3793 CFX_WideString& sError) { |
| 3641 Field* pField = (Field*)pJSField->GetEmbedObject(); | 3794 return FALSE; |
| 3642 ASSERT(pField != NULL); | 3795 } |
| 3643 | 3796 |
| 3644 pField->AttachField(m_pJSDoc, *pStr); | 3797 FX_BOOL Field::source(IFXJS_Context* cc, |
| 3645 | 3798 CJS_PropValue& vp, |
| 3646 CJS_Value FormFieldValue(m_isolate); | 3799 CFX_WideString& sError) { |
| 3647 FormFieldValue = pJSField; | 3800 if (vp.IsGetting()) { |
| 3648 FormFieldArray.SetElement(j, FormFieldValue); | 3801 vp << (CJS_Object*)NULL; |
| 3649 | 3802 } |
| 3650 delete pStr; | 3803 |
| 3651 } | 3804 return TRUE; |
| 3652 | 3805 } |
| 3653 vRet = FormFieldArray; | 3806 |
| 3654 swSort.RemoveAll(); | 3807 /////////////////////////////////////////// delay |
| 3655 return TRUE; | 3808 //////////////////////////////////////////////// |
| 3656 } | 3809 |
| 3657 | 3810 void Field::AddDelay_Int(enum FIELD_PROP prop, int32_t n) { |
| 3658 FX_BOOL Field::getItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 3811 ASSERT(m_pJSDoc != NULL); |
| 3659 { | 3812 |
| 3660 ASSERT(m_pDocument != NULL); | 3813 CJS_DelayData* pNewData = new CJS_DelayData; |
| 3661 int iSize = params.size(); | 3814 pNewData->sFieldName = m_FieldName; |
| 3662 | 3815 pNewData->nControlIndex = m_nFormControlIndex; |
| 3663 int nIdx = -1; | 3816 pNewData->eProp = prop; |
| 3664 if (iSize >= 1) | 3817 pNewData->num = n; |
| 3665 nIdx = params[0].ToInt(); | 3818 |
| 3666 | 3819 m_pJSDoc->AddDelayData(pNewData); |
| 3667 FX_BOOL bExport = TRUE; | 3820 } |
| 3668 if (iSize >= 2) | 3821 |
| 3669 bExport = params[1].ToBool(); | 3822 void Field::AddDelay_Bool(enum FIELD_PROP prop, bool b) { |
| 3670 | 3823 ASSERT(m_pJSDoc != NULL); |
| 3671 CFX_PtrArray FieldArray; | 3824 |
| 3672 GetFormFields(m_FieldName,FieldArray); | 3825 CJS_DelayData* pNewData = new CJS_DelayData; |
| 3673 if (FieldArray.GetSize() <= 0) return FALSE; | 3826 pNewData->sFieldName = m_FieldName; |
| 3674 | 3827 pNewData->nControlIndex = m_nFormControlIndex; |
| 3675 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3828 pNewData->eProp = prop; |
| 3676 ASSERT(pFormField != NULL); | 3829 pNewData->b = b; |
| 3677 | 3830 |
| 3678 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) | 3831 m_pJSDoc->AddDelayData(pNewData); |
| 3679 || (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) | 3832 } |
| 3680 { | 3833 |
| 3681 if (nIdx == -1 || nIdx > pFormField->CountOptions()) | 3834 void Field::AddDelay_String(enum FIELD_PROP prop, |
| 3682 nIdx = pFormField->CountOptions() -1; | 3835 const CFX_ByteString& string) { |
| 3683 if (bExport) | 3836 ASSERT(m_pJSDoc != NULL); |
| 3684 { | 3837 |
| 3685 CFX_WideString strval = pFormField->GetOptionValue(nIdx); | 3838 CJS_DelayData* pNewData = new CJS_DelayData; |
| 3686 if (strval.IsEmpty()) | 3839 pNewData->sFieldName = m_FieldName; |
| 3687 vRet = pFormField->GetOptionLabel(nIdx).c_str(); | 3840 pNewData->nControlIndex = m_nFormControlIndex; |
| 3688 else | 3841 pNewData->eProp = prop; |
| 3689 vRet = strval.c_str(); | 3842 pNewData->string = string; |
| 3690 } | 3843 |
| 3691 else | 3844 m_pJSDoc->AddDelayData(pNewData); |
| 3692 vRet = pFormField->GetOptionLabel(nIdx).c_str(); | 3845 } |
| 3693 } | 3846 |
| 3694 else | 3847 void Field::AddDelay_WideString(enum FIELD_PROP prop, |
| 3695 return FALSE; | 3848 const CFX_WideString& string) { |
| 3696 | 3849 ASSERT(m_pJSDoc != NULL); |
| 3697 return TRUE; | 3850 |
| 3698 } | 3851 CJS_DelayData* pNewData = new CJS_DelayData; |
| 3699 | 3852 pNewData->sFieldName = m_FieldName; |
| 3700 FX_BOOL Field::getLock(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) | 3853 pNewData->nControlIndex = m_nFormControlIndex; |
| 3701 { | 3854 pNewData->eProp = prop; |
| 3702 return FALSE; | 3855 pNewData->widestring = string; |
| 3703 } | 3856 |
| 3704 | 3857 m_pJSDoc->AddDelayData(pNewData); |
| 3705 FX_BOOL Field::insertItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 3858 } |
| 3706 { | 3859 |
| 3707 return TRUE; | 3860 void Field::AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect) { |
| 3708 } | 3861 ASSERT(m_pJSDoc != NULL); |
| 3709 | 3862 |
| 3710 FX_BOOL Field::isBoxChecked(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 3863 CJS_DelayData* pNewData = new CJS_DelayData; |
| 3711 { | 3864 pNewData->sFieldName = m_FieldName; |
| 3712 ASSERT(m_pDocument != NULL); | 3865 pNewData->nControlIndex = m_nFormControlIndex; |
| 3713 | 3866 pNewData->eProp = prop; |
| 3714 int nIndex = -1; | 3867 pNewData->rect = rect; |
| 3715 if (params.size() >= 1) | 3868 |
| 3716 nIndex = params[0].ToInt(); | 3869 m_pJSDoc->AddDelayData(pNewData); |
| 3717 | 3870 } |
| 3718 CFX_PtrArray FieldArray; | 3871 |
| 3719 GetFormFields(m_FieldName,FieldArray); | 3872 void Field::AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color) { |
| 3720 if (FieldArray.GetSize() <= 0) return FALSE; | 3873 ASSERT(m_pJSDoc != NULL); |
| 3721 | 3874 |
| 3722 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3875 CJS_DelayData* pNewData = new CJS_DelayData; |
| 3723 ASSERT(pFormField != NULL); | 3876 pNewData->sFieldName = m_FieldName; |
| 3724 | 3877 pNewData->nControlIndex = m_nFormControlIndex; |
| 3725 if(nIndex <0 || nIndex >= pFormField->CountControls()) | 3878 pNewData->eProp = prop; |
| 3726 { | 3879 pNewData->color = color; |
| 3727 vRet = FALSE; | 3880 |
| 3728 return FALSE; | 3881 m_pJSDoc->AddDelayData(pNewData); |
| 3729 } | 3882 } |
| 3730 | 3883 |
| 3731 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) | 3884 void Field::AddDelay_WordArray(enum FIELD_PROP prop, |
| 3732 || (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) | 3885 const CFX_DWordArray& array) { |
| 3733 { | 3886 ASSERT(m_pJSDoc != NULL); |
| 3734 if (pFormField->GetControl(nIndex)->IsChecked() !=0 ) | 3887 |
| 3735 vRet = TRUE; | 3888 CJS_DelayData* pNewData = new CJS_DelayData; |
| 3736 else | 3889 pNewData->sFieldName = m_FieldName; |
| 3737 vRet = FALSE; | 3890 pNewData->nControlIndex = m_nFormControlIndex; |
| 3738 } | 3891 pNewData->eProp = prop; |
| 3739 else | 3892 |
| 3740 vRet = FALSE; | 3893 for (int i = 0, sz = array.GetSize(); i < sz; i++) |
| 3741 | 3894 pNewData->wordarray.Add(array.GetAt(i)); |
| 3742 return TRUE; | 3895 |
| 3743 } | 3896 m_pJSDoc->AddDelayData(pNewData); |
| 3744 | 3897 } |
| 3745 FX_BOOL Field::isDefaultChecked(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 3898 |
| 3746 { | 3899 void Field::AddDelay_WideStringArray(enum FIELD_PROP prop, |
| 3747 ASSERT(m_pDocument != NULL); | 3900 const CJS_WideStringArray& array) { |
| 3748 | 3901 ASSERT(m_pJSDoc != NULL); |
| 3749 int nIndex = -1; | 3902 |
| 3750 if (params.size() >= 1) | 3903 CJS_DelayData* pNewData = new CJS_DelayData; |
| 3751 nIndex = params[0].ToInt(); | 3904 pNewData->sFieldName = m_FieldName; |
| 3752 | 3905 pNewData->nControlIndex = m_nFormControlIndex; |
| 3753 CFX_PtrArray FieldArray; | 3906 pNewData->eProp = prop; |
| 3754 GetFormFields(m_FieldName,FieldArray); | 3907 for (int i = 0, sz = array.GetSize(); i < sz; i++) |
| 3755 if (FieldArray.GetSize() <= 0) return FALSE; | 3908 pNewData->widestringarray.Add(array.GetAt(i)); |
| 3756 | 3909 |
| 3757 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3910 m_pJSDoc->AddDelayData(pNewData); |
| 3758 ASSERT(pFormField != NULL); | 3911 } |
| 3759 | 3912 |
| 3760 if(nIndex <0 || nIndex >= pFormField->CountControls()) | 3913 void Field::DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData) { |
| 3761 { | 3914 ASSERT(pDocument != NULL); |
| 3762 vRet = FALSE; | 3915 ASSERT(pData != NULL); |
| 3763 return FALSE; | 3916 |
| 3764 } | 3917 switch (pData->eProp) { |
| 3765 if ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) | |
| 3766 || (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)) | |
| 3767 { | |
| 3768 if (pFormField->GetControl(nIndex)->IsDefaultChecked() != 0) | |
| 3769 vRet = TRUE; | |
| 3770 else | |
| 3771 vRet = FALSE; | |
| 3772 } | |
| 3773 else | |
| 3774 vRet = FALSE; | |
| 3775 | |
| 3776 return TRUE; | |
| 3777 } | |
| 3778 | |
| 3779 FX_BOOL Field::setAction(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | |
| 3780 { | |
| 3781 return TRUE; | |
| 3782 } | |
| 3783 | |
| 3784 FX_BOOL Field::setFocus(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | |
| 3785 { | |
| 3786 ASSERT(m_pDocument != NULL); | |
| 3787 | |
| 3788 CFX_PtrArray FieldArray; | |
| 3789 GetFormFields(m_FieldName,FieldArray); | |
| 3790 if (FieldArray.GetSize() <= 0) return FALSE; | |
| 3791 | |
| 3792 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | |
| 3793 ASSERT(pFormField != NULL); | |
| 3794 | |
| 3795 int32_t nCount = pFormField->CountControls(); | |
| 3796 | |
| 3797 if (nCount < 1) return FALSE; | |
| 3798 | |
| 3799 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | |
| 3800 ASSERT(pInterForm != NULL); | |
| 3801 | |
| 3802 CPDFSDK_Widget* pWidget = NULL; | |
| 3803 if (nCount == 1) | |
| 3804 { | |
| 3805 pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); | |
| 3806 } | |
| 3807 else | |
| 3808 { | |
| 3809 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | |
| 3810 ASSERT(pEnv); | |
| 3811 CPDF_Page* pPage = (CPDF_Page*)pEnv->FFI_GetCurrentPage(m_pDocument->Get
Document()); | |
| 3812 if(!pPage) | |
| 3813 return FALSE; | |
| 3814 if (CPDFSDK_PageView* pCurPageView = m_pDocument->GetPageView(pPage)) | |
| 3815 { | |
| 3816 for (int32_t i=0; i<nCount; i++) | |
| 3817 { | |
| 3818 if (CPDFSDK_Widget* pTempWidget = pInterForm->GetWidget(pFormFi
eld->GetControl(i))) | |
| 3819 { | |
| 3820 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) | |
| 3821 { | |
| 3822 pWidget = pTempWidget; | |
| 3823 break; | |
| 3824 } | |
| 3825 } | |
| 3826 } | |
| 3827 } | |
| 3828 } | |
| 3829 | |
| 3830 if (pWidget) | |
| 3831 { | |
| 3832 m_pDocument->SetFocusAnnot(pWidget); | |
| 3833 } | |
| 3834 | |
| 3835 return TRUE; | |
| 3836 } | |
| 3837 | |
| 3838 FX_BOOL Field::setItems(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | |
| 3839 { | |
| 3840 return TRUE; | |
| 3841 } | |
| 3842 | |
| 3843 FX_BOOL Field::setLock(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) | |
| 3844 { | |
| 3845 return FALSE; | |
| 3846 } | |
| 3847 | |
| 3848 FX_BOOL Field::signatureGetModifications(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) | |
| 3849 { | |
| 3850 return FALSE; | |
| 3851 } | |
| 3852 | |
| 3853 FX_BOOL Field::signatureGetSeedValue(IFXJS_Context* cc, const CJS_Parameters& pa
rams, CJS_Value& vRet, CFX_WideString& sError) | |
| 3854 { | |
| 3855 return FALSE; | |
| 3856 } | |
| 3857 | |
| 3858 FX_BOOL Field::signatureInfo(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | |
| 3859 { | |
| 3860 return FALSE; | |
| 3861 } | |
| 3862 | |
| 3863 FX_BOOL Field::signatureSetSeedValue(IFXJS_Context* cc, const CJS_Parameters& pa
rams, CJS_Value& vRet, CFX_WideString& sError) | |
| 3864 { | |
| 3865 return FALSE; | |
| 3866 } | |
| 3867 | |
| 3868 FX_BOOL Field::signatureSign(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | |
| 3869 { | |
| 3870 return FALSE; | |
| 3871 } | |
| 3872 | |
| 3873 FX_BOOL Field::signatureValidate(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) | |
| 3874 { | |
| 3875 return FALSE; | |
| 3876 } | |
| 3877 | |
| 3878 FX_BOOL Field::source(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) | |
| 3879 { | |
| 3880 if (vp.IsGetting()) | |
| 3881 { | |
| 3882 vp << (CJS_Object*)NULL; | |
| 3883 } | |
| 3884 | |
| 3885 return TRUE; | |
| 3886 } | |
| 3887 | |
| 3888 /////////////////////////////////////////// delay //////////////////////////////
/////////////// | |
| 3889 | |
| 3890 void Field::AddDelay_Int(enum FIELD_PROP prop, int32_t n) | |
| 3891 { | |
| 3892 ASSERT(m_pJSDoc != NULL); | |
| 3893 | |
| 3894 CJS_DelayData* pNewData = new CJS_DelayData; | |
| 3895 pNewData->sFieldName = m_FieldName; | |
| 3896 pNewData->nControlIndex = m_nFormControlIndex; | |
| 3897 pNewData->eProp = prop; | |
| 3898 pNewData->num = n; | |
| 3899 | |
| 3900 m_pJSDoc->AddDelayData(pNewData); | |
| 3901 } | |
| 3902 | |
| 3903 void Field::AddDelay_Bool(enum FIELD_PROP prop,bool b) | |
| 3904 { | |
| 3905 ASSERT(m_pJSDoc != NULL); | |
| 3906 | |
| 3907 CJS_DelayData* pNewData = new CJS_DelayData; | |
| 3908 pNewData->sFieldName = m_FieldName; | |
| 3909 pNewData->nControlIndex = m_nFormControlIndex; | |
| 3910 pNewData->eProp = prop; | |
| 3911 pNewData->b = b; | |
| 3912 | |
| 3913 m_pJSDoc->AddDelayData(pNewData); | |
| 3914 } | |
| 3915 | |
| 3916 void Field::AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string) | |
| 3917 { | |
| 3918 ASSERT(m_pJSDoc != NULL); | |
| 3919 | |
| 3920 CJS_DelayData* pNewData = new CJS_DelayData; | |
| 3921 pNewData->sFieldName = m_FieldName; | |
| 3922 pNewData->nControlIndex = m_nFormControlIndex; | |
| 3923 pNewData->eProp = prop; | |
| 3924 pNewData->string = string; | |
| 3925 | |
| 3926 m_pJSDoc->AddDelayData(pNewData); | |
| 3927 } | |
| 3928 | |
| 3929 void Field::AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& stri
ng) | |
| 3930 { | |
| 3931 ASSERT(m_pJSDoc != NULL); | |
| 3932 | |
| 3933 CJS_DelayData* pNewData = new CJS_DelayData; | |
| 3934 pNewData->sFieldName = m_FieldName; | |
| 3935 pNewData->nControlIndex = m_nFormControlIndex; | |
| 3936 pNewData->eProp = prop; | |
| 3937 pNewData->widestring = string; | |
| 3938 | |
| 3939 m_pJSDoc->AddDelayData(pNewData); | |
| 3940 } | |
| 3941 | |
| 3942 void Field::AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect) | |
| 3943 { | |
| 3944 ASSERT(m_pJSDoc != NULL); | |
| 3945 | |
| 3946 CJS_DelayData* pNewData = new CJS_DelayData; | |
| 3947 pNewData->sFieldName = m_FieldName; | |
| 3948 pNewData->nControlIndex = m_nFormControlIndex; | |
| 3949 pNewData->eProp = prop; | |
| 3950 pNewData->rect = rect; | |
| 3951 | |
| 3952 m_pJSDoc->AddDelayData(pNewData); | |
| 3953 } | |
| 3954 | |
| 3955 void Field::AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color) | |
| 3956 { | |
| 3957 ASSERT(m_pJSDoc != NULL); | |
| 3958 | |
| 3959 CJS_DelayData* pNewData = new CJS_DelayData; | |
| 3960 pNewData->sFieldName = m_FieldName; | |
| 3961 pNewData->nControlIndex = m_nFormControlIndex; | |
| 3962 pNewData->eProp = prop; | |
| 3963 pNewData->color = color; | |
| 3964 | |
| 3965 m_pJSDoc->AddDelayData(pNewData); | |
| 3966 } | |
| 3967 | |
| 3968 void Field::AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array
) | |
| 3969 { | |
| 3970 ASSERT(m_pJSDoc != NULL); | |
| 3971 | |
| 3972 CJS_DelayData* pNewData = new CJS_DelayData; | |
| 3973 pNewData->sFieldName = m_FieldName; | |
| 3974 pNewData->nControlIndex = m_nFormControlIndex; | |
| 3975 pNewData->eProp = prop; | |
| 3976 | |
| 3977 for (int i=0,sz=array.GetSize(); i<sz; i++) | |
| 3978 pNewData->wordarray.Add(array.GetAt(i)); | |
| 3979 | |
| 3980 m_pJSDoc->AddDelayData(pNewData); | |
| 3981 } | |
| 3982 | |
| 3983 void Field::AddDelay_WideStringArray(enum FIELD_PROP prop, const CJS_WideStringA
rray& array) | |
| 3984 { | |
| 3985 ASSERT(m_pJSDoc != NULL); | |
| 3986 | |
| 3987 CJS_DelayData* pNewData = new CJS_DelayData; | |
| 3988 pNewData->sFieldName = m_FieldName; | |
| 3989 pNewData->nControlIndex = m_nFormControlIndex; | |
| 3990 pNewData->eProp = prop; | |
| 3991 for (int i=0,sz=array.GetSize(); i<sz; i++) | |
| 3992 pNewData->widestringarray.Add(array.GetAt(i)); | |
| 3993 | |
| 3994 m_pJSDoc->AddDelayData(pNewData); | |
| 3995 } | |
| 3996 | |
| 3997 void Field::DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData) | |
| 3998 { | |
| 3999 ASSERT(pDocument != NULL); | |
| 4000 ASSERT(pData != NULL); | |
| 4001 | |
| 4002 switch (pData->eProp) | |
| 4003 { | |
| 4004 case FP_ALIGNMENT: | 3918 case FP_ALIGNMENT: |
| 4005 Field::SetAlignment(pDocument, pData->sFieldName, pData->nControlIndex,
pData->string); | 3919 Field::SetAlignment(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4006 break; | 3920 pData->string); |
| 3921 break; |
| 4007 case FP_BORDERSTYLE: | 3922 case FP_BORDERSTYLE: |
| 4008 Field::SetBorderStyle(pDocument, pData->sFieldName, pData->nControlIndex
, pData->string); | 3923 Field::SetBorderStyle(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4009 break; | 3924 pData->string); |
| 3925 break; |
| 4010 case FP_BUTTONALIGNX: | 3926 case FP_BUTTONALIGNX: |
| 4011 Field::SetButtonAlignX(pDocument, pData->sFieldName, pData->nControlInde
x, pData->num); | 3927 Field::SetButtonAlignX(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4012 break; | 3928 pData->num); |
| 3929 break; |
| 4013 case FP_BUTTONALIGNY: | 3930 case FP_BUTTONALIGNY: |
| 4014 Field::SetButtonAlignY(pDocument, pData->sFieldName, pData->nControlInde
x, pData->num); | 3931 Field::SetButtonAlignY(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4015 break; | 3932 pData->num); |
| 3933 break; |
| 4016 case FP_BUTTONFITBOUNDS: | 3934 case FP_BUTTONFITBOUNDS: |
| 4017 Field::SetButtonFitBounds(pDocument, pData->sFieldName, pData->nControlI
ndex, pData->b); | 3935 Field::SetButtonFitBounds(pDocument, pData->sFieldName, |
| 4018 break; | 3936 pData->nControlIndex, pData->b); |
| 3937 break; |
| 4019 case FP_BUTTONPOSITION: | 3938 case FP_BUTTONPOSITION: |
| 4020 Field::SetButtonPosition(pDocument, pData->sFieldName, pData->nControlIn
dex, pData->num); | 3939 Field::SetButtonPosition(pDocument, pData->sFieldName, |
| 4021 break; | 3940 pData->nControlIndex, pData->num); |
| 3941 break; |
| 4022 case FP_BUTTONSCALEHOW: | 3942 case FP_BUTTONSCALEHOW: |
| 4023 Field::SetButtonScaleHow(pDocument, pData->sFieldName, pData->nControlIn
dex, pData->num); | 3943 Field::SetButtonScaleHow(pDocument, pData->sFieldName, |
| 4024 break; | 3944 pData->nControlIndex, pData->num); |
| 3945 break; |
| 4025 case FP_BUTTONSCALEWHEN: | 3946 case FP_BUTTONSCALEWHEN: |
| 4026 Field::SetButtonScaleWhen(pDocument, pData->sFieldName, pData->nControlI
ndex, pData->num); | 3947 Field::SetButtonScaleWhen(pDocument, pData->sFieldName, |
| 4027 break; | 3948 pData->nControlIndex, pData->num); |
| 3949 break; |
| 4028 case FP_CALCORDERINDEX: | 3950 case FP_CALCORDERINDEX: |
| 4029 Field::SetCalcOrderIndex(pDocument, pData->sFieldName, pData->nControlIn
dex, pData->num); | 3951 Field::SetCalcOrderIndex(pDocument, pData->sFieldName, |
| 4030 break; | 3952 pData->nControlIndex, pData->num); |
| 3953 break; |
| 4031 case FP_CHARLIMIT: | 3954 case FP_CHARLIMIT: |
| 4032 Field::SetCharLimit(pDocument, pData->sFieldName, pData->nControlIndex,
pData->num); | 3955 Field::SetCharLimit(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4033 break; | 3956 pData->num); |
| 3957 break; |
| 4034 case FP_COMB: | 3958 case FP_COMB: |
| 4035 Field::SetComb(pDocument, pData->sFieldName, pData->nControlIndex, pData
->b); | 3959 Field::SetComb(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4036 break; | 3960 pData->b); |
| 3961 break; |
| 4037 case FP_COMMITONSELCHANGE: | 3962 case FP_COMMITONSELCHANGE: |
| 4038 Field::SetCommitOnSelChange(pDocument, pData->sFieldName, pData->nContro
lIndex, pData->b); | 3963 Field::SetCommitOnSelChange(pDocument, pData->sFieldName, |
| 4039 break; | 3964 pData->nControlIndex, pData->b); |
| 3965 break; |
| 4040 case FP_CURRENTVALUEINDICES: | 3966 case FP_CURRENTVALUEINDICES: |
| 4041 Field::SetCurrentValueIndices(pDocument, pData->sFieldName, pData->nCont
rolIndex, pData->wordarray); | 3967 Field::SetCurrentValueIndices(pDocument, pData->sFieldName, |
| 4042 break; | 3968 pData->nControlIndex, pData->wordarray); |
| 3969 break; |
| 4043 case FP_DEFAULTVALUE: | 3970 case FP_DEFAULTVALUE: |
| 4044 Field::SetDefaultValue(pDocument, pData->sFieldName, pData->nControlInde
x, pData->widestring); | 3971 Field::SetDefaultValue(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4045 break; | 3972 pData->widestring); |
| 3973 break; |
| 4046 case FP_DONOTSCROLL: | 3974 case FP_DONOTSCROLL: |
| 4047 Field::SetDoNotScroll(pDocument, pData->sFieldName, pData->nControlIndex
, pData->b); | 3975 Field::SetDoNotScroll(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4048 break; | 3976 pData->b); |
| 3977 break; |
| 4049 case FP_DISPLAY: | 3978 case FP_DISPLAY: |
| 4050 Field::SetDisplay(pDocument, pData->sFieldName, pData->nControlIndex, pD
ata->num); | 3979 Field::SetDisplay(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4051 break; | 3980 pData->num); |
| 3981 break; |
| 4052 case FP_FILLCOLOR: | 3982 case FP_FILLCOLOR: |
| 4053 Field::SetFillColor(pDocument, pData->sFieldName, pData->nControlIndex,
pData->color); | 3983 Field::SetFillColor(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4054 break; | 3984 pData->color); |
| 3985 break; |
| 4055 case FP_HIDDEN: | 3986 case FP_HIDDEN: |
| 4056 Field::SetHidden(pDocument, pData->sFieldName, pData->nControlIndex, pDa
ta->b); | 3987 Field::SetHidden(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4057 break; | 3988 pData->b); |
| 3989 break; |
| 4058 case FP_HIGHLIGHT: | 3990 case FP_HIGHLIGHT: |
| 4059 Field::SetHighlight(pDocument, pData->sFieldName, pData->nControlIndex,
pData->string); | 3991 Field::SetHighlight(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4060 break; | 3992 pData->string); |
| 3993 break; |
| 4061 case FP_LINEWIDTH: | 3994 case FP_LINEWIDTH: |
| 4062 Field::SetLineWidth(pDocument, pData->sFieldName, pData->nControlIndex,
pData->num); | 3995 Field::SetLineWidth(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4063 break; | 3996 pData->num); |
| 3997 break; |
| 4064 case FP_MULTILINE: | 3998 case FP_MULTILINE: |
| 4065 Field::SetMultiline(pDocument, pData->sFieldName, pData->nControlIndex,
pData->b); | 3999 Field::SetMultiline(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4066 break; | 4000 pData->b); |
| 4001 break; |
| 4067 case FP_MULTIPLESELECTION: | 4002 case FP_MULTIPLESELECTION: |
| 4068 Field::SetMultipleSelection(pDocument, pData->sFieldName, pData->nContro
lIndex, pData->b); | 4003 Field::SetMultipleSelection(pDocument, pData->sFieldName, |
| 4069 break; | 4004 pData->nControlIndex, pData->b); |
| 4005 break; |
| 4070 case FP_PASSWORD: | 4006 case FP_PASSWORD: |
| 4071 Field::SetPassword(pDocument, pData->sFieldName, pData->nControlIndex, p
Data->b); | 4007 Field::SetPassword(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4072 break; | 4008 pData->b); |
| 4009 break; |
| 4073 case FP_RECT: | 4010 case FP_RECT: |
| 4074 Field::SetRect(pDocument, pData->sFieldName, pData->nControlIndex, pData
->rect); | 4011 Field::SetRect(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4075 break; | 4012 pData->rect); |
| 4013 break; |
| 4076 case FP_RICHTEXT: | 4014 case FP_RICHTEXT: |
| 4077 Field::SetRichText(pDocument, pData->sFieldName, pData->nControlIndex, p
Data->b); | 4015 Field::SetRichText(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4078 break; | 4016 pData->b); |
| 4017 break; |
| 4079 case FP_RICHVALUE: | 4018 case FP_RICHVALUE: |
| 4080 break; | 4019 break; |
| 4081 case FP_ROTATION: | 4020 case FP_ROTATION: |
| 4082 Field::SetRotation(pDocument, pData->sFieldName, pData->nControlIndex, p
Data->num); | 4021 Field::SetRotation(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4083 break; | 4022 pData->num); |
| 4023 break; |
| 4084 case FP_STROKECOLOR: | 4024 case FP_STROKECOLOR: |
| 4085 Field::SetStrokeColor(pDocument, pData->sFieldName, pData->nControlIndex
, pData->color); | 4025 Field::SetStrokeColor(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4086 break; | 4026 pData->color); |
| 4027 break; |
| 4087 case FP_STYLE: | 4028 case FP_STYLE: |
| 4088 Field::SetStyle(pDocument, pData->sFieldName, pData->nControlIndex, pDat
a->string); | 4029 Field::SetStyle(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4089 break; | 4030 pData->string); |
| 4031 break; |
| 4090 case FP_TEXTCOLOR: | 4032 case FP_TEXTCOLOR: |
| 4091 Field::SetTextColor(pDocument, pData->sFieldName, pData->nControlIndex,
pData->color); | 4033 Field::SetTextColor(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4092 break; | 4034 pData->color); |
| 4035 break; |
| 4093 case FP_TEXTFONT: | 4036 case FP_TEXTFONT: |
| 4094 Field::SetTextFont(pDocument, pData->sFieldName, pData->nControlIndex, p
Data->string); | 4037 Field::SetTextFont(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4095 break; | 4038 pData->string); |
| 4039 break; |
| 4096 case FP_TEXTSIZE: | 4040 case FP_TEXTSIZE: |
| 4097 Field::SetTextSize(pDocument, pData->sFieldName, pData->nControlIndex, p
Data->num); | 4041 Field::SetTextSize(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4098 break; | 4042 pData->num); |
| 4043 break; |
| 4099 case FP_USERNAME: | 4044 case FP_USERNAME: |
| 4100 Field::SetUserName(pDocument, pData->sFieldName, pData->nControlIndex, p
Data->widestring); | 4045 Field::SetUserName(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4101 break; | 4046 pData->widestring); |
| 4047 break; |
| 4102 case FP_VALUE: | 4048 case FP_VALUE: |
| 4103 Field::SetValue(pDocument, pData->sFieldName, pData->nControlIndex, pDat
a->widestringarray); | 4049 Field::SetValue(pDocument, pData->sFieldName, pData->nControlIndex, |
| 4104 break; | 4050 pData->widestringarray); |
| 4105 } | 4051 break; |
| 4106 } | 4052 } |
| 4107 | 4053 } |
| 4108 #define JS_FIELD_MINWIDTH 1 | 4054 |
| 4109 #define JS_FIELD_MINHEIGHT 1 | 4055 #define JS_FIELD_MINWIDTH 1 |
| 4110 | 4056 #define JS_FIELD_MINHEIGHT 1 |
| 4111 void Field::AddField(CPDFSDK_Document* pDocument, int nPageIndex, int nFieldType
, | 4057 |
| 4112 const CFX_WideString& sName, const CPDF_Rect& rcCoords) | 4058 void Field::AddField(CPDFSDK_Document* pDocument, |
| 4113 { | 4059 int nPageIndex, |
| 4114 //Not supported. | 4060 int nFieldType, |
| 4115 } | 4061 const CFX_WideString& sName, |
| 4116 | 4062 const CPDF_Rect& rcCoords) { |
| 4063 // Not supported. |
| 4064 } |
| OLD | NEW |