Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: core/src/fpdfdoc/doc_action.cpp

Issue 1417933002: Add type cast definitions for CPDF_String. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp ('k') | core/src/fpdfdoc/doc_ap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "../../include/fpdfdoc/fpdf_doc.h" 7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const { 8 CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
9 if (!m_pDict) { 9 if (!m_pDict) {
10 return CPDF_Dest(); 10 return CPDF_Dest();
11 } 11 }
12 CFX_ByteString type = m_pDict->GetString("S"); 12 CFX_ByteString type = m_pDict->GetString("S");
13 if (type != "GoTo" && type != "GoToR") { 13 if (type != "GoTo" && type != "GoToR") {
14 return CPDF_Dest(); 14 return CPDF_Dest();
15 } 15 }
16 CPDF_Object* pDest = m_pDict->GetElementValue("D"); 16 CPDF_Object* pDest = m_pDict->GetElementValue("D");
17 if (!pDest) { 17 if (!pDest) {
18 return CPDF_Dest(); 18 return CPDF_Dest();
19 } 19 }
20 if (pDest->GetType() == PDFOBJ_STRING || pDest->GetType() == PDFOBJ_NAME) { 20 if (pDest->IsString() || pDest->GetType() == PDFOBJ_NAME) {
21 CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); 21 CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests"));
22 CFX_ByteStringC name = pDest->GetString(); 22 CFX_ByteStringC name = pDest->GetString();
23 return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name)); 23 return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name));
24 } 24 }
25 if (pDest->GetType() == PDFOBJ_ARRAY) { 25 if (pDest->GetType() == PDFOBJ_ARRAY) {
26 return CPDF_Dest((CPDF_Array*)pDest); 26 return CPDF_Dest((CPDF_Array*)pDest);
27 } 27 }
28 return CPDF_Dest(); 28 return CPDF_Dest();
29 } 29 }
30 const FX_CHAR* g_sATypes[] = { 30 const FX_CHAR* g_sATypes[] = {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (pDict == NULL) { 95 if (pDict == NULL) {
96 return 0; 96 return 0;
97 } 97 }
98 CFX_ByteString csType = pDict->GetString("S"); 98 CFX_ByteString csType = pDict->GetString("S");
99 CPDF_Object* pFields = NULL; 99 CPDF_Object* pFields = NULL;
100 if (csType == "Hide") { 100 if (csType == "Hide") {
101 pFields = pDict->GetElementValue("T"); 101 pFields = pDict->GetElementValue("T");
102 } else { 102 } else {
103 pFields = pDict->GetArray("Fields"); 103 pFields = pDict->GetArray("Fields");
104 } 104 }
105 if (pFields == NULL) { 105 if (!pFields)
106 return 0; 106 return 0;
107 } 107 if (pFields->IsDictionary())
108 int iType = pFields->GetType();
109 if (iType == PDFOBJ_DICTIONARY) {
110 return 1; 108 return 1;
111 } 109 if (pFields->IsString())
112 if (iType == PDFOBJ_STRING) {
113 return 1; 110 return 1;
114 } 111 if (pFields->GetType() == PDFOBJ_ARRAY)
115 if (iType == PDFOBJ_ARRAY) {
116 return ((CPDF_Array*)pFields)->GetCount(); 112 return ((CPDF_Array*)pFields)->GetCount();
117 }
118 return 0; 113 return 0;
119 } 114 }
120 void CPDF_ActionFields::GetAllFields(CFX_PtrArray& fieldObjects) const { 115 void CPDF_ActionFields::GetAllFields(CFX_PtrArray& fieldObjects) const {
121 fieldObjects.RemoveAll(); 116 fieldObjects.RemoveAll();
122 if (m_pAction == NULL) { 117 if (m_pAction == NULL) {
123 return; 118 return;
124 } 119 }
125 CPDF_Dictionary* pDict = m_pAction->GetDict(); 120 CPDF_Dictionary* pDict = m_pAction->GetDict();
126 if (pDict == NULL) { 121 if (pDict == NULL) {
127 return; 122 return;
128 } 123 }
129 CFX_ByteString csType = pDict->GetString("S"); 124 CFX_ByteString csType = pDict->GetString("S");
130 CPDF_Object* pFields = NULL; 125 CPDF_Object* pFields = NULL;
131 if (csType == "Hide") { 126 if (csType == "Hide") {
132 pFields = pDict->GetElementValue("T"); 127 pFields = pDict->GetElementValue("T");
133 } else { 128 } else {
134 pFields = pDict->GetArray("Fields"); 129 pFields = pDict->GetArray("Fields");
135 } 130 }
136 if (pFields == NULL) { 131 if (!pFields)
137 return; 132 return;
138 } 133
139 int iType = pFields->GetType(); 134 if (pFields->IsDictionary() || pFields->IsString()) {
140 if (iType == PDFOBJ_DICTIONARY || iType == PDFOBJ_STRING) {
141 fieldObjects.Add(pFields); 135 fieldObjects.Add(pFields);
142 } else if (iType == PDFOBJ_ARRAY) { 136 } else if (pFields->GetType() == PDFOBJ_ARRAY) {
143 CPDF_Array* pArray = (CPDF_Array*)pFields; 137 CPDF_Array* pArray = (CPDF_Array*)pFields;
144 FX_DWORD iCount = pArray->GetCount(); 138 FX_DWORD iCount = pArray->GetCount();
145 for (FX_DWORD i = 0; i < iCount; i++) { 139 for (FX_DWORD i = 0; i < iCount; i++) {
146 CPDF_Object* pObj = pArray->GetElementValue(i); 140 CPDF_Object* pObj = pArray->GetElementValue(i);
147 if (pObj != NULL) { 141 if (pObj != NULL) {
148 fieldObjects.Add(pObj); 142 fieldObjects.Add(pObj);
149 } 143 }
150 } 144 }
151 } 145 }
152 } 146 }
153 CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const { 147 CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const {
154 if (m_pAction == NULL) { 148 if (m_pAction == NULL) {
155 return NULL; 149 return NULL;
156 } 150 }
157 CPDF_Dictionary* pDict = m_pAction->GetDict(); 151 CPDF_Dictionary* pDict = m_pAction->GetDict();
158 if (pDict == NULL) { 152 if (pDict == NULL) {
159 return NULL; 153 return NULL;
160 } 154 }
161 CFX_ByteString csType = pDict->GetString("S"); 155 CFX_ByteString csType = pDict->GetString("S");
162 CPDF_Object* pFields = NULL; 156 CPDF_Object* pFields = NULL;
163 if (csType == "Hide") { 157 if (csType == "Hide") {
164 pFields = pDict->GetElementValue("T"); 158 pFields = pDict->GetElementValue("T");
165 } else { 159 } else {
166 pFields = pDict->GetArray("Fields"); 160 pFields = pDict->GetArray("Fields");
167 } 161 }
168 if (pFields == NULL) { 162 if (pFields == NULL) {
169 return NULL; 163 return NULL;
170 } 164 }
171 CPDF_Object* pFindObj = NULL; 165 CPDF_Object* pFindObj = NULL;
172 int iType = pFields->GetType(); 166 if (pFields->IsDictionary() || pFields->IsString()) {
173 if (iType == PDFOBJ_DICTIONARY || iType == PDFOBJ_STRING) { 167 if (iIndex == 0)
174 if (iIndex == 0) {
175 pFindObj = pFields; 168 pFindObj = pFields;
176 } 169 } else if (pFields->GetType() == PDFOBJ_ARRAY) {
177 } else if (iType == PDFOBJ_ARRAY) {
178 pFindObj = ((CPDF_Array*)pFields)->GetElementValue(iIndex); 170 pFindObj = ((CPDF_Array*)pFields)->GetElementValue(iIndex);
179 } 171 }
180 return pFindObj; 172 return pFindObj;
181 } 173 }
182 174
183 CFX_WideString CPDF_Action::GetJavaScript() const { 175 CFX_WideString CPDF_Action::GetJavaScript() const {
184 CFX_WideString csJS; 176 CFX_WideString csJS;
185 if (m_pDict == NULL) { 177 if (m_pDict == NULL) {
186 return csJS; 178 return csJS;
187 } 179 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (!ToDictionary(pAction)) { 323 if (!ToDictionary(pAction)) {
332 return CPDF_Action(); 324 return CPDF_Action();
333 } 325 }
334 return CPDF_Action(pAction->GetDict()); 326 return CPDF_Action(pAction->GetDict());
335 } 327 }
336 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { 328 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const {
337 ASSERT(m_pDocument != NULL); 329 ASSERT(m_pDocument != NULL);
338 CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript")); 330 CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript"));
339 return name_tree.GetIndex(csName); 331 return name_tree.GetIndex(csName);
340 } 332 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp ('k') | core/src/fpdfdoc/doc_ap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698