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

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

Issue 1430213002: Remove CFX_PtrArray usage in fpdfsdk. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@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();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (!pFields) 104 if (!pFields)
105 return 0; 105 return 0;
106 if (pFields->IsDictionary()) 106 if (pFields->IsDictionary())
107 return 1; 107 return 1;
108 if (pFields->IsString()) 108 if (pFields->IsString())
109 return 1; 109 return 1;
110 if (CPDF_Array* pArray = pFields->AsArray()) 110 if (CPDF_Array* pArray = pFields->AsArray())
111 return pArray->GetCount(); 111 return pArray->GetCount();
112 return 0; 112 return 0;
113 } 113 }
114 void CPDF_ActionFields::GetAllFields(CFX_PtrArray& fieldObjects) const { 114
115 fieldObjects.RemoveAll(); 115 std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
Tom Sepez 2015/11/09 21:25:31 Is this always small, or are we just counting on c
Lei Zhang 2015/11/09 22:45:28 We do this in Chromium's base/ too. It's RVO.
116 if (m_pAction == NULL) { 116 std::vector<CPDF_Object*> fields;
117 return; 117 if (!m_pAction)
118 } 118 return fields;
119
119 CPDF_Dictionary* pDict = m_pAction->GetDict(); 120 CPDF_Dictionary* pDict = m_pAction->GetDict();
120 if (pDict == NULL) { 121 if (!pDict)
121 return; 122 return fields;
122 } 123
123 CFX_ByteString csType = pDict->GetString("S"); 124 CFX_ByteString csType = pDict->GetString("S");
124 CPDF_Object* pFields = NULL; 125 CPDF_Object* pFields;
125 if (csType == "Hide") { 126 if (csType == "Hide")
126 pFields = pDict->GetElementValue("T"); 127 pFields = pDict->GetElementValue("T");
127 } else { 128 else
128 pFields = pDict->GetArray("Fields"); 129 pFields = pDict->GetArray("Fields");
129 }
130 if (!pFields) 130 if (!pFields)
131 return; 131 return fields;
132 132
133 if (pFields->IsDictionary() || pFields->IsString()) { 133 if (pFields->IsDictionary() || pFields->IsString()) {
134 fieldObjects.Add(pFields); 134 fields.push_back(pFields);
135 } else if (CPDF_Array* pArray = pFields->AsArray()) { 135 } else if (CPDF_Array* pArray = pFields->AsArray()) {
136 FX_DWORD iCount = pArray->GetCount(); 136 FX_DWORD iCount = pArray->GetCount();
137 for (FX_DWORD i = 0; i < iCount; i++) { 137 for (FX_DWORD i = 0; i < iCount; ++i) {
138 CPDF_Object* pObj = pArray->GetElementValue(i); 138 CPDF_Object* pObj = pArray->GetElementValue(i);
139 if (pObj != NULL) { 139 if (pObj) {
140 fieldObjects.Add(pObj); 140 fields.push_back(pObj);
141 } 141 }
142 } 142 }
143 } 143 }
144 return fields;
144 } 145 }
146
145 CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const { 147 CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const {
146 if (m_pAction == NULL) { 148 if (m_pAction == NULL) {
147 return NULL; 149 return NULL;
148 } 150 }
149 CPDF_Dictionary* pDict = m_pAction->GetDict(); 151 CPDF_Dictionary* pDict = m_pAction->GetDict();
150 if (pDict == NULL) { 152 if (pDict == NULL) {
151 return NULL; 153 return NULL;
152 } 154 }
153 CFX_ByteString csType = pDict->GetString("S"); 155 CFX_ByteString csType = pDict->GetString("S");
154 CPDF_Object* pFields = NULL; 156 CPDF_Object* pFields = NULL;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if (!ToDictionary(pAction)) { 318 if (!ToDictionary(pAction)) {
317 return CPDF_Action(); 319 return CPDF_Action();
318 } 320 }
319 return CPDF_Action(pAction->GetDict()); 321 return CPDF_Action(pAction->GetDict());
320 } 322 }
321 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { 323 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const {
322 ASSERT(m_pDocument != NULL); 324 ASSERT(m_pDocument != NULL);
323 CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript")); 325 CPDF_NameTree name_tree(m_pDocument, FX_BSTRC("JavaScript"));
324 return name_tree.GetIndex(csName); 326 return name_tree.GetIndex(csName);
325 } 327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698