| 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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 m_Type = Colorant; | 1050 m_Type = Colorant; |
| 1051 CPDF_Object* pAltCS = pArray->GetElementValue(2); | 1051 CPDF_Object* pAltCS = pArray->GetElementValue(2); |
| 1052 if (pAltCS == m_pArray) { | 1052 if (pAltCS == m_pArray) { |
| 1053 return FALSE; | 1053 return FALSE; |
| 1054 } | 1054 } |
| 1055 m_pAltCS = Load(pDoc, pAltCS); | 1055 m_pAltCS = Load(pDoc, pAltCS); |
| 1056 if (!m_pAltCS) { | 1056 if (!m_pAltCS) { |
| 1057 return FALSE; | 1057 return FALSE; |
| 1058 } | 1058 } |
| 1059 CPDF_Object* pFuncObj = pArray->GetElementValue(3); | 1059 CPDF_Object* pFuncObj = pArray->GetElementValue(3); |
| 1060 if (pFuncObj && pFuncObj->GetType() != PDFOBJ_NAME) { | 1060 if (pFuncObj && !pFuncObj->IsName()) |
| 1061 m_pFunc = CPDF_Function::Load(pFuncObj); | 1061 m_pFunc = CPDF_Function::Load(pFuncObj); |
| 1062 } | 1062 |
| 1063 if (m_pFunc && m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) { | 1063 if (m_pFunc && m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) { |
| 1064 delete m_pFunc; | 1064 delete m_pFunc; |
| 1065 m_pFunc = NULL; | 1065 m_pFunc = NULL; |
| 1066 } | 1066 } |
| 1067 } | 1067 } |
| 1068 return TRUE; | 1068 return TRUE; |
| 1069 } | 1069 } |
| 1070 FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, | 1070 FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, |
| 1071 FX_FLOAT& R, | 1071 FX_FLOAT& R, |
| 1072 FX_FLOAT& G, | 1072 FX_FLOAT& G, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 } | 1195 } |
| 1196 if (name == FX_BSTRC("DeviceCMYK") || name == FX_BSTRC("CMYK")) { | 1196 if (name == FX_BSTRC("DeviceCMYK") || name == FX_BSTRC("CMYK")) { |
| 1197 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); | 1197 return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); |
| 1198 } | 1198 } |
| 1199 if (name == FX_BSTRC("Pattern")) { | 1199 if (name == FX_BSTRC("Pattern")) { |
| 1200 return CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN); | 1200 return CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN); |
| 1201 } | 1201 } |
| 1202 return NULL; | 1202 return NULL; |
| 1203 } | 1203 } |
| 1204 CPDF_ColorSpace* CPDF_ColorSpace::Load(CPDF_Document* pDoc, CPDF_Object* pObj) { | 1204 CPDF_ColorSpace* CPDF_ColorSpace::Load(CPDF_Document* pDoc, CPDF_Object* pObj) { |
| 1205 if (pObj == NULL) { | 1205 if (!pObj) |
| 1206 return NULL; | 1206 return nullptr; |
| 1207 } | 1207 if (pObj->IsName()) |
| 1208 if (pObj->GetType() == PDFOBJ_NAME) { | |
| 1209 return _CSFromName(pObj->GetString()); | 1208 return _CSFromName(pObj->GetString()); |
| 1210 } | 1209 |
| 1211 if (pObj->GetType() == PDFOBJ_STREAM) { | 1210 if (pObj->GetType() == PDFOBJ_STREAM) { |
| 1212 CPDF_Dictionary* pDict = ((CPDF_Stream*)pObj)->GetDict(); | 1211 CPDF_Dictionary* pDict = ((CPDF_Stream*)pObj)->GetDict(); |
| 1213 if (!pDict) { | 1212 if (!pDict) |
| 1214 return NULL; | 1213 return nullptr; |
| 1215 } | 1214 |
| 1216 CPDF_ColorSpace* pRet = NULL; | 1215 CPDF_ColorSpace* pRet = nullptr; |
| 1217 FX_POSITION pos = pDict->GetStartPos(); | 1216 FX_POSITION pos = pDict->GetStartPos(); |
| 1218 while (pos) { | 1217 while (pos) { |
| 1219 CFX_ByteString bsKey; | 1218 CFX_ByteString bsKey; |
| 1220 CPDF_Object* pValue = pDict->GetNextElement(pos, bsKey); | 1219 CPDF_Object* pValue = pDict->GetNextElement(pos, bsKey); |
| 1221 if (pValue && pValue->GetType() == PDFOBJ_NAME) { | 1220 if (ToName(pValue)) |
| 1222 pRet = _CSFromName(pValue->GetString()); | 1221 pRet = _CSFromName(pValue->GetString()); |
| 1223 } | 1222 if (pRet) |
| 1224 if (pRet) { | |
| 1225 return pRet; | 1223 return pRet; |
| 1226 } | |
| 1227 } | 1224 } |
| 1228 return NULL; | 1225 return nullptr; |
| 1229 } | 1226 } |
| 1230 if (pObj->GetType() != PDFOBJ_ARRAY) { | 1227 if (pObj->GetType() != PDFOBJ_ARRAY) { |
| 1231 return NULL; | 1228 return NULL; |
| 1232 } | 1229 } |
| 1233 CPDF_Array* pArray = (CPDF_Array*)pObj; | 1230 CPDF_Array* pArray = (CPDF_Array*)pObj; |
| 1234 if (pArray->GetCount() == 0) { | 1231 if (pArray->GetCount() == 0) { |
| 1235 return NULL; | 1232 return NULL; |
| 1236 } | 1233 } |
| 1237 CPDF_Object* pFamilyObj = pArray->GetElementValue(0); | 1234 CPDF_Object* pFamilyObj = pArray->GetElementValue(0); |
| 1238 if (!pFamilyObj) { | 1235 if (!pFamilyObj) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 } | 1530 } |
| 1534 PatternValue* pvalue = (PatternValue*)m_pBuffer; | 1531 PatternValue* pvalue = (PatternValue*)m_pBuffer; |
| 1535 return pvalue->m_nComps ? pvalue->m_Comps : NULL; | 1532 return pvalue->m_nComps ? pvalue->m_Comps : NULL; |
| 1536 } | 1533 } |
| 1537 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const { | 1534 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const { |
| 1538 if (m_pCS != other.m_pCS || m_pCS == NULL) { | 1535 if (m_pCS != other.m_pCS || m_pCS == NULL) { |
| 1539 return FALSE; | 1536 return FALSE; |
| 1540 } | 1537 } |
| 1541 return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; | 1538 return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; |
| 1542 } | 1539 } |
| OLD | NEW |