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