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

Side by Side Diff: fpdfsdk/fxedit/fxet_edit.cpp

Issue 2323493002: Pass CFX_WideString further down widget callers (Closed)
Patch Set: Null vs Empty string significant in places Created 4 years, 3 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
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 "fpdfsdk/fxedit/include/fxet_edit.h" 7 #include "fpdfsdk/fxedit/include/fxet_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 m_pEdit->SelectNone(); 699 m_pEdit->SelectNone();
700 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); 700 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos);
701 m_pEdit->Clear(FALSE, TRUE); 701 m_pEdit->Clear(FALSE, TRUE);
702 } 702 }
703 } 703 }
704 704
705 void CFXEU_Clear::Undo() { 705 void CFXEU_Clear::Undo() {
706 if (m_pEdit) { 706 if (m_pEdit) {
707 m_pEdit->SelectNone(); 707 m_pEdit->SelectNone();
708 m_pEdit->SetCaret(m_wrSel.BeginPos); 708 m_pEdit->SetCaret(m_wrSel.BeginPos);
709 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, FALSE, TRUE); 709 m_pEdit->InsertText(m_swText, DEFAULT_CHARSET, FALSE, TRUE);
710 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); 710 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos);
711 } 711 }
712 } 712 }
713 713
714 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit, 714 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit,
715 const CPVT_WordPlace& wpOldPlace, 715 const CPVT_WordPlace& wpOldPlace,
716 const CPVT_WordPlace& wpNewPlace, 716 const CPVT_WordPlace& wpNewPlace,
717 const CFX_WideString& swText, 717 const CFX_WideString& swText,
718 int32_t charset) 718 int32_t charset)
719 : m_pEdit(pEdit), 719 : m_pEdit(pEdit),
720 m_wpOld(wpOldPlace), 720 m_wpOld(wpOldPlace),
721 m_wpNew(wpNewPlace), 721 m_wpNew(wpNewPlace),
722 m_swText(swText), 722 m_swText(swText),
723 m_nCharset(charset) {} 723 m_nCharset(charset) {}
724 724
725 CFXEU_InsertText::~CFXEU_InsertText() {} 725 CFXEU_InsertText::~CFXEU_InsertText() {}
726 726
727 void CFXEU_InsertText::Redo() { 727 void CFXEU_InsertText::Redo() {
728 if (m_pEdit && IsLast()) { 728 if (m_pEdit && IsLast()) {
729 m_pEdit->SelectNone(); 729 m_pEdit->SelectNone();
730 m_pEdit->SetCaret(m_wpOld); 730 m_pEdit->SetCaret(m_wpOld);
731 m_pEdit->InsertText(m_swText.c_str(), m_nCharset, FALSE, TRUE); 731 m_pEdit->InsertText(m_swText, m_nCharset, FALSE, TRUE);
732 } 732 }
733 } 733 }
734 734
735 void CFXEU_InsertText::Undo() { 735 void CFXEU_InsertText::Undo() {
736 if (m_pEdit) { 736 if (m_pEdit) {
737 m_pEdit->SelectNone(); 737 m_pEdit->SelectNone();
738 m_pEdit->SetSel(m_wpOld, m_wpNew); 738 m_pEdit->SetSel(m_wpOld, m_wpNew);
739 m_pEdit->Clear(FALSE, TRUE); 739 m_pEdit->Clear(FALSE, TRUE);
740 } 740 }
741 } 741 }
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 1663
1664 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { 1664 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) {
1665 wrRet.EndPos = wr2.EndPos; 1665 wrRet.EndPos = wr2.EndPos;
1666 } else { 1666 } else {
1667 wrRet.EndPos = wr1.EndPos; 1667 wrRet.EndPos = wr1.EndPos;
1668 } 1668 }
1669 1669
1670 return wrRet; 1670 return wrRet;
1671 } 1671 }
1672 1672
1673 void CFX_Edit::SetText(const FX_WCHAR* text) { 1673 void CFX_Edit::SetText(const CFX_WideString& sText) {
dsinclair 2016/09/08 13:00:11 May as well leave this as |text| to match the rest
Tom Sepez 2016/09/08 18:01:11 Fixed the others, too.
1674 Empty(); 1674 Empty();
1675 DoInsertText(CPVT_WordPlace(0, 0, -1), text, DEFAULT_CHARSET); 1675 DoInsertText(CPVT_WordPlace(0, 0, -1), sText, DEFAULT_CHARSET);
1676 Paint(); 1676 Paint();
1677 } 1677 }
1678 1678
1679 FX_BOOL CFX_Edit::InsertWord(uint16_t word, int32_t charset) { 1679 FX_BOOL CFX_Edit::InsertWord(uint16_t word, int32_t charset) {
1680 return InsertWord(word, charset, nullptr, TRUE, TRUE); 1680 return InsertWord(word, charset, nullptr, TRUE, TRUE);
1681 } 1681 }
1682 1682
1683 FX_BOOL CFX_Edit::InsertReturn() { 1683 FX_BOOL CFX_Edit::InsertReturn() {
1684 return InsertReturn(nullptr, nullptr, TRUE, TRUE); 1684 return InsertReturn(nullptr, nullptr, TRUE, TRUE);
1685 } 1685 }
1686 1686
1687 FX_BOOL CFX_Edit::Backspace() { 1687 FX_BOOL CFX_Edit::Backspace() {
1688 return Backspace(TRUE, TRUE); 1688 return Backspace(TRUE, TRUE);
1689 } 1689 }
1690 1690
1691 FX_BOOL CFX_Edit::Delete() { 1691 FX_BOOL CFX_Edit::Delete() {
1692 return Delete(TRUE, TRUE); 1692 return Delete(TRUE, TRUE);
1693 } 1693 }
1694 1694
1695 FX_BOOL CFX_Edit::Clear() { 1695 FX_BOOL CFX_Edit::Clear() {
1696 return Clear(TRUE, TRUE); 1696 return Clear(TRUE, TRUE);
1697 } 1697 }
1698 1698
1699 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset) { 1699 FX_BOOL CFX_Edit::InsertText(const CFX_WideString& text, int32_t charset) {
1700 return InsertText(text, charset, TRUE, TRUE); 1700 return InsertText(text, charset, TRUE, TRUE);
1701 } 1701 }
1702 1702
1703 FX_FLOAT CFX_Edit::GetFontSize() const { 1703 FX_FLOAT CFX_Edit::GetFontSize() const {
1704 return m_pVT->GetFontSize(); 1704 return m_pVT->GetFontSize();
1705 } 1705 }
1706 1706
1707 uint16_t CFX_Edit::GetPasswordChar() const { 1707 uint16_t CFX_Edit::GetPasswordChar() const {
1708 return m_pVT->GetPasswordChar(); 1708 return m_pVT->GetPasswordChar();
1709 } 1709 }
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 SetCaretOrigin(); 2678 SetCaretOrigin();
2679 SetCaretInfo(); 2679 SetCaretInfo();
2680 } 2680 }
2681 2681
2682 if (m_bOprNotify && m_pOprNotify) 2682 if (m_bOprNotify && m_pOprNotify)
2683 m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret); 2683 m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret);
2684 2684
2685 return TRUE; 2685 return TRUE;
2686 } 2686 }
2687 2687
2688 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, 2688 FX_BOOL CFX_Edit::InsertText(const CFX_WideString& text,
2689 int32_t charset, 2689 int32_t charset,
2690 FX_BOOL bAddUndo, 2690 FX_BOOL bAddUndo,
2691 FX_BOOL bPaint) { 2691 FX_BOOL bPaint) {
2692 if (IsTextOverflow()) 2692 if (IsTextOverflow())
2693 return FALSE; 2693 return FALSE;
2694 2694
2695 m_pVT->UpdateWordPlace(m_wpCaret); 2695 m_pVT->UpdateWordPlace(m_wpCaret);
2696 SetCaret(DoInsertText(m_wpCaret, text, charset)); 2696 SetCaret(DoInsertText(m_wpCaret, text, charset));
2697 m_SelState.Set(m_wpCaret, m_wpCaret); 2697 m_SelState.Set(m_wpCaret, m_wpCaret);
2698 2698
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 pIterator->SetAt(place); 2876 pIterator->SetAt(place);
2877 CPVT_Line line; 2877 CPVT_Line line;
2878 pIterator->GetLine(line); 2878 pIterator->GetLine(line);
2879 2879
2880 pIterator->SetAt(wpOld); 2880 pIterator->SetAt(wpOld);
2881 2881
2882 return line.ptLine.y + line.fLineDescent; 2882 return line.ptLine.y + line.fLineDescent;
2883 } 2883 }
2884 2884
2885 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, 2885 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place,
2886 const FX_WCHAR* text, 2886 const CFX_WideString& sText,
dsinclair 2016/09/08 13:00:11 ditto
Tom Sepez 2016/09/08 18:01:12 Others match this.
2887 int32_t charset) { 2887 int32_t charset) {
2888 CPVT_WordPlace wp = place; 2888 CPVT_WordPlace wp = place;
2889 2889
2890 if (m_pVT->IsValid()) { 2890 if (m_pVT->IsValid()) {
2891 CFX_WideString sText = text;
2892
2893 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) { 2891 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) {
2894 uint16_t word = sText[i]; 2892 uint16_t word = sText[i];
2895 switch (word) { 2893 switch (word) {
2896 case 0x0D: 2894 case 0x0D:
2897 wp = m_pVT->InsertSection(wp, nullptr, nullptr); 2895 wp = m_pVT->InsertSection(wp, nullptr, nullptr);
2898 if (sText[i + 1] == 0x0A) 2896 if (sText[i + 1] == 0x0A)
2899 i++; 2897 i++;
2900 break; 2898 break;
2901 case 0x0A: 2899 case 0x0A:
2902 wp = m_pVT->InsertSection(wp, nullptr, nullptr); 2900 wp = m_pVT->InsertSection(wp, nullptr, nullptr);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3056 int32_t CFX_Edit_RectArray::GetSize() const { 3054 int32_t CFX_Edit_RectArray::GetSize() const {
3057 return m_Rects.GetSize(); 3055 return m_Rects.GetSize();
3058 } 3056 }
3059 3057
3060 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { 3058 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const {
3061 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) 3059 if (nIndex < 0 || nIndex >= m_Rects.GetSize())
3062 return nullptr; 3060 return nullptr;
3063 3061
3064 return m_Rects.GetAt(nIndex); 3062 return m_Rects.GetAt(nIndex);
3065 } 3063 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698