summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_edit
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-22 09:31:44 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-22 09:31:44 -0400
commitc2bfc000e502c42c9a3017038fd9104c7997d126 (patch)
treea693dd82199e7af83fac7b7b19d023e4c5fc5e36 /core/src/fpdfapi/fpdf_edit
parent69ceb6a9761b3ccb228a2405e9a493a3666e0601 (diff)
downloadpdfium-c2bfc000e502c42c9a3017038fd9104c7997d126.tar.xz
Add type cast definitions for CPDF_Array.
This Cl adds ToArray, CPDF_Object::AsArray and CPDF_Object::IsArray and updates the src to use them as needed. BUG=pdfium:201 R=thestig@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/1417893003 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_edit')
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp10
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp4
2 files changed, 6 insertions, 8 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
index 79bfbdb13a..32802d0001 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
@@ -120,13 +120,11 @@ void CPDF_PageContentGenerate::ProcessForm(CFX_ByteTextBuf& buf,
void CPDF_PageContentGenerate::TransformContent(CFX_Matrix& matrix) {
CPDF_Dictionary* pDict = m_pPage->m_pFormDict;
CPDF_Object* pContent = pDict ? pDict->GetElementValue("Contents") : NULL;
- if (!pContent) {
+ if (!pContent)
return;
- }
+
CFX_ByteTextBuf buf;
- int type = pContent->GetType();
- if (type == PDFOBJ_ARRAY) {
- CPDF_Array* pArray = (CPDF_Array*)pContent;
+ if (CPDF_Array* pArray = pContent->AsArray()) {
int iCount = pArray->GetCount();
CPDF_StreamAcc** pContentArray = FX_Alloc(CPDF_StreamAcc*, iCount);
int size = 0;
@@ -153,7 +151,7 @@ void CPDF_PageContentGenerate::TransformContent(CFX_Matrix& matrix) {
ProcessForm(buf, pBuf, size, matrix);
FX_Free(pBuf);
FX_Free(pContentArray);
- } else if (type == PDFOBJ_STREAM) {
+ } else if (pContent->GetType() == PDFOBJ_STREAM) {
CPDF_StreamAcc contentStream;
contentStream.LoadAllData((CPDF_Stream*)pContent);
ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix);
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index b097389160..d6522158f1 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -79,7 +79,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
return -1;
}
offset += 1;
- CPDF_Array* p = (CPDF_Array*)pObj;
+ const CPDF_Array* p = pObj->AsArray();
for (FX_DWORD i = 0; i < p->GetCount(); i++) {
CPDF_Object* pElement = p->GetElement(i);
if (pElement->GetObjNum()) {
@@ -1195,7 +1195,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
return -1;
}
m_Offset += 1;
- CPDF_Array* p = (CPDF_Array*)pObj;
+ const CPDF_Array* p = pObj->AsArray();
for (FX_DWORD i = 0; i < p->GetCount(); i++) {
CPDF_Object* pElement = p->GetElement(i);
if (pElement->GetObjNum()) {