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

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, 1 month 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
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
Lei Zhang 2015/10/21 16:55:56 no blank line
dsinclair 2015/10/21 17:08:05 Done.
137 } else if (pFields->GetType() == PDFOBJ_ARRAY) {
143 CPDF_Array* pArray = (CPDF_Array*)pFields; 138 CPDF_Array* pArray = (CPDF_Array*)pFields;
144 FX_DWORD iCount = pArray->GetCount(); 139 FX_DWORD iCount = pArray->GetCount();
145 for (FX_DWORD i = 0; i < iCount; i++) { 140 for (FX_DWORD i = 0; i < iCount; i++) {
146 CPDF_Object* pObj = pArray->GetElementValue(i); 141 CPDF_Object* pObj = pArray->GetElementValue(i);
147 if (pObj != NULL) { 142 if (pObj != NULL) {
148 fieldObjects.Add(pObj); 143 fieldObjects.Add(pObj);
149 } 144 }
150 } 145 }
151 } 146 }
152 } 147 }
153 CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const { 148 CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const {
154 if (m_pAction == NULL) { 149 if (m_pAction == NULL) {
155 return NULL; 150 return NULL;
156 } 151 }
157 CPDF_Dictionary* pDict = m_pAction->GetDict(); 152 CPDF_Dictionary* pDict = m_pAction->GetDict();
158 if (pDict == NULL) { 153 if (pDict == NULL) {
159 return NULL; 154 return NULL;
160 } 155 }
161 CFX_ByteString csType = pDict->GetString("S"); 156 CFX_ByteString csType = pDict->GetString("S");
162 CPDF_Object* pFields = NULL; 157 CPDF_Object* pFields = NULL;
163 if (csType == "Hide") { 158 if (csType == "Hide") {
164 pFields = pDict->GetElementValue("T"); 159 pFields = pDict->GetElementValue("T");
165 } else { 160 } else {
166 pFields = pDict->GetArray("Fields"); 161 pFields = pDict->GetArray("Fields");
167 } 162 }
168 if (pFields == NULL) { 163 if (pFields == NULL) {
169 return NULL; 164 return NULL;
170 } 165 }
171 CPDF_Object* pFindObj = NULL; 166 CPDF_Object* pFindObj = NULL;
172 int iType = pFields->GetType(); 167 if (pFields->IsDictionary() || pFields->IsString()) {
173 if (iType == PDFOBJ_DICTIONARY || iType == PDFOBJ_STRING) { 168 if (iIndex == 0)
174 if (iIndex == 0) {
175 pFindObj = pFields; 169 pFindObj = pFields;
176 } 170 } else if (pFields->GetType() == PDFOBJ_ARRAY) {
177 } else if (iType == PDFOBJ_ARRAY) {
178 pFindObj = ((CPDF_Array*)pFields)->GetElementValue(iIndex); 171 pFindObj = ((CPDF_Array*)pFields)->GetElementValue(iIndex);
179 } 172 }
180 return pFindObj; 173 return pFindObj;
181 } 174 }
182 175
183 CFX_WideString CPDF_Action::GetJavaScript() const { 176 CFX_WideString CPDF_Action::GetJavaScript() const {
184 CFX_WideString csJS; 177 CFX_WideString csJS;
185 if (m_pDict == NULL) { 178 if (m_pDict == NULL) {
186 return csJS; 179 return csJS;
187 } 180 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (!ToDictionary(pAction)) { 324 if (!ToDictionary(pAction)) {
332 return CPDF_Action(); 325 return CPDF_Action();
333 } 326 }
334 return CPDF_Action(pAction->GetDict()); 327 return CPDF_Action(pAction->GetDict());
335 } 328 }
336 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { 329 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const {
337 ASSERT(m_pDocument != NULL); 330 ASSERT(m_pDocument != NULL);
338 CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript")); 331 CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript"));
339 return name_tree.GetIndex(csName); 332 return name_tree.GetIndex(csName);
340 } 333 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698