summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp56
-rw-r--r--xfa/fde/cfde_txtedtengine.h11
2 files changed, 22 insertions, 45 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index be0270960d..38e43df257 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -193,7 +193,11 @@ void CFDE_TxtEdtEngine::ClearText() {
if (len == 0)
return;
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
- CFX_WideString wsText = GetPreDeleteText(0, len);
+ // This doesn't really make sense, if the cleared text isn't valid we
+ // don't clear it? But what if you want to clear and start again? Should
+ // this validation check be removed?
+ CFX_WideString wsText = GetText(0, GetTextLength());
+ wsText.Delete(0, len);
if (!m_Param.pEventSink->OnValidate(wsText))
return;
}
@@ -320,7 +324,7 @@ FDE_EditResult CFDE_TxtEdtEngine::Insert(const CFX_WideString& str) {
(m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz)) {
if (m_Param.dwMode & FDE_TEXTEDITMODE_Password) {
while (nLength > 0) {
- CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength);
+ CFX_WideString wsText = InsertIntoTextCopy(m_nCaret, lpBuffer, nLength);
int32_t nTotal = wsText.GetLength();
wchar_t* lpBuf = wsText.GetBuffer(nTotal);
for (int32_t i = 0; i < nTotal; i++) {
@@ -334,10 +338,10 @@ FDE_EditResult CFDE_TxtEdtEngine::Insert(const CFX_WideString& str) {
}
} else {
while (nLength > 0) {
- CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength);
- if (IsFitArea(wsText)) {
+ CFX_WideString wsText = InsertIntoTextCopy(m_nCaret, lpBuffer, nLength);
+ if (IsFitArea(wsText))
break;
- }
+
nLength--;
}
}
@@ -345,7 +349,7 @@ FDE_EditResult CFDE_TxtEdtEngine::Insert(const CFX_WideString& str) {
return FDE_EditResult::kFull;
}
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
- CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength);
+ CFX_WideString wsText = InsertIntoTextCopy(m_nCaret, lpBuffer, nLength);
if (!m_Param.pEventSink->OnValidate(wsText))
return FDE_EditResult::kInvalidate;
}
@@ -402,7 +406,12 @@ void CFDE_TxtEdtEngine::Delete(bool bBackspace) {
}
}
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
- CFX_WideString wsText = GetPreDeleteText(nStart, nCount);
+ // This doesn't really make sense, if the text with the character removed
+ // isn't valid we disallow the removal? Is that even possible as the string
+ // must have been valid in order to type the character in before hand?
+ // Should this check be removed?
+ CFX_WideString wsText = GetText(0, GetTextLength());
+ wsText.Delete(nStart, nCount);
if (!m_Param.pEventSink->OnValidate(wsText))
return;
}
@@ -555,16 +564,9 @@ int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag,
return i;
}
-CFX_WideString CFDE_TxtEdtEngine::GetPreDeleteText(int32_t nIndex,
- int32_t nLength) {
- CFX_WideString wsText = GetText(0, GetTextLength());
- wsText.Delete(nIndex, nLength);
- return wsText;
-}
-
-CFX_WideString CFDE_TxtEdtEngine::GetPreInsertText(int32_t nIndex,
- const wchar_t* lpText,
- int32_t nLength) {
+CFX_WideString CFDE_TxtEdtEngine::InsertIntoTextCopy(int32_t nIndex,
+ const wchar_t* lpText,
+ int32_t nLength) {
CFX_WideString wsText = GetText(0, GetTextLength());
int32_t nSelIndex = 0;
int32_t nSelLength = 0;
@@ -587,26 +589,6 @@ CFX_WideString CFDE_TxtEdtEngine::GetPreInsertText(int32_t nIndex,
return wsText;
}
-CFX_WideString CFDE_TxtEdtEngine::GetPreReplaceText(int32_t nIndex,
- int32_t nOriginLength,
- const wchar_t* lpText,
- int32_t nLength) {
- CFX_WideString wsText = GetText(0, GetTextLength());
- int32_t nSelIndex = 0;
- int32_t nSelLength = 0;
- int32_t nSelCount = CountSelRanges();
- while (nSelCount--) {
- nSelLength = GetSelRange(nSelCount, &nSelIndex);
- wsText.Delete(nSelIndex, nSelLength);
- }
- wsText.Delete(nIndex, nOriginLength);
- int32_t i = 0;
- for (i = 0; i < nLength; i++)
- wsText.Insert(nIndex++, lpText[i]);
-
- return wsText;
-}
-
void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
const CFX_WideString& wsText) {
const int32_t nLength = wsText.GetLength();
diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h
index 547cd57eae..f2bc62cd42 100644
--- a/xfa/fde/cfde_txtedtengine.h
+++ b/xfa/fde/cfde_txtedtengine.h
@@ -164,14 +164,9 @@ class CFDE_TxtEdtEngine {
bool IsLocked() const { return m_bLock; }
- CFX_WideString GetPreDeleteText(int32_t nIndex, int32_t nLength);
- CFX_WideString GetPreInsertText(int32_t nIndex,
- const wchar_t* lpText,
- int32_t nLength);
- CFX_WideString GetPreReplaceText(int32_t nIndex,
- int32_t nOriginLength,
- const wchar_t* lpText,
- int32_t nLength);
+ CFX_WideString InsertIntoTextCopy(int32_t nIndex,
+ const wchar_t* lpText,
+ int32_t nLength);
void DeleteRange_DoRecord(int32_t nStart, int32_t nCount, bool bSel);
void ResetEngine();