| 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 "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 FXSYS_assert(pDict != NULL); | |
| 28 CPDF_Object* pIntent = pDict->GetElementValue("Intent"); | 27 CPDF_Object* pIntent = pDict->GetElementValue("Intent"); |
| 29 if (pIntent == NULL) { | 28 if (pIntent == NULL) { |
| 30 return csElement == csDef; | 29 return csElement == csDef; |
| 31 } | 30 } |
| 32 CFX_ByteString bsIntent; | 31 CFX_ByteString bsIntent; |
| 33 if (CPDF_Array* pArray = pIntent->AsArray()) { | 32 if (CPDF_Array* pArray = pIntent->AsArray()) { |
| 34 FX_DWORD dwCount = pArray->GetCount(); | 33 FX_DWORD dwCount = pArray->GetCount(); |
| 35 for (FX_DWORD i = 0; i < dwCount; i++) { | 34 for (FX_DWORD i = 0; i < dwCount; i++) { |
| 36 bsIntent = pArray->GetString(i); | 35 bsIntent = pArray->GetString(i); |
| 37 if (bsIntent == "All" || bsIntent == csElement) | 36 if (bsIntent == "All" || bsIntent == csElement) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (eType == CPDF_OCContext::Design) { | 81 if (eType == CPDF_OCContext::Design) { |
| 83 csState = "Design"; | 82 csState = "Design"; |
| 84 } else if (eType == CPDF_OCContext::Print) { | 83 } else if (eType == CPDF_OCContext::Print) { |
| 85 csState = "Print"; | 84 csState = "Print"; |
| 86 } else if (eType == CPDF_OCContext::Export) { | 85 } else if (eType == CPDF_OCContext::Export) { |
| 87 csState = "Export"; | 86 csState = "Export"; |
| 88 } | 87 } |
| 89 return csState; | 88 return csState; |
| 90 } | 89 } |
| 91 CPDF_OCContext::CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType) { | 90 CPDF_OCContext::CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType) { |
| 92 FXSYS_assert(pDoc != NULL); | 91 FXSYS_assert(pDoc); |
| 93 m_pDocument = pDoc; | 92 m_pDocument = pDoc; |
| 94 m_eUsageType = eUsageType; | 93 m_eUsageType = eUsageType; |
| 95 } | 94 } |
| 96 CPDF_OCContext::~CPDF_OCContext() { | 95 CPDF_OCContext::~CPDF_OCContext() { |
| 97 m_OCGStates.clear(); | 96 m_OCGStates.clear(); |
| 98 } | 97 } |
| 99 FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig, | 98 FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig, |
| 100 const CPDF_Dictionary* pOCGDict, | 99 const CPDF_Dictionary* pOCGDict, |
| 101 FX_BOOL& bValidConfig) const { | 100 FX_BOOL& bValidConfig) const { |
| 102 CPDF_Dictionary* pConfig = | 101 CPDF_Dictionary* pConfig = |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 bValue = bValue && bItem; | 227 bValue = bValue && bItem; |
| 229 } | 228 } |
| 230 } | 229 } |
| 231 } | 230 } |
| 232 return bValue; | 231 return bValue; |
| 233 } | 232 } |
| 234 return FALSE; | 233 return FALSE; |
| 235 } | 234 } |
| 236 FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict, | 235 FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict, |
| 237 FX_BOOL bFromConfig) { | 236 FX_BOOL bFromConfig) { |
| 238 FXSYS_assert(pOCMDDict != NULL); | |
| 239 CPDF_Array* pVE = pOCMDDict->GetArray("VE"); | 237 CPDF_Array* pVE = pOCMDDict->GetArray("VE"); |
| 240 if (pVE != NULL) { | 238 if (pVE) { |
| 241 return GetOCGVE(pVE, bFromConfig); | 239 return GetOCGVE(pVE, bFromConfig); |
| 242 } | 240 } |
| 243 CFX_ByteString csP = pOCMDDict->GetString("P", "AnyOn"); | 241 CFX_ByteString csP = pOCMDDict->GetString("P", "AnyOn"); |
| 244 CPDF_Object* pOCGObj = pOCMDDict->GetElementValue("OCGs"); | 242 CPDF_Object* pOCGObj = pOCMDDict->GetElementValue("OCGs"); |
| 245 if (!pOCGObj) | 243 if (!pOCGObj) |
| 246 return TRUE; | 244 return TRUE; |
| 247 if (const CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) | 245 if (const CPDF_Dictionary* pDict = pOCGObj->AsDictionary()) |
| 248 return bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict); | 246 return bFromConfig ? LoadOCGState(pDict) : GetOCGVisible(pDict); |
| 249 | 247 |
| 250 CPDF_Array* pArray = pOCGObj->AsArray(); | 248 CPDF_Array* pArray = pOCGObj->AsArray(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 275 } | 273 } |
| 276 CFX_ByteString csType = pOCGDict->GetString("Type", "OCG"); | 274 CFX_ByteString csType = pOCGDict->GetString("Type", "OCG"); |
| 277 if (csType == "OCG") { | 275 if (csType == "OCG") { |
| 278 return GetOCGVisible(pOCGDict); | 276 return GetOCGVisible(pOCGDict); |
| 279 } | 277 } |
| 280 return LoadOCMDState(pOCGDict, FALSE); | 278 return LoadOCMDState(pOCGDict, FALSE); |
| 281 } | 279 } |
| 282 void CPDF_OCContext::ResetOCContext() { | 280 void CPDF_OCContext::ResetOCContext() { |
| 283 m_OCGStates.clear(); | 281 m_OCGStates.clear(); |
| 284 } | 282 } |
| OLD | NEW |