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

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

Issue 1867183002: Use std::vector as internal storage for CPDF_Array (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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
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 <vector> 7 #include <vector>
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 csURI = m_pDict->GetStringBy("URI"); 93 csURI = m_pDict->GetStringBy("URI");
94 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 94 CPDF_Dictionary* pRoot = pDoc->GetRoot();
95 CPDF_Dictionary* pURI = pRoot->GetDictBy("URI"); 95 CPDF_Dictionary* pURI = pRoot->GetDictBy("URI");
96 if (pURI) { 96 if (pURI) {
97 if (csURI.Find(":", 0) < 1) { 97 if (csURI.Find(":", 0) < 1) {
98 csURI = pURI->GetStringBy("Base") + csURI; 98 csURI = pURI->GetStringBy("Base") + csURI;
99 } 99 }
100 } 100 }
101 return csURI; 101 return csURI;
102 } 102 }
103 uint32_t CPDF_ActionFields::GetFieldsCount() const { 103 size_t CPDF_ActionFields::GetFieldsCount() const {
104 if (!m_pAction) { 104 if (!m_pAction) {
105 return 0; 105 return 0;
106 } 106 }
107 CPDF_Dictionary* pDict = m_pAction->GetDict(); 107 CPDF_Dictionary* pDict = m_pAction->GetDict();
108 if (!pDict) { 108 if (!pDict) {
109 return 0; 109 return 0;
110 } 110 }
111 CFX_ByteString csType = pDict->GetStringBy("S"); 111 CFX_ByteString csType = pDict->GetStringBy("S");
112 CPDF_Object* pFields = NULL; 112 CPDF_Object* pFields = NULL;
113 if (csType == "Hide") { 113 if (csType == "Hide") {
(...skipping 26 matching lines...) Expand all
140 if (csType == "Hide") 140 if (csType == "Hide")
141 pFields = pDict->GetDirectObjectBy("T"); 141 pFields = pDict->GetDirectObjectBy("T");
142 else 142 else
143 pFields = pDict->GetArrayBy("Fields"); 143 pFields = pDict->GetArrayBy("Fields");
144 if (!pFields) 144 if (!pFields)
145 return fields; 145 return fields;
146 146
147 if (pFields->IsDictionary() || pFields->IsString()) { 147 if (pFields->IsDictionary() || pFields->IsString()) {
148 fields.push_back(pFields); 148 fields.push_back(pFields);
149 } else if (CPDF_Array* pArray = pFields->AsArray()) { 149 } else if (CPDF_Array* pArray = pFields->AsArray()) {
150 uint32_t iCount = pArray->GetCount(); 150 for (size_t i = 0; i < pArray->GetCount(); ++i) {
151 for (uint32_t i = 0; i < iCount; ++i) {
152 CPDF_Object* pObj = pArray->GetDirectObjectAt(i); 151 CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
153 if (pObj) { 152 if (pObj) {
154 fields.push_back(pObj); 153 fields.push_back(pObj);
155 } 154 }
156 } 155 }
157 } 156 }
158 return fields; 157 return fields;
159 } 158 }
160 159
161 CPDF_Object* CPDF_ActionFields::GetField(uint32_t iIndex) const { 160 CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const {
162 if (!m_pAction) { 161 if (!m_pAction) {
163 return NULL; 162 return NULL;
164 } 163 }
165 CPDF_Dictionary* pDict = m_pAction->GetDict(); 164 CPDF_Dictionary* pDict = m_pAction->GetDict();
166 if (!pDict) { 165 if (!pDict) {
167 return NULL; 166 return NULL;
168 } 167 }
169 CFX_ByteString csType = pDict->GetStringBy("S"); 168 CFX_ByteString csType = pDict->GetStringBy("S");
170 CPDF_Object* pFields = NULL; 169 CPDF_Object* pFields = NULL;
171 if (csType == "Hide") { 170 if (csType == "Hide") {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 224 }
226 if (csOP == "Pause") { 225 if (csOP == "Pause") {
227 return 2; 226 return 2;
228 } 227 }
229 if (csOP == "Resume") { 228 if (csOP == "Resume") {
230 return 3; 229 return 3;
231 } 230 }
232 } 231 }
233 return 0; 232 return 0;
234 } 233 }
235 uint32_t CPDF_Action::GetSubActionsCount() const { 234 size_t CPDF_Action::GetSubActionsCount() const {
236 if (!m_pDict || !m_pDict->KeyExist("Next")) 235 if (!m_pDict || !m_pDict->KeyExist("Next"))
237 return 0; 236 return 0;
238 237
239 CPDF_Object* pNext = m_pDict->GetDirectObjectBy("Next"); 238 CPDF_Object* pNext = m_pDict->GetDirectObjectBy("Next");
240 if (!pNext) 239 if (!pNext)
241 return 0; 240 return 0;
242 if (pNext->IsDictionary()) 241 if (pNext->IsDictionary())
243 return 1; 242 return 1;
244 if (CPDF_Array* pArray = pNext->AsArray()) 243 if (CPDF_Array* pArray = pNext->AsArray())
245 return pArray->GetCount(); 244 return pArray->GetCount();
246 return 0; 245 return 0;
247 } 246 }
248 CPDF_Action CPDF_Action::GetSubAction(uint32_t iIndex) const { 247 CPDF_Action CPDF_Action::GetSubAction(size_t iIndex) const {
249 if (!m_pDict || !m_pDict->KeyExist("Next")) { 248 if (!m_pDict || !m_pDict->KeyExist("Next")) {
250 return CPDF_Action(); 249 return CPDF_Action();
251 } 250 }
252 CPDF_Object* pNext = m_pDict->GetDirectObjectBy("Next"); 251 CPDF_Object* pNext = m_pDict->GetDirectObjectBy("Next");
253 if (CPDF_Dictionary* pDict = ToDictionary(pNext)) { 252 if (CPDF_Dictionary* pDict = ToDictionary(pNext)) {
254 if (iIndex == 0) 253 if (iIndex == 0)
255 return CPDF_Action(pDict); 254 return CPDF_Action(pDict);
256 } else if (CPDF_Array* pArray = ToArray(pNext)) { 255 } else if (CPDF_Array* pArray = ToArray(pNext)) {
257 return CPDF_Action(pArray->GetDictAt(iIndex)); 256 return CPDF_Action(pArray->GetDictAt(iIndex));
258 } 257 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (!ToDictionary(pAction)) { 293 if (!ToDictionary(pAction)) {
295 return CPDF_Action(); 294 return CPDF_Action();
296 } 295 }
297 return CPDF_Action(pAction->GetDict()); 296 return CPDF_Action(pAction->GetDict());
298 } 297 }
299 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { 298 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const {
300 ASSERT(m_pDocument); 299 ASSERT(m_pDocument);
301 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); 300 CPDF_NameTree name_tree(m_pDocument, "JavaScript");
302 return name_tree.GetIndex(csName); 301 return name_tree.GetIndex(csName);
303 } 302 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698