| 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 "pageint.h" | 7 #include "core/src/fpdfapi/fpdf_page/pageint.h" |
| 8 | 8 |
| 9 #include "core/include/fpdfapi/fpdf_module.h" | 9 #include "core/include/fpdfapi/fpdf_module.h" |
| 10 #include "core/include/fpdfapi/fpdf_page.h" | 10 #include "core/include/fpdfapi/fpdf_page.h" |
| 11 #include "core/include/fpdfapi/fpdf_serial.h" | 11 #include "core/include/fpdfapi/fpdf_serial.h" |
| 12 | 12 |
| 13 #define REQUIRE_PARAMS(count) \ | 13 namespace { |
| 14 if (m_ParamCount != count) { \ | 14 |
| 15 return; \ | 15 struct _FX_BSTR { |
| 16 const FX_CHAR* m_Ptr; |
| 17 int m_Size; |
| 18 }; |
| 19 #define _FX_BSTRC(str) \ |
| 20 { str, sizeof(str) - 1 } |
| 21 |
| 22 struct PDF_AbbrPairs { |
| 23 _FX_BSTR full_name; |
| 24 _FX_BSTR abbr; |
| 25 }; |
| 26 |
| 27 const PDF_AbbrPairs PDF_InlineKeyAbbr[] = { |
| 28 {_FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC")}, |
| 29 {_FX_BSTRC("ColorSpace"), _FX_BSTRC("CS")}, |
| 30 {_FX_BSTRC("Decode"), _FX_BSTRC("D")}, |
| 31 {_FX_BSTRC("DecodeParms"), _FX_BSTRC("DP")}, |
| 32 {_FX_BSTRC("Filter"), _FX_BSTRC("F")}, |
| 33 {_FX_BSTRC("Height"), _FX_BSTRC("H")}, |
| 34 {_FX_BSTRC("ImageMask"), _FX_BSTRC("IM")}, |
| 35 {_FX_BSTRC("Interpolate"), _FX_BSTRC("I")}, |
| 36 {_FX_BSTRC("Width"), _FX_BSTRC("W")}, |
| 37 }; |
| 38 |
| 39 const PDF_AbbrPairs PDF_InlineValueAbbr[] = { |
| 40 {_FX_BSTRC("DeviceGray"), _FX_BSTRC("G")}, |
| 41 {_FX_BSTRC("DeviceRGB"), _FX_BSTRC("RGB")}, |
| 42 {_FX_BSTRC("DeviceCMYK"), _FX_BSTRC("CMYK")}, |
| 43 {_FX_BSTRC("Indexed"), _FX_BSTRC("I")}, |
| 44 {_FX_BSTRC("ASCIIHexDecode"), _FX_BSTRC("AHx")}, |
| 45 {_FX_BSTRC("ASCII85Decode"), _FX_BSTRC("A85")}, |
| 46 {_FX_BSTRC("LZWDecode"), _FX_BSTRC("LZW")}, |
| 47 {_FX_BSTRC("FlateDecode"), _FX_BSTRC("Fl")}, |
| 48 {_FX_BSTRC("RunLengthDecode"), _FX_BSTRC("RL")}, |
| 49 {_FX_BSTRC("CCITTFaxDecode"), _FX_BSTRC("CCF")}, |
| 50 {_FX_BSTRC("DCTDecode"), _FX_BSTRC("DCT")}, |
| 51 }; |
| 52 |
| 53 CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPairs* table, |
| 54 size_t count, |
| 55 const CFX_ByteStringC& abbr) { |
| 56 for (size_t i = 0; i < count; ++i) { |
| 57 if (abbr.GetLength() != table[i].abbr.m_Size) |
| 58 continue; |
| 59 if (memcmp(abbr.GetPtr(), table[i].abbr.m_Ptr, abbr.GetLength())) |
| 60 continue; |
| 61 return CFX_ByteStringC(table[i].full_name.m_Ptr, table[i].full_name.m_Size); |
| 16 } | 62 } |
| 63 return CFX_ByteStringC(); |
| 64 } |
| 65 |
| 66 CFX_ByteStringC PDF_FindAbbrName(const PDF_AbbrPairs* table, |
| 67 size_t count, |
| 68 const CFX_ByteStringC& name) { |
| 69 for (size_t i = 0; i < count; ++i) { |
| 70 if (name.GetLength() != table[i].full_name.m_Size) |
| 71 continue; |
| 72 if (memcmp(name.GetPtr(), table[i].full_name.m_Ptr, name.GetLength())) |
| 73 continue; |
| 74 return CFX_ByteStringC(table[i].abbr.m_Ptr, table[i].abbr.m_Size); |
| 75 } |
| 76 return CFX_ByteStringC(); |
| 77 } |
| 78 |
| 79 } // namespace |
| 17 | 80 |
| 18 CPDF_StreamContentParser::CPDF_StreamContentParser( | 81 CPDF_StreamContentParser::CPDF_StreamContentParser( |
| 19 CPDF_Document* pDocument, | 82 CPDF_Document* pDocument, |
| 20 CPDF_Dictionary* pPageResources, | 83 CPDF_Dictionary* pPageResources, |
| 21 CPDF_Dictionary* pParentResources, | 84 CPDF_Dictionary* pParentResources, |
| 22 CFX_Matrix* pmtContentToUser, | 85 CFX_Matrix* pmtContentToUser, |
| 23 CPDF_PageObjects* pObjList, | 86 CPDF_PageObjects* pObjList, |
| 24 CPDF_Dictionary* pResources, | 87 CPDF_Dictionary* pResources, |
| 25 CPDF_Rect* pBBox, | 88 CPDF_Rect* pBBox, |
| 26 CPDF_ParseOptions* pOptions, | 89 CPDF_ParseOptions* pOptions, |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 FX_BOOL CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) { | 417 FX_BOOL CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) { |
| 355 int i = 0; | 418 int i = 0; |
| 356 FX_DWORD opid = 0; | 419 FX_DWORD opid = 0; |
| 357 while (i < 4 && op[i]) { | 420 while (i < 4 && op[i]) { |
| 358 opid = (opid << 8) + op[i]; | 421 opid = (opid << 8) + op[i]; |
| 359 i++; | 422 i++; |
| 360 } | 423 } |
| 361 while (i < 4) { | 424 while (i < 4) { |
| 362 opid <<= 8; | 425 opid <<= 8; |
| 363 i++; | 426 i++; |
| 364 }; | 427 } |
| 365 int low = 0, high = sizeof g_OpCodes / sizeof(OpCode) - 1; | 428 int low = 0, high = sizeof g_OpCodes / sizeof(OpCode) - 1; |
| 366 while (low <= high) { | 429 while (low <= high) { |
| 367 int middle = (low + high) / 2; | 430 int middle = (low + high) / 2; |
| 368 int compare = opid - g_OpCodes[middle].m_OpId; | 431 int compare = opid - g_OpCodes[middle].m_OpId; |
| 369 if (compare == 0) { | 432 if (compare == 0) { |
| 370 (this->*g_OpCodes[middle].m_OpHandler)(); | 433 (this->*g_OpCodes[middle].m_OpHandler)(); |
| 371 return TRUE; | 434 return TRUE; |
| 372 } | 435 } |
| 373 if (compare < 0) { | 436 if (compare < 0) { |
| 374 high = middle - 1; | 437 high = middle - 1; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 m_CurContentMark.GetModify()->AddMark(tag, pDict, bDirect); | 487 m_CurContentMark.GetModify()->AddMark(tag, pDict, bDirect); |
| 425 } | 488 } |
| 426 } | 489 } |
| 427 void CPDF_StreamContentParser::Handle_BeginMarkedContent() { | 490 void CPDF_StreamContentParser::Handle_BeginMarkedContent() { |
| 428 if (!m_Options.m_bMarkedContent) { | 491 if (!m_Options.m_bMarkedContent) { |
| 429 return; | 492 return; |
| 430 } | 493 } |
| 431 CFX_ByteString tag = GetString(0); | 494 CFX_ByteString tag = GetString(0); |
| 432 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); | 495 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); |
| 433 } | 496 } |
| 434 struct _FX_BSTR { | 497 |
| 435 const FX_CHAR* m_Ptr; | 498 void PDF_ReplaceAbbr(CPDF_Object* pObj) { |
| 436 int m_Size; | |
| 437 }; | |
| 438 #define _FX_BSTRC(str) \ | |
| 439 { str, sizeof(str) - 1 } | |
| 440 const _FX_BSTR _PDF_InlineKeyAbbr[] = { | |
| 441 _FX_BSTRC("BitsPerComponent"), | |
| 442 _FX_BSTRC("BPC"), | |
| 443 _FX_BSTRC("ColorSpace"), | |
| 444 _FX_BSTRC("CS"), | |
| 445 _FX_BSTRC("Decode"), | |
| 446 _FX_BSTRC("D"), | |
| 447 _FX_BSTRC("DecodeParms"), | |
| 448 _FX_BSTRC("DP"), | |
| 449 _FX_BSTRC("Filter"), | |
| 450 _FX_BSTRC("F"), | |
| 451 _FX_BSTRC("Height"), | |
| 452 _FX_BSTRC("H"), | |
| 453 _FX_BSTRC("ImageMask"), | |
| 454 _FX_BSTRC("IM"), | |
| 455 _FX_BSTRC("Interpolate"), | |
| 456 _FX_BSTRC("I"), | |
| 457 _FX_BSTRC("Width"), | |
| 458 _FX_BSTRC("W"), | |
| 459 }; | |
| 460 const _FX_BSTR _PDF_InlineValueAbbr[] = { | |
| 461 _FX_BSTRC("DeviceGray"), _FX_BSTRC("G"), | |
| 462 _FX_BSTRC("DeviceRGB"), _FX_BSTRC("RGB"), | |
| 463 _FX_BSTRC("DeviceCMYK"), _FX_BSTRC("CMYK"), | |
| 464 _FX_BSTRC("Indexed"), _FX_BSTRC("I"), | |
| 465 _FX_BSTRC("ASCIIHexDecode"), _FX_BSTRC("AHx"), | |
| 466 _FX_BSTRC("ASCII85Decode"), _FX_BSTRC("A85"), | |
| 467 _FX_BSTRC("LZWDecode"), _FX_BSTRC("LZW"), | |
| 468 _FX_BSTRC("FlateDecode"), _FX_BSTRC("Fl"), | |
| 469 _FX_BSTRC("RunLengthDecode"), _FX_BSTRC("RL"), | |
| 470 _FX_BSTRC("CCITTFaxDecode"), _FX_BSTRC("CCF"), | |
| 471 _FX_BSTRC("DCTDecode"), _FX_BSTRC("DCT"), | |
| 472 }; | |
| 473 static CFX_ByteStringC _PDF_FindFullName(const _FX_BSTR* table, | |
| 474 int count, | |
| 475 const CFX_ByteStringC& abbr) { | |
| 476 int i = 0; | |
| 477 while (i < count) { | |
| 478 if (abbr.GetLength() == table[i + 1].m_Size && | |
| 479 FXSYS_memcmp(abbr.GetPtr(), table[i + 1].m_Ptr, abbr.GetLength()) == | |
| 480 0) { | |
| 481 return CFX_ByteStringC(table[i].m_Ptr, table[i].m_Size); | |
| 482 } | |
| 483 i += 2; | |
| 484 } | |
| 485 return CFX_ByteStringC(); | |
| 486 } | |
| 487 void _PDF_ReplaceAbbr(CPDF_Object* pObj) { | |
| 488 switch (pObj->GetType()) { | 499 switch (pObj->GetType()) { |
| 489 case PDFOBJ_DICTIONARY: { | 500 case PDFOBJ_DICTIONARY: { |
| 490 CPDF_Dictionary* pDict = pObj->AsDictionary(); | 501 CPDF_Dictionary* pDict = pObj->AsDictionary(); |
| 491 FX_POSITION pos = pDict->GetStartPos(); | 502 FX_POSITION pos = pDict->GetStartPos(); |
| 492 while (pos) { | 503 while (pos) { |
| 493 CFX_ByteString key; | 504 CFX_ByteString key; |
| 494 CPDF_Object* value = pDict->GetNextElement(pos, key); | 505 CPDF_Object* value = pDict->GetNextElement(pos, key); |
| 495 CFX_ByteStringC fullname = _PDF_FindFullName( | 506 CFX_ByteStringC fullname = PDF_FindFullName( |
| 496 _PDF_InlineKeyAbbr, sizeof _PDF_InlineKeyAbbr / sizeof(_FX_BSTR), | 507 PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key); |
| 497 key); | |
| 498 if (!fullname.IsEmpty()) { | 508 if (!fullname.IsEmpty()) { |
| 499 pDict->ReplaceKey(key, fullname); | 509 pDict->ReplaceKey(key, fullname); |
| 500 key = fullname; | 510 key = fullname; |
| 501 } | 511 } |
| 502 | 512 |
| 503 if (value->IsName()) { | 513 if (value->IsName()) { |
| 504 CFX_ByteString name = value->GetString(); | 514 CFX_ByteString name = value->GetString(); |
| 505 fullname = _PDF_FindFullName( | 515 fullname = PDF_FindFullName(PDF_InlineValueAbbr, |
| 506 _PDF_InlineValueAbbr, | 516 FX_ArraySize(PDF_InlineValueAbbr), name); |
| 507 sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name); | |
| 508 if (!fullname.IsEmpty()) { | 517 if (!fullname.IsEmpty()) { |
| 509 pDict->SetAtName(key, fullname); | 518 pDict->SetAtName(key, fullname); |
| 510 } | 519 } |
| 511 } else { | 520 } else { |
| 512 _PDF_ReplaceAbbr(value); | 521 PDF_ReplaceAbbr(value); |
| 513 } | 522 } |
| 514 } | 523 } |
| 515 break; | 524 break; |
| 516 } | 525 } |
| 517 case PDFOBJ_ARRAY: { | 526 case PDFOBJ_ARRAY: { |
| 518 CPDF_Array* pArray = pObj->AsArray(); | 527 CPDF_Array* pArray = pObj->AsArray(); |
| 519 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { | 528 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { |
| 520 CPDF_Object* pElement = pArray->GetElement(i); | 529 CPDF_Object* pElement = pArray->GetElement(i); |
| 521 if (pElement->IsName()) { | 530 if (pElement->IsName()) { |
| 522 CFX_ByteString name = pElement->GetString(); | 531 CFX_ByteString name = pElement->GetString(); |
| 523 CFX_ByteStringC fullname = _PDF_FindFullName( | 532 CFX_ByteStringC fullname = PDF_FindFullName( |
| 524 _PDF_InlineValueAbbr, | 533 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name); |
| 525 sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name); | |
| 526 if (!fullname.IsEmpty()) { | 534 if (!fullname.IsEmpty()) { |
| 527 pArray->SetAt(i, new CPDF_Name(fullname)); | 535 pArray->SetAt(i, new CPDF_Name(fullname)); |
| 528 } | 536 } |
| 529 } else { | 537 } else { |
| 530 _PDF_ReplaceAbbr(pElement); | 538 PDF_ReplaceAbbr(pElement); |
| 531 } | 539 } |
| 532 } | 540 } |
| 533 break; | 541 break; |
| 534 } | 542 } |
| 535 } | 543 } |
| 536 } | 544 } |
| 537 static CFX_ByteStringC _PDF_FindAbbrName(const _FX_BSTR* table, | 545 |
| 538 int count, | 546 void PDF_ReplaceFull(CPDF_Object* pObj) { |
| 539 const CFX_ByteStringC& fullName) { | |
| 540 int i = 0; | |
| 541 while (i < count) { | |
| 542 if (fullName.GetLength() == table[i].m_Size && | |
| 543 FXSYS_memcmp(fullName.GetPtr(), table[i].m_Ptr, fullName.GetLength()) == | |
| 544 0) { | |
| 545 return CFX_ByteStringC(table[i + 1].m_Ptr, table[i + 1].m_Size); | |
| 546 } | |
| 547 i += 2; | |
| 548 } | |
| 549 return CFX_ByteStringC(); | |
| 550 } | |
| 551 void _PDF_ReplaceFull(CPDF_Object* pObj) { | |
| 552 switch (pObj->GetType()) { | 547 switch (pObj->GetType()) { |
| 553 case PDFOBJ_DICTIONARY: { | 548 case PDFOBJ_DICTIONARY: { |
| 554 CPDF_Dictionary* pDict = pObj->AsDictionary(); | 549 CPDF_Dictionary* pDict = pObj->AsDictionary(); |
| 555 FX_POSITION pos = pDict->GetStartPos(); | 550 FX_POSITION pos = pDict->GetStartPos(); |
| 556 while (pos) { | 551 while (pos) { |
| 557 CFX_ByteString key; | 552 CFX_ByteString key; |
| 558 CPDF_Object* value = pDict->GetNextElement(pos, key); | 553 CPDF_Object* value = pDict->GetNextElement(pos, key); |
| 559 CFX_ByteStringC abbrName = _PDF_FindAbbrName( | 554 CFX_ByteStringC abbrName = PDF_FindAbbrName( |
| 560 _PDF_InlineKeyAbbr, sizeof(_PDF_InlineKeyAbbr) / sizeof(_FX_BSTR), | 555 PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key); |
| 561 key); | |
| 562 if (!abbrName.IsEmpty()) { | 556 if (!abbrName.IsEmpty()) { |
| 563 pDict->ReplaceKey(key, abbrName); | 557 pDict->ReplaceKey(key, abbrName); |
| 564 key = abbrName; | 558 key = abbrName; |
| 565 } | 559 } |
| 566 if (value->IsName()) { | 560 if (value->IsName()) { |
| 567 CFX_ByteString name = value->GetString(); | 561 CFX_ByteString name = value->GetString(); |
| 568 abbrName = _PDF_FindAbbrName( | 562 abbrName = PDF_FindAbbrName(PDF_InlineValueAbbr, |
| 569 _PDF_InlineValueAbbr, | 563 FX_ArraySize(PDF_InlineValueAbbr), name); |
| 570 sizeof(_PDF_InlineValueAbbr) / sizeof(_FX_BSTR), name); | |
| 571 if (!abbrName.IsEmpty()) { | 564 if (!abbrName.IsEmpty()) { |
| 572 pDict->SetAtName(key, abbrName); | 565 pDict->SetAtName(key, abbrName); |
| 573 } | 566 } |
| 574 } else { | 567 } else { |
| 575 _PDF_ReplaceFull(value); | 568 PDF_ReplaceFull(value); |
| 576 } | 569 } |
| 577 } | 570 } |
| 578 break; | 571 break; |
| 579 } | 572 } |
| 580 case PDFOBJ_ARRAY: { | 573 case PDFOBJ_ARRAY: { |
| 581 CPDF_Array* pArray = pObj->AsArray(); | 574 CPDF_Array* pArray = pObj->AsArray(); |
| 582 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { | 575 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { |
| 583 CPDF_Object* pElement = pArray->GetElement(i); | 576 CPDF_Object* pElement = pArray->GetElement(i); |
| 584 if (pElement->IsName()) { | 577 if (pElement->IsName()) { |
| 585 CFX_ByteString name = pElement->GetString(); | 578 CFX_ByteString name = pElement->GetString(); |
| 586 CFX_ByteStringC abbrName = _PDF_FindAbbrName( | 579 CFX_ByteStringC abbrName = PDF_FindAbbrName( |
| 587 _PDF_InlineValueAbbr, | 580 PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name); |
| 588 sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name); | |
| 589 if (!abbrName.IsEmpty()) { | 581 if (!abbrName.IsEmpty()) { |
| 590 pArray->SetAt(i, new CPDF_Name(abbrName)); | 582 pArray->SetAt(i, new CPDF_Name(abbrName)); |
| 591 } | 583 } |
| 592 } else { | 584 } else { |
| 593 _PDF_ReplaceFull(pElement); | 585 PDF_ReplaceFull(pElement); |
| 594 } | 586 } |
| 595 } | 587 } |
| 596 break; | 588 break; |
| 597 } | 589 } |
| 598 } | 590 } |
| 599 } | 591 } |
| 600 void CPDF_StreamContentParser::Handle_BeginText() { | 592 void CPDF_StreamContentParser::Handle_BeginText() { |
| 601 m_pCurStates->m_TextMatrix.Set(1.0f, 0, 0, 1.0f, 0, 0); | 593 m_pCurStates->m_TextMatrix.Set(1.0f, 0, 0, 1.0f, 0, 0); |
| 602 OnChangeTextMatrix(); | 594 OnChangeTextMatrix(); |
| 603 m_pCurStates->m_TextX = 0; | 595 m_pCurStates->m_TextX = 0; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 void CPDF_StreamContentParser::Handle_BeginImageData() {} | 878 void CPDF_StreamContentParser::Handle_BeginImageData() {} |
| 887 void CPDF_StreamContentParser::Handle_SetLineJoin() { | 879 void CPDF_StreamContentParser::Handle_SetLineJoin() { |
| 888 m_pCurStates->m_GraphState.GetModify()->m_LineJoin = | 880 m_pCurStates->m_GraphState.GetModify()->m_LineJoin = |
| 889 (CFX_GraphStateData::LineJoin)GetInteger(0); | 881 (CFX_GraphStateData::LineJoin)GetInteger(0); |
| 890 } | 882 } |
| 891 void CPDF_StreamContentParser::Handle_SetLineCap() { | 883 void CPDF_StreamContentParser::Handle_SetLineCap() { |
| 892 m_pCurStates->m_GraphState.GetModify()->m_LineCap = | 884 m_pCurStates->m_GraphState.GetModify()->m_LineCap = |
| 893 (CFX_GraphStateData::LineCap)GetInteger(0); | 885 (CFX_GraphStateData::LineCap)GetInteger(0); |
| 894 } | 886 } |
| 895 void CPDF_StreamContentParser::Handle_SetCMYKColor_Fill() { | 887 void CPDF_StreamContentParser::Handle_SetCMYKColor_Fill() { |
| 896 REQUIRE_PARAMS(4); | 888 if (m_ParamCount != 4) |
| 889 return; |
| 890 |
| 897 FX_FLOAT values[4]; | 891 FX_FLOAT values[4]; |
| 898 for (int i = 0; i < 4; i++) { | 892 for (int i = 0; i < 4; i++) { |
| 899 values[i] = GetNumber(3 - i); | 893 values[i] = GetNumber(3 - i); |
| 900 } | 894 } |
| 901 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); | 895 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); |
| 902 m_pCurStates->m_ColorState.SetFillColor(pCS, values, 4); | 896 m_pCurStates->m_ColorState.SetFillColor(pCS, values, 4); |
| 903 } | 897 } |
| 904 void CPDF_StreamContentParser::Handle_SetCMYKColor_Stroke() { | 898 void CPDF_StreamContentParser::Handle_SetCMYKColor_Stroke() { |
| 905 REQUIRE_PARAMS(4); | 899 if (m_ParamCount != 4) |
| 900 return; |
| 901 |
| 906 FX_FLOAT values[4]; | 902 FX_FLOAT values[4]; |
| 907 for (int i = 0; i < 4; i++) { | 903 for (int i = 0; i < 4; i++) { |
| 908 values[i] = GetNumber(3 - i); | 904 values[i] = GetNumber(3 - i); |
| 909 } | 905 } |
| 910 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); | 906 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); |
| 911 m_pCurStates->m_ColorState.SetStrokeColor(pCS, values, 4); | 907 m_pCurStates->m_ColorState.SetStrokeColor(pCS, values, 4); |
| 912 } | 908 } |
| 913 void CPDF_StreamContentParser::Handle_LineTo() { | 909 void CPDF_StreamContentParser::Handle_LineTo() { |
| 914 REQUIRE_PARAMS(2); | 910 if (m_ParamCount != 2) |
| 911 return; |
| 912 |
| 915 if (m_Options.m_bTextOnly) { | 913 if (m_Options.m_bTextOnly) { |
| 916 return; | 914 return; |
| 917 } | 915 } |
| 918 AddPathPoint(GetNumber(1), GetNumber(0), FXPT_LINETO); | 916 AddPathPoint(GetNumber(1), GetNumber(0), FXPT_LINETO); |
| 919 } | 917 } |
| 920 void CPDF_StreamContentParser::Handle_MoveTo() { | 918 void CPDF_StreamContentParser::Handle_MoveTo() { |
| 921 REQUIRE_PARAMS(2); | 919 if (m_ParamCount != 2) |
| 920 return; |
| 921 |
| 922 if (m_Options.m_bTextOnly) { | 922 if (m_Options.m_bTextOnly) { |
| 923 m_pSyntax->SkipPathObject(); | 923 m_pSyntax->SkipPathObject(); |
| 924 return; | 924 return; |
| 925 } | 925 } |
| 926 AddPathPoint(GetNumber(1), GetNumber(0), FXPT_MOVETO); | 926 AddPathPoint(GetNumber(1), GetNumber(0), FXPT_MOVETO); |
| 927 ParsePathObject(); | 927 ParsePathObject(); |
| 928 } | 928 } |
| 929 void CPDF_StreamContentParser::Handle_SetMiterLimit() { | 929 void CPDF_StreamContentParser::Handle_SetMiterLimit() { |
| 930 m_pCurStates->m_GraphState.GetModify()->m_MiterLimit = GetNumber(0); | 930 m_pCurStates->m_GraphState.GetModify()->m_MiterLimit = GetNumber(0); |
| 931 } | 931 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 FX_FLOAT y, | 963 FX_FLOAT y, |
| 964 FX_FLOAT w, | 964 FX_FLOAT w, |
| 965 FX_FLOAT h) { | 965 FX_FLOAT h) { |
| 966 AddPathPoint(x, y, FXPT_MOVETO); | 966 AddPathPoint(x, y, FXPT_MOVETO); |
| 967 AddPathPoint(x + w, y, FXPT_LINETO); | 967 AddPathPoint(x + w, y, FXPT_LINETO); |
| 968 AddPathPoint(x + w, y + h, FXPT_LINETO); | 968 AddPathPoint(x + w, y + h, FXPT_LINETO); |
| 969 AddPathPoint(x, y + h, FXPT_LINETO); | 969 AddPathPoint(x, y + h, FXPT_LINETO); |
| 970 AddPathPoint(x, y, FXPT_LINETO | FXPT_CLOSEFIGURE); | 970 AddPathPoint(x, y, FXPT_LINETO | FXPT_CLOSEFIGURE); |
| 971 } | 971 } |
| 972 void CPDF_StreamContentParser::Handle_SetRGBColor_Fill() { | 972 void CPDF_StreamContentParser::Handle_SetRGBColor_Fill() { |
| 973 REQUIRE_PARAMS(3); | 973 if (m_ParamCount != 3) |
| 974 return; |
| 975 |
| 974 FX_FLOAT values[3]; | 976 FX_FLOAT values[3]; |
| 975 for (int i = 0; i < 3; i++) { | 977 for (int i = 0; i < 3; i++) { |
| 976 values[i] = GetNumber(2 - i); | 978 values[i] = GetNumber(2 - i); |
| 977 } | 979 } |
| 978 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); | 980 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); |
| 979 m_pCurStates->m_ColorState.SetFillColor(pCS, values, 3); | 981 m_pCurStates->m_ColorState.SetFillColor(pCS, values, 3); |
| 980 } | 982 } |
| 981 void CPDF_StreamContentParser::Handle_SetRGBColor_Stroke() { | 983 void CPDF_StreamContentParser::Handle_SetRGBColor_Stroke() { |
| 982 REQUIRE_PARAMS(3); | 984 if (m_ParamCount != 3) |
| 985 return; |
| 986 |
| 983 FX_FLOAT values[3]; | 987 FX_FLOAT values[3]; |
| 984 for (int i = 0; i < 3; i++) { | 988 for (int i = 0; i < 3; i++) { |
| 985 values[i] = GetNumber(2 - i); | 989 values[i] = GetNumber(2 - i); |
| 986 } | 990 } |
| 987 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); | 991 CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); |
| 988 m_pCurStates->m_ColorState.SetStrokeColor(pCS, values, 3); | 992 m_pCurStates->m_ColorState.SetStrokeColor(pCS, values, 3); |
| 989 } | 993 } |
| 990 void CPDF_StreamContentParser::Handle_SetRenderIntent() {} | 994 void CPDF_StreamContentParser::Handle_SetRenderIntent() {} |
| 991 void CPDF_StreamContentParser::Handle_CloseStrokePath() { | 995 void CPDF_StreamContentParser::Handle_CloseStrokePath() { |
| 992 if (m_Options.m_bTextOnly) { | 996 if (m_Options.m_bTextOnly) { |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 for (int i = 0; i < n; i++) { | 1338 for (int i = 0; i < n; i++) { |
| 1335 if (pArray->GetElementValue(i)->IsString()) | 1339 if (pArray->GetElementValue(i)->IsString()) |
| 1336 nsegs++; | 1340 nsegs++; |
| 1337 } | 1341 } |
| 1338 if (nsegs == 0) { | 1342 if (nsegs == 0) { |
| 1339 for (int i = 0; i < n; i++) { | 1343 for (int i = 0; i < n; i++) { |
| 1340 m_pCurStates->m_TextX -= | 1344 m_pCurStates->m_TextX -= |
| 1341 FXSYS_Mul(pArray->GetNumber(i), | 1345 FXSYS_Mul(pArray->GetNumber(i), |
| 1342 m_pCurStates->m_TextState.GetFontSize()) / | 1346 m_pCurStates->m_TextState.GetFontSize()) / |
| 1343 1000; | 1347 1000; |
| 1344 }; | 1348 } |
| 1345 return; | 1349 return; |
| 1346 } | 1350 } |
| 1347 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; | 1351 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; |
| 1348 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); | 1352 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); |
| 1349 int iSegment = 0; | 1353 int iSegment = 0; |
| 1350 FX_FLOAT fInitKerning = 0; | 1354 FX_FLOAT fInitKerning = 0; |
| 1351 for (int i = 0; i < n; i++) { | 1355 for (int i = 0; i < n; i++) { |
| 1352 CPDF_Object* pObj = pArray->GetElementValue(i); | 1356 CPDF_Object* pObj = pArray->GetElementValue(i); |
| 1353 if (pObj->IsString()) { | 1357 if (pObj->IsString()) { |
| 1354 CFX_ByteString str = pObj->GetString(); | 1358 CFX_ByteString str = pObj->GetString(); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 m_pObjectList->m_ObjectList.AddTail(pPathObj); | 1524 m_pObjectList->m_ObjectList.AddTail(pPathObj); |
| 1521 } | 1525 } |
| 1522 if (PathClipType) { | 1526 if (PathClipType) { |
| 1523 if (!matrix.IsIdentity()) { | 1527 if (!matrix.IsIdentity()) { |
| 1524 Path.Transform(&matrix); | 1528 Path.Transform(&matrix); |
| 1525 matrix.SetIdentity(); | 1529 matrix.SetIdentity(); |
| 1526 } | 1530 } |
| 1527 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); | 1531 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); |
| 1528 } | 1532 } |
| 1529 } | 1533 } |
| OLD | NEW |