summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/fpdf_flatten.cpp2
-rw-r--r--fpdfsdk/src/fpdf_transformpage.cpp40
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp2
-rw-r--r--fpdfsdk/src/fpdfppo.cpp2
-rw-r--r--fpdfsdk/src/fpdfview.cpp9
-rw-r--r--fpdfsdk/src/fsdk_actionhandler.cpp14
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp2
7 files changed, 37 insertions, 34 deletions
diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp
index fee93f2663..f4d49ce182 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -226,7 +226,7 @@ void SetPageContents(CFX_ByteString key,
}
case PDFOBJ_ARRAY: {
- pContentsArray = (CPDF_Array*)pContentsObj;
+ pContentsArray = pContentsObj->AsArray();
break;
}
default:
diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp
index 1e24b68f08..d2ad26bf64 100644
--- a/fpdfsdk/src/fpdf_transformpage.cpp
+++ b/fpdfsdk/src/fpdf_transformpage.cpp
@@ -109,14 +109,15 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
textBuf << bsMatix;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
- CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL;
+ CPDF_Object* pContentObj =
+ pPageDic ? pPageDic->GetElement("Contents") : nullptr;
if (!pContentObj)
- pContentObj = pPageDic ? pPageDic->GetArray("Contents") : NULL;
+ pContentObj = pPageDic ? pPageDic->GetArray("Contents") : nullptr;
if (!pContentObj)
return FALSE;
CPDF_Dictionary* pDic = new CPDF_Dictionary;
- CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, pDic);
+ CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
@@ -124,22 +125,22 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
pDoc->AddIndirectObject(pStream);
pDic = new CPDF_Dictionary;
- CPDF_Stream* pEndStream = new CPDF_Stream(NULL, 0, pDic);
+ CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic);
pEndStream->SetData((const uint8_t*)" Q", 2, FALSE, FALSE);
pDoc->AddIndirectObject(pEndStream);
- CPDF_Array* pContentArray = NULL;
- if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY) {
- pContentArray = (CPDF_Array*)pContentObj;
+ CPDF_Array* pContentArray = nullptr;
+ if (CPDF_Array* pArray = ToArray(pContentObj)) {
+ pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
} else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) {
CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
CPDF_Object* pDirectObj = pReference->GetDirect();
- if (pDirectObj != NULL) {
- if (pDirectObj->GetType() == PDFOBJ_ARRAY) {
- pContentArray = (CPDF_Array*)pDirectObj;
+ if (pDirectObj) {
+ if (CPDF_Array* pArray = pDirectObj->AsArray()) {
+ pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
@@ -267,9 +268,10 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
return;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
- CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL;
+ CPDF_Object* pContentObj =
+ pPageDic ? pPageDic->GetElement("Contents") : nullptr;
if (!pContentObj)
- pContentObj = pPageDic ? pPageDic->GetArray("Contents") : NULL;
+ pContentObj = pPageDic ? pPageDic->GetArray("Contents") : nullptr;
if (!pContentObj)
return;
@@ -291,24 +293,24 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
}
}
CPDF_Dictionary* pDic = new CPDF_Dictionary;
- CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, pDic);
+ CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
pStream->SetData(strClip.GetBuffer(), strClip.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return;
pDoc->AddIndirectObject(pStream);
- CPDF_Array* pContentArray = NULL;
- if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY) {
- pContentArray = (CPDF_Array*)pContentObj;
+ CPDF_Array* pContentArray = nullptr;
+ if (CPDF_Array* pArray = ToArray(pContentObj)) {
+ pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
} else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) {
CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
CPDF_Object* pDirectObj = pReference->GetDirect();
- if (pDirectObj != NULL) {
- if (pDirectObj->GetType() == PDFOBJ_ARRAY) {
- pContentArray = (CPDF_Array*)pDirectObj;
+ if (pDirectObj) {
+ if (CPDF_Array* pArray = pDirectObj->AsArray()) {
+ pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
} else if (pDirectObj->GetType() == PDFOBJ_STREAM) {
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index ad8ef8bea3..8a4d619292 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -197,7 +197,7 @@ DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document,
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return 0;
- CPDF_Dest dest((CPDF_Array*)pDict);
+ CPDF_Dest dest(static_cast<CPDF_Array*>(pDict));
return dest.GetPageIndex(pDoc);
}
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index c37ecca490..b071630982 100644
--- a/fpdfsdk/src/fpdfppo.cpp
+++ b/fpdfsdk/src/fpdfppo.cpp
@@ -242,7 +242,7 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
break;
}
case PDFOBJ_ARRAY: {
- CPDF_Array* pArray = (CPDF_Array*)pObj;
+ CPDF_Array* pArray = pObj->AsArray();
FX_DWORD count = pArray->GetCount();
for (FX_DWORD i = 0; i < count; i++) {
CPDF_Object* pNextObj = pArray->GetElement(i);
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index bd7741d1e8..b3c8137d0c 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -1041,14 +1041,15 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
pDestObj = nameTree.LookupValue(index, bsName);
}
if (!pDestObj)
- return NULL;
+ return nullptr;
if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) {
pDestObj = pDict->GetArray(FX_BSTRC("D"));
if (!pDestObj)
- return NULL;
+ return nullptr;
}
- if (pDestObj->GetType() != PDFOBJ_ARRAY)
- return NULL;
+ if (!pDestObj->IsArray())
+ return nullptr;
+
CFX_WideString wsName = PDF_DecodeText(bsName);
CFX_ByteString utf16Name = wsName.UTF16LE_Encode();
unsigned int len = utf16Name.GetLength();
diff --git a/fpdfsdk/src/fsdk_actionhandler.cpp b/fpdfsdk/src/fsdk_actionhandler.cpp
index feb9a85137..9d510b74c2 100644
--- a/fpdfsdk/src/fsdk_actionhandler.cpp
+++ b/fpdfsdk/src/fsdk_actionhandler.cpp
@@ -426,7 +426,7 @@ void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action,
}
FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) {
- ASSERT(pDocument != NULL);
+ ASSERT(pDocument);
return TRUE;
}
@@ -435,17 +435,15 @@ void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
ASSERT(action);
CPDF_Document* pPDFDocument = pDocument->GetDocument()->GetPDFDoc();
- ASSERT(pPDFDocument != NULL);
- CPDFDoc_Environment* pApp = pDocument->GetEnv();
- ASSERT(pApp != NULL);
+ ASSERT(pPDFDocument);
CPDF_Dest MyDest = action.GetDest(pPDFDocument);
int nPageIndex = MyDest.GetPageIndex(pPDFDocument);
int nFitType = MyDest.GetZoomMode();
- const CPDF_Array* pMyArray = (CPDF_Array*)MyDest.GetObject();
- float* pPosAry = NULL;
+ const CPDF_Array* pMyArray = ToArray(MyDest.GetObject());
+ float* pPosAry = nullptr;
int sizeOfAry = 0;
- if (pMyArray != NULL) {
+ if (pMyArray) {
pPosAry = new float[pMyArray->GetCount()];
int j = 0;
for (int i = 2; i < (int)pMyArray->GetCount(); i++) {
@@ -453,6 +451,8 @@ void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
}
sizeOfAry = j;
}
+
+ CPDFDoc_Environment* pApp = pDocument->GetEnv();
pApp->FFI_DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry);
delete[] pPosAry;
}
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index b7de36c7d3..a698453c04 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -484,7 +484,7 @@ FX_BOOL CPDFSDK_Document::ProcOpenAction() {
if (!pOpenAction)
return FALSE;
- if (pOpenAction->GetType() == PDFOBJ_ARRAY)
+ if (pOpenAction->IsArray())
return TRUE;
if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) {