| OLD | NEW |
| 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 static int32_t FPDFDOC_OCG_FindGroup(const CPDF_Object* pObject, | 8 static int32_t FPDFDOC_OCG_FindGroup(const CPDF_Object* pObject, |
| 9 const CPDF_Dictionary* pGroupDict) { | 9 const CPDF_Dictionary* pGroupDict) { |
| 10 if (pObject == NULL || pGroupDict == NULL) { | 10 if (pObject == NULL || pGroupDict == NULL) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 return FALSE; | 202 return FALSE; |
| 203 } | 203 } |
| 204 int32_t iCount = pExpression->GetCount(); | 204 int32_t iCount = pExpression->GetCount(); |
| 205 CPDF_Object* pOCGObj; | 205 CPDF_Object* pOCGObj; |
| 206 CFX_ByteString csOperator = pExpression->GetString(0); | 206 CFX_ByteString csOperator = pExpression->GetString(0); |
| 207 if (csOperator == FX_BSTRC("Not")) { | 207 if (csOperator == FX_BSTRC("Not")) { |
| 208 pOCGObj = pExpression->GetElementValue(1); | 208 pOCGObj = pExpression->GetElementValue(1); |
| 209 if (pOCGObj == NULL) { | 209 if (pOCGObj == NULL) { |
| 210 return FALSE; | 210 return FALSE; |
| 211 } | 211 } |
| 212 if (pOCGObj->GetType() == PDFOBJ_DICTIONARY) { | 212 if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) { |
| 213 return !(bFromConfig ? LoadOCGState((CPDF_Dictionary*)pOCGObj) | 213 return !(bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict)); |
| 214 : GetOCGVisible((CPDF_Dictionary*)pOCGObj)); | |
| 215 } | 214 } |
| 216 if (pOCGObj->GetType() == PDFOBJ_ARRAY) { | 215 if (pOCGObj->GetType() == PDFOBJ_ARRAY) { |
| 217 return !GetOCGVE((CPDF_Array*)pOCGObj, bFromConfig, nLevel + 1); | 216 return !GetOCGVE((CPDF_Array*)pOCGObj, bFromConfig, nLevel + 1); |
| 218 } | 217 } |
| 219 return FALSE; | 218 return FALSE; |
| 220 } | 219 } |
| 221 if (csOperator == FX_BSTRC("Or") || csOperator == FX_BSTRC("And")) { | 220 if (csOperator == FX_BSTRC("Or") || csOperator == FX_BSTRC("And")) { |
| 222 FX_BOOL bValue = FALSE; | 221 FX_BOOL bValue = FALSE; |
| 223 for (int32_t i = 1; i < iCount; i++) { | 222 for (int32_t i = 1; i < iCount; i++) { |
| 224 pOCGObj = pExpression->GetElementValue(1); | 223 pOCGObj = pExpression->GetElementValue(1); |
| 225 if (pOCGObj == NULL) { | 224 if (pOCGObj == NULL) { |
| 226 continue; | 225 continue; |
| 227 } | 226 } |
| 228 FX_BOOL bItem = FALSE; | 227 FX_BOOL bItem = FALSE; |
| 229 if (pOCGObj->GetType() == PDFOBJ_DICTIONARY) { | 228 if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) { |
| 230 bItem = bFromConfig ? LoadOCGState((CPDF_Dictionary*)pOCGObj) | 229 bItem = bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict); |
| 231 : GetOCGVisible((CPDF_Dictionary*)pOCGObj); | |
| 232 } else if (pOCGObj->GetType() == PDFOBJ_ARRAY) { | 230 } else if (pOCGObj->GetType() == PDFOBJ_ARRAY) { |
| 233 bItem = GetOCGVE((CPDF_Array*)pOCGObj, bFromConfig, nLevel + 1); | 231 bItem = GetOCGVE((CPDF_Array*)pOCGObj, bFromConfig, nLevel + 1); |
| 234 } | 232 } |
| 235 if (i == 1) { | 233 if (i == 1) { |
| 236 bValue = bItem; | 234 bValue = bItem; |
| 237 } else { | 235 } else { |
| 238 if (csOperator == FX_BSTRC("Or")) { | 236 if (csOperator == FX_BSTRC("Or")) { |
| 239 bValue = bValue || bItem; | 237 bValue = bValue || bItem; |
| 240 } else { | 238 } else { |
| 241 bValue = bValue && bItem; | 239 bValue = bValue && bItem; |
| 242 } | 240 } |
| 243 } | 241 } |
| 244 } | 242 } |
| 245 return bValue; | 243 return bValue; |
| 246 } | 244 } |
| 247 return FALSE; | 245 return FALSE; |
| 248 } | 246 } |
| 249 FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict, | 247 FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict, |
| 250 FX_BOOL bFromConfig) { | 248 FX_BOOL bFromConfig) { |
| 251 FXSYS_assert(pOCMDDict != NULL); | 249 FXSYS_assert(pOCMDDict != NULL); |
| 252 CPDF_Array* pVE = pOCMDDict->GetArray(FX_BSTRC("VE")); | 250 CPDF_Array* pVE = pOCMDDict->GetArray(FX_BSTRC("VE")); |
| 253 if (pVE != NULL) { | 251 if (pVE != NULL) { |
| 254 return GetOCGVE(pVE, bFromConfig); | 252 return GetOCGVE(pVE, bFromConfig); |
| 255 } | 253 } |
| 256 CFX_ByteString csP = pOCMDDict->GetString(FX_BSTRC("P"), FX_BSTRC("AnyOn")); | 254 CFX_ByteString csP = pOCMDDict->GetString(FX_BSTRC("P"), FX_BSTRC("AnyOn")); |
| 257 CPDF_Object* pOCGObj = pOCMDDict->GetElementValue(FX_BSTRC("OCGs")); | 255 CPDF_Object* pOCGObj = pOCMDDict->GetElementValue(FX_BSTRC("OCGs")); |
| 258 if (pOCGObj == NULL) { | 256 if (pOCGObj == NULL) { |
| 259 return TRUE; | 257 return TRUE; |
| 260 } | 258 } |
| 261 if (pOCGObj->GetType() == PDFOBJ_DICTIONARY) { | 259 if (const CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) { |
| 262 return bFromConfig ? LoadOCGState((CPDF_Dictionary*)pOCGObj) | 260 return bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict); |
| 263 : GetOCGVisible((CPDF_Dictionary*)pOCGObj); | |
| 264 } | 261 } |
| 265 if (pOCGObj->GetType() != PDFOBJ_ARRAY) { | 262 if (pOCGObj->GetType() != PDFOBJ_ARRAY) { |
| 266 return TRUE; | 263 return TRUE; |
| 267 } | 264 } |
| 268 FX_BOOL bState = FALSE; | 265 FX_BOOL bState = FALSE; |
| 269 if (csP == FX_BSTRC("AllOn") || csP == FX_BSTRC("AllOff")) { | 266 if (csP == FX_BSTRC("AllOn") || csP == FX_BSTRC("AllOff")) { |
| 270 bState = TRUE; | 267 bState = TRUE; |
| 271 } | 268 } |
| 272 int32_t iCount = ((CPDF_Array*)pOCGObj)->GetCount(); | 269 int32_t iCount = ((CPDF_Array*)pOCGObj)->GetCount(); |
| 273 for (int32_t i = 0; i < iCount; i++) { | 270 for (int32_t i = 0; i < iCount; i++) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 298 CFX_ByteString csType = | 295 CFX_ByteString csType = |
| 299 pOCGDict->GetString(FX_BSTRC("Type"), FX_BSTRC("OCG")); | 296 pOCGDict->GetString(FX_BSTRC("Type"), FX_BSTRC("OCG")); |
| 300 if (csType == FX_BSTRC("OCG")) { | 297 if (csType == FX_BSTRC("OCG")) { |
| 301 return GetOCGVisible(pOCGDict); | 298 return GetOCGVisible(pOCGDict); |
| 302 } | 299 } |
| 303 return LoadOCMDState(pOCGDict, FALSE); | 300 return LoadOCMDState(pOCGDict, FALSE); |
| 304 } | 301 } |
| 305 void CPDF_OCContext::ResetOCContext() { | 302 void CPDF_OCContext::ResetOCContext() { |
| 306 m_OCGStates.clear(); | 303 m_OCGStates.clear(); |
| 307 } | 304 } |
| OLD | NEW |