Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6471)

Unified Diff: core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp

Issue 1417893003: Add type cast definitions for CPDF_Array. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
index 62a3c679961083ae80a42d70600753c4715710ca..78d3d26188ca6ebfb752bc60eb13090045046088 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -461,10 +461,10 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
while (pos) {
CFX_ByteString key_str;
CPDF_Object* pElement = pGS->GetNextElement(pos, key_str);
- CPDF_Object* pObject = pElement ? pElement->GetDirect() : NULL;
- if (pObject == NULL) {
+ CPDF_Object* pObject = pElement ? pElement->GetDirect() : nullptr;
+ if (!pObject)
continue;
- }
+
FX_DWORD key = key_str.GetID();
switch (key) {
case FXBSTR_ID('L', 'W', 0, 0):
@@ -482,14 +482,14 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
m_GraphState.GetModify()->m_MiterLimit = pObject->GetNumber();
break;
case FXBSTR_ID('D', 0, 0, 0): {
- if (pObject->GetType() != PDFOBJ_ARRAY) {
+ CPDF_Array* pDash = pObject->AsArray();
+ if (!pDash)
break;
- }
- CPDF_Array* pDash = (CPDF_Array*)pObject;
+
CPDF_Array* pArray = pDash->GetArray(0);
- if (pArray == NULL) {
+ if (!pArray)
break;
- }
+
SetLineDash(pArray, pDash->GetNumber(1), 1.0f);
break;
}
@@ -497,10 +497,10 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
m_GeneralState.SetRenderIntent(pObject->GetString());
break;
case FXBSTR_ID('F', 'o', 'n', 't'): {
- if (pObject->GetType() != PDFOBJ_ARRAY) {
+ CPDF_Array* pFont = pObject->AsArray();
+ if (!pFont)
break;
- }
- CPDF_Array* pFont = (CPDF_Array*)pObject;
+
m_TextState.GetModify()->m_FontSize = pFont->GetNumber(1);
m_TextState.SetFont(pParser->FindFont(pFont->GetString(0)));
break;
@@ -514,12 +514,10 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
(pObject && !pObject->IsName()) ? pObject : nullptr;
break;
case FXBSTR_ID('B', 'M', 0, 0): {
- CFX_ByteString mode;
- if (pObject->GetType() == PDFOBJ_ARRAY) {
- mode = ((CPDF_Array*)pObject)->GetString(0);
- } else {
- mode = pObject->GetString();
- }
+ CPDF_Array* pArray = pObject->AsArray();
+ CFX_ByteString mode =
+ pArray ? pArray->GetString(0) : pObject->GetString();
+
pGeneralState->SetBlendMode(mode);
if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) {
pParser->GetObjectList()->m_bBackgroundAlphaNeeded = TRUE;
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698