| 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 "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
| 10 #include "pageint.h" | 10 #include "pageint.h" |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 } | 1132 } |
| 1133 void CPDF_DeviceNCS::GetDefaultValue(int iComponent, | 1133 void CPDF_DeviceNCS::GetDefaultValue(int iComponent, |
| 1134 FX_FLOAT& value, | 1134 FX_FLOAT& value, |
| 1135 FX_FLOAT& min, | 1135 FX_FLOAT& min, |
| 1136 FX_FLOAT& max) const { | 1136 FX_FLOAT& max) const { |
| 1137 value = 1.0f; | 1137 value = 1.0f; |
| 1138 min = 0; | 1138 min = 0; |
| 1139 max = 1.0f; | 1139 max = 1.0f; |
| 1140 } | 1140 } |
| 1141 FX_BOOL CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { | 1141 FX_BOOL CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { |
| 1142 CPDF_Object* pObj = pArray->GetElementValue(1); | 1142 CPDF_Array* pObj = ToArray(pArray->GetElementValue(1)); |
| 1143 if (!pObj) { | 1143 if (!pObj) |
| 1144 return FALSE; | 1144 return FALSE; |
| 1145 } | 1145 |
| 1146 if (pObj->GetType() != PDFOBJ_ARRAY) { | 1146 m_nComponents = pObj->GetCount(); |
| 1147 return FALSE; | |
| 1148 } | |
| 1149 m_nComponents = ((CPDF_Array*)pObj)->GetCount(); | |
| 1150 CPDF_Object* pAltCS = pArray->GetElementValue(2); | 1147 CPDF_Object* pAltCS = pArray->GetElementValue(2); |
| 1151 if (!pAltCS || pAltCS == m_pArray) { | 1148 if (!pAltCS || pAltCS == m_pArray) { |
| 1152 return FALSE; | 1149 return FALSE; |
| 1153 } | 1150 } |
| 1154 m_pAltCS = Load(pDoc, pAltCS); | 1151 m_pAltCS = Load(pDoc, pAltCS); |
| 1155 m_pFunc = CPDF_Function::Load(pArray->GetElementValue(3)); | 1152 m_pFunc = CPDF_Function::Load(pArray->GetElementValue(3)); |
| 1156 if (m_pAltCS == NULL || m_pFunc == NULL) { | 1153 if (m_pAltCS == NULL || m_pFunc == NULL) { |
| 1157 return FALSE; | 1154 return FALSE; |
| 1158 } | 1155 } |
| 1159 if (m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) { | 1156 if (m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 while (pos) { | 1214 while (pos) { |
| 1218 CFX_ByteString bsKey; | 1215 CFX_ByteString bsKey; |
| 1219 CPDF_Object* pValue = pDict->GetNextElement(pos, bsKey); | 1216 CPDF_Object* pValue = pDict->GetNextElement(pos, bsKey); |
| 1220 if (ToName(pValue)) | 1217 if (ToName(pValue)) |
| 1221 pRet = _CSFromName(pValue->GetString()); | 1218 pRet = _CSFromName(pValue->GetString()); |
| 1222 if (pRet) | 1219 if (pRet) |
| 1223 return pRet; | 1220 return pRet; |
| 1224 } | 1221 } |
| 1225 return nullptr; | 1222 return nullptr; |
| 1226 } | 1223 } |
| 1227 if (pObj->GetType() != PDFOBJ_ARRAY) { | 1224 |
| 1228 return NULL; | 1225 CPDF_Array* pArray = pObj->AsArray(); |
| 1229 } | 1226 if (!pArray || pArray->GetCount() == 0) |
| 1230 CPDF_Array* pArray = (CPDF_Array*)pObj; | 1227 return nullptr; |
| 1231 if (pArray->GetCount() == 0) { | 1228 |
| 1232 return NULL; | |
| 1233 } | |
| 1234 CPDF_Object* pFamilyObj = pArray->GetElementValue(0); | 1229 CPDF_Object* pFamilyObj = pArray->GetElementValue(0); |
| 1235 if (!pFamilyObj) { | 1230 if (!pFamilyObj) |
| 1236 return NULL; | 1231 return nullptr; |
| 1237 } | 1232 |
| 1238 CFX_ByteString familyname = pFamilyObj->GetString(); | 1233 CFX_ByteString familyname = pFamilyObj->GetString(); |
| 1239 if (pArray->GetCount() == 1) { | 1234 if (pArray->GetCount() == 1) |
| 1240 return _CSFromName(familyname); | 1235 return _CSFromName(familyname); |
| 1241 } | 1236 |
| 1242 CPDF_ColorSpace* pCS = NULL; | 1237 CPDF_ColorSpace* pCS = NULL; |
| 1243 FX_DWORD id = familyname.GetID(); | 1238 FX_DWORD id = familyname.GetID(); |
| 1244 if (id == FXBSTR_ID('C', 'a', 'l', 'G')) { | 1239 if (id == FXBSTR_ID('C', 'a', 'l', 'G')) { |
| 1245 pCS = new CPDF_CalGray(pDoc); | 1240 pCS = new CPDF_CalGray(pDoc); |
| 1246 } else if (id == FXBSTR_ID('C', 'a', 'l', 'R')) { | 1241 } else if (id == FXBSTR_ID('C', 'a', 'l', 'R')) { |
| 1247 pCS = new CPDF_CalRGB(pDoc); | 1242 pCS = new CPDF_CalRGB(pDoc); |
| 1248 } else if (id == FXBSTR_ID('L', 'a', 'b', 0)) { | 1243 } else if (id == FXBSTR_ID('L', 'a', 'b', 0)) { |
| 1249 pCS = new CPDF_LabCS(pDoc); | 1244 pCS = new CPDF_LabCS(pDoc); |
| 1250 } else if (id == FXBSTR_ID('I', 'C', 'C', 'B')) { | 1245 } else if (id == FXBSTR_ID('I', 'C', 'C', 'B')) { |
| 1251 pCS = new CPDF_ICCBasedCS(pDoc); | 1246 pCS = new CPDF_ICCBasedCS(pDoc); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 } | 1525 } |
| 1531 PatternValue* pvalue = (PatternValue*)m_pBuffer; | 1526 PatternValue* pvalue = (PatternValue*)m_pBuffer; |
| 1532 return pvalue->m_nComps ? pvalue->m_Comps : NULL; | 1527 return pvalue->m_nComps ? pvalue->m_Comps : NULL; |
| 1533 } | 1528 } |
| 1534 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const { | 1529 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const { |
| 1535 if (m_pCS != other.m_pCS || m_pCS == NULL) { | 1530 if (m_pCS != other.m_pCS || m_pCS == NULL) { |
| 1536 return FALSE; | 1531 return FALSE; |
| 1537 } | 1532 } |
| 1538 return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; | 1533 return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; |
| 1539 } | 1534 } |
| OLD | NEW |