| 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_pageobj.h" | 8 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
| 9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
| 10 #include "../../../include/fpdfapi/fpdf_render.h" | 10 #include "../../../include/fpdfapi/fpdf_render.h" |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 pData->m_DashArray[i] = FXSYS_Mul(pArray->GetNumber(i), scale); | 454 pData->m_DashArray[i] = FXSYS_Mul(pArray->GetNumber(i), scale); |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, | 457 void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, |
| 458 CPDF_StreamContentParser* pParser) { | 458 CPDF_StreamContentParser* pParser) { |
| 459 CPDF_GeneralStateData* pGeneralState = m_GeneralState.GetModify(); | 459 CPDF_GeneralStateData* pGeneralState = m_GeneralState.GetModify(); |
| 460 FX_POSITION pos = pGS->GetStartPos(); | 460 FX_POSITION pos = pGS->GetStartPos(); |
| 461 while (pos) { | 461 while (pos) { |
| 462 CFX_ByteString key_str; | 462 CFX_ByteString key_str; |
| 463 CPDF_Object* pElement = pGS->GetNextElement(pos, key_str); | 463 CPDF_Object* pElement = pGS->GetNextElement(pos, key_str); |
| 464 CPDF_Object* pObject = pElement ? pElement->GetDirect() : NULL; | 464 CPDF_Object* pObject = pElement ? pElement->GetDirect() : nullptr; |
| 465 if (pObject == NULL) { | 465 if (!pObject) |
| 466 continue; | 466 continue; |
| 467 } | 467 |
| 468 FX_DWORD key = key_str.GetID(); | 468 FX_DWORD key = key_str.GetID(); |
| 469 switch (key) { | 469 switch (key) { |
| 470 case FXBSTR_ID('L', 'W', 0, 0): | 470 case FXBSTR_ID('L', 'W', 0, 0): |
| 471 m_GraphState.GetModify()->m_LineWidth = pObject->GetNumber(); | 471 m_GraphState.GetModify()->m_LineWidth = pObject->GetNumber(); |
| 472 break; | 472 break; |
| 473 case FXBSTR_ID('L', 'C', 0, 0): | 473 case FXBSTR_ID('L', 'C', 0, 0): |
| 474 m_GraphState.GetModify()->m_LineCap = | 474 m_GraphState.GetModify()->m_LineCap = |
| 475 (CFX_GraphStateData::LineCap)pObject->GetInteger(); | 475 (CFX_GraphStateData::LineCap)pObject->GetInteger(); |
| 476 break; | 476 break; |
| 477 case FXBSTR_ID('L', 'J', 0, 0): | 477 case FXBSTR_ID('L', 'J', 0, 0): |
| 478 m_GraphState.GetModify()->m_LineJoin = | 478 m_GraphState.GetModify()->m_LineJoin = |
| 479 (CFX_GraphStateData::LineJoin)pObject->GetInteger(); | 479 (CFX_GraphStateData::LineJoin)pObject->GetInteger(); |
| 480 break; | 480 break; |
| 481 case FXBSTR_ID('M', 'L', 0, 0): | 481 case FXBSTR_ID('M', 'L', 0, 0): |
| 482 m_GraphState.GetModify()->m_MiterLimit = pObject->GetNumber(); | 482 m_GraphState.GetModify()->m_MiterLimit = pObject->GetNumber(); |
| 483 break; | 483 break; |
| 484 case FXBSTR_ID('D', 0, 0, 0): { | 484 case FXBSTR_ID('D', 0, 0, 0): { |
| 485 if (pObject->GetType() != PDFOBJ_ARRAY) { | 485 CPDF_Array* pDash = pObject->AsArray(); |
| 486 if (!pDash) |
| 486 break; | 487 break; |
| 487 } | 488 |
| 488 CPDF_Array* pDash = (CPDF_Array*)pObject; | |
| 489 CPDF_Array* pArray = pDash->GetArray(0); | 489 CPDF_Array* pArray = pDash->GetArray(0); |
| 490 if (pArray == NULL) { | 490 if (!pArray) |
| 491 break; | 491 break; |
| 492 } | 492 |
| 493 SetLineDash(pArray, pDash->GetNumber(1), 1.0f); | 493 SetLineDash(pArray, pDash->GetNumber(1), 1.0f); |
| 494 break; | 494 break; |
| 495 } | 495 } |
| 496 case FXBSTR_ID('R', 'I', 0, 0): | 496 case FXBSTR_ID('R', 'I', 0, 0): |
| 497 m_GeneralState.SetRenderIntent(pObject->GetString()); | 497 m_GeneralState.SetRenderIntent(pObject->GetString()); |
| 498 break; | 498 break; |
| 499 case FXBSTR_ID('F', 'o', 'n', 't'): { | 499 case FXBSTR_ID('F', 'o', 'n', 't'): { |
| 500 if (pObject->GetType() != PDFOBJ_ARRAY) { | 500 CPDF_Array* pFont = pObject->AsArray(); |
| 501 if (!pFont) |
| 501 break; | 502 break; |
| 502 } | 503 |
| 503 CPDF_Array* pFont = (CPDF_Array*)pObject; | |
| 504 m_TextState.GetModify()->m_FontSize = pFont->GetNumber(1); | 504 m_TextState.GetModify()->m_FontSize = pFont->GetNumber(1); |
| 505 m_TextState.SetFont(pParser->FindFont(pFont->GetString(0))); | 505 m_TextState.SetFont(pParser->FindFont(pFont->GetString(0))); |
| 506 break; | 506 break; |
| 507 } | 507 } |
| 508 case FXBSTR_ID('T', 'R', 0, 0): | 508 case FXBSTR_ID('T', 'R', 0, 0): |
| 509 if (pGS->KeyExist(FX_BSTRC("TR2"))) { | 509 if (pGS->KeyExist(FX_BSTRC("TR2"))) { |
| 510 continue; | 510 continue; |
| 511 } | 511 } |
| 512 case FXBSTR_ID('T', 'R', '2', 0): | 512 case FXBSTR_ID('T', 'R', '2', 0): |
| 513 pGeneralState->m_pTR = | 513 pGeneralState->m_pTR = |
| 514 (pObject && !pObject->IsName()) ? pObject : nullptr; | 514 (pObject && !pObject->IsName()) ? pObject : nullptr; |
| 515 break; | 515 break; |
| 516 case FXBSTR_ID('B', 'M', 0, 0): { | 516 case FXBSTR_ID('B', 'M', 0, 0): { |
| 517 CFX_ByteString mode; | 517 CPDF_Array* pArray = pObject->AsArray(); |
| 518 if (pObject->GetType() == PDFOBJ_ARRAY) { | 518 CFX_ByteString mode = |
| 519 mode = ((CPDF_Array*)pObject)->GetString(0); | 519 pArray ? pArray->GetString(0) : pObject->GetString(); |
| 520 } else { | 520 |
| 521 mode = pObject->GetString(); | |
| 522 } | |
| 523 pGeneralState->SetBlendMode(mode); | 521 pGeneralState->SetBlendMode(mode); |
| 524 if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) { | 522 if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) { |
| 525 pParser->GetObjectList()->m_bBackgroundAlphaNeeded = TRUE; | 523 pParser->GetObjectList()->m_bBackgroundAlphaNeeded = TRUE; |
| 526 } | 524 } |
| 527 break; | 525 break; |
| 528 } | 526 } |
| 529 case FXBSTR_ID('S', 'M', 'a', 's'): | 527 case FXBSTR_ID('S', 'M', 'a', 's'): |
| 530 if (ToDictionary(pObject)) { | 528 if (ToDictionary(pObject)) { |
| 531 pGeneralState->m_pSoftMask = pObject; | 529 pGeneralState->m_pSoftMask = pObject; |
| 532 FXSYS_memcpy(pGeneralState->m_SMaskMatrix, | 530 FXSYS_memcpy(pGeneralState->m_SMaskMatrix, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 pDict = NULL; | 674 pDict = NULL; |
| 677 if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict || | 675 if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict || |
| 678 item.GetParamType() == CPDF_ContentMarkItem::DirectDict) { | 676 item.GetParamType() == CPDF_ContentMarkItem::DirectDict) { |
| 679 pDict = ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); | 677 pDict = ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); |
| 680 } | 678 } |
| 681 return TRUE; | 679 return TRUE; |
| 682 } | 680 } |
| 683 } | 681 } |
| 684 return FALSE; | 682 return FALSE; |
| 685 } | 683 } |
| OLD | NEW |