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

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

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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/fpdfdoc/doc_formfield.cpp ('k') | core/src/fpdfdoc/doc_tagged.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 "core/include/fpdfdoc/fpdf_doc.h" 7 #include "core/include/fpdfdoc/fpdf_doc.h"
8 8
9 static int32_t FPDFDOC_OCG_FindGroup(const CPDF_Object* pObject, 9 static int32_t FPDFDOC_OCG_FindGroup(const CPDF_Object* pObject,
10 const CPDF_Dictionary* pGroupDict) { 10 const CPDF_Dictionary* pGroupDict) {
11 if (!pObject || !pGroupDict) 11 if (!pObject || !pGroupDict)
12 return -1; 12 return -1;
13 13
14 if (const CPDF_Array* pArray = pObject->AsArray()) { 14 if (const CPDF_Array* pArray = pObject->AsArray()) {
15 FX_DWORD dwCount = pArray->GetCount(); 15 FX_DWORD dwCount = pArray->GetCount();
16 for (FX_DWORD i = 0; i < dwCount; i++) { 16 for (FX_DWORD i = 0; i < dwCount; i++) {
17 if (pArray->GetDict(i) == pGroupDict) 17 if (pArray->GetDict(i) == pGroupDict)
18 return i; 18 return i;
19 } 19 }
20 return -1; 20 return -1;
21 } 21 }
22 return pObject->GetDict() == pGroupDict ? 0 : -1; 22 return pObject->GetDict() == pGroupDict ? 0 : -1;
23 } 23 }
24 static FX_BOOL FPDFDOC_OCG_HasIntent(const CPDF_Dictionary* pDict, 24 static FX_BOOL FPDFDOC_OCG_HasIntent(const CPDF_Dictionary* pDict,
25 const CFX_ByteStringC& csElement, 25 const CFX_ByteStringC& csElement,
26 const CFX_ByteStringC& csDef = "") { 26 const CFX_ByteStringC& csDef = "") {
27 CPDF_Object* pIntent = pDict->GetElementValue("Intent"); 27 CPDF_Object* pIntent = pDict->GetElementValue("Intent");
28 if (pIntent == NULL) { 28 if (!pIntent) {
29 return csElement == csDef; 29 return csElement == csDef;
30 } 30 }
31 CFX_ByteString bsIntent; 31 CFX_ByteString bsIntent;
32 if (CPDF_Array* pArray = pIntent->AsArray()) { 32 if (CPDF_Array* pArray = pIntent->AsArray()) {
33 FX_DWORD dwCount = pArray->GetCount(); 33 FX_DWORD dwCount = pArray->GetCount();
34 for (FX_DWORD i = 0; i < dwCount; i++) { 34 for (FX_DWORD i = 0; i < dwCount; i++) {
35 bsIntent = pArray->GetString(i); 35 bsIntent = pArray->GetString(i);
36 if (bsIntent == "All" || bsIntent == csElement) 36 if (bsIntent == "All" || bsIntent == csElement)
37 return TRUE; 37 return TRUE;
38 } 38 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 m_OCGStates[pOCGDict] = bState; 182 m_OCGStates[pOCGDict] = bState;
183 return bState; 183 return bState;
184 } 184 }
185 185
186 FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, 186 FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression,
187 FX_BOOL bFromConfig, 187 FX_BOOL bFromConfig,
188 int nLevel) { 188 int nLevel) {
189 if (nLevel > 32) { 189 if (nLevel > 32) {
190 return FALSE; 190 return FALSE;
191 } 191 }
192 if (pExpression == NULL) { 192 if (!pExpression) {
193 return FALSE; 193 return FALSE;
194 } 194 }
195 int32_t iCount = pExpression->GetCount(); 195 int32_t iCount = pExpression->GetCount();
196 CPDF_Object* pOCGObj; 196 CPDF_Object* pOCGObj;
197 CFX_ByteString csOperator = pExpression->GetString(0); 197 CFX_ByteString csOperator = pExpression->GetString(0);
198 if (csOperator == "Not") { 198 if (csOperator == "Not") {
199 pOCGObj = pExpression->GetElementValue(1); 199 pOCGObj = pExpression->GetElementValue(1);
200 if (!pOCGObj) 200 if (!pOCGObj)
201 return FALSE; 201 return FALSE;
202 if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) 202 if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary())
203 return !(bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict)); 203 return !(bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict));
204 if (CPDF_Array* pArray = pOCGObj->AsArray()) 204 if (CPDF_Array* pArray = pOCGObj->AsArray())
205 return !GetOCGVE(pArray, bFromConfig, nLevel + 1); 205 return !GetOCGVE(pArray, bFromConfig, nLevel + 1);
206 return FALSE; 206 return FALSE;
207 } 207 }
208 if (csOperator == "Or" || csOperator == "And") { 208 if (csOperator == "Or" || csOperator == "And") {
209 FX_BOOL bValue = FALSE; 209 FX_BOOL bValue = FALSE;
210 for (int32_t i = 1; i < iCount; i++) { 210 for (int32_t i = 1; i < iCount; i++) {
211 pOCGObj = pExpression->GetElementValue(1); 211 pOCGObj = pExpression->GetElementValue(1);
212 if (pOCGObj == NULL) { 212 if (!pOCGObj) {
213 continue; 213 continue;
214 } 214 }
215 FX_BOOL bItem = FALSE; 215 FX_BOOL bItem = FALSE;
216 if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) 216 if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary())
217 bItem = bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict); 217 bItem = bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict);
218 else if (CPDF_Array* pArray = pOCGObj->AsArray()) 218 else if (CPDF_Array* pArray = pOCGObj->AsArray())
219 bItem = GetOCGVE(pArray, bFromConfig, nLevel + 1); 219 bItem = GetOCGVE(pArray, bFromConfig, nLevel + 1);
220 220
221 if (i == 1) { 221 if (i == 1) {
222 bValue = bItem; 222 bValue = bItem;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 273 }
274 CFX_ByteString csType = pOCGDict->GetString("Type", "OCG"); 274 CFX_ByteString csType = pOCGDict->GetString("Type", "OCG");
275 if (csType == "OCG") { 275 if (csType == "OCG") {
276 return GetOCGVisible(pOCGDict); 276 return GetOCGVisible(pOCGDict);
277 } 277 }
278 return LoadOCMDState(pOCGDict, FALSE); 278 return LoadOCMDState(pOCGDict, FALSE);
279 } 279 }
280 void CPDF_OCContext::ResetOCContext() { 280 void CPDF_OCContext::ResetOCContext() {
281 m_OCGStates.clear(); 281 m_OCGStates.clear();
282 } 282 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_formfield.cpp ('k') | core/src/fpdfdoc/doc_tagged.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698