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 "../../third_party/base/nonstd_unique_ptr.h" | 7 #include "../../third_party/base/nonstd_unique_ptr.h" |
8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
9 #include "../include/fsdk_mgr.h" | 9 #include "../include/fsdk_mgr.h" |
10 #include "../include/fsdk_baseannot.h" | 10 #include "../include/fsdk_baseannot.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 ASSERT(m_pInterForm != NULL); | 32 ASSERT(m_pInterForm != NULL); |
33 } | 33 } |
34 | 34 |
35 CPDFSDK_Widget::~CPDFSDK_Widget() | 35 CPDFSDK_Widget::~CPDFSDK_Widget() |
36 { | 36 { |
37 | 37 |
38 } | 38 } |
39 | 39 |
40 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMo
de mode) | 40 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMo
de mode) |
41 { | 41 { |
42 » ASSERT(m_pAnnot != NULL); | 42 » CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
43 » ASSERT(m_pAnnot->m_pAnnotDict != NULL); | |
44 » | |
45 » CPDF_Dictionary* pAP = m_pAnnot->m_pAnnotDict->GetDict("AP"); | |
46 if (pAP == NULL) return FALSE; | 43 if (pAP == NULL) return FALSE; |
47 | 44 |
48 // Choose the right sub-ap | 45 // Choose the right sub-ap |
49 const FX_CHAR* ap_entry = "N"; | 46 const FX_CHAR* ap_entry = "N"; |
50 if (mode == CPDF_Annot::Down) | 47 if (mode == CPDF_Annot::Down) |
51 ap_entry = "D"; | 48 ap_entry = "D"; |
52 else if (mode == CPDF_Annot::Rollover) | 49 else if (mode == CPDF_Annot::Rollover) |
53 ap_entry = "R"; | 50 ap_entry = "R"; |
54 if (!pAP->KeyExist(ap_entry)) | 51 if (!pAP->KeyExist(ap_entry)) |
55 ap_entry = "N"; | 52 ap_entry = "N"; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 ASSERT(pField != NULL); | 86 ASSERT(pField != NULL); |
90 | 87 |
91 return pField->GetFieldType(); | 88 return pField->GetFieldType(); |
92 } | 89 } |
93 | 90 |
94 int CPDFSDK_Widget::GetFieldFlags() const | 91 int CPDFSDK_Widget::GetFieldFlags() const |
95 { | 92 { |
96 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); | 93 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); |
97 ASSERT(pPDFInterForm != NULL); | 94 ASSERT(pPDFInterForm != NULL); |
98 | 95 |
99 » CPDF_FormControl* pFormControl = pPDFInterForm->GetControlByDict(m_pAnno
t->m_pAnnotDict); | 96 » CPDF_FormControl* pFormControl = pPDFInterForm->GetControlByDict(m_pAnno
t->GetAnnotDict()); |
100 CPDF_FormField* pFormField = pFormControl->GetField(); | 97 CPDF_FormField* pFormField = pFormControl->GetField(); |
101 return pFormField->GetFieldFlags(); | 98 return pFormField->GetFieldFlags(); |
102 } | 99 } |
103 | 100 |
104 CFX_ByteString CPDFSDK_Widget::GetSubType() const | 101 CFX_ByteString CPDFSDK_Widget::GetSubType() const |
105 { | 102 { |
106 int nType = GetFieldType(); | 103 int nType = GetFieldType(); |
107 | 104 |
108 if (nType == FIELDTYPE_SIGNATURE) | 105 if (nType == FIELDTYPE_SIGNATURE) |
109 return BFFT_SIGNATURE; | 106 return BFFT_SIGNATURE; |
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 if (iColorType > 0) | 1528 if (iColorType > 0) |
1532 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1529 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
1533 | 1530 |
1534 return crFill; | 1531 return crFill; |
1535 } | 1532 } |
1536 | 1533 |
1537 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_St
ream* pImage) | 1534 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_St
ream* pImage) |
1538 { | 1535 { |
1539 ASSERT(pImage != NULL); | 1536 ASSERT(pImage != NULL); |
1540 | 1537 |
1541 ASSERT(m_pAnnot != NULL); | |
1542 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | |
1543 | |
1544 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();//pDocument->GetDocu
ment(); | 1538 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();//pDocument->GetDocu
ment(); |
1545 ASSERT(pDoc != NULL); | 1539 ASSERT(pDoc != NULL); |
1546 | 1540 |
1547 » CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP"); | 1541 » CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
1548 ASSERT(pAPDict != NULL); | 1542 ASSERT(pAPDict != NULL); |
1549 | 1543 |
1550 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); | 1544 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); |
1551 ASSERT(pStream != NULL); | 1545 ASSERT(pStream != NULL); |
1552 | 1546 |
1553 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 1547 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
1554 ASSERT(pStreamDict != NULL); | 1548 ASSERT(pStreamDict != NULL); |
1555 | 1549 |
1556 CFX_ByteString sImageAlias = "IMG"; | 1550 CFX_ByteString sImageAlias = "IMG"; |
1557 | 1551 |
(...skipping 14 matching lines...) Expand all Loading... |
1572 if (pStreamResList) | 1566 if (pStreamResList) |
1573 { | 1567 { |
1574 CPDF_Dictionary* pXObject = new CPDF_Dictionary; | 1568 CPDF_Dictionary* pXObject = new CPDF_Dictionary; |
1575 pXObject->SetAtReference(sImageAlias, pDoc, pImage); | 1569 pXObject->SetAtReference(sImageAlias, pDoc, pImage); |
1576 pStreamResList->SetAt("XObject", pXObject); | 1570 pStreamResList->SetAt("XObject", pXObject); |
1577 } | 1571 } |
1578 } | 1572 } |
1579 | 1573 |
1580 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) | 1574 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) |
1581 { | 1575 { |
1582 » ASSERT(m_pAnnot != NULL); | 1576 » if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP")) |
1583 » ASSERT(m_pAnnot->m_pAnnotDict != NULL); | |
1584 | |
1585 » if (CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP")) | |
1586 { | 1577 { |
1587 pAPDict->RemoveAt(sAPType); | 1578 pAPDict->RemoveAt(sAPType); |
1588 } | 1579 } |
1589 } | 1580 } |
1590 | 1581 |
1591 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAc
tion& data, CPDFSDK_PageView* pPageView) | 1582 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAc
tion& data, CPDFSDK_PageView* pPageView) |
1592 { | 1583 { |
1593 CPDF_Action action = GetAAction(type); | 1584 CPDF_Action action = GetAAction(type); |
1594 | 1585 |
1595 if (action && action.GetType() != CPDF_Action::Unknown) | 1586 if (action && action.GetType() != CPDF_Action::Unknown) |
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2993 | 2984 |
2994 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 2985 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
2995 ASSERT(pPDFAnnot != NULL); | 2986 ASSERT(pPDFAnnot != NULL); |
2996 | 2987 |
2997 CPDF_Rect rcAnnot; | 2988 CPDF_Rect rcAnnot; |
2998 pPDFAnnot->GetRect(rcAnnot); | 2989 pPDFAnnot->GetRect(rcAnnot); |
2999 | 2990 |
3000 return rcAnnot; | 2991 return rcAnnot; |
3001 } | 2992 } |
3002 | 2993 |
OLD | NEW |