diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-20 13:19:19 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-20 13:19:19 -0400 |
commit | 4816432671eef6467354aa252f22bb80acc315b7 (patch) | |
tree | 403313130206e70abf8ceae78353042a38221bec /core/src/fpdfapi/fpdf_edit | |
parent | 8b8dfd7934d669b2c74a0502f82387e5df0f573b (diff) | |
download | pdfium-4816432671eef6467354aa252f22bb80acc315b7.tar.xz |
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/1399233003 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_edit')
-rw-r--r-- | core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 11 |
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) { |