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/fpdfapi/fpdf_parser/include/cpdf_array.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
9 #include "core/fpdfdoc/include/fpdf_doc.h" | 9 #include "core/fpdfdoc/include/fpdf_doc.h" |
10 | 10 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 if (!pOCGs) { | 135 if (!pOCGs) { |
136 continue; | 136 continue; |
137 } | 137 } |
138 if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0) { | 138 if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0) { |
139 continue; | 139 continue; |
140 } | 140 } |
141 CPDF_Dictionary* pState = pUsage->GetDictBy(csConfig); | 141 CPDF_Dictionary* pState = pUsage->GetDictBy(csConfig); |
142 if (!pState) { | 142 if (!pState) { |
143 continue; | 143 continue; |
144 } | 144 } |
145 bState = pState->GetStringBy(csFind.AsByteStringC()) != "OFF"; | 145 bState = pState->GetStringBy(csFind.AsStringC()) != "OFF"; |
146 } | 146 } |
147 } | 147 } |
148 return bState; | 148 return bState; |
149 } | 149 } |
150 FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const { | 150 FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const { |
151 if (!FPDFDOC_OCG_HasIntent(pOCGDict, "View", "View")) { | 151 if (!FPDFDOC_OCG_HasIntent(pOCGDict, "View", "View")) { |
152 return TRUE; | 152 return TRUE; |
153 } | 153 } |
154 CFX_ByteString csState = FPDFDOC_OCG_GetUsageTypeString(m_eUsageType); | 154 CFX_ByteString csState = FPDFDOC_OCG_GetUsageTypeString(m_eUsageType); |
155 CPDF_Dictionary* pUsage = pOCGDict->GetDictBy("Usage"); | 155 CPDF_Dictionary* pUsage = pOCGDict->GetDictBy("Usage"); |
156 if (pUsage) { | 156 if (pUsage) { |
157 CPDF_Dictionary* pState = pUsage->GetDictBy(csState.AsByteStringC()); | 157 CPDF_Dictionary* pState = pUsage->GetDictBy(csState.AsStringC()); |
158 if (pState) { | 158 if (pState) { |
159 CFX_ByteString csFind = csState + "State"; | 159 CFX_ByteString csFind = csState + "State"; |
160 if (pState->KeyExist(csFind.AsByteStringC())) { | 160 if (pState->KeyExist(csFind.AsStringC())) { |
161 return pState->GetStringBy(csFind.AsByteStringC()) != "OFF"; | 161 return pState->GetStringBy(csFind.AsStringC()) != "OFF"; |
162 } | 162 } |
163 } | 163 } |
164 if (csState != "View") { | 164 if (csState != "View") { |
165 pState = pUsage->GetDictBy("View"); | 165 pState = pUsage->GetDictBy("View"); |
166 if (pState && pState->KeyExist("ViewState")) { | 166 if (pState && pState->KeyExist("ViewState")) { |
167 return pState->GetStringBy("ViewState") != "OFF"; | 167 return pState->GetStringBy("ViewState") != "OFF"; |
168 } | 168 } |
169 } | 169 } |
170 } | 170 } |
171 FX_BOOL bDefValid = FALSE; | 171 FX_BOOL bDefValid = FALSE; |
172 return LoadOCGStateFromConfig(csState.AsByteStringC(), pOCGDict, bDefValid); | 172 return LoadOCGStateFromConfig(csState.AsStringC(), pOCGDict, bDefValid); |
173 } | 173 } |
174 | 174 |
175 FX_BOOL CPDF_OCContext::GetOCGVisible(const CPDF_Dictionary* pOCGDict) { | 175 FX_BOOL CPDF_OCContext::GetOCGVisible(const CPDF_Dictionary* pOCGDict) { |
176 if (!pOCGDict) | 176 if (!pOCGDict) |
177 return FALSE; | 177 return FALSE; |
178 | 178 |
179 const auto it = m_OCGStates.find(pOCGDict); | 179 const auto it = m_OCGStates.find(pOCGDict); |
180 if (it != m_OCGStates.end()) | 180 if (it != m_OCGStates.end()) |
181 return it->second; | 181 return it->second; |
182 | 182 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 275 } |
276 CFX_ByteString csType = pOCGDict->GetStringBy("Type", "OCG"); | 276 CFX_ByteString csType = pOCGDict->GetStringBy("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 |