OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/javascript/Field.h" | 7 #include "fpdfsdk/javascript/Field.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 210 } |
211 | 211 |
212 FX_BOOL Field::AttachField(Document* pDocument, | 212 FX_BOOL Field::AttachField(Document* pDocument, |
213 const CFX_WideString& csFieldName) { | 213 const CFX_WideString& csFieldName) { |
214 m_pJSDoc = pDocument; | 214 m_pJSDoc = pDocument; |
215 m_pDocument.Reset(pDocument->GetReaderDoc()); | 215 m_pDocument.Reset(pDocument->GetReaderDoc()); |
216 m_bCanSet = m_pDocument->GetPermissions(FPDFPERM_FILL_FORM) || | 216 m_bCanSet = m_pDocument->GetPermissions(FPDFPERM_FILL_FORM) || |
217 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 217 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
218 m_pDocument->GetPermissions(FPDFPERM_MODIFY); | 218 m_pDocument->GetPermissions(FPDFPERM_MODIFY); |
219 | 219 |
220 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); | 220 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetEnv()->GetInterForm(); |
221 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); | 221 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); |
222 CFX_WideString swFieldNameTemp = csFieldName; | 222 CFX_WideString swFieldNameTemp = csFieldName; |
223 swFieldNameTemp.Replace(L"..", L"."); | 223 swFieldNameTemp.Replace(L"..", L"."); |
224 | 224 |
225 if (pInterForm->CountFields(swFieldNameTemp) <= 0) { | 225 if (pInterForm->CountFields(swFieldNameTemp) <= 0) { |
226 std::wstring strFieldName; | 226 std::wstring strFieldName; |
227 int iControlNo = -1; | 227 int iControlNo = -1; |
228 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo); | 228 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo); |
229 if (iControlNo == -1) | 229 if (iControlNo == -1) |
230 return FALSE; | 230 return FALSE; |
231 | 231 |
232 m_FieldName = strFieldName.c_str(); | 232 m_FieldName = strFieldName.c_str(); |
233 m_nFormControlIndex = iControlNo; | 233 m_nFormControlIndex = iControlNo; |
234 return TRUE; | 234 return TRUE; |
235 } | 235 } |
236 | 236 |
237 m_FieldName = swFieldNameTemp; | 237 m_FieldName = swFieldNameTemp; |
238 m_nFormControlIndex = -1; | 238 m_nFormControlIndex = -1; |
239 | 239 |
240 return TRUE; | 240 return TRUE; |
241 } | 241 } |
242 | 242 |
243 std::vector<CPDF_FormField*> Field::GetFormFields( | 243 std::vector<CPDF_FormField*> Field::GetFormFields( |
244 CPDFSDK_Document* pDocument, | 244 CPDFSDK_Document* pDocument, |
245 const CFX_WideString& csFieldName) { | 245 const CFX_WideString& csFieldName) { |
246 std::vector<CPDF_FormField*> fields; | 246 std::vector<CPDF_FormField*> fields; |
247 CPDFSDK_InterForm* pReaderInterForm = pDocument->GetInterForm(); | 247 CPDFSDK_InterForm* pReaderInterForm = pDocument->GetEnv()->GetInterForm(); |
248 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); | 248 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); |
249 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) { | 249 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) { |
250 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) | 250 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) |
251 fields.push_back(pFormField); | 251 fields.push_back(pFormField); |
252 } | 252 } |
253 return fields; | 253 return fields; |
254 } | 254 } |
255 | 255 |
256 std::vector<CPDF_FormField*> Field::GetFormFields( | 256 std::vector<CPDF_FormField*> Field::GetFormFields( |
257 const CFX_WideString& csFieldName) const { | 257 const CFX_WideString& csFieldName) const { |
258 return Field::GetFormFields(m_pDocument.Get(), csFieldName); | 258 return Field::GetFormFields(m_pDocument.Get(), csFieldName); |
259 } | 259 } |
260 | 260 |
261 void Field::UpdateFormField(CPDFSDK_Document* pDocument, | 261 void Field::UpdateFormField(CPDFSDK_Document* pDocument, |
262 CPDF_FormField* pFormField, | 262 CPDF_FormField* pFormField, |
263 FX_BOOL bChangeMark, | 263 FX_BOOL bChangeMark, |
264 FX_BOOL bResetAP, | 264 FX_BOOL bResetAP, |
265 FX_BOOL bRefresh) { | 265 FX_BOOL bRefresh) { |
266 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 266 CPDFSDK_InterForm* pInterForm = pDocument->GetEnv()->GetInterForm(); |
267 | 267 |
268 if (bResetAP) { | 268 if (bResetAP) { |
269 std::vector<CPDFSDK_Widget*> widgets; | 269 std::vector<CPDFSDK_Widget*> widgets; |
270 pInterForm->GetWidgets(pFormField, &widgets); | 270 pInterForm->GetWidgets(pFormField, &widgets); |
271 | 271 |
272 int nFieldType = pFormField->GetFieldType(); | 272 int nFieldType = pFormField->GetFieldType(); |
273 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { | 273 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { |
274 for (CPDFSDK_Annot* pAnnot : widgets) { | 274 for (CPDFSDK_Annot* pAnnot : widgets) { |
275 FX_BOOL bFormatted = FALSE; | 275 FX_BOOL bFormatted = FALSE; |
276 CPDFSDK_Annot::ObservedPtr pObserved(pAnnot); | 276 CPDFSDK_Annot::ObservedPtr pObserved(pAnnot); |
(...skipping 12 matching lines...) Expand all Loading... |
289 } | 289 } |
290 | 290 |
291 if (bRefresh) { | 291 if (bRefresh) { |
292 // Refresh the widget list. The calls in |bResetAP| may have caused widgets | 292 // Refresh the widget list. The calls in |bResetAP| may have caused widgets |
293 // to be removed from the list. We need to call |GetWidgets| again to be | 293 // to be removed from the list. We need to call |GetWidgets| again to be |
294 // sure none of the widgets have been deleted. | 294 // sure none of the widgets have been deleted. |
295 std::vector<CPDFSDK_Widget*> widgets; | 295 std::vector<CPDFSDK_Widget*> widgets; |
296 pInterForm->GetWidgets(pFormField, &widgets); | 296 pInterForm->GetWidgets(pFormField, &widgets); |
297 | 297 |
298 for (CPDFSDK_Widget* pWidget : widgets) { | 298 for (CPDFSDK_Widget* pWidget : widgets) { |
299 CPDFSDK_Document* pDoc = pWidget->GetInterForm()->GetDocument(); | 299 CPDFSDK_Document* pDoc = |
| 300 pWidget->GetInterForm()->GetFormFillEnv()->GetSDKDocument(); |
300 pDoc->UpdateAllViews(nullptr, pWidget); | 301 pDoc->UpdateAllViews(nullptr, pWidget); |
301 } | 302 } |
302 } | 303 } |
303 | 304 |
304 if (bChangeMark) | 305 if (bChangeMark) |
305 pDocument->SetChangeMark(); | 306 pDocument->SetChangeMark(); |
306 } | 307 } |
307 | 308 |
308 void Field::UpdateFormControl(CPDFSDK_Document* pDocument, | 309 void Field::UpdateFormControl(CPDFSDK_Document* pDocument, |
309 CPDF_FormControl* pFormControl, | 310 CPDF_FormControl* pFormControl, |
310 FX_BOOL bChangeMark, | 311 FX_BOOL bChangeMark, |
311 FX_BOOL bResetAP, | 312 FX_BOOL bResetAP, |
312 FX_BOOL bRefresh) { | 313 FX_BOOL bRefresh) { |
313 ASSERT(pFormControl); | 314 ASSERT(pFormControl); |
314 | 315 |
315 CPDFSDK_InterForm* pForm = pDocument->GetInterForm(); | 316 CPDFSDK_InterForm* pForm = pDocument->GetEnv()->GetInterForm(); |
316 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false); | 317 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false); |
317 | 318 |
318 if (pWidget) { | 319 if (pWidget) { |
319 if (bResetAP) { | 320 if (bResetAP) { |
320 int nFieldType = pWidget->GetFieldType(); | 321 int nFieldType = pWidget->GetFieldType(); |
321 if (nFieldType == FIELDTYPE_COMBOBOX || | 322 if (nFieldType == FIELDTYPE_COMBOBOX || |
322 nFieldType == FIELDTYPE_TEXTFIELD) { | 323 nFieldType == FIELDTYPE_TEXTFIELD) { |
323 FX_BOOL bFormatted = FALSE; | 324 FX_BOOL bFormatted = FALSE; |
324 CFX_WideString sValue = pWidget->OnFormat(bFormatted); | 325 CFX_WideString sValue = pWidget->OnFormat(bFormatted); |
325 pWidget->ResetAppearance(bFormatted ? &sValue : nullptr, FALSE); | 326 pWidget->ResetAppearance(bFormatted ? &sValue : nullptr, FALSE); |
326 } else { | 327 } else { |
327 pWidget->ResetAppearance(nullptr, FALSE); | 328 pWidget->ResetAppearance(nullptr, FALSE); |
328 } | 329 } |
329 } | 330 } |
330 | 331 |
331 if (bRefresh) { | 332 if (bRefresh) { |
332 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); | 333 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
333 CPDFSDK_Document* pDoc = pInterForm->GetDocument(); | 334 CPDFSDK_Document* pDoc = pInterForm->GetFormFillEnv()->GetSDKDocument(); |
334 pDoc->UpdateAllViews(nullptr, pWidget); | 335 pDoc->UpdateAllViews(nullptr, pWidget); |
335 } | 336 } |
336 } | 337 } |
337 | 338 |
338 if (bChangeMark) | 339 if (bChangeMark) |
339 pDocument->SetChangeMark(); | 340 pDocument->SetChangeMark(); |
340 } | 341 } |
341 | 342 |
342 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument, | 343 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_Document* pDocument, |
343 CPDF_FormControl* pFormControl, | 344 CPDF_FormControl* pFormControl, |
344 bool createIfNeeded) { | 345 bool createIfNeeded) { |
345 CPDFSDK_InterForm* pInterForm = | 346 CPDFSDK_InterForm* pInterForm = |
346 static_cast<CPDFSDK_InterForm*>(pDocument->GetInterForm()); | 347 static_cast<CPDFSDK_InterForm*>(pDocument->GetEnv()->GetInterForm()); |
347 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded) | 348 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded) |
348 : nullptr; | 349 : nullptr; |
349 } | 350 } |
350 | 351 |
351 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, | 352 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, |
352 CFX_WideString csOptLabel) { | 353 CFX_WideString csOptLabel) { |
353 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) { | 354 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) { |
354 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) | 355 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) |
355 return TRUE; | 356 return TRUE; |
356 } | 357 } |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 850 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
850 if (FieldArray.empty()) | 851 if (FieldArray.empty()) |
851 return FALSE; | 852 return FALSE; |
852 | 853 |
853 CPDF_FormField* pFormField = FieldArray[0]; | 854 CPDF_FormField* pFormField = FieldArray[0]; |
854 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && | 855 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && |
855 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) { | 856 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) { |
856 return FALSE; | 857 return FALSE; |
857 } | 858 } |
858 | 859 |
859 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetInterForm(); | 860 CPDFSDK_InterForm* pRDInterForm = m_pDocument->GetEnv()->GetInterForm(); |
860 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); | 861 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); |
861 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); | 862 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); |
862 } | 863 } |
863 | 864 |
864 return TRUE; | 865 return TRUE; |
865 } | 866 } |
866 | 867 |
867 void Field::SetCalcOrderIndex(CPDFSDK_Document* pDocument, | 868 void Field::SetCalcOrderIndex(CPDFSDK_Document* pDocument, |
868 const CFX_WideString& swFieldName, | 869 const CFX_WideString& swFieldName, |
869 int nControlIndex, | 870 int nControlIndex, |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 Field::SetDisplay(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, | 1253 Field::SetDisplay(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, |
1253 nVP); | 1254 nVP); |
1254 } | 1255 } |
1255 } else { | 1256 } else { |
1256 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 1257 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1257 if (FieldArray.empty()) | 1258 if (FieldArray.empty()) |
1258 return FALSE; | 1259 return FALSE; |
1259 | 1260 |
1260 CPDF_FormField* pFormField = FieldArray[0]; | 1261 CPDF_FormField* pFormField = FieldArray[0]; |
1261 ASSERT(pFormField); | 1262 ASSERT(pFormField); |
1262 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 1263 CPDFSDK_InterForm* pInterForm = m_pDocument->GetEnv()->GetInterForm(); |
1263 CPDFSDK_Widget* pWidget = | 1264 CPDFSDK_Widget* pWidget = |
1264 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); | 1265 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); |
1265 if (!pWidget) | 1266 if (!pWidget) |
1266 return FALSE; | 1267 return FALSE; |
1267 | 1268 |
1268 uint32_t dwFlag = pWidget->GetFlags(); | 1269 uint32_t dwFlag = pWidget->GetFlags(); |
1269 | 1270 |
1270 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { | 1271 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { |
1271 vp << (int32_t)1; | 1272 vp << (int32_t)1; |
1272 } else { | 1273 } else { |
1273 if (ANNOTFLAG_PRINT & dwFlag) { | 1274 if (ANNOTFLAG_PRINT & dwFlag) { |
1274 if (ANNOTFLAG_NOVIEW & dwFlag) { | 1275 if (ANNOTFLAG_NOVIEW & dwFlag) { |
1275 vp << (int32_t)3; | 1276 vp << (int32_t)3; |
1276 } else { | 1277 } else { |
1277 vp << (int32_t)0; | 1278 vp << (int32_t)0; |
1278 } | 1279 } |
1279 } else { | 1280 } else { |
1280 vp << (int32_t)2; | 1281 vp << (int32_t)2; |
1281 } | 1282 } |
1282 } | 1283 } |
1283 } | 1284 } |
1284 | 1285 |
1285 return TRUE; | 1286 return TRUE; |
1286 } | 1287 } |
1287 | 1288 |
1288 void Field::SetDisplay(CPDFSDK_Document* pDocument, | 1289 void Field::SetDisplay(CPDFSDK_Document* pDocument, |
1289 const CFX_WideString& swFieldName, | 1290 const CFX_WideString& swFieldName, |
1290 int nControlIndex, | 1291 int nControlIndex, |
1291 int number) { | 1292 int number) { |
1292 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 1293 CPDFSDK_InterForm* pInterForm = pDocument->GetEnv()->GetInterForm(); |
1293 std::vector<CPDF_FormField*> FieldArray = | 1294 std::vector<CPDF_FormField*> FieldArray = |
1294 GetFormFields(pDocument, swFieldName); | 1295 GetFormFields(pDocument, swFieldName); |
1295 for (CPDF_FormField* pFormField : FieldArray) { | 1296 for (CPDF_FormField* pFormField : FieldArray) { |
1296 if (nControlIndex < 0) { | 1297 if (nControlIndex < 0) { |
1297 bool bAnySet = false; | 1298 bool bAnySet = false; |
1298 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { | 1299 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { |
1299 CPDF_FormControl* pFormControl = pFormField->GetControl(i); | 1300 CPDF_FormControl* pFormControl = pFormField->GetControl(i); |
1300 ASSERT(pFormControl); | 1301 ASSERT(pFormControl); |
1301 | 1302 |
1302 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true); | 1303 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 Field::SetHidden(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, | 1517 Field::SetHidden(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, |
1517 bVP); | 1518 bVP); |
1518 } | 1519 } |
1519 } else { | 1520 } else { |
1520 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 1521 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1521 if (FieldArray.empty()) | 1522 if (FieldArray.empty()) |
1522 return FALSE; | 1523 return FALSE; |
1523 | 1524 |
1524 CPDF_FormField* pFormField = FieldArray[0]; | 1525 CPDF_FormField* pFormField = FieldArray[0]; |
1525 ASSERT(pFormField); | 1526 ASSERT(pFormField); |
1526 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 1527 CPDFSDK_InterForm* pInterForm = m_pDocument->GetEnv()->GetInterForm(); |
1527 CPDFSDK_Widget* pWidget = | 1528 CPDFSDK_Widget* pWidget = |
1528 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false); | 1529 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false); |
1529 if (!pWidget) | 1530 if (!pWidget) |
1530 return FALSE; | 1531 return FALSE; |
1531 | 1532 |
1532 uint32_t dwFlags = pWidget->GetFlags(); | 1533 uint32_t dwFlags = pWidget->GetFlags(); |
1533 | 1534 |
1534 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) | 1535 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) |
1535 vp << true; | 1536 vp << true; |
1536 else | 1537 else |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 1630 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1630 if (FieldArray.empty()) | 1631 if (FieldArray.empty()) |
1631 return FALSE; | 1632 return FALSE; |
1632 | 1633 |
1633 CPDF_FormField* pFormField = FieldArray[0]; | 1634 CPDF_FormField* pFormField = FieldArray[0]; |
1634 ASSERT(pFormField); | 1635 ASSERT(pFormField); |
1635 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 1636 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
1636 if (!pFormControl) | 1637 if (!pFormControl) |
1637 return FALSE; | 1638 return FALSE; |
1638 | 1639 |
1639 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 1640 CPDFSDK_InterForm* pInterForm = m_pDocument->GetEnv()->GetInterForm(); |
1640 if (!pFormField->CountControls()) | 1641 if (!pFormField->CountControls()) |
1641 return FALSE; | 1642 return FALSE; |
1642 | 1643 |
1643 CPDFSDK_Widget* pWidget = | 1644 CPDFSDK_Widget* pWidget = |
1644 pInterForm->GetWidget(pFormField->GetControl(0), false); | 1645 pInterForm->GetWidget(pFormField->GetControl(0), false); |
1645 if (!pWidget) | 1646 if (!pWidget) |
1646 return FALSE; | 1647 return FALSE; |
1647 | 1648 |
1648 vp << (int32_t)pWidget->GetBorderWidth(); | 1649 vp << (int32_t)pWidget->GetBorderWidth(); |
1649 } | 1650 } |
1650 | 1651 |
1651 return TRUE; | 1652 return TRUE; |
1652 } | 1653 } |
1653 | 1654 |
1654 void Field::SetLineWidth(CPDFSDK_Document* pDocument, | 1655 void Field::SetLineWidth(CPDFSDK_Document* pDocument, |
1655 const CFX_WideString& swFieldName, | 1656 const CFX_WideString& swFieldName, |
1656 int nControlIndex, | 1657 int nControlIndex, |
1657 int number) { | 1658 int number) { |
1658 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 1659 CPDFSDK_InterForm* pInterForm = pDocument->GetEnv()->GetInterForm(); |
1659 std::vector<CPDF_FormField*> FieldArray = | 1660 std::vector<CPDF_FormField*> FieldArray = |
1660 GetFormFields(pDocument, swFieldName); | 1661 GetFormFields(pDocument, swFieldName); |
1661 for (CPDF_FormField* pFormField : FieldArray) { | 1662 for (CPDF_FormField* pFormField : FieldArray) { |
1662 if (nControlIndex < 0) { | 1663 if (nControlIndex < 0) { |
1663 FX_BOOL bSet = FALSE; | 1664 FX_BOOL bSet = FALSE; |
1664 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { | 1665 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { |
1665 CPDF_FormControl* pFormControl = pFormField->GetControl(i); | 1666 CPDF_FormControl* pFormControl = pFormField->GetControl(i); |
1666 ASSERT(pFormControl); | 1667 ASSERT(pFormControl); |
1667 | 1668 |
1668 if (CPDFSDK_Widget* pWidget = | 1669 if (CPDFSDK_Widget* pWidget = |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 | 1822 |
1822 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 1823 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1823 if (FieldArray.empty()) | 1824 if (FieldArray.empty()) |
1824 return FALSE; | 1825 return FALSE; |
1825 | 1826 |
1826 CPDF_FormField* pFormField = FieldArray[0]; | 1827 CPDF_FormField* pFormField = FieldArray[0]; |
1827 if (!pFormField) | 1828 if (!pFormField) |
1828 return FALSE; | 1829 return FALSE; |
1829 | 1830 |
1830 std::vector<CPDFSDK_Widget*> widgets; | 1831 std::vector<CPDFSDK_Widget*> widgets; |
1831 m_pDocument->GetInterForm()->GetWidgets(pFormField, &widgets); | 1832 m_pDocument->GetEnv()->GetInterForm()->GetWidgets(pFormField, &widgets); |
1832 | 1833 |
1833 if (widgets.empty()) { | 1834 if (widgets.empty()) { |
1834 vp << (int32_t)-1; | 1835 vp << (int32_t)-1; |
1835 return TRUE; | 1836 return TRUE; |
1836 } | 1837 } |
1837 | 1838 |
1838 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 1839 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
1839 CJS_Array PageArray; | 1840 CJS_Array PageArray; |
1840 for (size_t i = 0; i < widgets.size(); ++i) { | 1841 for (size_t i = 0; i < widgets.size(); ++i) { |
1841 CPDFSDK_PageView* pPageView = widgets[i]->GetPageView(); | 1842 CPDFSDK_PageView* pPageView = widgets[i]->GetPageView(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 void Field::SetPassword(CPDFSDK_Document* pDocument, | 1890 void Field::SetPassword(CPDFSDK_Document* pDocument, |
1890 const CFX_WideString& swFieldName, | 1891 const CFX_WideString& swFieldName, |
1891 int nControlIndex, | 1892 int nControlIndex, |
1892 bool b) { | 1893 bool b) { |
1893 // Not supported. | 1894 // Not supported. |
1894 } | 1895 } |
1895 | 1896 |
1896 FX_BOOL Field::print(IJS_Context* cc, | 1897 FX_BOOL Field::print(IJS_Context* cc, |
1897 CJS_PropValue& vp, | 1898 CJS_PropValue& vp, |
1898 CFX_WideString& sError) { | 1899 CFX_WideString& sError) { |
1899 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 1900 CPDFSDK_InterForm* pInterForm = m_pDocument->GetEnv()->GetInterForm(); |
1900 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 1901 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
1901 if (FieldArray.empty()) | 1902 if (FieldArray.empty()) |
1902 return FALSE; | 1903 return FALSE; |
1903 | 1904 |
1904 if (vp.IsSetting()) { | 1905 if (vp.IsSetting()) { |
1905 if (!m_bCanSet) | 1906 if (!m_bCanSet) |
1906 return FALSE; | 1907 return FALSE; |
1907 | 1908 |
1908 bool bVP; | 1909 bool bVP; |
1909 vp >> bVP; | 1910 vp >> bVP; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2055 } else { | 2056 } else { |
2056 Field::SetRect(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, | 2057 Field::SetRect(m_pDocument.Get(), m_FieldName, m_nFormControlIndex, |
2057 crRect); | 2058 crRect); |
2058 } | 2059 } |
2059 } else { | 2060 } else { |
2060 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 2061 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
2061 if (FieldArray.empty()) | 2062 if (FieldArray.empty()) |
2062 return FALSE; | 2063 return FALSE; |
2063 | 2064 |
2064 CPDF_FormField* pFormField = FieldArray[0]; | 2065 CPDF_FormField* pFormField = FieldArray[0]; |
2065 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 2066 CPDFSDK_InterForm* pInterForm = m_pDocument->GetEnv()->GetInterForm(); |
2066 CPDFSDK_Widget* pWidget = | 2067 CPDFSDK_Widget* pWidget = |
2067 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); | 2068 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); |
2068 if (!pWidget) | 2069 if (!pWidget) |
2069 return FALSE; | 2070 return FALSE; |
2070 | 2071 |
2071 CFX_FloatRect crRect = pWidget->GetRect(); | 2072 CFX_FloatRect crRect = pWidget->GetRect(); |
2072 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left)); | 2073 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left)); |
2073 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top)); | 2074 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top)); |
2074 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)); | 2075 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)); |
2075 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)); | 2076 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)); |
2076 | 2077 |
2077 CJS_Array rcArray; | 2078 CJS_Array rcArray; |
2078 rcArray.SetElement(pRuntime, 0, Upper_Leftx); | 2079 rcArray.SetElement(pRuntime, 0, Upper_Leftx); |
2079 rcArray.SetElement(pRuntime, 1, Upper_Lefty); | 2080 rcArray.SetElement(pRuntime, 1, Upper_Lefty); |
2080 rcArray.SetElement(pRuntime, 2, Lower_Rightx); | 2081 rcArray.SetElement(pRuntime, 2, Lower_Rightx); |
2081 rcArray.SetElement(pRuntime, 3, Lower_Righty); | 2082 rcArray.SetElement(pRuntime, 3, Lower_Righty); |
2082 vp << rcArray; | 2083 vp << rcArray; |
2083 } | 2084 } |
2084 return TRUE; | 2085 return TRUE; |
2085 } | 2086 } |
2086 | 2087 |
2087 void Field::SetRect(CPDFSDK_Document* pDocument, | 2088 void Field::SetRect(CPDFSDK_Document* pDocument, |
2088 const CFX_WideString& swFieldName, | 2089 const CFX_WideString& swFieldName, |
2089 int nControlIndex, | 2090 int nControlIndex, |
2090 const CFX_FloatRect& rect) { | 2091 const CFX_FloatRect& rect) { |
2091 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 2092 CPDFSDK_InterForm* pInterForm = pDocument->GetEnv()->GetInterForm(); |
2092 std::vector<CPDF_FormField*> FieldArray = | 2093 std::vector<CPDF_FormField*> FieldArray = |
2093 GetFormFields(pDocument, swFieldName); | 2094 GetFormFields(pDocument, swFieldName); |
2094 for (CPDF_FormField* pFormField : FieldArray) { | 2095 for (CPDF_FormField* pFormField : FieldArray) { |
2095 if (nControlIndex < 0) { | 2096 if (nControlIndex < 0) { |
2096 FX_BOOL bSet = FALSE; | 2097 FX_BOOL bSet = FALSE; |
2097 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { | 2098 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { |
2098 CPDF_FormControl* pFormControl = pFormField->GetControl(i); | 2099 CPDF_FormControl* pFormControl = pFormField->GetControl(i); |
2099 ASSERT(pFormControl); | 2100 ASSERT(pFormControl); |
2100 | 2101 |
2101 if (CPDFSDK_Widget* pWidget = | 2102 if (CPDFSDK_Widget* pWidget = |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3190 CFX_WideString& sError) { | 3191 CFX_WideString& sError) { |
3191 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); | 3192 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); |
3192 if (FieldArray.empty()) | 3193 if (FieldArray.empty()) |
3193 return FALSE; | 3194 return FALSE; |
3194 | 3195 |
3195 CPDF_FormField* pFormField = FieldArray[0]; | 3196 CPDF_FormField* pFormField = FieldArray[0]; |
3196 int32_t nCount = pFormField->CountControls(); | 3197 int32_t nCount = pFormField->CountControls(); |
3197 if (nCount < 1) | 3198 if (nCount < 1) |
3198 return FALSE; | 3199 return FALSE; |
3199 | 3200 |
3200 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 3201 CPDFSDK_InterForm* pInterForm = m_pDocument->GetEnv()->GetInterForm(); |
3201 CPDFSDK_Widget* pWidget = nullptr; | 3202 CPDFSDK_Widget* pWidget = nullptr; |
3202 if (nCount == 1) { | 3203 if (nCount == 1) { |
3203 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false); | 3204 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false); |
3204 } else { | 3205 } else { |
3205 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); | 3206 CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetEnv(); |
3206 UnderlyingPageType* pPage = UnderlyingFromFPDFPage( | 3207 UnderlyingPageType* pPage = UnderlyingFromFPDFPage( |
3207 pEnv->GetCurrentPage(m_pDocument->GetUnderlyingDocument())); | 3208 pEnv->GetCurrentPage(m_pDocument->GetUnderlyingDocument())); |
3208 if (!pPage) | 3209 if (!pPage) |
3209 return FALSE; | 3210 return FALSE; |
3210 if (CPDFSDK_PageView* pCurPageView = | 3211 if (CPDFSDK_PageView* pCurPageView = |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3492 } | 3493 } |
3493 } | 3494 } |
3494 | 3495 |
3495 void Field::AddField(CPDFSDK_Document* pDocument, | 3496 void Field::AddField(CPDFSDK_Document* pDocument, |
3496 int nPageIndex, | 3497 int nPageIndex, |
3497 int nFieldType, | 3498 int nFieldType, |
3498 const CFX_WideString& sName, | 3499 const CFX_WideString& sName, |
3499 const CFX_FloatRect& rcCoords) { | 3500 const CFX_FloatRect& rcCoords) { |
3500 // Not supported. | 3501 // Not supported. |
3501 } | 3502 } |
OLD | NEW |