diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-21 11:07:42 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-21 11:07:42 -0400 |
commit | 43ce9035a026c7b4f15aa938dc39444d9253ea9f (patch) | |
tree | 8f18c1508dfd0db47d9dec1dbc708fd018349b3f /core/src/fpdfdoc | |
parent | 1edb860fd465879311ec85c5c6385067b7985013 (diff) | |
download | pdfium-43ce9035a026c7b4f15aa938dc39444d9253ea9f.tar.xz |
Merge to XFA: Add type cast definitions for CPDF_Number.
This Cl adds ToNumber, CPDF_Object::AsNumber and CPDF_Object::IsNumber and
updates the src to use them as needed.
BUG=pdfium:201
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1410673005 .
(cherry picked from commit 83bf02dfb860a66d756434d194118dae572d04d3)
Review URL: https://codereview.chromium.org/1422583002 .
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r-- | core/src/fpdfdoc/doc_basic.cpp | 18 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formfield.cpp | 8 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_tagged.cpp | 17 |
3 files changed, 16 insertions, 27 deletions
diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp index e3b630862c..bbf51139ad 100644 --- a/core/src/fpdfdoc/doc_basic.cpp +++ b/core/src/fpdfdoc/doc_basic.cpp @@ -11,15 +11,12 @@ int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) { return 0; } CPDF_Object* pPage = ((CPDF_Array*)m_pObj)->GetElementValue(0); - if (pPage == NULL) { + if (!pPage) return 0; - } - if (pPage->GetType() == PDFOBJ_NUMBER) { + if (pPage->IsNumber()) return pPage->GetInteger(); - } - if (!pPage->IsDictionary()) { + if (!pPage->IsDictionary()) return 0; - } return pDoc->GetPageIndex(pPage->GetObjNum()); } FX_DWORD CPDF_Dest::GetPageObjNum() { @@ -27,15 +24,12 @@ FX_DWORD CPDF_Dest::GetPageObjNum() { return 0; } CPDF_Object* pPage = ((CPDF_Array*)m_pObj)->GetElementValue(0); - if (pPage == NULL) { + if (!pPage) return 0; - } - if (pPage->GetType() == PDFOBJ_NUMBER) { + if (pPage->IsNumber()) return pPage->GetInteger(); - } - if (pPage->IsDictionary()) { + if (pPage->IsDictionary()) return pPage->GetObjNum(); - } return 0; } const FX_CHAR* g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR", diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index 8c99cf4a78..aafc17f65c 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -431,7 +431,7 @@ int CPDF_FormField::CountSelectedItems() { } return 1; } - if (pValue->GetType() == PDFOBJ_NUMBER) { + if (pValue->IsNumber()) { if (pValue->GetString().IsEmpty()) { return 0; } @@ -450,9 +450,9 @@ int CPDF_FormField::GetSelectedIndex(int index) { return -1; } } - if (pValue->GetType() == PDFOBJ_NUMBER) { + if (pValue->IsNumber()) return pValue->GetInteger(); - } + CFX_WideString sel_value; if (pValue->GetType() == PDFOBJ_STRING) { if (index != 0) { @@ -541,7 +541,7 @@ FX_BOOL CPDF_FormField::IsItemSelected(int index) { } return FALSE; } - if (pValue->GetType() == PDFOBJ_NUMBER) { + if (pValue->IsNumber()) { if (pValue->GetString().IsEmpty()) { return FALSE; } diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp index fb3a05d59f..d9d439f730 100644 --- a/core/src/fpdfdoc/doc_tagged.cpp +++ b/core/src/fpdfdoc/doc_tagged.cpp @@ -254,10 +254,10 @@ void CPDF_StructElementImpl::LoadKid(FX_DWORD PageObjNum, CPDF_Object* pKidObj, CPDF_StructKid* pKid) { pKid->m_Type = CPDF_StructKid::Invalid; - if (pKidObj == NULL) { + if (!pKidObj) return; - } - if (pKidObj->GetType() == PDFOBJ_NUMBER) { + + if (pKidObj->IsNumber()) { if (m_pTree->m_pPage && m_pTree->m_pPage->GetObjNum() != PageObjNum) { return; } @@ -266,6 +266,7 @@ void CPDF_StructElementImpl::LoadKid(FX_DWORD PageObjNum, pKid->m_PageContent.m_PageObjNum = PageObjNum; return; } + CPDF_Dictionary* pKidDict = pKidObj->AsDictionary(); if (!pKidDict) return; @@ -441,10 +442,7 @@ FX_FLOAT CPDF_StructElementImpl::GetNumber(const CFX_ByteStringC& owner, FX_BOOL bInheritable, int subindex) { CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex); - if (pAttr == NULL || pAttr->GetType() != PDFOBJ_NUMBER) { - return default_value; - } - return pAttr->GetNumber(); + return ToNumber(pAttr) ? pAttr->GetNumber() : default_value; } int CPDF_StructElementImpl::GetInteger(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, @@ -452,8 +450,5 @@ int CPDF_StructElementImpl::GetInteger(const CFX_ByteStringC& owner, FX_BOOL bInheritable, int subindex) { CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex); - if (pAttr == NULL || pAttr->GetType() != PDFOBJ_NUMBER) { - return default_value; - } - return pAttr->GetInteger(); + return ToNumber(pAttr) ? pAttr->GetInteger() : default_value; } |