summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_edit
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-20 14:57:56 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-20 14:57:56 -0400
commit39869b641511c882d78e17548293cdb458c36f38 (patch)
tree6e7fee229f9c8a5d628c2dfe81b3e9848a9670d2 /core/src/fpdfapi/fpdf_edit
parent19169dae5bf92813b7419793f61dfca8b4fb9124 (diff)
downloadpdfium-39869b641511c882d78e17548293cdb458c36f38.tar.xz
Revert "Revert "Add type cast definitions for CPDF_Dictionary.""
This reverts commit 937840e1722d1f2b77d80575d6e710d760662c9c. Add type cast definitions for CPDF_Dictionary. This CL adds ToCPDFDictionary type definitions and updates one file to use instead of straight casts. I had to fix two places where we'd casted off the constness of the original pointer. BUG=pdfium:201 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1420583003 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_edit')
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index 4e6c72355d..054cf10c22 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -110,7 +110,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
return -1;
}
offset += 2;
- CPDF_Dictionary* p = (CPDF_Dictionary*)pObj;
+ const CPDF_Dictionary* p = pObj->AsDictionary();
FX_POSITION pos = p->GetStartPos();
while (pos) {
CFX_ByteString key;
@@ -334,7 +334,8 @@ CPDF_FlateEncoder::CPDF_FlateEncoder() {
}
void CPDF_FlateEncoder::CloneDict() {
if (!m_bCloned) {
- m_pDict = (CPDF_Dictionary*)m_pDict->Clone();
+ m_pDict = ToDictionary(m_pDict->Clone());
+ ASSERT(m_pDict);
m_bCloned = TRUE;
}
}
@@ -349,7 +350,7 @@ FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream,
destAcc.LoadAllData(pStream);
m_dwSize = destAcc.GetSize();
m_pData = (uint8_t*)destAcc.DetachData();
- m_pDict = (CPDF_Dictionary*)pStream->GetDict()->Clone();
+ m_pDict = ToDictionary(pStream->GetDict()->Clone());
m_pDict->RemoveAt(FX_BSTRC("Filter"));
m_bNewData = TRUE;
m_bCloned = TRUE;
@@ -365,7 +366,7 @@ FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream,
m_bNewData = TRUE;
m_bCloned = TRUE;
::FlateEncode(m_Acc.GetData(), m_Acc.GetSize(), m_pData, m_dwSize);
- m_pDict = (CPDF_Dictionary*)pStream->GetDict()->Clone();
+ m_pDict = ToDictionary(pStream->GetDict()->Clone());
m_pDict->SetAtInteger("Length", m_dwSize);
m_pDict->SetAtName("Filter", "FlateDecode");
m_pDict->RemoveAt("DecodeParms");
@@ -1227,7 +1228,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
return -1;
}
m_Offset += 2;
- CPDF_Dictionary* p = (CPDF_Dictionary*)pObj;
+ const CPDF_Dictionary* p = pObj->AsDictionary();
FX_BOOL bSignDict = IsSignatureDict(p);
FX_POSITION pos = p->GetStartPos();
while (pos) {