summaryrefslogtreecommitdiff
path: root/fpdfsdk/fxedit
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fxedit')
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp43
-rw-r--r--fpdfsdk/fxedit/include/fxet_edit.h8
2 files changed, 24 insertions, 27 deletions
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 7d207a83ca..7aa8534a0a 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) {
diff --git a/fpdfsdk/fxedit/include/fxet_edit.h b/fpdfsdk/fxedit/include/fxet_edit.h
index 9adf17271b..e0fca92dd2 100644
--- a/fpdfsdk/fxedit/include/fxet_edit.h
+++ b/fpdfsdk/fxedit/include/fxet_edit.h
@@ -470,13 +470,13 @@ class CFX_Edit {
void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl);
void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl);
void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl);
- void SetText(const FX_WCHAR* text);
+ void SetText(const CFX_WideString& sText);
FX_BOOL InsertWord(uint16_t word, int32_t charset);
FX_BOOL InsertReturn();
FX_BOOL Backspace();
FX_BOOL Delete();
FX_BOOL Clear();
- FX_BOOL InsertText(const FX_WCHAR* text, int32_t charset);
+ FX_BOOL InsertText(const CFX_WideString& sText, int32_t charset);
FX_BOOL Redo();
FX_BOOL Undo();
int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const;
@@ -525,7 +525,7 @@ class CFX_Edit {
FX_BOOL Empty();
CPVT_WordPlace DoInsertText(const CPVT_WordPlace& place,
- const FX_WCHAR* text,
+ const CFX_WideString& sText,
int32_t charset);
int32_t GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset);
@@ -563,7 +563,7 @@ class CFX_Edit {
FX_BOOL Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint);
FX_BOOL Delete(FX_BOOL bAddUndo, FX_BOOL bPaint);
FX_BOOL Clear(FX_BOOL bAddUndo, FX_BOOL bPaint);
- FX_BOOL InsertText(const FX_WCHAR* text,
+ FX_BOOL InsertText(const CFX_WideString& sText,
int32_t charset,
FX_BOOL bAddUndo,
FX_BOOL bPaint);