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

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

Issue 1977093002: Make CFX_ByteString(const CFX_ByteStringC&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nit Created 4 years, 7 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_page/cpdf_contentmarkdata.h" 7 #include "core/fpdfapi/fpdf_page/cpdf_contentmarkdata.h"
8 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" 8 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h"
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
(...skipping 25 matching lines...) Expand all
36 for (size_t i = 0; i < pArray->GetCount(); i++) { 36 for (size_t i = 0; i < pArray->GetCount(); i++) {
37 bsIntent = pArray->GetStringAt(i); 37 bsIntent = pArray->GetStringAt(i);
38 if (bsIntent == "All" || bsIntent == csElement) 38 if (bsIntent == "All" || bsIntent == csElement)
39 return TRUE; 39 return TRUE;
40 } 40 }
41 return FALSE; 41 return FALSE;
42 } 42 }
43 bsIntent = pIntent->GetString(); 43 bsIntent = pIntent->GetString();
44 return bsIntent == "All" || bsIntent == csElement; 44 return bsIntent == "All" || bsIntent == csElement;
45 } 45 }
46
46 static CPDF_Dictionary* FPDFDOC_OCG_GetConfig(CPDF_Document* pDoc, 47 static CPDF_Dictionary* FPDFDOC_OCG_GetConfig(CPDF_Document* pDoc,
47 const CPDF_Dictionary* pOCGDict, 48 const CPDF_Dictionary* pOCGDict) {
48 const CFX_ByteStringC& bsState) { 49 ASSERT(pOCGDict);
49 ASSERT(pDoc && pOCGDict);
50 CPDF_Dictionary* pOCProperties = pDoc->GetRoot()->GetDictBy("OCProperties"); 50 CPDF_Dictionary* pOCProperties = pDoc->GetRoot()->GetDictBy("OCProperties");
51 if (!pOCProperties) { 51 if (!pOCProperties)
52 return NULL; 52 return nullptr;
53 } 53
54 CPDF_Array* pOCGs = pOCProperties->GetArrayBy("OCGs"); 54 CPDF_Array* pOCGs = pOCProperties->GetArrayBy("OCGs");
55 if (!pOCGs) { 55 if (!pOCGs)
56 return NULL; 56 return nullptr;
57 } 57
58 if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0) { 58 if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0)
59 return NULL; 59 return nullptr;
60 } 60
61 CPDF_Dictionary* pConfig = pOCProperties->GetDictBy("D"); 61 CPDF_Dictionary* pConfig = pOCProperties->GetDictBy("D");
62 CPDF_Array* pConfigs = pOCProperties->GetArrayBy("Configs"); 62 CPDF_Array* pConfigs = pOCProperties->GetArrayBy("Configs");
63 if (pConfigs) { 63 if (pConfigs) {
64 CPDF_Dictionary* pFind; 64 CPDF_Dictionary* pFind;
65 for (size_t i = 0; i < pConfigs->GetCount(); i++) { 65 for (size_t i = 0; i < pConfigs->GetCount(); i++) {
66 pFind = pConfigs->GetDictAt(i); 66 pFind = pConfigs->GetDictAt(i);
67 if (!pFind) { 67 if (!pFind) {
68 continue; 68 continue;
69 } 69 }
70 if (!FPDFDOC_OCG_HasIntent(pFind, "View", "View")) { 70 if (!FPDFDOC_OCG_HasIntent(pFind, "View", "View")) {
(...skipping 18 matching lines...) Expand all
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 ASSERT(pDoc); 92 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
100 FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteString& csConfig,
100 const CPDF_Dictionary* pOCGDict, 101 const CPDF_Dictionary* pOCGDict,
101 FX_BOOL& bValidConfig) const { 102 FX_BOOL& bValidConfig) const {
102 CPDF_Dictionary* pConfig = 103 CPDF_Dictionary* pConfig = FPDFDOC_OCG_GetConfig(m_pDocument, pOCGDict);
103 FPDFDOC_OCG_GetConfig(m_pDocument, pOCGDict, csConfig); 104 if (!pConfig)
104 if (!pConfig) {
105 return TRUE; 105 return TRUE;
106 } 106
107 bValidConfig = TRUE; 107 bValidConfig = TRUE;
108 FX_BOOL bState = pConfig->GetStringBy("BaseState", "ON") != "OFF"; 108 FX_BOOL bState = pConfig->GetStringBy("BaseState", "ON") != "OFF";
109 CPDF_Array* pArray = pConfig->GetArrayBy("ON"); 109 CPDF_Array* pArray = pConfig->GetArrayBy("ON");
110 if (pArray) { 110 if (pArray) {
111 if (FPDFDOC_OCG_FindGroup(pArray, pOCGDict) >= 0) { 111 if (FPDFDOC_OCG_FindGroup(pArray, pOCGDict) >= 0) {
112 bState = TRUE; 112 bState = TRUE;
113 } 113 }
114 } 114 }
115 pArray = pConfig->GetArrayBy("OFF"); 115 pArray = pConfig->GetArrayBy("OFF");
116 if (pArray) { 116 if (pArray) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 } 161 }
162 if (csState != "View") { 162 if (csState != "View") {
163 pState = pUsage->GetDictBy("View"); 163 pState = pUsage->GetDictBy("View");
164 if (pState && pState->KeyExist("ViewState")) { 164 if (pState && pState->KeyExist("ViewState")) {
165 return pState->GetStringBy("ViewState") != "OFF"; 165 return pState->GetStringBy("ViewState") != "OFF";
166 } 166 }
167 } 167 }
168 } 168 }
169 FX_BOOL bDefValid = FALSE; 169 FX_BOOL bDefValid = FALSE;
170 return LoadOCGStateFromConfig(csState.AsStringC(), pOCGDict, bDefValid); 170 return LoadOCGStateFromConfig(csState, pOCGDict, bDefValid);
171 } 171 }
172 172
173 FX_BOOL CPDF_OCContext::GetOCGVisible(const CPDF_Dictionary* pOCGDict) { 173 FX_BOOL CPDF_OCContext::GetOCGVisible(const CPDF_Dictionary* pOCGDict) {
174 if (!pOCGDict) 174 if (!pOCGDict)
175 return FALSE; 175 return FALSE;
176 176
177 const auto it = m_OCGStates.find(pOCGDict); 177 const auto it = m_OCGStates.find(pOCGDict);
178 if (it != m_OCGStates.end()) 178 if (it != m_OCGStates.end())
179 return it->second; 179 return it->second;
180 180
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 284 }
285 CFX_ByteString csType = pOCGDict->GetStringBy("Type", "OCG"); 285 CFX_ByteString csType = pOCGDict->GetStringBy("Type", "OCG");
286 if (csType == "OCG") { 286 if (csType == "OCG") {
287 return GetOCGVisible(pOCGDict); 287 return GetOCGVisible(pOCGDict);
288 } 288 }
289 return LoadOCMDState(pOCGDict, FALSE); 289 return LoadOCMDState(pOCGDict, FALSE);
290 } 290 }
291 void CPDF_OCContext::ResetOCContext() { 291 void CPDF_OCContext::ResetOCContext() {
292 m_OCGStates.clear(); 292 m_OCGStates.clear();
293 } 293 }
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