| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/include/fsdk_baseform.h" | 7 #include "fpdfsdk/include/fsdk_baseform.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1544 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 1545 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1545 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
| 1546 | 1546 |
| 1547 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 1547 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
| 1548 pEdit->SetFontMap(&font_map); | 1548 pEdit->SetFontMap(&font_map); |
| 1549 | 1549 |
| 1550 CFX_FloatRect rcClient = GetClientRect(); | 1550 CFX_FloatRect rcClient = GetClientRect(); |
| 1551 pEdit->SetPlateRect(rcClient); | 1551 pEdit->SetPlateRect(rcClient); |
| 1552 pEdit->SetAlignmentH(pControl->GetControlAlignment()); | 1552 pEdit->SetAlignmentH(pControl->GetControlAlignment()); |
| 1553 | 1553 |
| 1554 FX_DWORD dwFieldFlags = pField->GetFieldFlags(); | 1554 uint32_t dwFieldFlags = pField->GetFieldFlags(); |
| 1555 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; | 1555 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; |
| 1556 | 1556 |
| 1557 if (bMultiLine) { | 1557 if (bMultiLine) { |
| 1558 pEdit->SetMultiLine(TRUE); | 1558 pEdit->SetMultiLine(TRUE); |
| 1559 pEdit->SetAutoReturn(TRUE); | 1559 pEdit->SetAutoReturn(TRUE); |
| 1560 } else { | 1560 } else { |
| 1561 pEdit->SetAlignmentV(1); | 1561 pEdit->SetAlignmentV(1); |
| 1562 } | 1562 } |
| 1563 | 1563 |
| 1564 uint16_t subWord = 0; | 1564 uint16_t subWord = 0; |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2364 | 2364 |
| 2365 FX_BOOL bHide = action.GetHideStatus(); | 2365 FX_BOOL bHide = action.GetHideStatus(); |
| 2366 FX_BOOL bChanged = FALSE; | 2366 FX_BOOL bChanged = FALSE; |
| 2367 | 2367 |
| 2368 for (CPDF_FormField* pField : fields) { | 2368 for (CPDF_FormField* pField : fields) { |
| 2369 for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { | 2369 for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { |
| 2370 CPDF_FormControl* pControl = pField->GetControl(i); | 2370 CPDF_FormControl* pControl = pField->GetControl(i); |
| 2371 ASSERT(pControl); | 2371 ASSERT(pControl); |
| 2372 | 2372 |
| 2373 if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) { | 2373 if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) { |
| 2374 FX_DWORD nFlags = pWidget->GetFlags(); | 2374 uint32_t nFlags = pWidget->GetFlags(); |
| 2375 nFlags &= ~ANNOTFLAG_INVISIBLE; | 2375 nFlags &= ~ANNOTFLAG_INVISIBLE; |
| 2376 nFlags &= ~ANNOTFLAG_NOVIEW; | 2376 nFlags &= ~ANNOTFLAG_NOVIEW; |
| 2377 if (bHide) | 2377 if (bHide) |
| 2378 nFlags |= ANNOTFLAG_HIDDEN; | 2378 nFlags |= ANNOTFLAG_HIDDEN; |
| 2379 else | 2379 else |
| 2380 nFlags &= ~ANNOTFLAG_HIDDEN; | 2380 nFlags &= ~ANNOTFLAG_HIDDEN; |
| 2381 pWidget->SetFlags(nFlags); | 2381 pWidget->SetFlags(nFlags); |
| 2382 pWidget->GetPageView()->UpdateView(pWidget); | 2382 pWidget->GetPageView()->UpdateView(pWidget); |
| 2383 bChanged = TRUE; | 2383 bChanged = TRUE; |
| 2384 } | 2384 } |
| 2385 } | 2385 } |
| 2386 } | 2386 } |
| 2387 | 2387 |
| 2388 return bChanged; | 2388 return bChanged; |
| 2389 } | 2389 } |
| 2390 | 2390 |
| 2391 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { | 2391 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { |
| 2392 CFX_WideString sDestination = action.GetFilePath(); | 2392 CFX_WideString sDestination = action.GetFilePath(); |
| 2393 if (sDestination.IsEmpty()) | 2393 if (sDestination.IsEmpty()) |
| 2394 return FALSE; | 2394 return FALSE; |
| 2395 | 2395 |
| 2396 CPDF_Dictionary* pActionDict = action.GetDict(); | 2396 CPDF_Dictionary* pActionDict = action.GetDict(); |
| 2397 if (pActionDict->KeyExist("Fields")) { | 2397 if (pActionDict->KeyExist("Fields")) { |
| 2398 CPDF_ActionFields af(&action); | 2398 CPDF_ActionFields af(&action); |
| 2399 FX_DWORD dwFlags = action.GetFlags(); | 2399 uint32_t dwFlags = action.GetFlags(); |
| 2400 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 2400 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
| 2401 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 2401 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
| 2402 if (!fields.empty()) { | 2402 if (!fields.empty()) { |
| 2403 bool bIncludeOrExclude = !(dwFlags & 0x01); | 2403 bool bIncludeOrExclude = !(dwFlags & 0x01); |
| 2404 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) | 2404 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) |
| 2405 return FALSE; | 2405 return FALSE; |
| 2406 | 2406 |
| 2407 return SubmitFields(sDestination, fields, bIncludeOrExclude, false); | 2407 return SubmitFields(sDestination, fields, bIncludeOrExclude, false); |
| 2408 } | 2408 } |
| 2409 } | 2409 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2445 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictBy("FDF"); | 2445 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictBy("FDF"); |
| 2446 if (!pMainDict) | 2446 if (!pMainDict) |
| 2447 return FALSE; | 2447 return FALSE; |
| 2448 | 2448 |
| 2449 // Get fields | 2449 // Get fields |
| 2450 CPDF_Array* pFields = pMainDict->GetArrayBy("Fields"); | 2450 CPDF_Array* pFields = pMainDict->GetArrayBy("Fields"); |
| 2451 if (!pFields) | 2451 if (!pFields) |
| 2452 return FALSE; | 2452 return FALSE; |
| 2453 | 2453 |
| 2454 CFX_ByteTextBuf fdfEncodedData; | 2454 CFX_ByteTextBuf fdfEncodedData; |
| 2455 for (FX_DWORD i = 0; i < pFields->GetCount(); i++) { | 2455 for (uint32_t i = 0; i < pFields->GetCount(); i++) { |
| 2456 CPDF_Dictionary* pField = pFields->GetDictAt(i); | 2456 CPDF_Dictionary* pField = pFields->GetDictAt(i); |
| 2457 if (!pField) | 2457 if (!pField) |
| 2458 continue; | 2458 continue; |
| 2459 CFX_WideString name; | 2459 CFX_WideString name; |
| 2460 name = pField->GetUnicodeTextBy("T"); | 2460 name = pField->GetUnicodeTextBy("T"); |
| 2461 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); | 2461 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); |
| 2462 CFX_ByteString csBValue = pField->GetStringBy("V"); | 2462 CFX_ByteString csBValue = pField->GetStringBy("V"); |
| 2463 CFX_WideString csWValue = PDF_DecodeText(csBValue); | 2463 CFX_WideString csWValue = PDF_DecodeText(csBValue); |
| 2464 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); | 2464 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); |
| 2465 | 2465 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 } | 2562 } |
| 2563 | 2563 |
| 2564 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { | 2564 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { |
| 2565 ASSERT(action.GetDict()); | 2565 ASSERT(action.GetDict()); |
| 2566 | 2566 |
| 2567 CPDF_Dictionary* pActionDict = action.GetDict(); | 2567 CPDF_Dictionary* pActionDict = action.GetDict(); |
| 2568 if (!pActionDict->KeyExist("Fields")) | 2568 if (!pActionDict->KeyExist("Fields")) |
| 2569 return m_pInterForm->ResetForm(true); | 2569 return m_pInterForm->ResetForm(true); |
| 2570 | 2570 |
| 2571 CPDF_ActionFields af(&action); | 2571 CPDF_ActionFields af(&action); |
| 2572 FX_DWORD dwFlags = action.GetFlags(); | 2572 uint32_t dwFlags = action.GetFlags(); |
| 2573 | 2573 |
| 2574 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 2574 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
| 2575 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 2575 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
| 2576 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true); | 2576 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true); |
| 2577 } | 2577 } |
| 2578 | 2578 |
| 2579 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) { | 2579 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) { |
| 2580 return FALSE; | 2580 return FALSE; |
| 2581 } | 2581 } |
| 2582 | 2582 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2860 break; | 2860 break; |
| 2861 } | 2861 } |
| 2862 } | 2862 } |
| 2863 } | 2863 } |
| 2864 | 2864 |
| 2865 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2865 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { |
| 2866 CFX_FloatRect rcAnnot; | 2866 CFX_FloatRect rcAnnot; |
| 2867 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2867 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
| 2868 return rcAnnot; | 2868 return rcAnnot; |
| 2869 } | 2869 } |
| OLD | NEW |