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

Unified Diff: fpdfsdk/fxedit/fxet_edit.cpp

Issue 2323493002: Pass CFX_WideString further down widget callers (Closed)
Patch Set: Fix comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/formfiller/cffl_iformfiller.cpp ('k') | fpdfsdk/fxedit/include/fxet_edit.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fxedit/fxet_edit.cpp
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 7d207a83caaee26fc8eb5ac3cf3001cd8f659efe..7aa8534a0a5592df4e436e7e330d4ebb363f2424 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -706,7 +706,7 @@ void CFXEU_Clear::Undo() {
if (m_pEdit) {
m_pEdit->SelectNone();
m_pEdit->SetCaret(m_wrSel.BeginPos);
- m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, FALSE, TRUE);
+ m_pEdit->InsertText(m_swText, DEFAULT_CHARSET, FALSE, TRUE);
m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos);
}
}
@@ -728,7 +728,7 @@ void CFXEU_InsertText::Redo() {
if (m_pEdit && IsLast()) {
m_pEdit->SelectNone();
m_pEdit->SetCaret(m_wpOld);
- m_pEdit->InsertText(m_swText.c_str(), m_nCharset, FALSE, TRUE);
+ m_pEdit->InsertText(m_swText, m_nCharset, FALSE, TRUE);
}
}
@@ -1670,9 +1670,9 @@ CPVT_WordRange CFX_Edit::CombineWordRange(const CPVT_WordRange& wr1,
return wrRet;
}
-void CFX_Edit::SetText(const FX_WCHAR* text) {
+void CFX_Edit::SetText(const CFX_WideString& sText) {
Empty();
- DoInsertText(CPVT_WordPlace(0, 0, -1), text, DEFAULT_CHARSET);
+ DoInsertText(CPVT_WordPlace(0, 0, -1), sText, DEFAULT_CHARSET);
Paint();
}
@@ -1696,8 +1696,8 @@ FX_BOOL CFX_Edit::Clear() {
return Clear(TRUE, TRUE);
}
-FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset) {
- return InsertText(text, charset, TRUE, TRUE);
+FX_BOOL CFX_Edit::InsertText(const CFX_WideString& sText, int32_t charset) {
+ return InsertText(sText, charset, TRUE, TRUE);
}
FX_FLOAT CFX_Edit::GetFontSize() const {
@@ -2685,7 +2685,7 @@ FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint) {
return TRUE;
}
-FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text,
+FX_BOOL CFX_Edit::InsertText(const CFX_WideString& sText,
int32_t charset,
FX_BOOL bAddUndo,
FX_BOOL bPaint) {
@@ -2693,24 +2693,23 @@ FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text,
return FALSE;
m_pVT->UpdateWordPlace(m_wpCaret);
- SetCaret(DoInsertText(m_wpCaret, text, charset));
+ SetCaret(DoInsertText(m_wpCaret, sText, charset));
m_SelState.Set(m_wpCaret, m_wpCaret);
+ if (m_wpCaret == m_wpOldCaret)
+ return FALSE;
- if (m_wpCaret != m_wpOldCaret) {
- if (bAddUndo && m_bEnableUndo) {
- AddEditUndoItem(
- new CFXEU_InsertText(this, m_wpOldCaret, m_wpCaret, text, charset));
- }
+ if (bAddUndo && m_bEnableUndo) {
+ AddEditUndoItem(
+ new CFXEU_InsertText(this, m_wpOldCaret, m_wpCaret, sText, charset));
+ }
- if (bPaint)
- PaintInsertText(m_wpOldCaret, m_wpCaret);
+ if (bPaint)
+ PaintInsertText(m_wpOldCaret, m_wpCaret);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
- return FALSE;
+ return TRUE;
}
void CFX_Edit::PaintInsertText(const CPVT_WordPlace& wpOld,
@@ -2883,13 +2882,11 @@ FX_FLOAT CFX_Edit::GetLineBottom(const CPVT_WordPlace& place) const {
}
CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place,
- const FX_WCHAR* text,
+ const CFX_WideString& sText,
int32_t charset) {
CPVT_WordPlace wp = place;
if (m_pVT->IsValid()) {
- CFX_WideString sText = text;
-
for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) {
uint16_t word = sText[i];
switch (word) {
« no previous file with comments | « fpdfsdk/formfiller/cffl_iformfiller.cpp ('k') | fpdfsdk/fxedit/include/fxet_edit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698