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 "fpdfsdk/include/pdfwindow/PWL_Edit.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" |
8 | 8 |
9 #include "core/include/fxcrt/fx_safe_types.h" | 9 #include "core/include/fxcrt/fx_safe_types.h" |
10 #include "core/include/fxcrt/fx_xml.h" | 10 #include "core/include/fxcrt/fx_xml.h" |
11 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h" | 11 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h" |
12 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" | 12 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" |
13 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" | 13 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" |
14 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" | 14 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" |
15 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 15 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
16 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 16 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
17 #include "public/fpdf_fwlevent.h" | 17 #include "public/fpdf_fwlevent.h" |
| 18 #include "third_party/base/stl_util.h" |
18 | 19 |
19 CPWL_Edit::CPWL_Edit() | 20 CPWL_Edit::CPWL_Edit() |
20 : m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) { | 21 : m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) { |
21 m_pFormFiller = NULL; | 22 m_pFormFiller = NULL; |
22 } | 23 } |
23 | 24 |
24 CPWL_Edit::~CPWL_Edit() { | 25 CPWL_Edit::~CPWL_Edit() { |
25 ASSERT(m_bFocus == FALSE); | 26 ASSERT(m_bFocus == FALSE); |
26 } | 27 } |
27 | 28 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 | 513 |
513 SetFocus(); | 514 SetFocus(); |
514 | 515 |
515 CPVT_WordRange wrLatin = GetLatinWordsRange(point); | 516 CPVT_WordRange wrLatin = GetLatinWordsRange(point); |
516 CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin); | 517 CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin); |
517 | 518 |
518 FX_HMENU hPopup = pSH->CreatePopupMenu(); | 519 FX_HMENU hPopup = pSH->CreatePopupMenu(); |
519 if (!hPopup) | 520 if (!hPopup) |
520 return FALSE; | 521 return FALSE; |
521 | 522 |
522 CFX_ByteStringArray sSuggestWords; | 523 std::vector<CFX_ByteString> sSuggestWords; |
523 CPDF_Point ptPopup = point; | 524 CPDF_Point ptPopup = point; |
524 | 525 |
525 if (!IsReadOnly()) { | 526 if (!IsReadOnly()) { |
526 if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) { | 527 if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) { |
527 if (m_pSpellCheck) { | 528 if (m_pSpellCheck) { |
528 CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin); | 529 CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin); |
529 | |
530 if (!m_pSpellCheck->CheckWord(sLatin)) { | 530 if (!m_pSpellCheck->CheckWord(sLatin)) { |
531 m_pSpellCheck->SuggestWords(sLatin, sSuggestWords); | 531 m_pSpellCheck->SuggestWords(sLatin, sSuggestWords); |
532 | 532 |
533 int32_t nSuggest = sSuggestWords.GetSize(); | 533 int32_t nSuggest = pdfium::CollectionSize<int32_t>(sSuggestWords); |
534 | |
535 for (int32_t nWord = 0; nWord < nSuggest; nWord++) { | 534 for (int32_t nWord = 0; nWord < nSuggest; nWord++) { |
536 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord, | 535 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord, |
537 sSuggestWords[nWord].UTF8Decode()); | 536 sSuggestWords[nWord].UTF8Decode()); |
538 } | 537 } |
539 | |
540 if (nSuggest > 0) | 538 if (nSuggest > 0) |
541 pSH->AppendMenuItem(hPopup, 0, L""); | 539 pSH->AppendMenuItem(hPopup, 0, L""); |
542 | 540 |
543 ptPopup = GetWordRightBottomPoint(wrLatin.EndPos); | 541 ptPopup = GetWordRightBottomPoint(wrLatin.EndPos); |
544 } | 542 } |
545 } | 543 } |
546 } | 544 } |
547 } | 545 } |
548 | 546 |
549 IPWL_Provider* pProvider = GetProvider(); | 547 IPWL_Provider* pProvider = GetProvider(); |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 } | 1176 } |
1179 | 1177 |
1180 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pPageObjects, | 1178 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pPageObjects, |
1181 const CPDF_Point& ptOffset) { | 1179 const CPDF_Point& ptOffset) { |
1182 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 1180 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
1183 IFX_Edit::GeneratePageObjects( | 1181 IFX_Edit::GeneratePageObjects( |
1184 pPageObjects, m_pEdit, ptOffset, NULL, | 1182 pPageObjects, m_pEdit, ptOffset, NULL, |
1185 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1183 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
1186 ObjArray); | 1184 ObjArray); |
1187 } | 1185 } |
OLD | NEW |