diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp | 2 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp | 6 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 10 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/pageint.h | 4 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 5 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp | 36 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 59 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp | 6 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/render_int.h | 5 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_form.cpp | 41 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formfield.cpp | 36 | ||||
-rw-r--r-- | core/src/fpdfdoc/tagged_int.h | 2 | ||||
-rw-r--r-- | core/src/fpdftext/fpdf_text.cpp | 63 | ||||
-rw-r--r-- | core/src/fpdftext/txtproc.h | 7 | ||||
-rw-r--r-- | core/src/fxcrt/extension.h | 18 | ||||
-rw-r--r-- | core/src/fxge/agg/include/fx_agg_driver.h | 2 | ||||
-rw-r--r-- | core/src/fxge/agg/src/fx_agg_driver.cpp | 7 |
17 files changed, 139 insertions, 170 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp index 59fa1afb50..36dbb97a6c 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp @@ -37,7 +37,7 @@ void CPDF_PageContentGenerate::GenerateContent() { CFX_ByteTextBuf buf; CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict; for (int i = 0; i < m_pageObjects.GetSize(); ++i) { - CPDF_PageObject* pPageObj = (CPDF_PageObject*)m_pageObjects[i]; + CPDF_PageObject* pPageObj = m_pageObjects[i]; if (!pPageObj || pPageObj->m_Type != PDFPAGE_IMAGE) { continue; } diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index 349b007c43..b3891d78dd 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -1017,7 +1017,7 @@ static int InsertDeletePDFPage(CPDF_Document* pDoc, int nPagesToGo, CPDF_Dictionary* pPage, FX_BOOL bInsert, - CFX_PtrArray& stackList) { + CFX_ArrayTemplate<CPDF_Dictionary*>& stackList) { CPDF_Array* pKidList = pPages->GetArray("Kids"); if (!pKidList) { return -1; @@ -1088,7 +1088,7 @@ static int InsertNewPage(CPDF_Document* pDoc, pPages->SetAtInteger(FX_BSTRC("Count"), nPages + 1); pPageDict->SetAtReference(FX_BSTRC("Parent"), pDoc, pPages->GetObjNum()); } else { - CFX_PtrArray stack; + CFX_ArrayTemplate<CPDF_Dictionary*> stack; stack.Add(pPages); if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, stack) < 0) { return -1; @@ -1129,7 +1129,7 @@ void CPDF_Document::DeletePage(int iPage) { if (iPage < 0 || iPage >= nPages) { return; } - CFX_PtrArray stack; + CFX_ArrayTemplate<CPDF_Dictionary*> stack; stack.Add(pPages); if (InsertDeletePDFPage(this, pPages, iPage, NULL, FALSE, stack) < 0) { return; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 163b6e9d53..a2d4988f92 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -80,7 +80,7 @@ CPDF_StreamContentParser::CPDF_StreamContentParser( CPDF_StreamContentParser::~CPDF_StreamContentParser() { ClearAllParams(); for (int i = 0; i < m_StateStack.GetSize(); ++i) { - delete (CPDF_AllStates*)m_StateStack[i]; + delete m_StateStack[i]; } FX_Free(m_pPathPoints); if (m_pLastImageDict) { @@ -819,12 +819,10 @@ void CPDF_StreamContentParser::Handle_EndText() { } if (m_pCurStates->m_TextState.GetObject()->m_TextMode < 4) { for (int i = 0; i < count; i++) { - CPDF_TextObject* pText = (CPDF_TextObject*)m_ClipTextList.GetAt(i); - delete pText; + delete m_ClipTextList.GetAt(i); } } else { - m_pCurStates->m_ClipPath.AppendTexts( - (CPDF_TextObject**)m_ClipTextList.GetData(), count); + m_pCurStates->m_ClipPath.AppendTexts(m_ClipTextList.GetData(), count); } m_ClipTextList.RemoveAll(); } @@ -950,7 +948,7 @@ void CPDF_StreamContentParser::Handle_RestoreGraphState() { if (size == 0) { return; } - CPDF_AllStates* pStates = (CPDF_AllStates*)m_StateStack.GetAt(size - 1); + CPDF_AllStates* pStates = m_StateStack.GetAt(size - 1); m_pCurStates->Copy(*pStates); delete pStates; m_StateStack.RemoveAt(size - 1); diff --git a/core/src/fpdfapi/fpdf_page/pageint.h b/core/src/fpdfapi/fpdf_page/pageint.h index 96c70c2245..208a09b8d8 100644 --- a/core/src/fpdfapi/fpdf_page/pageint.h +++ b/core/src/fpdfapi/fpdf_page/pageint.h @@ -321,7 +321,7 @@ class CPDF_StreamContentParser { CPDF_StreamParser* m_pSyntax; nonstd::unique_ptr<CPDF_AllStates> m_pCurStates; CPDF_ContentMark m_CurContentMark; - CFX_PtrArray m_ClipTextList; + CFX_ArrayTemplate<CPDF_TextObject*> m_ClipTextList; CPDF_TextObject* m_pLastTextObject; FX_FLOAT m_DefFontSize; int m_CompatCount; @@ -344,7 +344,7 @@ class CPDF_StreamContentParser { FX_BOOL m_bColored; FX_FLOAT m_Type3Data[6]; FX_BOOL m_bResourceMissing; - CFX_PtrArray m_StateStack; + CFX_ArrayTemplate<CPDF_AllStates*> m_StateStack; }; class CPDF_ContentParser { public: diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 57d1971889..dbd5f311a6 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -335,7 +335,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, CPDF_Object* pParams = pDict ? pDict->GetElementValue(FX_BSTRC("DecodeParms")) : nullptr; CFX_ByteStringArray DecoderList; - CFX_PtrArray ParamList; + CFX_ArrayTemplate<CPDF_Object*> ParamList; if (CPDF_Array* pDecoders = pDecoder->AsArray()) { CPDF_Array* pParamsArray = ToArray(pParams); if (!pParamsArray) @@ -357,8 +357,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, i == DecoderList.GetSize() - 1 ? last_estimated_size : 0; CFX_ByteString decoder = DecoderList[i]; // Use ToDictionary here because we can push NULL into the ParamList. - CPDF_Dictionary* pParam = - ToDictionary(static_cast<CPDF_Object*>(ParamList[i])); + CPDF_Dictionary* pParam = ToDictionary(ParamList[i]); uint8_t* new_buf = nullptr; FX_DWORD new_size = (FX_DWORD)-1; int offset = -1; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index edf80d0618..752a09d83d 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -251,8 +251,7 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, const CPDF_Array* pThis = AsArray(); int n = pThis->GetCount(); for (int i = 0; i < n; i++) { - CPDF_Object* value = - static_cast<CPDF_Object*>(pThis->m_Objects.GetAt(i)); + CPDF_Object* value = pThis->m_Objects.GetAt(i); pCopy->m_Objects.Add(value->CloneInternal(bDirect, visited)); } return pCopy; @@ -424,7 +423,7 @@ CPDF_String::CPDF_String(const CFX_WideString& str) } CPDF_Array::~CPDF_Array() { int size = m_Objects.GetSize(); - CPDF_Object** pList = (CPDF_Object**)m_Objects.GetData(); + CPDF_Object** pList = m_Objects.GetData(); for (int i = 0; i < size; i++) { if (pList[i]) pList[i]->Release(); @@ -453,32 +452,32 @@ CFX_AffineMatrix CPDF_Array::GetMatrix() { CPDF_Object* CPDF_Array::GetElement(FX_DWORD i) const { if (i >= (FX_DWORD)m_Objects.GetSize()) return nullptr; - return static_cast<CPDF_Object*>(m_Objects.GetAt(i)); + return m_Objects.GetAt(i); } CPDF_Object* CPDF_Array::GetElementValue(FX_DWORD i) const { if (i >= (FX_DWORD)m_Objects.GetSize()) return nullptr; - return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetDirect(); + return m_Objects.GetAt(i)->GetDirect(); } CFX_ByteString CPDF_Array::GetString(FX_DWORD i) const { - if (i < (FX_DWORD)m_Objects.GetSize()) - return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetString(); - return CFX_ByteString(); + if (i >= (FX_DWORD)m_Objects.GetSize()) + return CFX_ByteString(); + return m_Objects.GetAt(i)->GetString(); } CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const { - if (i < (FX_DWORD)m_Objects.GetSize()) - return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetConstString(); - return CFX_ByteStringC(); + if (i >= (FX_DWORD)m_Objects.GetSize()) + return CFX_ByteStringC(); + return m_Objects.GetAt(i)->GetConstString(); } int CPDF_Array::GetInteger(FX_DWORD i) const { if (i >= (FX_DWORD)m_Objects.GetSize()) return 0; - return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetInteger(); + return m_Objects.GetAt(i)->GetInteger(); } FX_FLOAT CPDF_Array::GetNumber(FX_DWORD i) const { if (i >= (FX_DWORD)m_Objects.GetSize()) return 0; - return static_cast<CPDF_Object*>(m_Objects.GetAt(i))->GetNumber(); + return m_Objects.GetAt(i)->GetNumber(); } CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const { CPDF_Object* p = GetElementValue(i); @@ -504,7 +503,7 @@ void CPDF_Array::RemoveAt(FX_DWORD i, int nCount) { return; for (int j = 0; j < nCount; ++j) { - if (CPDF_Object* p = static_cast<CPDF_Object*>(m_Objects.GetAt(i + j))) + if (CPDF_Object* p = m_Objects.GetAt(i + j)) p->Release(); } m_Objects.RemoveAt(i, nCount); @@ -516,7 +515,7 @@ void CPDF_Array::SetAt(FX_DWORD i, ASSERT(i < (FX_DWORD)m_Objects.GetSize()); if (i >= (FX_DWORD)m_Objects.GetSize()) return; - if (CPDF_Object* pOld = static_cast<CPDF_Object*>(m_Objects.GetAt(i))) + if (CPDF_Object* pOld = m_Objects.GetAt(i)) pOld->Release(); if (pObj->GetObjNum()) { ASSERT(pObjs); @@ -568,11 +567,10 @@ FX_BOOL CPDF_Array::Identical(CPDF_Array* pOther) const { if (m_Objects.GetSize() != pOther->m_Objects.GetSize()) { return FALSE; } - for (int i = 0; i < m_Objects.GetSize(); i++) - if (!static_cast<CPDF_Object*>(m_Objects[i]) - ->IsIdentical(static_cast<CPDF_Object*>(pOther->m_Objects[i]))) { + for (int i = 0; i < m_Objects.GetSize(); i++) { + if (!m_Objects[i]->IsIdentical(pOther->m_Objects[i])) return FALSE; - } + } return TRUE; } CPDF_Dictionary::~CPDF_Dictionary() { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index 04aca91082..f64ba0deb0 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -2693,10 +2693,10 @@ class CPDF_DataAvail final : public IPDF_DataAvail { static const int kMaxPageRecursionDepth = 1024; FX_DWORD GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset); - FX_BOOL IsObjectsAvail(CFX_PtrArray& obj_array, + FX_BOOL IsObjectsAvail(CFX_ArrayTemplate<CPDF_Object*>& obj_array, FX_BOOL bParsePage, IFX_DownloadHints* pHints, - CFX_PtrArray& ret_array); + CFX_ArrayTemplate<CPDF_Object*>& ret_array); FX_BOOL CheckDocStatus(IFX_DownloadHints* pHints); FX_BOOL CheckHeader(IFX_DownloadHints* pHints); FX_BOOL CheckFirstPage(IFX_DownloadHints* pHints); @@ -2795,7 +2795,7 @@ class CPDF_DataAvail final : public IPDF_DataAvail { CPDF_SortObjNumArray m_objnum_array; - CFX_PtrArray m_objs_array; + CFX_ArrayTemplate<CPDF_Object*> m_objs_array; FX_FILESIZE m_Pos; @@ -2847,7 +2847,7 @@ class CPDF_DataAvail final : public IPDF_DataAvail { CPDF_Object* m_pAcroForm; - CFX_PtrArray m_arrayAcroforms; + CFX_ArrayTemplate<CPDF_Object*> m_arrayAcroforms; CPDF_Dictionary* m_pPageDict; @@ -2859,7 +2859,7 @@ class CPDF_DataAvail final : public IPDF_DataAvail { FX_BOOL m_bLinearizedFormParamLoad; - CFX_PtrArray m_PagesArray; + CFX_ArrayTemplate<CPDF_Object*> m_PagesArray; FX_DWORD m_dwEncryptObjNum; @@ -2954,7 +2954,7 @@ CPDF_DataAvail::~CPDF_DataAvail() { int iSize = m_arrayAcroforms.GetSize(); for (int i = 0; i < iSize; ++i) { - static_cast<CPDF_Object*>(m_arrayAcroforms.GetAt(i))->Release(); + m_arrayAcroforms.GetAt(i)->Release(); } } void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) { @@ -2991,18 +2991,19 @@ FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) { } return 0; } -FX_BOOL CPDF_DataAvail::IsObjectsAvail(CFX_PtrArray& obj_array, - FX_BOOL bParsePage, - IFX_DownloadHints* pHints, - CFX_PtrArray& ret_array) { +FX_BOOL CPDF_DataAvail::IsObjectsAvail( + CFX_ArrayTemplate<CPDF_Object*>& obj_array, + FX_BOOL bParsePage, + IFX_DownloadHints* pHints, + CFX_ArrayTemplate<CPDF_Object*>& ret_array) { if (!obj_array.GetSize()) { return TRUE; } FX_DWORD count = 0; - CFX_PtrArray new_obj_array; + CFX_ArrayTemplate<CPDF_Object*> new_obj_array; int32_t i = 0; for (i = 0; i < obj_array.GetSize(); i++) { - CPDF_Object* pObj = static_cast<CPDF_Object*>(obj_array[i]); + CPDF_Object* pObj = obj_array[i]; if (!pObj) continue; @@ -3056,7 +3057,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(CFX_PtrArray& obj_array, if (count > 0) { int32_t iSize = new_obj_array.GetSize(); for (i = 0; i < iSize; ++i) { - CPDF_Object* pObj = static_cast<CPDF_Object*>(new_obj_array[i]); + CPDF_Object* pObj = new_obj_array[i]; if (CPDF_Reference* pRef = pObj->AsReference()) { FX_DWORD dwNum = pRef->GetRefObjNum(); if (!m_objnum_array.Find(dwNum)) @@ -3092,7 +3093,7 @@ FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) { if (!m_objs_array.GetSize()) { m_objs_array.RemoveAll(); m_objnum_array.RemoveAll(); - CFX_PtrArray obj_array; + CFX_ArrayTemplate<CPDF_Object*> obj_array; obj_array.Append(m_arrayAcroforms); FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); if (bRet) { @@ -3100,12 +3101,12 @@ FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) { } return bRet; } - CFX_PtrArray new_objs_array; + CFX_ArrayTemplate<CPDF_Object*> new_objs_array; FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); if (bRet) { int32_t iSize = m_arrayAcroforms.GetSize(); for (int32_t i = 0; i < iSize; ++i) { - static_cast<CPDF_Object*>(m_arrayAcroforms.GetAt(i))->Release(); + m_arrayAcroforms.GetAt(i)->Release(); } m_arrayAcroforms.RemoveAll(); } else { @@ -3391,14 +3392,14 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) { } FX_DWORD iPages = m_PagesArray.GetSize(); for (FX_DWORD i = 0; i < iPages; i++) { - CPDF_Object* pPages = static_cast<CPDF_Object*>(m_PagesArray.GetAt(i)); + CPDF_Object* pPages = m_PagesArray.GetAt(i); if (!pPages) continue; if (!GetPageKids(m_pCurrentParser, pPages)) { pPages->Release(); while (++i < iPages) { - pPages = static_cast<CPDF_Object*>(m_PagesArray.GetAt(i)); + pPages = m_PagesArray.GetAt(i); pPages->Release(); } m_PagesArray.RemoveAll(); @@ -4163,7 +4164,7 @@ FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_PageNode& pageNodes, return FALSE; } for (int32_t i = 0; i < iSize; ++i) { - CPDF_PageNode* pNode = (CPDF_PageNode*)pageNodes.m_childNode.GetAt(i); + CPDF_PageNode* pNode = pageNodes.m_childNode.GetAt(i); if (!pNode) { continue; } @@ -4310,7 +4311,7 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, if (!pAnnots) { return TRUE; } - CFX_PtrArray obj_array; + CFX_ArrayTemplate<CPDF_Object*> obj_array; obj_array.Add(pAnnots); FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); if (bRet) { @@ -4318,7 +4319,7 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, } return bRet; } - CFX_PtrArray new_objs_array; + CFX_ArrayTemplate<CPDF_Object*> new_objs_array; FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); m_objs_array.RemoveAll(); if (!bRet) { @@ -4432,7 +4433,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) { ResetFirstCheck(iPage); return DataAvailable; } - CFX_PtrArray obj_array; + CFX_ArrayTemplate<CPDF_Object*> obj_array; obj_array.Add(m_pPageDict); FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); if (bRet) { @@ -4442,7 +4443,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) { return bRet; } } else { - CFX_PtrArray new_objs_array; + CFX_ArrayTemplate<CPDF_Object*> new_objs_array; FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); m_objs_array.RemoveAll(); @@ -4487,7 +4488,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) { FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) { if (!m_objs_array.GetSize()) { m_objs_array.RemoveAll(); - CFX_PtrArray obj_array; + CFX_ArrayTemplate<CPDF_Object*> obj_array; obj_array.Add(m_pPageResource); FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); if (bRet) { @@ -4495,7 +4496,7 @@ FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) { } return bRet; } - CFX_PtrArray new_objs_array; + CFX_ArrayTemplate<CPDF_Object*> new_objs_array; FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); m_objs_array.RemoveAll(); if (!bRet) { @@ -4570,7 +4571,7 @@ IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( } m_bLinearizedFormParamLoad = TRUE; } - CFX_PtrArray new_objs_array; + CFX_ArrayTemplate<CPDF_Object*> new_objs_array; FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); m_objs_array.RemoveAll(); if (!bRet) { @@ -4609,10 +4610,8 @@ FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t& iNext) { return FALSE; } CPDF_PageNode::~CPDF_PageNode() { - int32_t iSize = m_childNode.GetSize(); - for (int32_t i = 0; i < iSize; ++i) { - CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; - delete pNode; + for (int32_t i = 0; i < m_childNode.GetSize(); ++i) { + delete m_childNode[i]; } m_childNode.RemoveAll(); } diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp index a714d38615..8cfa8dc4fb 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -358,10 +358,10 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text( const CPDF_TextObject* textobj, const CFX_AffineMatrix* pObj2Device) { CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->GetType3Font(); - for (int j = 0; j < m_Type3FontCache.GetSize(); j++) - if ((CPDF_Type3Font*)m_Type3FontCache.GetAt(j) == pType3Font) { + for (int j = 0; j < m_Type3FontCache.GetSize(); j++) { + if (m_Type3FontCache.GetAt(j) == pType3Font) return TRUE; - } + } CFX_Matrix dCTM = m_pDevice->GetCTM(); FX_FLOAT sa = FXSYS_fabs(dCTM.a); FX_FLOAT sd = FXSYS_fabs(dCTM.d); diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h index dbc9f1102b..d764c9a5ff 100644 --- a/core/src/fpdfapi/fpdf_render/render_int.h +++ b/core/src/fpdfapi/fpdf_render/render_int.h @@ -137,11 +137,12 @@ class CPDF_RenderStatus { FX_BOOL ContinueSingleObject(const CPDF_PageObject* pObj, const CFX_AffineMatrix* pObj2Device, IFX_Pause* pPause); + CPDF_RenderContext* GetContext() { return m_pContext; } + CPDF_RenderOptions m_Options; CPDF_Dictionary* m_pFormResource; CPDF_Dictionary* m_pPageResource; - CFX_PtrArray m_Type3FontCache; - CPDF_RenderContext* GetContext() { return m_pContext; } + CFX_ArrayTemplate<CPDF_Type3Font*> m_Type3FontCache; protected: friend class CPDF_ImageRenderer; diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index 07c54a08a8..2397d6b74a 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -36,7 +36,7 @@ class CFieldTree { public: struct _Node { _Node* parent; - CFX_PtrArray children; + CFX_ArrayTemplate<_Node*> children; CFX_WideString short_name; CPDF_FormField* field_ptr; int CountFields(int nLevel = 0) { @@ -48,7 +48,7 @@ class CFieldTree { } int count = 0; for (int i = 0; i < children.GetSize(); i++) { - count += ((_Node*)children.GetAt(i))->CountFields(nLevel + 1); + count += children.GetAt(i)->CountFields(nLevel + 1); } return count; } @@ -61,11 +61,8 @@ class CFieldTree { return NULL; } for (int i = 0; i < children.GetSize(); i++) { - _Node* pNode = (_Node*)children.GetAt(i); - CPDF_FormField* pField = pNode->GetField(fields_to_go); - if (pField) { + if (CPDF_FormField* pField = children.GetAt(i)->GetField(fields_to_go)) return pField; - } } return NULL; } @@ -109,17 +106,13 @@ CFieldTree::_Node* CFieldTree::AddChild(_Node* pParent, return pNode; } void CFieldTree::RemoveNode(_Node* pNode, int nLevel) { - if (pNode == NULL) { + if (!pNode) { return; } - if (nLevel > nMaxRecursion) { - delete pNode; - return; - } - CFX_PtrArray& ptr_array = pNode->children; - for (int i = 0; i < ptr_array.GetSize(); i++) { - _Node* pChild = (_Node*)ptr_array[i]; - RemoveNode(pChild, nLevel + 1); + if (nLevel <= nMaxRecursion) { + for (int i = 0; i < pNode->children.GetSize(); i++) { + RemoveNode(pNode->children[i], nLevel + 1); + } } delete pNode; } @@ -128,9 +121,8 @@ CFieldTree::_Node* CFieldTree::_Lookup(_Node* pParent, if (pParent == NULL) { return NULL; } - CFX_PtrArray& ptr_array = pParent->children; - for (int i = 0; i < ptr_array.GetSize(); i++) { - _Node* pNode = (_Node*)ptr_array[i]; + for (int i = 0; i < pParent->children.GetSize(); i++) { + _Node* pNode = pParent->children[i]; if (pNode->short_name.GetLength() == short_name.GetLength() && FXSYS_memcmp(pNode->short_name.c_str(), short_name.c_str(), short_name.GetLength() * sizeof(FX_WCHAR)) == 0) { @@ -140,10 +132,8 @@ CFieldTree::_Node* CFieldTree::_Lookup(_Node* pParent, return NULL; } void CFieldTree::RemoveAll() { - CFX_PtrArray& ptr_array = m_Root.children; - for (int i = 0; i < ptr_array.GetSize(); i++) { - _Node* pNode = (_Node*)ptr_array[i]; - RemoveNode(pNode); + for (int i = 0; i < m_Root.children.GetSize(); i++) { + RemoveNode(m_Root.children[i]); } } void CFieldTree::SetField(const CFX_WideString& full_name, @@ -202,10 +192,9 @@ CPDF_FormField* CFieldTree::RemoveField(const CFX_WideString& full_name) { name_extractor.GetNext(pName, nLength); } if (pNode && pNode != &m_Root) { - CFX_PtrArray& ptr_array = pLast->children; - for (int i = 0; i < ptr_array.GetSize(); i++) { - if (pNode == (_Node*)ptr_array[i]) { - ptr_array.RemoveAt(i); + for (int i = 0; i < pLast->children.GetSize(); i++) { + if (pNode == pLast->children[i]) { + pLast->children.RemoveAt(i); break; } } diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index 193ed21d45..e840665385 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -207,15 +207,12 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { return TRUE; } int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) { - if (pControl == NULL) { + if (!pControl) { return -1; } - int iCount = m_ControlList.GetSize(); - for (int i = 0; i < iCount; i++) { - CPDF_FormControl* pFind = (CPDF_FormControl*)m_ControlList.GetAt(i); - if (pFind == pControl) { + for (int i = 0; i < m_ControlList.GetSize(); i++) { + if (m_ControlList.GetAt(i) == pControl) return i; - } } return -1; } @@ -399,22 +396,19 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, FX_BOOL bNotify) { return SetValue(value, FALSE, bNotify); } int CPDF_FormField::GetMaxLen() { - CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen"); - if (pObj == NULL) { - int iCount = m_ControlList.GetSize(); - for (int i = 0; i < iCount; i++) { - CPDF_FormControl* pControl = (CPDF_FormControl*)m_ControlList.GetAt(i); - if (pControl == NULL) { - continue; - } - CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; - if (pWidgetDict->KeyExist("MaxLen")) { - return pWidgetDict->GetInteger("MaxLen"); - } - } - return 0; + if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen")) + return pObj->GetInteger(); + + for (int i = 0; i < m_ControlList.GetSize(); i++) { + CPDF_FormControl* pControl = m_ControlList.GetAt(i); + if (!pControl) + continue; + + CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; + if (pWidgetDict->KeyExist("MaxLen")) + return pWidgetDict->GetInteger("MaxLen"); } - return pObj->GetInteger(); + return 0; } int CPDF_FormField::CountSelectedItems() { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); diff --git a/core/src/fpdfdoc/tagged_int.h b/core/src/fpdfdoc/tagged_int.h index b7f18bd177..b9ae86bc6a 100644 --- a/core/src/fpdfdoc/tagged_int.h +++ b/core/src/fpdfdoc/tagged_int.h @@ -53,7 +53,6 @@ class CPDF_StructElementImpl final : public CPDF_StructElement { const CPDF_StructKid& GetKid(int index) const override { return m_Kids.GetData()[index]; } - CFX_PtrArray* GetObjectArray() override { return &m_ObjectArray; } CPDF_Object* GetAttr(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, FX_BOOL bInheritable = FALSE, @@ -79,7 +78,6 @@ class CPDF_StructElementImpl final : public CPDF_StructElement { FX_BOOL bInheritable = FALSE, int subindex = -1) override; - CFX_PtrArray m_ObjectArray; void LoadKids(CPDF_Dictionary* pDict); void LoadKid(FX_DWORD PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid); CPDF_Object* GetAttr(const CFX_ByteStringC& owner, diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp index 0b7a849c75..e70d0e0e4b 100644 --- a/core/src/fpdftext/fpdf_text.cpp +++ b/core/src/fpdftext/fpdf_text.cpp @@ -41,12 +41,10 @@ CTextPage::CTextPage() {} CTextPage::~CTextPage() { int i; for (i = 0; i < m_BaseLines.GetSize(); i++) { - CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); - delete pBaseLine; + delete m_BaseLines.GetAt(i); } for (i = 0; i < m_TextColumns.GetSize(); i++) { - CTextColumn* pTextColumn = (CTextColumn*)m_TextColumns.GetAt(i); - delete pTextColumn; + delete m_TextColumns.GetAt(i); } } void CTextPage::ProcessObject(CPDF_PageObject* pObject) { @@ -173,7 +171,7 @@ CTextBaseLine* CTextPage::InsertTextBox(CTextBaseLine* pBaseLine, if (pBaseLine == NULL) { int i; for (i = 0; i < m_BaseLines.GetSize(); i++) { - CTextBaseLine* pExistLine = (CTextBaseLine*)m_BaseLines.GetAt(i); + CTextBaseLine* pExistLine = m_BaseLines.GetAt(i); if (pExistLine->m_BaseLine == basey) { pBaseLine = pExistLine; break; @@ -211,7 +209,7 @@ void CTextPage::WriteOutput(CFX_WideStringArray& lines, int iMinWidth) { FX_FLOAT MaxRightX = 0; int i; for (i = 0; i < m_BaseLines.GetSize(); i++) { - CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); + CTextBaseLine* pBaseLine = m_BaseLines.GetAt(i); FX_FLOAT leftx, rightx; if (pBaseLine->GetWidth(leftx, rightx)) { if (leftx < MinLeftX) { @@ -223,12 +221,11 @@ void CTextPage::WriteOutput(CFX_WideStringArray& lines, int iMinWidth) { } } for (i = 0; i < m_BaseLines.GetSize(); i++) { - CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); - pBaseLine->MergeBoxes(); + m_BaseLines.GetAt(i)->MergeBoxes(); } for (i = 1; i < m_BaseLines.GetSize(); i++) { - CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); - CTextBaseLine* pPrevLine = (CTextBaseLine*)m_BaseLines.GetAt(i - 1); + CTextBaseLine* pBaseLine = m_BaseLines.GetAt(i); + CTextBaseLine* pPrevLine = m_BaseLines.GetAt(i - 1); if (pBaseLine->CanMerge(pPrevLine)) { pPrevLine->Merge(pBaseLine); delete pBaseLine; @@ -240,7 +237,7 @@ void CTextPage::WriteOutput(CFX_WideStringArray& lines, int iMinWidth) { int* widths = FX_Alloc(int, m_BaseLines.GetSize()); for (i = 0; i < m_BaseLines.GetSize(); i++) { widths[i] = 0; - CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); + CTextBaseLine* pBaseLine = m_BaseLines.GetAt(i); int TotalChars = 0; FX_FLOAT TotalWidth = 0; int minchars; @@ -277,14 +274,13 @@ void CTextPage::WriteOutput(CFX_WideStringArray& lines, int iMinWidth) { } } for (i = 0; i < m_BaseLines.GetSize(); i++) { - CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); - pBaseLine->MergeBoxes(); + m_BaseLines.GetAt(i)->MergeBoxes(); } if (m_bKeepColumn) { FindColumns(); } for (i = 0; i < m_BaseLines.GetSize(); i++) { - CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); + CTextBaseLine* pBaseLine = m_BaseLines.GetAt(i); if (lastheight >= 0) { FX_FLOAT dy = lastbaseline - pBaseLine->m_BaseLine; if (dy >= (pBaseLine->m_MaxFontSizeV) * 1.5 || dy >= lastheight * 1.5) { @@ -448,9 +444,9 @@ static FX_BOOL IsNumber(CFX_WideString& str) { void CTextPage::FindColumns() { int i; for (i = 0; i < m_BaseLines.GetSize(); i++) { - CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); + CTextBaseLine* pBaseLine = m_BaseLines.GetAt(i); for (int j = 0; j < pBaseLine->m_TextList.GetSize(); j++) { - CTextBox* pTextBox = (CTextBox*)pBaseLine->m_TextList.GetAt(j); + CTextBox* pTextBox = pBaseLine->m_TextList.GetAt(j); CTextColumn* pColumn = FindColumn(pTextBox->m_Right); if (pColumn == NULL) { pColumn = new CTextColumn; @@ -468,7 +464,7 @@ void CTextPage::FindColumns() { } int mincount = m_BaseLines.GetSize() / 4; for (i = 0; i < m_TextColumns.GetSize(); i++) { - CTextColumn* pTextColumn = (CTextColumn*)m_TextColumns.GetAt(i); + CTextColumn* pTextColumn = m_TextColumns.GetAt(i); if (pTextColumn->m_Count >= mincount) { continue; } @@ -477,9 +473,9 @@ void CTextPage::FindColumns() { i--; } for (i = 0; i < m_BaseLines.GetSize(); i++) { - CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); + CTextBaseLine* pBaseLine = m_BaseLines.GetAt(i); for (int j = 0; j < pBaseLine->m_TextList.GetSize(); j++) { - CTextBox* pTextBox = (CTextBox*)pBaseLine->m_TextList.GetAt(j); + CTextBox* pTextBox = pBaseLine->m_TextList.GetAt(j); if (IsNumber(pTextBox->m_Text)) { pTextBox->m_pColumn = FindColumn(pTextBox->m_Right); } @@ -488,7 +484,7 @@ void CTextPage::FindColumns() { } CTextColumn* CTextPage::FindColumn(FX_FLOAT xpos) { for (int i = 0; i < m_TextColumns.GetSize(); i++) { - CTextColumn* pColumn = (CTextColumn*)m_TextColumns.GetAt(i); + CTextColumn* pColumn = m_TextColumns.GetAt(i); if (pColumn->m_AvgPos < xpos + 1 && pColumn->m_AvgPos > xpos - 1) { return pColumn; } @@ -503,8 +499,7 @@ CTextBaseLine::CTextBaseLine() { } CTextBaseLine::~CTextBaseLine() { for (int i = 0; i < m_TextList.GetSize(); i++) { - CTextBox* pText = (CTextBox*)m_TextList.GetAt(i); - delete pText; + delete m_TextList.GetAt(i); } } void CTextBaseLine::InsertTextBox(FX_FLOAT leftx, @@ -525,7 +520,7 @@ void CTextBaseLine::InsertTextBox(FX_FLOAT leftx, } int i; for (i = 0; i < m_TextList.GetSize(); i++) { - CTextBox* pText = (CTextBox*)m_TextList.GetAt(i); + CTextBox* pText = m_TextList.GetAt(i); if (pText->m_Left > leftx) { break; } @@ -560,9 +555,9 @@ FX_BOOL CTextBaseLine::CanMerge(CTextBaseLine* pOther) { } FX_FLOAT dy = (FX_FLOAT)FXSYS_fabs(m_BaseLine - pOther->m_BaseLine); for (int i = 0; i < m_TextList.GetSize(); i++) { - CTextBox* pText = (CTextBox*)m_TextList.GetAt(i); + CTextBox* pText = m_TextList.GetAt(i); for (int j = 0; j < pOther->m_TextList.GetSize(); j++) { - CTextBox* pOtherText = (CTextBox*)pOther->m_TextList.GetAt(j); + CTextBox* pOtherText = pOther->m_TextList.GetAt(j); FX_FLOAT inter_left, inter_right; if (!GetIntersection(pText->m_Left, pText->m_Right, pOtherText->m_Left, pOtherText->m_Right, inter_left, inter_right)) { @@ -583,7 +578,7 @@ FX_BOOL CTextBaseLine::CanMerge(CTextBaseLine* pOther) { } void CTextBaseLine::Merge(CTextBaseLine* pOther) { for (int i = 0; i < pOther->m_TextList.GetSize(); i++) { - CTextBox* pText = (CTextBox*)pOther->m_TextList.GetAt(i); + CTextBox* pText = pOther->m_TextList.GetAt(i); InsertTextBox(pText->m_Left, pText->m_Right, pText->m_Top, pText->m_Bottom, pText->m_SpaceWidth, pText->m_FontSizeV, pText->m_Text); } @@ -591,7 +586,7 @@ void CTextBaseLine::Merge(CTextBaseLine* pOther) { FX_BOOL CTextBaseLine::GetWidth(FX_FLOAT& leftx, FX_FLOAT& rightx) { int i; for (i = 0; i < m_TextList.GetSize(); i++) { - CTextBox* pText = (CTextBox*)m_TextList.GetAt(i); + CTextBox* pText = m_TextList.GetAt(i); if (pText->m_Text != L" ") { break; } @@ -599,15 +594,15 @@ FX_BOOL CTextBaseLine::GetWidth(FX_FLOAT& leftx, FX_FLOAT& rightx) { if (i == m_TextList.GetSize()) { return FALSE; } - CTextBox* pText = (CTextBox*)m_TextList.GetAt(i); + CTextBox* pText = m_TextList.GetAt(i); leftx = pText->m_Left; for (i = m_TextList.GetSize() - 1; i >= 0; i--) { - CTextBox* pText = (CTextBox*)m_TextList.GetAt(i); + CTextBox* pText = m_TextList.GetAt(i); if (pText->m_Text != L" ") { break; } } - pText = (CTextBox*)m_TextList.GetAt(i); + pText = m_TextList.GetAt(i); rightx = pText->m_Right; return TRUE; } @@ -617,8 +612,8 @@ void CTextBaseLine::MergeBoxes() { if (i >= m_TextList.GetSize() - 1) { break; } - CTextBox* pThisText = (CTextBox*)m_TextList.GetAt(i); - CTextBox* pNextText = (CTextBox*)m_TextList.GetAt(i + 1); + CTextBox* pThisText = m_TextList.GetAt(i); + CTextBox* pNextText = m_TextList.GetAt(i + 1); FX_FLOAT dx = pNextText->m_Left - pThisText->m_Right; FX_FLOAT spacew = (pThisText->m_SpaceWidth == 0.0) ? pNextText->m_SpaceWidth @@ -646,7 +641,7 @@ void CTextBaseLine::WriteOutput(CFX_WideString& str, int iTextWidth) { int lastpos = -1; for (int i = 0; i < m_TextList.GetSize(); i++) { - CTextBox* pText = (CTextBox*)m_TextList.GetAt(i); + CTextBox* pText = m_TextList.GetAt(i); int xpos; if (pText->m_pColumn) { xpos = @@ -672,7 +667,7 @@ void CTextBaseLine::WriteOutput(CFX_WideString& str, void CTextBaseLine::CountChars(int& count, FX_FLOAT& width, int& minchars) { minchars = 0; for (int i = 0; i < m_TextList.GetSize(); i++) { - CTextBox* pText = (CTextBox*)m_TextList.GetAt(i); + CTextBox* pText = m_TextList.GetAt(i); if (pText->m_Right - pText->m_Left < 0.002) { continue; } diff --git a/core/src/fpdftext/txtproc.h b/core/src/fpdftext/txtproc.h index 22088f2450..27cec5d0a6 100644 --- a/core/src/fpdftext/txtproc.h +++ b/core/src/fpdftext/txtproc.h @@ -48,7 +48,7 @@ class CTextBaseLine { FX_FLOAT m_Top; FX_FLOAT m_Bottom; FX_FLOAT m_MaxFontSizeV; - CFX_PtrArray m_TextList; + CFX_ArrayTemplate<CTextBox*> m_TextList; }; class CPDF_PageObject; class CPDF_TextObject; @@ -73,11 +73,12 @@ class CTextPage { FX_BOOL m_bBreakSpace; private: - CFX_PtrArray m_BaseLines; - CFX_PtrArray m_TextColumns; void FindColumns(); CTextColumn* FindColumn(FX_FLOAT xpos); void BreakSpace(CPDF_TextObject* pTextObj); + + CFX_ArrayTemplate<CTextBaseLine*> m_BaseLines; + CFX_ArrayTemplate<CTextColumn*> m_TextColumns; }; #endif // CORE_SRC_FPDFTEXT_TXTPROC_H_ diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index a23eab5c58..58b0457a7c 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -99,7 +99,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { ~CFX_MemoryStream() override { if (m_dwFlags & FX_MEMSTREAM_TakeOver) { for (int32_t i = 0; i < m_Blocks.GetSize(); i++) { - FX_Free((uint8_t*)m_Blocks[i]); + FX_Free(m_Blocks[i]); } } m_Blocks.RemoveAll(); @@ -134,7 +134,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { m_nCurPos = newPos.ValueOrDie(); if (m_dwFlags & FX_MEMSTREAM_Consecutive) { - FXSYS_memcpy(buffer, (uint8_t*)m_Blocks[0] + (size_t)offset, size); + FXSYS_memcpy(buffer, m_Blocks[0] + (size_t)offset, size); return TRUE; } size_t nStartBlock = (size_t)offset / m_nGrowSize; @@ -144,8 +144,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { if (nRead > size) { nRead = size; } - FXSYS_memcpy( - buffer, (uint8_t*)m_Blocks[(int)nStartBlock] + (size_t)offset, nRead); + FXSYS_memcpy(buffer, m_Blocks[(int)nStartBlock] + (size_t)offset, nRead); buffer = ((uint8_t*)buffer) + nRead; size -= nRead; nStartBlock++; @@ -180,7 +179,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { m_nTotalSize = (m_nCurPos + m_nGrowSize - 1) / m_nGrowSize * m_nGrowSize; if (m_Blocks.GetSize() < 1) { - void* block = FX_Alloc(uint8_t, m_nTotalSize); + uint8_t* block = FX_Alloc(uint8_t, m_nTotalSize); m_Blocks.Add(block); } else { m_Blocks[0] = FX_Realloc(uint8_t, m_Blocks[0], m_nTotalSize); @@ -190,7 +189,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { return FALSE; } } - FXSYS_memcpy((uint8_t*)m_Blocks[0] + (size_t)offset, buffer, size); + FXSYS_memcpy(m_Blocks[0] + (size_t)offset, buffer, size); if (m_nCurSize < m_nCurPos) { m_nCurSize = m_nCurPos; } @@ -214,8 +213,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { if (nWrite > size) { nWrite = size; } - FXSYS_memcpy((uint8_t*)m_Blocks[(int)nStartBlock] + (size_t)offset, - buffer, nWrite); + FXSYS_memcpy(m_Blocks[(int)nStartBlock] + (size_t)offset, buffer, nWrite); buffer = ((uint8_t*)buffer) + nWrite; size -= nWrite; nStartBlock++; @@ -239,7 +237,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { } } uint8_t* GetBuffer() const override { - return m_Blocks.GetSize() ? (uint8_t*)m_Blocks[0] : NULL; + return m_Blocks.GetSize() ? m_Blocks[0] : nullptr; } void AttachBuffer(uint8_t* pBuffer, size_t nSize, @@ -264,7 +262,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { } protected: - CFX_PtrArray m_Blocks; + CFX_ArrayTemplate<uint8_t*> m_Blocks; FX_DWORD m_dwCount; size_t m_nTotalSize; size_t m_nCurSize; diff --git a/core/src/fxge/agg/include/fx_agg_driver.h b/core/src/fxge/agg/include/fx_agg_driver.h index 77d2f2af6e..0e79a3fc5e 100644 --- a/core/src/fxge/agg/include/fx_agg_driver.h +++ b/core/src/fxge/agg/include/fx_agg_driver.h @@ -137,7 +137,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { CFX_DIBitmap* m_pBitmap; CFX_ClipRgn* m_pClipRgn; - CFX_PtrArray m_StateStack; + CFX_ArrayTemplate<CFX_ClipRgn*> m_StateStack; void* m_pPlatformGraphics; void* m_pPlatformBitmap; void* m_pDwRenderTartget; diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp index 78186a8f96..4b3389bb4c 100644 --- a/core/src/fxge/agg/src/fx_agg_driver.cpp +++ b/core/src/fxge/agg/src/fx_agg_driver.cpp @@ -211,7 +211,7 @@ CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, CFX_AggDeviceDriver::~CFX_AggDeviceDriver() { delete m_pClipRgn; for (int i = 0; i < m_StateStack.GetSize(); i++) - delete (CFX_ClipRgn*)m_StateStack[i]; + delete m_StateStack[i]; DestroyPlatform(); } #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ @@ -266,7 +266,7 @@ int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) { return 0; } void CFX_AggDeviceDriver::SaveState() { - void* pClip = NULL; + CFX_ClipRgn* pClip = NULL; if (m_pClipRgn) { pClip = new CFX_ClipRgn(*m_pClipRgn); } @@ -278,8 +278,7 @@ void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) { m_pClipRgn = NULL; return; } - CFX_ClipRgn* pSavedClip = - (CFX_ClipRgn*)m_StateStack[m_StateStack.GetSize() - 1]; + CFX_ClipRgn* pSavedClip = m_StateStack[m_StateStack.GetSize() - 1]; delete m_pClipRgn; m_pClipRgn = NULL; if (bKeepSaved) { |