| 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/fpdfapi/fpdf_serial.h" | 9 #include "../../../include/fpdfapi/fpdf_serial.h" |
| 10 #include "pageint.h" | 10 #include "pageint.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 return; | 411 return; |
| 412 } | 412 } |
| 413 FX_BOOL bDirect = TRUE; | 413 FX_BOOL bDirect = TRUE; |
| 414 if (pProperty->GetType() == PDFOBJ_NAME) { | 414 if (pProperty->GetType() == PDFOBJ_NAME) { |
| 415 pProperty = FindResourceObj(FX_BSTRC("Properties"), pProperty->GetString()); | 415 pProperty = FindResourceObj(FX_BSTRC("Properties"), pProperty->GetString()); |
| 416 if (pProperty == NULL) { | 416 if (pProperty == NULL) { |
| 417 return; | 417 return; |
| 418 } | 418 } |
| 419 bDirect = FALSE; | 419 bDirect = FALSE; |
| 420 } | 420 } |
| 421 if (pProperty->GetType() != PDFOBJ_DICTIONARY) { | 421 if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { |
| 422 return; | 422 m_CurContentMark.GetModify()->AddMark(tag, pDict, bDirect); |
| 423 } | 423 } |
| 424 m_CurContentMark.GetModify()->AddMark(tag, (CPDF_Dictionary*)pProperty, | |
| 425 bDirect); | |
| 426 } | 424 } |
| 427 void CPDF_StreamContentParser::Handle_BeginMarkedContent() { | 425 void CPDF_StreamContentParser::Handle_BeginMarkedContent() { |
| 428 if (!m_Options.m_bMarkedContent) { | 426 if (!m_Options.m_bMarkedContent) { |
| 429 return; | 427 return; |
| 430 } | 428 } |
| 431 CFX_ByteString tag = GetString(0); | 429 CFX_ByteString tag = GetString(0); |
| 432 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); | 430 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); |
| 433 } | 431 } |
| 434 struct _FX_BSTR { | 432 struct _FX_BSTR { |
| 435 const FX_CHAR* m_Ptr; | 433 const FX_CHAR* m_Ptr; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 0) { | 478 0) { |
| 481 return CFX_ByteStringC(table[i].m_Ptr, table[i].m_Size); | 479 return CFX_ByteStringC(table[i].m_Ptr, table[i].m_Size); |
| 482 } | 480 } |
| 483 i += 2; | 481 i += 2; |
| 484 } | 482 } |
| 485 return CFX_ByteStringC(); | 483 return CFX_ByteStringC(); |
| 486 } | 484 } |
| 487 void _PDF_ReplaceAbbr(CPDF_Object* pObj) { | 485 void _PDF_ReplaceAbbr(CPDF_Object* pObj) { |
| 488 switch (pObj->GetType()) { | 486 switch (pObj->GetType()) { |
| 489 case PDFOBJ_DICTIONARY: { | 487 case PDFOBJ_DICTIONARY: { |
| 490 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj; | 488 CPDF_Dictionary* pDict = pObj->AsDictionary(); |
| 491 FX_POSITION pos = pDict->GetStartPos(); | 489 FX_POSITION pos = pDict->GetStartPos(); |
| 492 while (pos) { | 490 while (pos) { |
| 493 CFX_ByteString key; | 491 CFX_ByteString key; |
| 494 CPDF_Object* value = pDict->GetNextElement(pos, key); | 492 CPDF_Object* value = pDict->GetNextElement(pos, key); |
| 495 CFX_ByteStringC fullname = _PDF_FindFullName( | 493 CFX_ByteStringC fullname = _PDF_FindFullName( |
| 496 _PDF_InlineKeyAbbr, sizeof _PDF_InlineKeyAbbr / sizeof(_FX_BSTR), | 494 _PDF_InlineKeyAbbr, sizeof _PDF_InlineKeyAbbr / sizeof(_FX_BSTR), |
| 497 key); | 495 key); |
| 498 if (!fullname.IsEmpty()) { | 496 if (!fullname.IsEmpty()) { |
| 499 pDict->ReplaceKey(key, fullname); | 497 pDict->ReplaceKey(key, fullname); |
| 500 key = fullname; | 498 key = fullname; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 0) { | 541 0) { |
| 544 return CFX_ByteStringC(table[i + 1].m_Ptr, table[i + 1].m_Size); | 542 return CFX_ByteStringC(table[i + 1].m_Ptr, table[i + 1].m_Size); |
| 545 } | 543 } |
| 546 i += 2; | 544 i += 2; |
| 547 } | 545 } |
| 548 return CFX_ByteStringC(); | 546 return CFX_ByteStringC(); |
| 549 } | 547 } |
| 550 void _PDF_ReplaceFull(CPDF_Object* pObj) { | 548 void _PDF_ReplaceFull(CPDF_Object* pObj) { |
| 551 switch (pObj->GetType()) { | 549 switch (pObj->GetType()) { |
| 552 case PDFOBJ_DICTIONARY: { | 550 case PDFOBJ_DICTIONARY: { |
| 553 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj; | 551 CPDF_Dictionary* pDict = pObj->AsDictionary(); |
| 554 FX_POSITION pos = pDict->GetStartPos(); | 552 FX_POSITION pos = pDict->GetStartPos(); |
| 555 while (pos) { | 553 while (pos) { |
| 556 CFX_ByteString key; | 554 CFX_ByteString key; |
| 557 CPDF_Object* value = pDict->GetNextElement(pos, key); | 555 CPDF_Object* value = pDict->GetNextElement(pos, key); |
| 558 CFX_ByteStringC abbrName = _PDF_FindAbbrName( | 556 CFX_ByteStringC abbrName = _PDF_FindAbbrName( |
| 559 _PDF_InlineKeyAbbr, sizeof(_PDF_InlineKeyAbbr) / sizeof(_FX_BSTR), | 557 _PDF_InlineKeyAbbr, sizeof(_PDF_InlineKeyAbbr) / sizeof(_FX_BSTR), |
| 560 key); | 558 key); |
| 561 if (!abbrName.IsEmpty()) { | 559 if (!abbrName.IsEmpty()) { |
| 562 pDict->ReplaceKey(key, abbrName); | 560 pDict->ReplaceKey(key, abbrName); |
| 563 key = abbrName; | 561 key = abbrName; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 m_pCurStates->m_ColorState.SetFillColor(pCS, &value, 1); | 877 m_pCurStates->m_ColorState.SetFillColor(pCS, &value, 1); |
| 880 } | 878 } |
| 881 void CPDF_StreamContentParser::Handle_SetGray_Stroke() { | 879 void CPDF_StreamContentParser::Handle_SetGray_Stroke() { |
| 882 FX_FLOAT value = GetNumber(0); | 880 FX_FLOAT value = GetNumber(0); |
| 883 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); | 881 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); |
| 884 m_pCurStates->m_ColorState.SetStrokeColor(pCS, &value, 1); | 882 m_pCurStates->m_ColorState.SetStrokeColor(pCS, &value, 1); |
| 885 } | 883 } |
| 886 void CPDF_StreamContentParser::Handle_SetExtendGraphState() { | 884 void CPDF_StreamContentParser::Handle_SetExtendGraphState() { |
| 887 CFX_ByteString name = GetString(0); | 885 CFX_ByteString name = GetString(0); |
| 888 CPDF_Dictionary* pGS = | 886 CPDF_Dictionary* pGS = |
| 889 (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("ExtGState"), name); | 887 ToDictionary(FindResourceObj(FX_BSTRC("ExtGState"), name)); |
| 890 if (pGS == NULL || pGS->GetType() != PDFOBJ_DICTIONARY) { | 888 if (!pGS) { |
| 891 m_bResourceMissing = TRUE; | 889 m_bResourceMissing = TRUE; |
| 892 return; | 890 return; |
| 893 } | 891 } |
| 894 m_pCurStates->ProcessExtGS(pGS, this); | 892 m_pCurStates->ProcessExtGS(pGS, this); |
| 895 } | 893 } |
| 896 void CPDF_StreamContentParser::Handle_ClosePath() { | 894 void CPDF_StreamContentParser::Handle_ClosePath() { |
| 897 if (m_Options.m_bTextOnly) { | 895 if (m_Options.m_bTextOnly) { |
| 898 return; | 896 return; |
| 899 } | 897 } |
| 900 if (m_PathPointCount == 0) { | 898 if (m_PathPointCount == 0) { |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 return NULL; | 1208 return NULL; |
| 1211 } | 1209 } |
| 1212 CPDF_Object* pRes = pList->GetElementValue(name); | 1210 CPDF_Object* pRes = pList->GetElementValue(name); |
| 1213 return pRes; | 1211 return pRes; |
| 1214 } | 1212 } |
| 1215 CPDF_Object* pRes = pList->GetElementValue(name); | 1213 CPDF_Object* pRes = pList->GetElementValue(name); |
| 1216 return pRes; | 1214 return pRes; |
| 1217 } | 1215 } |
| 1218 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { | 1216 CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { |
| 1219 CPDF_Dictionary* pFontDict = | 1217 CPDF_Dictionary* pFontDict = |
| 1220 (CPDF_Dictionary*)FindResourceObj(FX_BSTRC("Font"), name); | 1218 ToDictionary(FindResourceObj(FX_BSTRC("Font"), name)); |
| 1221 if (pFontDict == NULL || pFontDict->GetType() != PDFOBJ_DICTIONARY) { | 1219 if (!pFontDict) { |
| 1222 m_bResourceMissing = TRUE; | 1220 m_bResourceMissing = TRUE; |
| 1223 return CPDF_Font::GetStockFont(m_pDocument, FX_BSTRC("Helvetica")); | 1221 return CPDF_Font::GetStockFont(m_pDocument, FX_BSTRC("Helvetica")); |
| 1224 } | 1222 } |
| 1223 |
| 1225 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); | 1224 CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict); |
| 1226 if (pFont && pFont->GetType3Font()) { | 1225 if (pFont && pFont->GetType3Font()) { |
| 1227 pFont->GetType3Font()->SetPageResources(m_pResources); | 1226 pFont->GetType3Font()->SetPageResources(m_pResources); |
| 1228 pFont->GetType3Font()->CheckType3FontMetrics(); | 1227 pFont->GetType3Font()->CheckType3FontMetrics(); |
| 1229 } | 1228 } |
| 1230 return pFont; | 1229 return pFont; |
| 1231 } | 1230 } |
| 1232 CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace( | 1231 CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace( |
| 1233 const CFX_ByteString& name) { | 1232 const CFX_ByteString& name) { |
| 1234 if (name == FX_BSTRC("Pattern")) { | 1233 if (name == FX_BSTRC("Pattern")) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1254 if (pCSObj == NULL) { | 1253 if (pCSObj == NULL) { |
| 1255 m_bResourceMissing = TRUE; | 1254 m_bResourceMissing = TRUE; |
| 1256 return NULL; | 1255 return NULL; |
| 1257 } | 1256 } |
| 1258 return m_pDocument->LoadColorSpace(pCSObj); | 1257 return m_pDocument->LoadColorSpace(pCSObj); |
| 1259 } | 1258 } |
| 1260 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name, | 1259 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name, |
| 1261 FX_BOOL bShading) { | 1260 FX_BOOL bShading) { |
| 1262 CPDF_Object* pPattern = FindResourceObj( | 1261 CPDF_Object* pPattern = FindResourceObj( |
| 1263 bShading ? FX_BSTRC("Shading") : FX_BSTRC("Pattern"), name); | 1262 bShading ? FX_BSTRC("Shading") : FX_BSTRC("Pattern"), name); |
| 1264 if (pPattern == NULL || (pPattern->GetType() != PDFOBJ_DICTIONARY && | 1263 if (pPattern == NULL || |
| 1265 pPattern->GetType() != PDFOBJ_STREAM)) { | 1264 (!pPattern->IsDictionary() && pPattern->GetType() != PDFOBJ_STREAM)) { |
| 1266 m_bResourceMissing = TRUE; | 1265 m_bResourceMissing = TRUE; |
| 1267 return NULL; | 1266 return NULL; |
| 1268 } | 1267 } |
| 1269 return m_pDocument->LoadPattern(pPattern, bShading, | 1268 return m_pDocument->LoadPattern(pPattern, bShading, |
| 1270 &m_pCurStates->m_ParentMatrix); | 1269 &m_pCurStates->m_ParentMatrix); |
| 1271 } | 1270 } |
| 1272 void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y) { | 1271 void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y) { |
| 1273 m_pCurStates->m_TextMatrix.Transform(x, y, x, y); | 1272 m_pCurStates->m_TextMatrix.Transform(x, y, x, y); |
| 1274 ConvertUserSpace(x, y); | 1273 ConvertUserSpace(x, y); |
| 1275 } | 1274 } |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 buf.AppendChar((char)code); | 1586 buf.AppendChar((char)code); |
| 1588 } | 1587 } |
| 1589 bFirst = !bFirst; | 1588 bFirst = !bFirst; |
| 1590 } | 1589 } |
| 1591 } | 1590 } |
| 1592 if (!bFirst) { | 1591 if (!bFirst) { |
| 1593 buf.AppendChar((char)code); | 1592 buf.AppendChar((char)code); |
| 1594 } | 1593 } |
| 1595 return buf.GetByteString(); | 1594 return buf.GetByteString(); |
| 1596 } | 1595 } |
| OLD | NEW |