| 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 switch (nFieldType) { | 459 switch (nFieldType) { |
| 460 case FIELDTYPE_PUSHBUTTON: | 460 case FIELDTYPE_PUSHBUTTON: |
| 461 case FIELDTYPE_COMBOBOX: | 461 case FIELDTYPE_COMBOBOX: |
| 462 case FIELDTYPE_LISTBOX: | 462 case FIELDTYPE_LISTBOX: |
| 463 case FIELDTYPE_TEXTFIELD: | 463 case FIELDTYPE_TEXTFIELD: |
| 464 case FIELDTYPE_SIGNATURE: | 464 case FIELDTYPE_SIGNATURE: |
| 465 return psub->IsStream(); | 465 return psub->IsStream(); |
| 466 case FIELDTYPE_CHECKBOX: | 466 case FIELDTYPE_CHECKBOX: |
| 467 case FIELDTYPE_RADIOBUTTON: | 467 case FIELDTYPE_RADIOBUTTON: |
| 468 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { | 468 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { |
| 469 return pSubDict->GetStreamBy(GetAppState()) != NULL; | 469 return !!pSubDict->GetStreamBy(GetAppState().AsByteStringC()); |
| 470 } | 470 } |
| 471 return FALSE; | 471 return FALSE; |
| 472 } | 472 } |
| 473 return TRUE; | 473 return TRUE; |
| 474 } | 474 } |
| 475 | 475 |
| 476 int CPDFSDK_Widget::GetFieldType() const { | 476 int CPDFSDK_Widget::GetFieldType() const { |
| 477 return GetFormField()->GetFieldType(); | 477 return GetFormField()->GetFieldType(); |
| 478 } | 478 } |
| 479 | 479 |
| (...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 | 1806 |
| 1807 return crFill; | 1807 return crFill; |
| 1808 } | 1808 } |
| 1809 | 1809 |
| 1810 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, | 1810 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, |
| 1811 CPDF_Stream* pImage) { | 1811 CPDF_Stream* pImage) { |
| 1812 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 1812 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
| 1813 ASSERT(pDoc); | 1813 ASSERT(pDoc); |
| 1814 | 1814 |
| 1815 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); | 1815 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); |
| 1816 CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType); | 1816 CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType.AsByteStringC()); |
| 1817 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 1817 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
| 1818 CFX_ByteString sImageAlias = "IMG"; | 1818 CFX_ByteString sImageAlias = "IMG"; |
| 1819 | 1819 |
| 1820 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { | 1820 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { |
| 1821 sImageAlias = pImageDict->GetStringBy("Name"); | 1821 sImageAlias = pImageDict->GetStringBy("Name"); |
| 1822 if (sImageAlias.IsEmpty()) | 1822 if (sImageAlias.IsEmpty()) |
| 1823 sImageAlias = "IMG"; | 1823 sImageAlias = "IMG"; |
| 1824 } | 1824 } |
| 1825 | 1825 |
| 1826 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); | 1826 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); |
| 1827 if (!pStreamResList) { | 1827 if (!pStreamResList) { |
| 1828 pStreamResList = new CPDF_Dictionary(); | 1828 pStreamResList = new CPDF_Dictionary(); |
| 1829 pStreamDict->SetAt("Resources", pStreamResList); | 1829 pStreamDict->SetAt("Resources", pStreamResList); |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 if (pStreamResList) { | 1832 if (pStreamResList) { |
| 1833 CPDF_Dictionary* pXObject = new CPDF_Dictionary; | 1833 CPDF_Dictionary* pXObject = new CPDF_Dictionary; |
| 1834 pXObject->SetAtReference(sImageAlias, pDoc, pImage); | 1834 pXObject->SetAtReference(sImageAlias.AsByteStringC(), pDoc, pImage); |
| 1835 pStreamResList->SetAt("XObject", pXObject); | 1835 pStreamResList->SetAt("XObject", pXObject); |
| 1836 } | 1836 } |
| 1837 } | 1837 } |
| 1838 | 1838 |
| 1839 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { | 1839 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { |
| 1840 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) { | 1840 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) { |
| 1841 pAPDict->RemoveAt(sAPType); | 1841 pAPDict->RemoveAt(sAPType.AsByteStringC()); |
| 1842 } | 1842 } |
| 1843 } | 1843 } |
| 1844 | 1844 |
| 1845 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, | 1845 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
| 1846 PDFSDK_FieldAction& data, | 1846 PDFSDK_FieldAction& data, |
| 1847 CPDFSDK_PageView* pPageView) { | 1847 CPDFSDK_PageView* pPageView) { |
| 1848 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1848 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
| 1849 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 1849 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 1850 | 1850 |
| 1851 #ifdef PDF_ENABLE_XFA | 1851 #ifdef PDF_ENABLE_XFA |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2829 break; | 2829 break; |
| 2830 } | 2830 } |
| 2831 } | 2831 } |
| 2832 } | 2832 } |
| 2833 | 2833 |
| 2834 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2834 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { |
| 2835 CFX_FloatRect rcAnnot; | 2835 CFX_FloatRect rcAnnot; |
| 2836 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2836 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
| 2837 return rcAnnot; | 2837 return rcAnnot; |
| 2838 } | 2838 } |
| OLD | NEW |