diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-21 13:55:38 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-21 13:55:38 -0400 |
commit | 1c77edb7b34e03787605b7965784cea38ef9f1d7 (patch) | |
tree | 621c8d67cb3d5fd72bceed59e2e5a39c6e037fbe /core | |
parent | 53d3ab125ef583be8cfac907b308a6551b93067a (diff) | |
download | pdfium-1c77edb7b34e03787605b7965784cea38ef9f1d7.tar.xz |
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 .
Diffstat (limited to 'core')
19 files changed, 105 insertions, 99 deletions
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h index c3e5df4118..2404774dcb 100644 --- a/core/include/fpdfapi/fpdf_objects.h +++ b/core/include/fpdfapi/fpdf_objects.h @@ -16,6 +16,7 @@ class CPDF_CryptoHandler; class CPDF_Dictionary; class CPDF_Document; class CPDF_IndirectObjects; +class CPDF_Name; class CPDF_Null; class CPDF_Number; class CPDF_Parser; @@ -80,6 +81,7 @@ class CPDF_Object { bool IsBoolean() const { return m_Type == PDFOBJ_BOOLEAN; } bool IsDictionary() const { return m_Type == PDFOBJ_DICTIONARY; } + bool IsName() const { return m_Type == PDFOBJ_NAME; } bool IsNumber() const { return m_Type == PDFOBJ_NUMBER; } bool IsString() const { return m_Type == PDFOBJ_STRING; } @@ -89,6 +91,9 @@ class CPDF_Object { CPDF_Dictionary* AsDictionary(); const CPDF_Dictionary* AsDictionary() const; + CPDF_Name* AsName(); + const CPDF_Name* AsName() const; + CPDF_Number* AsNumber(); const CPDF_Number* AsNumber() const; @@ -259,6 +264,13 @@ class CPDF_Name : public CPDF_Object { CFX_ByteString m_Name; friend class CPDF_Object; }; +inline CPDF_Name* ToName(CPDF_Object* obj) { + return obj ? obj->AsName() : nullptr; +} +inline const CPDF_Name* ToName(const CPDF_Object* obj) { + return obj ? obj->AsName() : nullptr; +} + class CPDF_Array : public CPDF_Object { public: static CPDF_Array* Create() { return new CPDF_Array(); } diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp index 10ca3113e3..9954efcc5d 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp @@ -728,7 +728,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, } return; } - if (pEncoding->GetType() == PDFOBJ_NAME) { + if (pEncoding->IsName()) { if (iBaseEncoding == PDFFONT_ENCODING_ADOBE_SYMBOL || iBaseEncoding == PDFFONT_ENCODING_ZAPFDINGBATS) { return; @@ -770,13 +770,12 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, FX_DWORD cur_code = 0; for (FX_DWORD i = 0; i < pDiffs->GetCount(); i++) { CPDF_Object* pElement = pDiffs->GetElementValue(i); - if (pElement == NULL) { + if (!pElement) continue; - } - if (pElement->GetType() == PDFOBJ_NAME) { - if (cur_code < 256) { - pCharNames[cur_code] = ((CPDF_Name*)pElement)->GetString(); - } + + if (CPDF_Name* pName = pElement->AsName()) { + if (cur_code < 256) + pCharNames[cur_code] = pName->GetString(); cur_code++; } else { cur_code = pElement->GetInteger(); diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp index 0f7d128786..6ccc4a345b 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -1206,11 +1206,9 @@ FX_BOOL CPDF_CIDFont::_Load() { return FALSE; } CFX_ByteString subtype = pCIDFontDict->GetString(FX_BSTRC("Subtype")); - m_bType1 = FALSE; - if (subtype == FX_BSTRC("CIDFontType0")) { - m_bType1 = TRUE; - } - if (pEncoding->GetType() == PDFOBJ_NAME) { + m_bType1 = (subtype == FX_BSTRC("CIDFontType0")); + + if (pEncoding->IsName()) { CFX_ByteString cmap = pEncoding->GetString(); m_pCMap = CPDF_ModuleMgr::Get() diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp index 584f9c24d3..73b1091856 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -1057,9 +1057,9 @@ FX_BOOL CPDF_SeparationCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return FALSE; } CPDF_Object* pFuncObj = pArray->GetElementValue(3); - if (pFuncObj && pFuncObj->GetType() != PDFOBJ_NAME) { + if (pFuncObj && !pFuncObj->IsName()) m_pFunc = CPDF_Function::Load(pFuncObj); - } + if (m_pFunc && m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) { delete m_pFunc; m_pFunc = NULL; @@ -1202,30 +1202,27 @@ CPDF_ColorSpace* _CSFromName(const CFX_ByteString& name) { return NULL; } CPDF_ColorSpace* CPDF_ColorSpace::Load(CPDF_Document* pDoc, CPDF_Object* pObj) { - if (pObj == NULL) { - return NULL; - } - if (pObj->GetType() == PDFOBJ_NAME) { + if (!pObj) + return nullptr; + if (pObj->IsName()) return _CSFromName(pObj->GetString()); - } + if (pObj->GetType() == PDFOBJ_STREAM) { CPDF_Dictionary* pDict = ((CPDF_Stream*)pObj)->GetDict(); - if (!pDict) { - return NULL; - } - CPDF_ColorSpace* pRet = NULL; + if (!pDict) + return nullptr; + + CPDF_ColorSpace* pRet = nullptr; FX_POSITION pos = pDict->GetStartPos(); while (pos) { CFX_ByteString bsKey; CPDF_Object* pValue = pDict->GetNextElement(pos, bsKey); - if (pValue && pValue->GetType() == PDFOBJ_NAME) { + if (ToName(pValue)) pRet = _CSFromName(pValue->GetString()); - } - if (pRet) { + if (pRet) return pRet; - } } - return NULL; + return nullptr; } if (pObj->GetType() != PDFOBJ_ARRAY) { return NULL; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp index 210d5433be..9a1d48a416 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -308,27 +308,27 @@ void CPDF_DocPageData::ReleaseFont(CPDF_Dictionary* pFontDict) { CPDF_ColorSpace* CPDF_DocPageData::GetColorSpace(CPDF_Object* pCSObj, CPDF_Dictionary* pResources) { - if (!pCSObj) { - return NULL; - } - if (pCSObj->GetType() == PDFOBJ_NAME) { + if (!pCSObj) + return nullptr; + + if (pCSObj->IsName()) { CFX_ByteString name = pCSObj->GetConstString(); CPDF_ColorSpace* pCS = _CSFromName(name); if (!pCS && pResources) { CPDF_Dictionary* pList = pResources->GetDict(FX_BSTRC("ColorSpace")); if (pList) { pCSObj = pList->GetElementValue(name); - return GetColorSpace(pCSObj, NULL); + return GetColorSpace(pCSObj, nullptr); } } - if (pCS == NULL || pResources == NULL) { + if (!pCS || !pResources) return pCS; - } + CPDF_Dictionary* pColorSpaces = pResources->GetDict(FX_BSTRC("ColorSpace")); - if (pColorSpaces == NULL) { + if (!pColorSpaces) return pCS; - } - CPDF_Object* pDefaultCS = NULL; + + CPDF_Object* pDefaultCS = nullptr; switch (pCS->GetFamily()) { case PDFCS_DEVICERGB: pDefaultCS = pColorSpaces->GetElementValue(FX_BSTRC("DefaultRGB")); @@ -340,10 +340,7 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpace(CPDF_Object* pCSObj, pDefaultCS = pColorSpaces->GetElementValue(FX_BSTRC("DefaultCMYK")); break; } - if (pDefaultCS == NULL) { - return pCS; - } - return GetColorSpace(pDefaultCS, NULL); + return pDefaultCS ? GetColorSpace(pDefaultCS, nullptr) : pCS; } if (pCSObj->GetType() != PDFOBJ_ARRAY) 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 6d071f3ae0..62a3c67996 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp @@ -510,11 +510,8 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, continue; } case FXBSTR_ID('T', 'R', '2', 0): - if (pObject && pObject->GetType() != PDFOBJ_NAME) { - pGeneralState->m_pTR = pObject; - } else { - pGeneralState->m_pTR = NULL; - } + pGeneralState->m_pTR = + (pObject && !pObject->IsName()) ? pObject : nullptr; break; case FXBSTR_ID('B', 'M', 0, 0): { CFX_ByteString mode; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp index fbb364ee12..6f186e6c3b 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -413,11 +413,10 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() { return; } FX_BOOL bDirect = TRUE; - if (pProperty->GetType() == PDFOBJ_NAME) { + if (pProperty->IsName()) { pProperty = FindResourceObj(FX_BSTRC("Properties"), pProperty->GetString()); - if (pProperty == NULL) { + if (!pProperty) return; - } bDirect = FALSE; } if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { @@ -499,7 +498,8 @@ void _PDF_ReplaceAbbr(CPDF_Object* pObj) { pDict->ReplaceKey(key, fullname); key = fullname; } - if (value->GetType() == PDFOBJ_NAME) { + + if (value->IsName()) { CFX_ByteString name = value->GetString(); fullname = _PDF_FindFullName( _PDF_InlineValueAbbr, @@ -517,7 +517,7 @@ void _PDF_ReplaceAbbr(CPDF_Object* pObj) { CPDF_Array* pArray = (CPDF_Array*)pObj; for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { CPDF_Object* pElement = pArray->GetElement(i); - if (pElement->GetType() == PDFOBJ_NAME) { + if (pElement->IsName()) { CFX_ByteString name = pElement->GetString(); CFX_ByteStringC fullname = _PDF_FindFullName( _PDF_InlineValueAbbr, @@ -562,7 +562,7 @@ void _PDF_ReplaceFull(CPDF_Object* pObj) { pDict->ReplaceKey(key, abbrName); key = abbrName; } - if (value->GetType() == PDFOBJ_NAME) { + if (value->IsName()) { CFX_ByteString name = value->GetString(); abbrName = _PDF_FindAbbrName( _PDF_InlineValueAbbr, @@ -580,7 +580,7 @@ void _PDF_ReplaceFull(CPDF_Object* pObj) { CPDF_Array* pArray = (CPDF_Array*)pObj; for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { CPDF_Object* pElement = pArray->GetElement(i); - if (pElement->GetType() == PDFOBJ_NAME) { + if (pElement->IsName()) { CFX_ByteString name = pElement->GetString(); CFX_ByteStringC abbrName = _PDF_FindAbbrName( _PDF_InlineValueAbbr, @@ -1065,7 +1065,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() { } int nargs = m_ParamCount; int nvalues = nargs; - if (pLastParam->GetType() == PDFOBJ_NAME) { + if (pLastParam->IsName()) { nvalues--; } FX_FLOAT* values = NULL; @@ -1095,9 +1095,9 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() { } int nargs = m_ParamCount; int nvalues = nargs; - if (pLastParam->GetType() == PDFOBJ_NAME) { + if (pLastParam->IsName()) nvalues--; - } + FX_FLOAT* values = NULL; if (nvalues) { values = FX_Alloc(FX_FLOAT, nvalues); @@ -1357,13 +1357,14 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() { if (pArray == NULL) { return; } - int n = pArray->GetCount(), nsegs = 0, i; - for (i = 0; i < n; i++) { + int n = pArray->GetCount(); + int nsegs = 0; + for (int i = 0; i < n; i++) { if (pArray->GetElementValue(i)->IsString()) nsegs++; } if (nsegs == 0) { - for (i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { m_pCurStates->m_TextX -= FXSYS_Mul(pArray->GetNumber(i), m_pCurStates->m_TextState.GetFontSize()) / @@ -1375,7 +1376,7 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() { FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); int iSegment = 0; FX_FLOAT fInitKerning = 0; - for (i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { CPDF_Object* pObj = pArray->GetElementValue(i); if (pObj->IsString()) { CFX_ByteString str = pObj->GetString(); diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index b1e89e8cc4..f051d0db5a 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -88,7 +88,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { CPDF_Object* pCSObj = NULL; if (pDict->KeyExist(FX_BSTRC("ColorSpace"))) { pCSObj = pDict->GetElementValue(FX_BSTRC("ColorSpace")); - if (pCSObj->GetType() == PDFOBJ_NAME) { + if (pCSObj->IsName()) { CFX_ByteString name = pCSObj->GetString(); if (name != FX_BSTRC("DeviceRGB") && name != FX_BSTRC("DeviceGray") && name != FX_BSTRC("DeviceCMYK")) { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 55c62e2878..cbbfbd7197 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -332,10 +332,9 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, { CPDF_Object* pDecoder = pDict ? pDict->GetElementValue(FX_BSTRC("Filter")) : NULL; - if (pDecoder == NULL || (pDecoder->GetType() != PDFOBJ_ARRAY && - pDecoder->GetType() != PDFOBJ_NAME)) { + if (!pDecoder || (pDecoder->GetType() != PDFOBJ_ARRAY && !pDecoder->IsName())) return FALSE; - } + CPDF_Object* pParams = pDict ? pDict->GetElementValue(FX_BSTRC("DecodeParms")) : NULL; CFX_ByteStringArray DecoderList; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index b2dc924322..e3d9cd7291 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -22,7 +22,7 @@ void CPDF_Object::Destroy() { delete AsString(); break; case PDFOBJ_NAME: - delete (CPDF_Name*)this; + delete AsName(); break; case PDFOBJ_ARRAY: delete (CPDF_Array*)this; @@ -46,7 +46,7 @@ CFX_ByteString CPDF_Object::GetString() const { case PDFOBJ_STRING: return AsString()->m_String; case PDFOBJ_NAME: - return ((CPDF_Name*)this)->m_Name; + return AsName()->m_Name; case PDFOBJ_REFERENCE: { CPDF_Reference* pRef = (CPDF_Reference*)(void*)this; if (pRef->m_pObjList == NULL) { @@ -68,9 +68,10 @@ CFX_ByteStringC CPDF_Object::GetConstString() const { CFX_ByteString str = AsString()->m_String; return CFX_ByteStringC((const uint8_t*)str, str.GetLength()); } - case PDFOBJ_NAME: - return CFX_ByteStringC((const uint8_t*)((CPDF_Name*)this)->m_Name, - ((CPDF_Name*)this)->m_Name.GetLength()); + case PDFOBJ_NAME: { + CFX_ByteString name = AsName()->m_Name; + return CFX_ByteStringC((const uint8_t*)name, name.GetLength()); + } case PDFOBJ_REFERENCE: { CPDF_Reference* pRef = (CPDF_Reference*)(void*)this; if (pRef->m_pObjList == NULL) { @@ -178,7 +179,7 @@ void CPDF_Object::SetString(const CFX_ByteString& str) { AsString()->m_String = str; return; case PDFOBJ_NAME: - ((CPDF_Name*)this)->m_Name = str; + AsName()->m_Name = str; return; } ASSERT(FALSE); @@ -214,7 +215,7 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const { case PDFOBJ_STRING: return AsString()->Identical(pOther->AsString()); case PDFOBJ_NAME: - return (((CPDF_Name*)this)->Identical((CPDF_Name*)pOther)); + return AsName()->Identical(pOther->AsName()); case PDFOBJ_ARRAY: return (((CPDF_Array*)this)->Identical((CPDF_Array*)pOther)); case PDFOBJ_DICTIONARY: @@ -257,7 +258,7 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, return new CPDF_String(pString->m_String, pString->IsHex()); } case PDFOBJ_NAME: - return new CPDF_Name(((CPDF_Name*)this)->m_Name); + return new CPDF_Name(AsName()->m_Name); case PDFOBJ_ARRAY: { CPDF_Array* pCopy = new CPDF_Array(); CPDF_Array* pThis = (CPDF_Array*)this; @@ -326,9 +327,8 @@ CFX_WideString CPDF_Object::GetUnicodeText(CFX_CharMap* pCharMap) const { PDF_DecodeText(stream.GetData(), stream.GetSize(), pCharMap); return result; } - if (m_Type == PDFOBJ_NAME) { - return PDF_DecodeText(((CPDF_Name*)this)->m_Name, pCharMap); - } + if (const CPDF_Name* pName = AsName()) + return PDF_DecodeText(pName->m_Name, pCharMap); return CFX_WideString(); } void CPDF_Object::SetUnicodeText(const FX_WCHAR* pUnicodes, int len) { @@ -357,6 +357,14 @@ const CPDF_Dictionary* CPDF_Object::AsDictionary() const { return IsDictionary() ? static_cast<const CPDF_Dictionary*>(this) : nullptr; } +CPDF_Name* CPDF_Object::AsName() { + return IsName() ? static_cast<CPDF_Name*>(this) : nullptr; +} + +const CPDF_Name* CPDF_Object::AsName() const { + return IsName() ? static_cast<const CPDF_Name*>(this) : nullptr; +} + CPDF_Number* CPDF_Object::AsNumber() { return IsNumber() ? static_cast<CPDF_Number*>(this) : nullptr; } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index d9a745393a..514380eeab 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -3807,8 +3807,9 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, return 0; } CPDF_Dictionary* pDict = pObj->GetDict(); - CPDF_Object* pName = pDict ? pDict->GetElement(FX_BSTRC("Type")) : NULL; - if (pName && pName->GetType() == PDFOBJ_NAME) { + CPDF_Name* pName = + ToName(pDict ? pDict->GetElement(FX_BSTRC("Type")) : nullptr); + if (pName) { if (pName->GetString() == FX_BSTRC("XRef")) { m_Pos += m_parser.m_Syntax.SavePos(); xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev")); diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 84d1301c60..2c161a7dd4 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -372,12 +372,9 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) { case PDFOBJ_NUMBER: buf << " " << pObj->GetString(); break; - case PDFOBJ_STRING: { - CFX_ByteString str = pObj->GetString(); - FX_BOOL bHex = pObj->AsString()->IsHex(); - buf << PDF_EncodeString(str, bHex); + case PDFOBJ_STRING: + buf << PDF_EncodeString(pObj->GetString(), pObj->AsString()->IsHex()); break; - } case PDFOBJ_NAME: { CFX_ByteString str = pObj->GetString(); buf << FX_BSTRC("/") << PDF_NameEncode(str); diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp index e4afdd80c2..cdf2104f82 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -406,7 +406,7 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue( FX_BSTRC("Filter")); if (pFilters) { - if (pFilters->GetType() == PDFOBJ_NAME) { + if (pFilters->IsName()) { CFX_ByteStringC bsDecodeType = pFilters->GetConstString(); if (bsDecodeType == FX_BSTRC("DCTDecode") || bsDecodeType == FX_BSTRC("JPXDecode")) { diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index c3029e0091..79b4bba162 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -476,7 +476,7 @@ FX_BOOL CPDF_DIBSource::LoadColorInfo(CPDF_Dictionary* pFormResources, CPDF_Object* pFilter = m_pDict->GetElementValue(FX_BSTRC("Filter")); if (pFilter) { CFX_ByteString filter; - if (pFilter->GetType() == PDFOBJ_NAME) { + if (pFilter->IsName()) { filter = pFilter->GetString(); if (filter == FX_BSTRC("JPXDecode")) { m_bDoBpcCheck = FALSE; @@ -514,7 +514,7 @@ FX_BOOL CPDF_DIBSource::LoadColorInfo(CPDF_Dictionary* pFormResources, } m_Family = m_pColorSpace->GetFamily(); m_nComponents = m_pColorSpace->CountComponents(); - if (m_Family == PDFCS_ICCBASED && pCSObj->GetType() == PDFOBJ_NAME) { + if (m_Family == PDFCS_ICCBASED && pCSObj->IsName()) { CFX_ByteString cs = pCSObj->GetString(); if (cs == FX_BSTRC("DeviceGray")) { m_nComponents = 1; @@ -939,7 +939,7 @@ void CPDF_DIBSource::ValidateDictParam() { m_bpc = m_bpc_orig; CPDF_Object* pFilter = m_pDict->GetElementValue(FX_BSTRC("Filter")); if (pFilter) { - if (pFilter->GetType() == PDFOBJ_NAME) { + if (pFilter->IsName()) { CFX_ByteString filter = pFilter->GetString(); if (filter == FX_BSTRC("CCITTFaxDecode") || filter == FX_BSTRC("JBIG2Decode")) { diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp index c55c20cb1d..bcbfe0f112 100644 --- a/core/src/fpdfdoc/doc_action.cpp +++ b/core/src/fpdfdoc/doc_action.cpp @@ -17,7 +17,7 @@ CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const { if (!pDest) { return CPDF_Dest(); } - if (pDest->IsString() || pDest->GetType() == PDFOBJ_NAME) { + if (pDest->IsString() || pDest->IsName()) { CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); CFX_ByteStringC name = pDest->GetString(); return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name)); diff --git a/core/src/fpdfdoc/doc_bookmark.cpp b/core/src/fpdfdoc/doc_bookmark.cpp index 9d2a9f61ea..6b020e5957 100644 --- a/core/src/fpdfdoc/doc_bookmark.cpp +++ b/core/src/fpdfdoc/doc_bookmark.cpp @@ -72,10 +72,10 @@ CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const { return CPDF_Dest(); } CPDF_Object* pDest = m_pDict->GetElementValue("Dest"); - if (!pDest) { + if (!pDest) return CPDF_Dest(); - } - if (pDest->IsString() || pDest->GetType() == PDFOBJ_NAME) { + + if (pDest->IsString() || pDest->IsName()) { CPDF_NameTree name_tree(pDocument, FX_BSTRC("Dests")); CFX_ByteStringC name = pDest->GetString(); return CPDF_Dest(name_tree.LookupNamedDest(pDocument, name)); diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index 25f5490a72..f9b8438a0e 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -529,7 +529,7 @@ FX_BOOL CPDF_FormField::IsItemSelected(int index) { } if (pValue->IsString()) - return (pValue->GetUnicodeText() == opt_value); + return pValue->GetUnicodeText() == opt_value; if (pValue->IsNumber()) { if (pValue->GetString().IsEmpty()) diff --git a/core/src/fpdfdoc/doc_link.cpp b/core/src/fpdfdoc/doc_link.cpp index 95411013b4..977efeafd1 100644 --- a/core/src/fpdfdoc/doc_link.cpp +++ b/core/src/fpdfdoc/doc_link.cpp @@ -73,10 +73,10 @@ CPDF_Rect CPDF_Link::GetRect() { } CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) { CPDF_Object* pDest = m_pDict->GetElementValue("Dest"); - if (pDest == NULL) { + if (!pDest) return CPDF_Dest(); - } - if (pDest->IsString() || pDest->GetType() == PDFOBJ_NAME) { + + if (pDest->IsString() || pDest->IsName()) { CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); CFX_ByteStringC name = pDest->GetString(); return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name)); diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp index d9d439f730..ac29d90118 100644 --- a/core/src/fpdfdoc/doc_tagged.cpp +++ b/core/src/fpdfdoc/doc_tagged.cpp @@ -417,11 +417,11 @@ CFX_ByteString CPDF_StructElementImpl::GetName( FX_BOOL bInheritable, int subindex) { CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex); - if (pAttr == NULL || pAttr->GetType() != PDFOBJ_NAME) { - return default_value; - } - return pAttr->GetString(); + if (ToName(pAttr)) + return pAttr->GetString(); + return default_value; } + FX_ARGB CPDF_StructElementImpl::GetColor(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, FX_ARGB default_value, |