From 1c77edb7b34e03787605b7965784cea38ef9f1d7 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 21 Oct 2015 13:55:38 -0400 Subject: Add type cast definitions for CPDF_Name. This Cl adds ToName, CPDF_Object::AsName and CPDF_Object::IsName and updates the src to use them as needed. BUG=pdfium:201 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1417823005 . --- fpdfsdk/src/formfiller/FFL_Utils.cpp | 2 +- fpdfsdk/src/fpdfppo.cpp | 2 +- fpdfsdk/src/javascript/Document.cpp | 11 ++++------- 3 files changed, 6 insertions(+), 9 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/src/formfiller/FFL_Utils.cpp b/fpdfsdk/src/formfiller/FFL_Utils.cpp index e3c8306a0a..3c1edc8455 100644 --- a/fpdfsdk/src/formfiller/FFL_Utils.cpp +++ b/fpdfsdk/src/formfiller/FFL_Utils.cpp @@ -84,7 +84,7 @@ FX_BOOL CFFL_Utils::TraceObject(CPDF_Object* pObj) { // TRACE(pObj->AsString()->GetString() + "\n"); break; case PDFOBJ_NAME: - // TRACE(((CPDF_Name*)pObj)->GetString() + "\n"); + // TRACE(pObj->AsName()->GetString() + "\n"); break; case PDFOBJ_NULL: // case PDFOBJ_KEYWORD: diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp index ab25b76934..d50e98f0ac 100644 --- a/fpdfsdk/src/fpdfppo.cpp +++ b/fpdfsdk/src/fpdfppo.cpp @@ -178,7 +178,7 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( return nullptr; CPDF_Object* pType = pDict->GetElement("Type")->GetDirect(); - if (!pType || pType->GetType() != PDFOBJ_NAME) + if (!ToName(pType)) return nullptr; if (pType->GetString().Compare("Page")) return nullptr; diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index 21f68c9b42..8908dfb664 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -848,17 +848,14 @@ FX_BOOL Document::info(IJS_Context* cc, CFX_ByteString bsKey; CPDF_Object* pValueObj = pDictionary->GetNextElement(pos, bsKey); CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength()); - if (pValueObj->IsString() || (pValueObj->GetType() == PDFOBJ_NAME)) { + + if (pValueObj->IsString() || pValueObj->IsName()) { FXJS_PutObjectString(isolate, pObj, wsKey.c_str(), pValueObj->GetUnicodeText().c_str()); - } - - if (pValueObj->IsNumber()) { + } else if (pValueObj->IsNumber()) { FXJS_PutObjectNumber(isolate, pObj, wsKey.c_str(), (float)pValueObj->GetNumber()); - } - - if (pValueObj->IsBoolean()) { + } else if (pValueObj->IsBoolean()) { FXJS_PutObjectBoolean(isolate, pObj, wsKey.c_str(), (bool)pValueObj->GetInteger()); } -- cgit v1.2.3