Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: core/src/reflow/reflowedtextpage.cpp

Issue 1084613006: Fix all remaining instances of FX_NEW. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: std::min Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/reflow/reflowedpage.cpp ('k') | core/src/reflow/reflowengine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <algorithm>
8
7 #include "reflowedtextpage.h" 9 #include "reflowedtextpage.h"
10
8 IPDF_TextPage* IPDF_TextPage::CreateReflowTextPage(IPDF_ReflowedPage* pRefPage) 11 IPDF_TextPage* IPDF_TextPage::CreateReflowTextPage(IPDF_ReflowedPage* pRefPage)
9 { 12 {
10 return FX_NEW CRF_TextPage(pRefPage); 13 return new CRF_TextPage(pRefPage);
11 } 14 }
12 CRF_TextPage::CRF_TextPage(IPDF_ReflowedPage* pRefPage) 15 CRF_TextPage::CRF_TextPage(IPDF_ReflowedPage* pRefPage)
13 { 16 {
14 m_pRefPage = (CPDF_ReflowedPage*)(pRefPage); 17 m_pRefPage = (CPDF_ReflowedPage*)(pRefPage);
15 m_pDataList = NULL; 18 m_pDataList = NULL;
16 m_CountBSArray = NULL; 19 m_CountBSArray = NULL;
17 } 20 }
18 CRF_TextPage::~CRF_TextPage() 21 CRF_TextPage::~CRF_TextPage()
19 { 22 {
20 if(m_pDataList) { 23 if(m_pDataList) {
21 delete m_pDataList; 24 delete m_pDataList;
22 m_pDataList = NULL; 25 m_pDataList = NULL;
23 } 26 }
24 if(m_CountBSArray) { 27 if(m_CountBSArray) {
25 delete m_CountBSArray; 28 delete m_CountBSArray;
26 m_CountBSArray = NULL; 29 m_CountBSArray = NULL;
27 } 30 }
28 } 31 }
29 FX_BOOL CRF_TextPage::ParseTextPage() 32 FX_BOOL CRF_TextPage::ParseTextPage()
30 { 33 {
31 if(!m_pRefPage) { 34 if(!m_pRefPage) {
32 return FALSE; 35 return FALSE;
33 } 36 }
34 int count = m_pRefPage->m_pReflowed->GetSize(); 37 int count = m_pRefPage->m_pReflowed->GetSize();
35 if(count < 500) { 38 m_pDataList = new CRF_CharDataPtrArray(std::min(count, 500));
36 m_pDataList = FX_NEW CRF_CharDataPtrArray(count);
37 } else {
38 m_pDataList = FX_NEW CRF_CharDataPtrArray(500);
39 }
40 if (NULL == m_pDataList) {
41 return FALSE;
42 }
43 for(int i = 0; i < count; i++) { 39 for(int i = 0; i < count; i++) {
44 CRF_Data* pData = (*(m_pRefPage->m_pReflowed))[i]; 40 CRF_Data* pData = (*(m_pRefPage->m_pReflowed))[i];
45 if(pData->GetType() == CRF_Data::Text) { 41 if(pData->GetType() == CRF_Data::Text) {
46 m_pDataList->Add((CRF_CharData*)pData); 42 m_pDataList->Add((CRF_CharData*)pData);
47 } 43 }
48 } 44 }
49 m_CountBSArray = FX_NEW CFX_CountBSINT32Array(20); 45 m_CountBSArray = new CFX_CountBSINT32Array(20);
50 if(NULL == m_CountBSArray) {
51 return FALSE;
52 }
53 return TRUE; 46 return TRUE;
54 } 47 }
55 FX_BOOL CRF_TextPage::IsParsered() const 48 FX_BOOL CRF_TextPage::IsParsered() const
56 { 49 {
57 if(m_pDataList) { 50 if(m_pDataList) {
58 return TRUE; 51 return TRUE;
59 } 52 }
60 return FALSE; 53 return FALSE;
61 } 54 }
62 int CRF_TextPage::CharIndexFromTextIndex(int TextIndex) const 55 int CRF_TextPage::CharIndexFromTextIndex(int TextIndex) const
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 str += L"\r\n"; 386 str += L"\r\n";
394 recttmp = info.m_CharBox; 387 recttmp = info.m_CharBox;
395 str += info.m_Unicode; 388 str += info.m_Unicode;
396 } 389 }
397 } 390 }
398 if(str.IsEmpty()) { 391 if(str.IsEmpty()) {
399 return L""; 392 return L"";
400 } 393 }
401 return str; 394 return str;
402 } 395 }
OLDNEW
« no previous file with comments | « core/src/reflow/reflowedpage.cpp ('k') | core/src/reflow/reflowengine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698