diff options
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r-- | core/src/fpdfdoc/doc_action.cpp | 32 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_ap.cpp | 2 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_basic.cpp | 3 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_bookmark.cpp | 8 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formfield.cpp | 50 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_link.cpp | 2 |
6 files changed, 37 insertions, 60 deletions
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp index 409d050484..c55c20cb1d 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->GetType() == PDFOBJ_STRING || pDest->GetType() == PDFOBJ_NAME) { + if (pDest->IsString() || pDest->GetType() == PDFOBJ_NAME) { CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); CFX_ByteStringC name = pDest->GetString(); return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name)); @@ -102,19 +102,14 @@ FX_DWORD CPDF_ActionFields::GetFieldsCount() const { } else { pFields = pDict->GetArray("Fields"); } - if (pFields == NULL) { + if (!pFields) return 0; - } - int iType = pFields->GetType(); - if (iType == PDFOBJ_DICTIONARY) { + if (pFields->IsDictionary()) return 1; - } - if (iType == PDFOBJ_STRING) { + if (pFields->IsString()) return 1; - } - if (iType == PDFOBJ_ARRAY) { + if (pFields->GetType() == PDFOBJ_ARRAY) return ((CPDF_Array*)pFields)->GetCount(); - } return 0; } void CPDF_ActionFields::GetAllFields(CFX_PtrArray& fieldObjects) const { @@ -133,13 +128,12 @@ void CPDF_ActionFields::GetAllFields(CFX_PtrArray& fieldObjects) const { } else { pFields = pDict->GetArray("Fields"); } - if (pFields == NULL) { + if (!pFields) return; - } - int iType = pFields->GetType(); - if (iType == PDFOBJ_DICTIONARY || iType == PDFOBJ_STRING) { + + if (pFields->IsDictionary() || pFields->IsString()) { fieldObjects.Add(pFields); - } else if (iType == PDFOBJ_ARRAY) { + } else if (pFields->GetType() == PDFOBJ_ARRAY) { CPDF_Array* pArray = (CPDF_Array*)pFields; FX_DWORD iCount = pArray->GetCount(); for (FX_DWORD i = 0; i < iCount; i++) { @@ -169,12 +163,10 @@ CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const { return NULL; } CPDF_Object* pFindObj = NULL; - int iType = pFields->GetType(); - if (iType == PDFOBJ_DICTIONARY || iType == PDFOBJ_STRING) { - if (iIndex == 0) { + if (pFields->IsDictionary() || pFields->IsString()) { + if (iIndex == 0) pFindObj = pFields; - } - } else if (iType == PDFOBJ_ARRAY) { + } else if (pFields->GetType() == PDFOBJ_ARRAY) { pFindObj = ((CPDF_Array*)pFields)->GetElementValue(iIndex); } return pFindObj; diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp index 2367d0e7e9..71025ec532 100644 --- a/core/src/fpdfdoc/doc_ap.cpp +++ b/core/src/fpdfdoc/doc_ap.cpp @@ -618,7 +618,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, } if (CPDF_Object* pOpt = pOpts->GetElementValue(i)) { CFX_WideString swItem; - if (pOpt->GetType() == PDFOBJ_STRING) { + if (pOpt->IsString()) { swItem = pOpt->GetUnicodeText(); } else if (pOpt->GetType() == PDFOBJ_ARRAY) { swItem = diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp index bbf51139ad..cbf956bd9b 100644 --- a/core/src/fpdfdoc/doc_basic.cpp +++ b/core/src/fpdfdoc/doc_basic.cpp @@ -406,8 +406,7 @@ static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object* pObj, } else { wsStr = FILESPEC_EncodeFileName(wsFileName); } - int32_t iType = pObj->GetType(); - if (iType == PDFOBJ_STRING) { + if (pObj->IsString()) { pObj->SetString(CFX_ByteString::FromUnicode(wsStr)); } else if (CPDF_Dictionary* pDict = pObj->AsDictionary()) { pDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(wsStr)); diff --git a/core/src/fpdfdoc/doc_bookmark.cpp b/core/src/fpdfdoc/doc_bookmark.cpp index 2fea810ecc..9d2a9f61ea 100644 --- a/core/src/fpdfdoc/doc_bookmark.cpp +++ b/core/src/fpdfdoc/doc_bookmark.cpp @@ -51,10 +51,10 @@ CFX_WideString CPDF_Bookmark::GetTitle() const { if (!m_pDict) { return CFX_WideString(); } - CPDF_String* pString = (CPDF_String*)m_pDict->GetElementValue("Title"); - if (!pString || pString->GetType() != PDFOBJ_STRING) { + CPDF_String* pString = ToString(m_pDict->GetElementValue("Title")); + if (!pString) return CFX_WideString(); - } + CFX_WideString title = pString->GetUnicodeText(); int len = title.GetLength(); if (!len) { @@ -75,7 +75,7 @@ CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const { if (!pDest) { return CPDF_Dest(); } - if (pDest->GetType() == PDFOBJ_STRING || pDest->GetType() == PDFOBJ_NAME) { + if (pDest->IsString() || pDest->GetType() == PDFOBJ_NAME) { 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 9ef28836a1..25f5490a72 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -425,18 +425,10 @@ int CPDF_FormField::CountSelectedItems() { return 0; } } - if (pValue->GetType() == PDFOBJ_STRING) { - if (pValue->GetString().IsEmpty()) { - return 0; - } - return 1; - } - if (pValue->IsNumber()) { - if (pValue->GetString().IsEmpty()) { - return 0; - } - return 1; - } + + if (pValue->IsString() || pValue->IsNumber()) + return pValue->GetString().IsEmpty() ? 0 : 1; + if (pValue->GetType() != PDFOBJ_ARRAY) { return 0; } @@ -454,10 +446,10 @@ int CPDF_FormField::GetSelectedIndex(int index) { return pValue->GetInteger(); CFX_WideString sel_value; - if (pValue->GetType() == PDFOBJ_STRING) { - if (index != 0) { + if (pValue->IsString()) { + if (index != 0) return -1; - } + sel_value = pValue->GetUnicodeText(); } else { if (pValue->GetType() != PDFOBJ_ARRAY) { @@ -535,21 +527,16 @@ FX_BOOL CPDF_FormField::IsItemSelected(int index) { return FALSE; } } - if (pValue->GetType() == PDFOBJ_STRING) { - if (pValue->GetUnicodeText() == opt_value) { - return TRUE; - } - return FALSE; - } + + if (pValue->IsString()) + return (pValue->GetUnicodeText() == opt_value); + if (pValue->IsNumber()) { - if (pValue->GetString().IsEmpty()) { + if (pValue->GetString().IsEmpty()) return FALSE; - } - if (pValue->GetInteger() == index) { - return TRUE; - } - return FALSE; + return (pValue->GetInteger() == index); } + if (pValue->GetType() != PDFOBJ_ARRAY) { return FALSE; } @@ -593,7 +580,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, if (pValue != NULL) { if (m_Type == ListBox) { SelectOption(index, FALSE); - if (pValue->GetType() == PDFOBJ_STRING) { + if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) { m_pDict->RemoveAt("V"); } @@ -734,10 +721,9 @@ CFX_WideString CPDF_FormField::GetOptionText(int index, int sub_index) { if (pOption->GetType() == PDFOBJ_ARRAY) { pOption = ((CPDF_Array*)pOption)->GetElementValue(sub_index); } - if (pOption == NULL || pOption->GetType() != PDFOBJ_STRING) { - return CFX_WideString(); - } - return ((CPDF_String*)pOption)->GetUnicodeText(); + + CPDF_String* pString = ToString(pOption); + return pString ? pString->GetUnicodeText() : CFX_WideString(); } CFX_WideString CPDF_FormField::GetOptionLabel(int index) { return GetOptionText(index, 1); diff --git a/core/src/fpdfdoc/doc_link.cpp b/core/src/fpdfdoc/doc_link.cpp index fbf18f99e5..95411013b4 100644 --- a/core/src/fpdfdoc/doc_link.cpp +++ b/core/src/fpdfdoc/doc_link.cpp @@ -76,7 +76,7 @@ CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) { if (pDest == NULL) { return CPDF_Dest(); } - if (pDest->GetType() == PDFOBJ_STRING || pDest->GetType() == PDFOBJ_NAME) { + if (pDest->IsString() || pDest->GetType() == PDFOBJ_NAME) { CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); CFX_ByteStringC name = pDest->GetString(); return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name)); |