OLD | NEW |
---|---|
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 "reflowedtextpage.h" | 7 #include "reflowedtextpage.h" |
8 IPDF_TextPage* IPDF_TextPage::CreateReflowTextPage(IPDF_ReflowedPage* pRefPage) | 8 IPDF_TextPage* IPDF_TextPage::CreateReflowTextPage(IPDF_ReflowedPage* pRefPage) |
9 { | 9 { |
10 return FX_NEW CRF_TextPage(pRefPage); | 10 return new CRF_TextPage(pRefPage); |
11 } | 11 } |
12 CRF_TextPage::CRF_TextPage(IPDF_ReflowedPage* pRefPage) | 12 CRF_TextPage::CRF_TextPage(IPDF_ReflowedPage* pRefPage) |
13 { | 13 { |
14 m_pRefPage = (CPDF_ReflowedPage*)(pRefPage); | 14 m_pRefPage = (CPDF_ReflowedPage*)(pRefPage); |
15 m_pDataList = NULL; | 15 m_pDataList = NULL; |
16 m_CountBSArray = NULL; | 16 m_CountBSArray = NULL; |
17 } | 17 } |
18 CRF_TextPage::~CRF_TextPage() | 18 CRF_TextPage::~CRF_TextPage() |
19 { | 19 { |
20 if(m_pDataList) { | 20 if(m_pDataList) { |
21 delete m_pDataList; | 21 delete m_pDataList; |
22 m_pDataList = NULL; | 22 m_pDataList = NULL; |
23 } | 23 } |
24 if(m_CountBSArray) { | 24 if(m_CountBSArray) { |
25 delete m_CountBSArray; | 25 delete m_CountBSArray; |
26 m_CountBSArray = NULL; | 26 m_CountBSArray = NULL; |
27 } | 27 } |
28 } | 28 } |
29 FX_BOOL CRF_TextPage::ParseTextPage() | 29 FX_BOOL CRF_TextPage::ParseTextPage() |
30 { | 30 { |
31 if(!m_pRefPage) { | 31 if(!m_pRefPage) { |
32 return FALSE; | 32 return FALSE; |
33 } | 33 } |
34 int count = m_pRefPage->m_pReflowed->GetSize(); | 34 int count = m_pRefPage->m_pReflowed->GetSize(); |
35 if(count < 500) { | 35 m_pDataList = new CRF_CharDataPtrArray(count < 500 ? count : 500); |
Lei Zhang
2015/04/17 21:58:53
std::min()
Tom Sepez
2015/04/17 22:14:45
Done.
| |
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++) { | 36 for(int i = 0; i < count; i++) { |
44 CRF_Data* pData = (*(m_pRefPage->m_pReflowed))[i]; | 37 CRF_Data* pData = (*(m_pRefPage->m_pReflowed))[i]; |
45 if(pData->GetType() == CRF_Data::Text) { | 38 if(pData->GetType() == CRF_Data::Text) { |
46 m_pDataList->Add((CRF_CharData*)pData); | 39 m_pDataList->Add((CRF_CharData*)pData); |
47 } | 40 } |
48 } | 41 } |
49 m_CountBSArray = FX_NEW CFX_CountBSINT32Array(20); | 42 m_CountBSArray = new CFX_CountBSINT32Array(20); |
50 if(NULL == m_CountBSArray) { | |
51 return FALSE; | |
52 } | |
53 return TRUE; | 43 return TRUE; |
54 } | 44 } |
55 FX_BOOL CRF_TextPage::IsParsered() const | 45 FX_BOOL CRF_TextPage::IsParsered() const |
56 { | 46 { |
57 if(m_pDataList) { | 47 if(m_pDataList) { |
58 return TRUE; | 48 return TRUE; |
59 } | 49 } |
60 return FALSE; | 50 return FALSE; |
61 } | 51 } |
62 int CRF_TextPage::CharIndexFromTextIndex(int TextIndex) const | 52 int CRF_TextPage::CharIndexFromTextIndex(int TextIndex) const |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 str += L"\r\n"; | 383 str += L"\r\n"; |
394 recttmp = info.m_CharBox; | 384 recttmp = info.m_CharBox; |
395 str += info.m_Unicode; | 385 str += info.m_Unicode; |
396 } | 386 } |
397 } | 387 } |
398 if(str.IsEmpty()) { | 388 if(str.IsEmpty()) { |
399 return L""; | 389 return L""; |
400 } | 390 } |
401 return str; | 391 return str; |
402 } | 392 } |
OLD | NEW |