| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/cpdfsdk_widget.h" | 7 #include "fpdfsdk/include/cpdfsdk_widget.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 448 |
| 449 pFormField->SetValue(L"", TRUE); | 449 pFormField->SetValue(L"", TRUE); |
| 450 break; | 450 break; |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 #endif // PDF_ENABLE_XFA | 454 #endif // PDF_ENABLE_XFA |
| 455 | 455 |
| 456 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( | 456 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( |
| 457 CPDF_Annot::AppearanceMode mode) { | 457 CPDF_Annot::AppearanceMode mode) { |
| 458 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); | 458 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); |
| 459 if (!pAP) | 459 if (!pAP) |
| 460 return FALSE; | 460 return FALSE; |
| 461 | 461 |
| 462 // Choose the right sub-ap | 462 // Choose the right sub-ap |
| 463 const FX_CHAR* ap_entry = "N"; | 463 const FX_CHAR* ap_entry = "N"; |
| 464 if (mode == CPDF_Annot::Down) | 464 if (mode == CPDF_Annot::Down) |
| 465 ap_entry = "D"; | 465 ap_entry = "D"; |
| 466 else if (mode == CPDF_Annot::Rollover) | 466 else if (mode == CPDF_Annot::Rollover) |
| 467 ap_entry = "R"; | 467 ap_entry = "R"; |
| 468 if (!pAP->KeyExist(ap_entry)) | 468 if (!pAP->KeyExist(ap_entry)) |
| 469 ap_entry = "N"; | 469 ap_entry = "N"; |
| 470 | 470 |
| 471 // Get the AP stream or subdirectory | 471 // Get the AP stream or subdirectory |
| 472 CPDF_Object* psub = pAP->GetDirectObjectBy(ap_entry); | 472 CPDF_Object* psub = pAP->GetDirectObjectFor(ap_entry); |
| 473 if (!psub) | 473 if (!psub) |
| 474 return FALSE; | 474 return FALSE; |
| 475 | 475 |
| 476 int nFieldType = GetFieldType(); | 476 int nFieldType = GetFieldType(); |
| 477 switch (nFieldType) { | 477 switch (nFieldType) { |
| 478 case FIELDTYPE_PUSHBUTTON: | 478 case FIELDTYPE_PUSHBUTTON: |
| 479 case FIELDTYPE_COMBOBOX: | 479 case FIELDTYPE_COMBOBOX: |
| 480 case FIELDTYPE_LISTBOX: | 480 case FIELDTYPE_LISTBOX: |
| 481 case FIELDTYPE_TEXTFIELD: | 481 case FIELDTYPE_TEXTFIELD: |
| 482 case FIELDTYPE_SIGNATURE: | 482 case FIELDTYPE_SIGNATURE: |
| 483 return psub->IsStream(); | 483 return psub->IsStream(); |
| 484 case FIELDTYPE_CHECKBOX: | 484 case FIELDTYPE_CHECKBOX: |
| 485 case FIELDTYPE_RADIOBUTTON: | 485 case FIELDTYPE_RADIOBUTTON: |
| 486 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { | 486 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { |
| 487 return !!pSubDict->GetStreamBy(GetAppState()); | 487 return !!pSubDict->GetStreamFor(GetAppState()); |
| 488 } | 488 } |
| 489 return FALSE; | 489 return FALSE; |
| 490 } | 490 } |
| 491 return TRUE; | 491 return TRUE; |
| 492 } | 492 } |
| 493 | 493 |
| 494 int CPDFSDK_Widget::GetFieldType() const { | 494 int CPDFSDK_Widget::GetFieldType() const { |
| 495 CPDF_FormField* pField = GetFormField(); | 495 CPDF_FormField* pField = GetFormField(); |
| 496 return pField ? pField->GetFieldType() : FIELDTYPE_UNKNOWN; | 496 return pField ? pField->GetFieldType() : FIELDTYPE_UNKNOWN; |
| 497 } | 497 } |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 pNormalIcon = pControl->GetNormalIcon(); | 963 pNormalIcon = pControl->GetNormalIcon(); |
| 964 | 964 |
| 965 if (pControl->HasMKEntry("RI")) | 965 if (pControl->HasMKEntry("RI")) |
| 966 pRolloverIcon = pControl->GetRolloverIcon(); | 966 pRolloverIcon = pControl->GetRolloverIcon(); |
| 967 | 967 |
| 968 if (pControl->HasMKEntry("IX")) | 968 if (pControl->HasMKEntry("IX")) |
| 969 pDownIcon = pControl->GetDownIcon(); | 969 pDownIcon = pControl->GetDownIcon(); |
| 970 | 970 |
| 971 if (pNormalIcon) { | 971 if (pNormalIcon) { |
| 972 if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict()) { | 972 if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict()) { |
| 973 if (pImageDict->GetStringBy("Name").IsEmpty()) | 973 if (pImageDict->GetStringFor("Name").IsEmpty()) |
| 974 pImageDict->SetAtString("Name", "ImgA"); | 974 pImageDict->SetStringFor("Name", "ImgA"); |
| 975 } | 975 } |
| 976 } | 976 } |
| 977 | 977 |
| 978 if (pRolloverIcon) { | 978 if (pRolloverIcon) { |
| 979 if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict()) { | 979 if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict()) { |
| 980 if (pImageDict->GetStringBy("Name").IsEmpty()) | 980 if (pImageDict->GetStringFor("Name").IsEmpty()) |
| 981 pImageDict->SetAtString("Name", "ImgB"); | 981 pImageDict->SetStringFor("Name", "ImgB"); |
| 982 } | 982 } |
| 983 } | 983 } |
| 984 | 984 |
| 985 if (pDownIcon) { | 985 if (pDownIcon) { |
| 986 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { | 986 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { |
| 987 if (pImageDict->GetStringBy("Name").IsEmpty()) | 987 if (pImageDict->GetStringFor("Name").IsEmpty()) |
| 988 pImageDict->SetAtString("Name", "ImgC"); | 988 pImageDict->SetStringFor("Name", "ImgC"); |
| 989 } | 989 } |
| 990 } | 990 } |
| 991 | 991 |
| 992 CPDF_IconFit iconFit = pControl->GetIconFit(); | 992 CPDF_IconFit iconFit = pControl->GetIconFit(); |
| 993 | 993 |
| 994 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 994 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
| 995 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); | 995 CPDFSDK_Environment* pEnv = pDoc->GetEnv(); |
| 996 | 996 |
| 997 CBA_FontMap font_map(this, pEnv->GetSysHandler()); | 997 CBA_FontMap font_map(this, pEnv->GetSysHandler()); |
| 998 font_map.SetAPType("N"); | 998 font_map.SetAPType("N"); |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1803 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1804 | 1804 |
| 1805 return crFill; | 1805 return crFill; |
| 1806 } | 1806 } |
| 1807 | 1807 |
| 1808 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, | 1808 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, |
| 1809 CPDF_Stream* pImage) { | 1809 CPDF_Stream* pImage) { |
| 1810 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 1810 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
| 1811 ASSERT(pDoc); | 1811 ASSERT(pDoc); |
| 1812 | 1812 |
| 1813 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); | 1813 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); |
| 1814 CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType); | 1814 CPDF_Stream* pStream = pAPDict->GetStreamFor(sAPType); |
| 1815 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 1815 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
| 1816 CFX_ByteString sImageAlias = "IMG"; | 1816 CFX_ByteString sImageAlias = "IMG"; |
| 1817 | 1817 |
| 1818 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { | 1818 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { |
| 1819 sImageAlias = pImageDict->GetStringBy("Name"); | 1819 sImageAlias = pImageDict->GetStringFor("Name"); |
| 1820 if (sImageAlias.IsEmpty()) | 1820 if (sImageAlias.IsEmpty()) |
| 1821 sImageAlias = "IMG"; | 1821 sImageAlias = "IMG"; |
| 1822 } | 1822 } |
| 1823 | 1823 |
| 1824 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); | 1824 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); |
| 1825 if (!pStreamResList) { | 1825 if (!pStreamResList) { |
| 1826 pStreamResList = new CPDF_Dictionary(); | 1826 pStreamResList = new CPDF_Dictionary(); |
| 1827 pStreamDict->SetAt("Resources", pStreamResList); | 1827 pStreamDict->SetFor("Resources", pStreamResList); |
| 1828 } | 1828 } |
| 1829 | 1829 |
| 1830 if (pStreamResList) { | 1830 if (pStreamResList) { |
| 1831 CPDF_Dictionary* pXObject = new CPDF_Dictionary; | 1831 CPDF_Dictionary* pXObject = new CPDF_Dictionary; |
| 1832 pXObject->SetAtReference(sImageAlias, pDoc, pImage); | 1832 pXObject->SetReferenceFor(sImageAlias, pDoc, pImage); |
| 1833 pStreamResList->SetAt("XObject", pXObject); | 1833 pStreamResList->SetFor("XObject", pXObject); |
| 1834 } | 1834 } |
| 1835 } | 1835 } |
| 1836 | 1836 |
| 1837 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { | 1837 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { |
| 1838 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) | 1838 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) |
| 1839 pAPDict->RemoveAt(sAPType); | 1839 pAPDict->RemoveFor(sAPType); |
| 1840 } | 1840 } |
| 1841 | 1841 |
| 1842 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, | 1842 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
| 1843 PDFSDK_FieldAction& data, | 1843 PDFSDK_FieldAction& data, |
| 1844 CPDFSDK_PageView* pPageView) { | 1844 CPDFSDK_PageView* pPageView) { |
| 1845 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1845 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
| 1846 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); | 1846 CPDFSDK_Environment* pEnv = pDocument->GetEnv(); |
| 1847 | 1847 |
| 1848 #ifdef PDF_ENABLE_XFA | 1848 #ifdef PDF_ENABLE_XFA |
| 1849 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | 1849 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1943 return FALSE; | 1943 return FALSE; |
| 1944 | 1944 |
| 1945 if (!IsVisible()) | 1945 if (!IsVisible()) |
| 1946 return FALSE; | 1946 return FALSE; |
| 1947 | 1947 |
| 1948 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 1948 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
| 1949 return FALSE; | 1949 return FALSE; |
| 1950 | 1950 |
| 1951 return TRUE; | 1951 return TRUE; |
| 1952 } | 1952 } |
| OLD | NEW |