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