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/cpdfsdk_document.h" | 7 #include "fpdfsdk/cpdfsdk_document.h" |
8 | 8 |
9 #include "core/fpdfapi/parser/cpdf_array.h" | 9 #include "core/fpdfapi/parser/cpdf_array.h" |
10 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 10 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 CPDF_Document* pPDFDoc = GetPDFDocument(); | 90 CPDF_Document* pPDFDoc = GetPDFDocument(); |
91 CPDF_DocJSActions docJS(pPDFDoc); | 91 CPDF_DocJSActions docJS(pPDFDoc); |
92 int iCount = docJS.CountJSActions(); | 92 int iCount = docJS.CountJSActions(); |
93 if (iCount < 1) | 93 if (iCount < 1) |
94 return; | 94 return; |
95 for (int i = 0; i < iCount; i++) { | 95 for (int i = 0; i < iCount; i++) { |
96 CFX_ByteString csJSName; | 96 CFX_ByteString csJSName; |
97 CPDF_Action jsAction = docJS.GetJSAction(i, csJSName); | 97 CPDF_Action jsAction = docJS.GetJSAction(i, csJSName); |
98 if (m_pEnv->GetActionHander()) | 98 if (m_pEnv->GetActionHander()) |
99 m_pEnv->GetActionHander()->DoAction_JavaScript( | 99 m_pEnv->GetActionHander()->DoAction_JavaScript( |
100 jsAction, CFX_WideString::FromLocal(csJSName.AsStringC()), this); | 100 jsAction, CFX_WideString::FromLocal(csJSName.AsStringC()), GetEnv()); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 FX_BOOL CPDFSDK_Document::ProcOpenAction() { | 104 FX_BOOL CPDFSDK_Document::ProcOpenAction() { |
105 if (!m_pDoc) | 105 if (!m_pDoc) |
106 return FALSE; | 106 return FALSE; |
107 | 107 |
108 CPDF_Dictionary* pRoot = GetPDFDocument()->GetRoot(); | 108 CPDF_Dictionary* pRoot = GetPDFDocument()->GetRoot(); |
109 if (!pRoot) | 109 if (!pRoot) |
110 return FALSE; | 110 return FALSE; |
111 | 111 |
112 CPDF_Object* pOpenAction = pRoot->GetDictFor("OpenAction"); | 112 CPDF_Object* pOpenAction = pRoot->GetDictFor("OpenAction"); |
113 if (!pOpenAction) | 113 if (!pOpenAction) |
114 pOpenAction = pRoot->GetArrayFor("OpenAction"); | 114 pOpenAction = pRoot->GetArrayFor("OpenAction"); |
115 | 115 |
116 if (!pOpenAction) | 116 if (!pOpenAction) |
117 return FALSE; | 117 return FALSE; |
118 | 118 |
119 if (pOpenAction->IsArray()) | 119 if (pOpenAction->IsArray()) |
120 return TRUE; | 120 return TRUE; |
121 | 121 |
122 if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) { | 122 if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) { |
123 CPDF_Action action(pDict); | 123 CPDF_Action action(pDict); |
124 if (m_pEnv->GetActionHander()) | 124 if (m_pEnv->GetActionHander()) |
125 m_pEnv->GetActionHander()->DoAction_DocOpen(action, this); | 125 m_pEnv->GetActionHander()->DoAction_DocOpen(action, GetEnv()); |
126 return TRUE; | 126 return TRUE; |
127 } | 127 } |
128 return FALSE; | 128 return FALSE; |
129 } | 129 } |
130 | 130 |
131 void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) { | 131 void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) { |
132 auto it = m_pageMap.find(pUnderlyingPage); | 132 auto it = m_pageMap.find(pUnderlyingPage); |
133 if (it == m_pageMap.end()) | 133 if (it == m_pageMap.end()) |
134 return; | 134 return; |
135 | 135 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 return GetPDFDocument()->GetUserPermissions() & nFlag; | 246 return GetPDFDocument()->GetUserPermissions() & nFlag; |
247 } | 247 } |
248 | 248 |
249 IJS_Runtime* CPDFSDK_Document::GetJsRuntime() { | 249 IJS_Runtime* CPDFSDK_Document::GetJsRuntime() { |
250 return m_pEnv->GetJSRuntime(); | 250 return m_pEnv->GetJSRuntime(); |
251 } | 251 } |
252 | 252 |
253 CFX_WideString CPDFSDK_Document::GetPath() { | 253 CFX_WideString CPDFSDK_Document::GetPath() { |
254 return m_pEnv->JS_docGetFilePath(); | 254 return m_pEnv->JS_docGetFilePath(); |
255 } | 255 } |
OLD | NEW |