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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 switch (nFieldType) { | 478 switch (nFieldType) { |
479 case FIELDTYPE_PUSHBUTTON: | 479 case FIELDTYPE_PUSHBUTTON: |
480 case FIELDTYPE_COMBOBOX: | 480 case FIELDTYPE_COMBOBOX: |
481 case FIELDTYPE_LISTBOX: | 481 case FIELDTYPE_LISTBOX: |
482 case FIELDTYPE_TEXTFIELD: | 482 case FIELDTYPE_TEXTFIELD: |
483 case FIELDTYPE_SIGNATURE: | 483 case FIELDTYPE_SIGNATURE: |
484 return psub->IsStream(); | 484 return psub->IsStream(); |
485 case FIELDTYPE_CHECKBOX: | 485 case FIELDTYPE_CHECKBOX: |
486 case FIELDTYPE_RADIOBUTTON: | 486 case FIELDTYPE_RADIOBUTTON: |
487 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { | 487 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { |
488 return pSubDict->GetStreamBy(GetAppState()) != NULL; | 488 return !!pSubDict->GetStreamBy(GetAppState().AsByteStringC()); |
489 } | 489 } |
490 return FALSE; | 490 return FALSE; |
491 } | 491 } |
492 return TRUE; | 492 return TRUE; |
493 } | 493 } |
494 | 494 |
495 int CPDFSDK_Widget::GetFieldType() const { | 495 int CPDFSDK_Widget::GetFieldType() const { |
496 return GetFormField()->GetFieldType(); | 496 return GetFormField()->GetFieldType(); |
497 } | 497 } |
498 | 498 |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 | 1833 |
1834 return crFill; | 1834 return crFill; |
1835 } | 1835 } |
1836 | 1836 |
1837 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, | 1837 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, |
1838 CPDF_Stream* pImage) { | 1838 CPDF_Stream* pImage) { |
1839 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 1839 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
1840 ASSERT(pDoc); | 1840 ASSERT(pDoc); |
1841 | 1841 |
1842 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); | 1842 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); |
1843 CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType); | 1843 CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType.AsByteStringC()); |
1844 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 1844 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
1845 CFX_ByteString sImageAlias = "IMG"; | 1845 CFX_ByteString sImageAlias = "IMG"; |
1846 | 1846 |
1847 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { | 1847 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { |
1848 sImageAlias = pImageDict->GetStringBy("Name"); | 1848 sImageAlias = pImageDict->GetStringBy("Name"); |
1849 if (sImageAlias.IsEmpty()) | 1849 if (sImageAlias.IsEmpty()) |
1850 sImageAlias = "IMG"; | 1850 sImageAlias = "IMG"; |
1851 } | 1851 } |
1852 | 1852 |
1853 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); | 1853 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); |
1854 if (!pStreamResList) { | 1854 if (!pStreamResList) { |
1855 pStreamResList = new CPDF_Dictionary(); | 1855 pStreamResList = new CPDF_Dictionary(); |
1856 pStreamDict->SetAt("Resources", pStreamResList); | 1856 pStreamDict->SetAt("Resources", pStreamResList); |
1857 } | 1857 } |
1858 | 1858 |
1859 if (pStreamResList) { | 1859 if (pStreamResList) { |
1860 CPDF_Dictionary* pXObject = new CPDF_Dictionary; | 1860 CPDF_Dictionary* pXObject = new CPDF_Dictionary; |
1861 pXObject->SetAtReference(sImageAlias, pDoc, pImage); | 1861 pXObject->SetAtReference(sImageAlias.AsByteStringC(), pDoc, pImage); |
1862 pStreamResList->SetAt("XObject", pXObject); | 1862 pStreamResList->SetAt("XObject", pXObject); |
1863 } | 1863 } |
1864 } | 1864 } |
1865 | 1865 |
1866 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { | 1866 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { |
1867 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) { | 1867 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) { |
1868 pAPDict->RemoveAt(sAPType); | 1868 pAPDict->RemoveAt(sAPType.AsByteStringC()); |
1869 } | 1869 } |
1870 } | 1870 } |
1871 | 1871 |
1872 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, | 1872 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
1873 PDFSDK_FieldAction& data, | 1873 PDFSDK_FieldAction& data, |
1874 CPDFSDK_PageView* pPageView) { | 1874 CPDFSDK_PageView* pPageView) { |
1875 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1875 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
1876 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 1876 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
1877 | 1877 |
1878 #ifdef PDF_ENABLE_XFA | 1878 #ifdef PDF_ENABLE_XFA |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 break; | 2863 break; |
2864 } | 2864 } |
2865 } | 2865 } |
2866 } | 2866 } |
2867 | 2867 |
2868 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2868 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { |
2869 CFX_FloatRect rcAnnot; | 2869 CFX_FloatRect rcAnnot; |
2870 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2870 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
2871 return rcAnnot; | 2871 return rcAnnot; |
2872 } | 2872 } |
OLD | NEW |