summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_edit
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-20 16:24:45 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-20 16:24:45 -0400
commitf1251c1ff2b3452854681d0648b4c1ca4180ff0d (patch)
treedbcff41b8f8a5ea3d1d5280ff0c946b9647c301a /core/src/fpdfapi/fpdf_edit
parent49f88b708d905b052bc00769ac7cb48202cac019 (diff)
downloadpdfium-f1251c1ff2b3452854681d0648b4c1ca4180ff0d.tar.xz
[Merge to XFA] 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 . (cherry picked from commit 39869b641511c882d78e17548293cdb458c36f38) Review URL: https://codereview.chromium.org/1410343003 .
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) {