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 "core/include/fpdfapi/fpdf_page.h" | 7 #include "core/include/fpdfapi/fpdf_page.h" |
8 #include "core/include/fpdfapi/fpdf_pageobj.h" | 8 #include "core/include/fpdfapi/fpdf_pageobj.h" |
9 #include "core/include/fpdfapi/fpdf_resource.h" | 9 #include "core/include/fpdfapi/fpdf_resource.h" |
10 #include "core/include/fpdftext/fpdf_text.h" | 10 #include "core/include/fpdftext/fpdf_text.h" |
11 #include "core/include/fxcrt/fx_bidi.h" | 11 #include "core/include/fxcrt/fx_bidi.h" |
12 #include "core/include/fxcrt/fx_ucd.h" | 12 #include "core/include/fxcrt/fx_ucd.h" |
13 #include "text_int.h" | 13 #include "text_int.h" |
14 #include "third_party/base/nonstd_unique_ptr.h" | 14 #include "third_party/base/nonstd_unique_ptr.h" |
15 #include "txtproc.h" | 15 #include "txtproc.h" |
16 | 16 |
| 17 #include <cctype> |
| 18 |
17 CFX_ByteString CharFromUnicodeAlt(FX_WCHAR unicode, | 19 CFX_ByteString CharFromUnicodeAlt(FX_WCHAR unicode, |
18 int destcp, | 20 int destcp, |
19 const FX_CHAR* defchar) { | 21 const FX_CHAR* defchar) { |
20 if (destcp == 0) { | 22 if (destcp == 0) { |
21 if (unicode < 0x80) { | 23 if (unicode < 0x80) { |
22 return CFX_ByteString((char)unicode); | 24 return CFX_ByteString((char)unicode); |
23 } | 25 } |
24 const FX_CHAR* altstr = FCS_GetAltStr(unicode); | 26 const FX_CHAR* altstr = FCS_GetAltStr(unicode); |
25 return CFX_ByteString(altstr ? altstr : defchar); | 27 return CFX_ByteString(altstr ? altstr : defchar); |
26 } | 28 } |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } | 431 } |
430 } | 432 } |
431 } | 433 } |
432 } | 434 } |
433 str.Empty(); | 435 str.Empty(); |
434 str += sBuffer; | 436 str += sBuffer; |
435 } | 437 } |
436 static FX_BOOL IsNumber(CFX_WideString& str) { | 438 static FX_BOOL IsNumber(CFX_WideString& str) { |
437 for (int i = 0; i < str.GetLength(); i++) { | 439 for (int i = 0; i < str.GetLength(); i++) { |
438 FX_WCHAR ch = str[i]; | 440 FX_WCHAR ch = str[i]; |
439 if ((ch < '0' || ch > '9') && ch != '-' && ch != '+' && ch != '.' && | 441 // TODO(dsinclair): --.+ +.-- should probably not be a number. |
440 ch != ' ') { | 442 if (!std::iswdigit(ch) && ch != '-' && ch != '+' && ch != '.' && ch != ' ') |
441 return FALSE; | 443 return FALSE; |
442 } | |
443 } | 444 } |
444 return TRUE; | 445 return TRUE; |
445 } | 446 } |
446 void CTextPage::FindColumns() { | 447 void CTextPage::FindColumns() { |
447 int i; | 448 int i; |
448 for (i = 0; i < m_BaseLines.GetSize(); i++) { | 449 for (i = 0; i < m_BaseLines.GetSize(); i++) { |
449 CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); | 450 CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i); |
450 for (int j = 0; j < pBaseLine->m_TextList.GetSize(); j++) { | 451 for (int j = 0; j < pBaseLine->m_TextList.GetSize(); j++) { |
451 CTextBox* pTextBox = (CTextBox*)pBaseLine->m_TextList.GetAt(j); | 452 CTextBox* pTextBox = (CTextBox*)pBaseLine->m_TextList.GetAt(j); |
452 CTextColumn* pColumn = FindColumn(pTextBox->m_Right); | 453 CTextColumn* pColumn = FindColumn(pTextBox->m_Right); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 FX_DWORD flags) { | 784 FX_DWORD flags) { |
784 buffer.EstimateSize(0, 10240); | 785 buffer.EstimateSize(0, 10240); |
785 CPDF_Page page; | 786 CPDF_Page page; |
786 page.Load(pDoc, pPage); | 787 page.Load(pDoc, pPage); |
787 CPDF_ParseOptions options; | 788 CPDF_ParseOptions options; |
788 options.m_bTextOnly = TRUE; | 789 options.m_bTextOnly = TRUE; |
789 options.m_bSeparateForm = FALSE; | 790 options.m_bSeparateForm = FALSE; |
790 page.ParseContent(&options); | 791 page.ParseContent(&options); |
791 GetTextStream_Unicode(buffer, &page, TRUE, NULL); | 792 GetTextStream_Unicode(buffer, &page, TRUE, NULL); |
792 } | 793 } |
OLD | NEW |