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

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

Issue 1853233002: Make down-conversion explicit from CFX_ByteString to CFX_ByteStringC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix CPDF_Name::GetConstString() Created 4 years, 8 months 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/fpdfdoc/doc_link.cpp ('k') | core/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/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/include/fpdfdoc/fpdf_doc.h" 9 #include "core/include/fpdfdoc/fpdf_doc.h"
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) != "OFF"; 145 bState = pState->GetStringBy(csFind.AsByteStringC()) != "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); 157 CPDF_Dictionary* pState = pUsage->GetDictBy(csState.AsByteStringC());
158 if (pState) { 158 if (pState) {
159 CFX_ByteString csFind = csState + "State"; 159 CFX_ByteString csFind = csState + "State";
160 if (pState->KeyExist(csFind)) { 160 if (pState->KeyExist(csFind.AsByteStringC())) {
161 return pState->GetStringBy(csFind) != "OFF"; 161 return pState->GetStringBy(csFind.AsByteStringC()) != "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, pOCGDict, bDefValid); 172 return LoadOCGStateFromConfig(csState.AsByteStringC(), 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
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 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_link.cpp ('k') | core/fpdfdoc/doc_tagged.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698