summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-22 15:34:16 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-22 15:34:16 -0400
commit338805f1366dcdf9a5b48cf591541cf98d7490f1 (patch)
tree161b722bbb0628b290084b20fa8aa8f1d436c896 /fpdfsdk
parentc6d8683dbdd922c86375fb0520d420de13d683ed (diff)
downloadpdfium-338805f1366dcdf9a5b48cf591541cf98d7490f1.tar.xz
Add type cast definitions for CPDF_Stream.
This Cl adds ToStream, CPDF_Object::AsStream and CPDF_Object::IsStream and updates the src to use them as needed. BUG=pdfium:201 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1402413004 .
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/src/fpdf_flatten.cpp7
-rw-r--r--fpdfsdk/src/fpdf_transformpage.cpp15
-rw-r--r--fpdfsdk/src/fpdfppo.cpp2
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp2
4 files changed, 13 insertions, 13 deletions
diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp
index f4d49ce182..39441c4aef 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -211,7 +211,7 @@ void SetPageContents(CFX_ByteString key,
switch (iType) {
case PDFOBJ_STREAM: {
pContentsArray = new CPDF_Array;
- CPDF_Stream* pContents = (CPDF_Stream*)pContentsObj;
+ CPDF_Stream* pContents = pContentsObj->AsStream();
FX_DWORD dwObjNum = pDocument->AddIndirectObject(pContents);
CPDF_StreamAcc acc;
acc.LoadAllData(pContents);
@@ -447,15 +447,14 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
if (pFirstObj->GetType() == PDFOBJ_REFERENCE)
pFirstObj = pFirstObj->GetDirect();
- if (pFirstObj->GetType() != PDFOBJ_STREAM)
+ if (!pFirstObj->IsStream())
continue;
- pAPStream = (CPDF_Stream*)pFirstObj;
+ pAPStream = pFirstObj->AsStream();
}
}
}
}
-
if (!pAPStream)
continue;
diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp
index d2ad26bf64..20713fe07d 100644
--- a/fpdfsdk/src/fpdf_transformpage.cpp
+++ b/fpdfsdk/src/fpdf_transformpage.cpp
@@ -144,7 +144,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
- } else if (pDirectObj->GetType() == PDFOBJ_STREAM) {
+ } else if (pDirectObj->IsStream()) {
pContentArray = new CPDF_Array();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
@@ -162,16 +162,17 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
if (pPattenDict) {
FX_POSITION pos = pPattenDict->GetStartPos();
while (pos) {
- CPDF_Dictionary* pDict = NULL;
+ CPDF_Dictionary* pDict = nullptr;
CFX_ByteString key;
CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key);
if (pObj->GetType() == PDFOBJ_REFERENCE)
pObj = pObj->GetDirect();
- if (pObj->IsDictionary()) {
+
+ if (pObj->IsDictionary())
pDict = pObj->AsDictionary();
- } else if (pObj->GetType() == PDFOBJ_STREAM) {
- pDict = ((CPDF_Stream*)pObj)->GetDict();
- } else
+ else if (CPDF_Stream* pStream = pObj->AsStream())
+ pDict = pStream->GetDict();
+ else
continue;
CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix"));
@@ -313,7 +314,7 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
- } else if (pDirectObj->GetType() == PDFOBJ_STREAM) {
+ } else if (pDirectObj->IsStream()) {
pContentArray = new CPDF_Array();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index 7b589b585f..c9df813789 100644
--- a/fpdfsdk/src/fpdfppo.cpp
+++ b/fpdfsdk/src/fpdfppo.cpp
@@ -247,7 +247,7 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
break;
}
case PDFOBJ_STREAM: {
- CPDF_Stream* pStream = (CPDF_Stream*)pObj;
+ CPDF_Stream* pStream = pObj->AsStream();
CPDF_Dictionary* pDict = pStream->GetDict();
if (pDict) {
if (!UpdateReference(pDict, pDoc, pObjNumberMap))
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 3b845b017e..e083220fe2 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -62,7 +62,7 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(
case FIELDTYPE_LISTBOX:
case FIELDTYPE_TEXTFIELD:
case FIELDTYPE_SIGNATURE:
- return psub->GetType() == PDFOBJ_STREAM;
+ return psub->IsStream();
case FIELDTYPE_CHECKBOX:
case FIELDTYPE_RADIOBUTTON:
if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) {