summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2016-11-24 10:45:29 -0500
committerChromium commit bot <commit-bot@chromium.org>2016-11-24 16:34:32 +0000
commit0354ccf37f05f25b1bf64fd60bb3b48efab4d7d0 (patch)
tree378745e450e4f02128ab6766d6ca71bd0b27f4ab
parent41ba08e5552c2eccad0c34024dc680feb3f2b251 (diff)
downloadpdfium-chromium/2933.tar.xz
Change TxtEdtEngine to return CFX_WideStringchromium/2935chromium/2934chromium/2933chromium/2932
This Cl updates the TxtEdtEngine and TxtEdtBuf to return CFX_WideStrings on a Get instead of taking an out param. The change is propagated out through the various Get methods that call into the edit engine. Change-Id: Iccf10a8ee06678ae3b59f3afd6e65308dacd16bd Reviewed-on: https://pdfium-review.googlesource.com/2070 Commit-Queue: ooo 11-24 -- 12-05 (dsinclair) <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
-rw-r--r--xfa/fde/cfde_txtedtbuf.cpp12
-rw-r--r--xfa/fde/cfde_txtedtbuf.h6
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp76
-rw-r--r--xfa/fde/cfde_txtedtengine.h24
-rw-r--r--xfa/fwl/core/cfwl_barcode.cpp3
-rw-r--r--xfa/fwl/core/cfwl_combobox.cpp45
-rw-r--r--xfa/fwl/core/cfwl_combobox.h4
-rw-r--r--xfa/fwl/core/cfwl_combolist.cpp3
-rw-r--r--xfa/fwl/core/cfwl_datetimepicker.cpp8
-rw-r--r--xfa/fwl/core/cfwl_datetimepicker.h4
-rw-r--r--xfa/fwl/core/cfwl_edit.cpp19
-rw-r--r--xfa/fwl/core/cfwl_edit.h4
-rw-r--r--xfa/fwl/core/cfwl_listbox.cpp21
-rw-r--r--xfa/fwl/core/cfwl_listbox.h6
-rw-r--r--xfa/fxfa/app/xfa_ffchoicelist.cpp9
-rw-r--r--xfa/fxfa/app/xfa_fftextedit.cpp19
16 files changed, 107 insertions, 156 deletions
diff --git a/xfa/fde/cfde_txtedtbuf.cpp b/xfa/fde/cfde_txtedtbuf.cpp
index b01081e3c9..94383c261c 100644
--- a/xfa/fde/cfde_txtedtbuf.cpp
+++ b/xfa/fde/cfde_txtedtbuf.cpp
@@ -67,8 +67,8 @@ void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) {
m_bChanged = true;
}
-void CFDE_TxtEdtBuf::GetText(CFX_WideString& wsText) const {
- GetRange(wsText, 0, m_nTotal);
+CFX_WideString CFDE_TxtEdtBuf::GetText() const {
+ return GetRange(0, m_nTotal);
}
FX_WCHAR CFDE_TxtEdtBuf::GetCharByIndex(int32_t nIndex) const {
@@ -88,13 +88,13 @@ FX_WCHAR CFDE_TxtEdtBuf::GetCharByIndex(int32_t nIndex) const {
return pChunkHeader->wChars[pChunkHeader->nUsed - (nTotal - nIndex)];
}
-void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
- int32_t nBegin,
- int32_t nLength) const {
+CFX_WideString CFDE_TxtEdtBuf::GetRange(int32_t nBegin, int32_t nLength) const {
FDE_CHUNKPLACE cp;
Index2CP(nBegin, cp);
int32_t nLeave = nLength;
int32_t nCount = m_Chunks.GetSize();
+
+ CFX_WideString wsText;
FX_WCHAR* lpDstBuf = wsText.GetBuffer(nLength);
int32_t nChunkIndex = cp.nChunkIndex;
FDE_CHUNKHEADER* lpChunkHeader = m_Chunks[nChunkIndex];
@@ -116,6 +116,8 @@ void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
nCopyLength = lpChunkHeader->nUsed;
}
wsText.ReleaseBuffer();
+
+ return wsText;
}
void CFDE_TxtEdtBuf::Insert(int32_t nPos,
diff --git a/xfa/fde/cfde_txtedtbuf.h b/xfa/fde/cfde_txtedtbuf.h
index f85dcb352a..ac25a080e5 100644
--- a/xfa/fde/cfde_txtedtbuf.h
+++ b/xfa/fde/cfde_txtedtbuf.h
@@ -23,11 +23,9 @@ class CFDE_TxtEdtBuf {
int32_t GetChunkSize() const;
int32_t GetTextLength() const;
void SetText(const CFX_WideString& wsText);
- void GetText(CFX_WideString& wsText) const;
+ CFX_WideString GetText() const;
FX_WCHAR GetCharByIndex(int32_t nIndex) const;
- void GetRange(CFX_WideString& wsText,
- int32_t nBegin,
- int32_t nCount = -1) const;
+ CFX_WideString GetRange(int32_t nBegin, int32_t nCount = -1) const;
void Insert(int32_t nPos, const FX_WCHAR* lpText, int32_t nLength = 1);
void Delete(int32_t nIndex, int32_t nLength = 1);
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 3b3caf6a0d..63a0748cd1 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -160,15 +160,15 @@ int32_t CFDE_TxtEdtEngine::GetTextLength() const {
return GetTextBufLength();
}
-void CFDE_TxtEdtEngine::GetText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+CFX_WideString CFDE_TxtEdtEngine::GetText(int32_t nStart,
+ int32_t nCount) const {
int32_t nTextBufLength = GetTextBufLength();
if (nCount == -1)
nCount = nTextBufLength - nStart;
- m_pTxtBuf->GetRange(wsText, nStart, nCount);
+ CFX_WideString wsText = m_pTxtBuf->GetRange(nStart, nCount);
RecoverParagEnd(wsText);
+ return wsText;
}
void CFDE_TxtEdtEngine::ClearText() {
@@ -374,9 +374,8 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
(m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz)) {
int32_t nTemp = nLength;
if (m_Param.dwMode & FDE_TEXTEDITMODE_Password) {
- CFX_WideString wsText;
while (nLength > 0) {
- GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength);
+ CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength);
int32_t nTotal = wsText.GetLength();
FX_WCHAR* lpBuf = wsText.GetBuffer(nTotal);
for (int32_t i = 0; i < nTotal; i++) {
@@ -389,9 +388,8 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
nLength--;
}
} else {
- CFX_WideString wsText;
while (nLength > 0) {
- GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength);
+ CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength);
if (IsFitArea(wsText)) {
break;
}
@@ -406,8 +404,7 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
}
}
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
- CFX_WideString wsText;
- GetPreInsertText(wsText, m_nCaret, lpBuffer, nLength);
+ CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength);
if (!m_Param.pEventSink->On_Validate(this, wsText)) {
return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
}
@@ -420,7 +417,7 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
this,
new CFDE_TxtEdtDoRecord_Insert(this, m_nCaret, lpBuffer, nLength));
- GetText(m_ChangeInfo.wsPrevText, 0);
+ m_ChangeInfo.wsPrevText = GetText(0);
Inner_Insert(m_nCaret, lpBuffer, nLength);
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
m_ChangeInfo.wsInsert = CFX_WideString(lpBuffer, nLength);
@@ -468,21 +465,19 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, bool bBackspace) {
}
}
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
- CFX_WideString wsText;
- GetPreDeleteText(wsText, nStart, nCount);
+ CFX_WideString wsText = GetPreDeleteText(nStart, nCount);
if (!m_Param.pEventSink->On_Validate(this, wsText)) {
return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
}
}
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
- CFX_WideString wsRange;
- m_pTxtBuf->GetRange(wsRange, nStart, nCount);
+ CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount);
m_Param.pEventSink->On_AddDoRecord(
this,
new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, wsRange));
}
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
- GetText(m_ChangeInfo.wsDelete, nStart, nCount);
+ m_ChangeInfo.wsDelete = GetText(nStart, nCount);
Inner_DeleteRange(nStart, nCount);
SetCaretPos(nStart + ((!bBackspace && nStart > 0) ? -1 : 0),
(bBackspace || nStart == 0));
@@ -501,8 +496,7 @@ int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) {
return FDE_TXTEDT_MODIFY_RET_S_Normal;
}
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
- CFX_WideString wsText;
- GetPreDeleteText(wsText, nStart, nCount);
+ CFX_WideString wsText = GetPreDeleteText(nStart, nCount);
if (!m_Param.pEventSink->On_Validate(this, wsText)) {
return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
}
@@ -523,9 +517,8 @@ int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart,
return FDE_TXTEDT_MODIFY_RET_F_Boundary;
}
if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
- CFX_WideString wsText;
- GetPreReplaceText(wsText, nStart, nLength, wsReplace.c_str(),
- wsReplace.GetLength());
+ CFX_WideString wsText = GetPreReplaceText(
+ nStart, nLength, wsReplace.c_str(), wsReplace.GetLength());
if (!m_Param.pEventSink->On_Validate(this, wsText)) {
return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
}
@@ -534,7 +527,7 @@ int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart,
ClearSelection();
}
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Replace;
- GetText(m_ChangeInfo.wsDelete, nStart, nLength);
+ m_ChangeInfo.wsDelete = GetText(nStart, nLength);
if (nLength > 0) {
Inner_DeleteRange(nStart, nLength);
}
@@ -778,18 +771,17 @@ int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag,
return i;
}
-void CFDE_TxtEdtEngine::GetPreDeleteText(CFX_WideString& wsText,
- int32_t nIndex,
- int32_t nLength) {
- GetText(wsText, 0, GetTextBufLength());
+CFX_WideString CFDE_TxtEdtEngine::GetPreDeleteText(int32_t nIndex,
+ int32_t nLength) {
+ CFX_WideString wsText = GetText(0, GetTextBufLength());
wsText.Delete(nIndex, nLength);
+ return wsText;
}
-void CFDE_TxtEdtEngine::GetPreInsertText(CFX_WideString& wsText,
- int32_t nIndex,
- const FX_WCHAR* lpText,
- int32_t nLength) {
- GetText(wsText, 0, GetTextBufLength());
+CFX_WideString CFDE_TxtEdtEngine::GetPreInsertText(int32_t nIndex,
+ const FX_WCHAR* lpText,
+ int32_t nLength) {
+ CFX_WideString wsText = GetText(0, GetTextBufLength());
int32_t nSelIndex = 0;
int32_t nSelLength = 0;
int32_t nSelCount = CountSelRanges();
@@ -808,14 +800,14 @@ void CFDE_TxtEdtEngine::GetPreInsertText(CFX_WideString& wsText,
(nOldLength - nIndex) * sizeof(FX_WCHAR));
wsTemp.ReleaseBuffer(nOldLength + nLength);
wsText = wsTemp;
+ return wsText;
}
-void CFDE_TxtEdtEngine::GetPreReplaceText(CFX_WideString& wsText,
- int32_t nIndex,
- int32_t nOriginLength,
- const FX_WCHAR* lpText,
- int32_t nLength) {
- GetText(wsText, 0, GetTextBufLength());
+CFX_WideString CFDE_TxtEdtEngine::GetPreReplaceText(int32_t nIndex,
+ int32_t nOriginLength,
+ const FX_WCHAR* lpText,
+ int32_t nLength) {
+ CFX_WideString wsText = GetText(0, GetTextBufLength());
int32_t nSelIndex = 0;
int32_t nSelLength = 0;
int32_t nSelCount = CountSelRanges();
@@ -825,9 +817,10 @@ void CFDE_TxtEdtEngine::GetPreReplaceText(CFX_WideString& wsText,
}
wsText.Delete(nIndex, nOriginLength);
int32_t i = 0;
- for (i = 0; i < nLength; i++) {
+ for (i = 0; i < nLength; i++)
wsText.Insert(nIndex++, lpText[i]);
- }
+
+ return wsText;
}
void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
@@ -959,14 +952,13 @@ void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
ASSERT((nStart + nCount) <= m_pTxtBuf->GetTextLength());
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
- CFX_WideString wsRange;
- m_pTxtBuf->GetRange(wsRange, nStart, nCount);
+ CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount);
m_Param.pEventSink->On_AddDoRecord(
this, new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret,
wsRange, bSel));
}
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
- GetText(m_ChangeInfo.wsDelete, nStart, nCount);
+ m_ChangeInfo.wsDelete = GetText(nStart, nCount);
Inner_DeleteRange(nStart, nCount);
}
diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h
index 587402d414..6b4c34a958 100644
--- a/xfa/fde/cfde_txtedtengine.h
+++ b/xfa/fde/cfde_txtedtengine.h
@@ -31,9 +31,7 @@ class CFDE_TxtEdtEngine {
void SetTextByStream(IFX_Stream* pStream);
void SetText(const CFX_WideString& wsText);
int32_t GetTextLength() const;
- void GetText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount = -1) const;
+ CFX_WideString GetText(int32_t nStart, int32_t nCount = -1) const;
void ClearText();
int32_t GetCaretRect(CFX_RectF& rtCaret) const;
@@ -102,18 +100,14 @@ class CFDE_TxtEdtEngine {
};
void Inner_Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength);
- void GetPreDeleteText(CFX_WideString& wsText,
- int32_t nIndex,
- int32_t nLength);
- void GetPreInsertText(CFX_WideString& wsText,
- int32_t nIndex,
- const FX_WCHAR* lpText,
- int32_t nLength);
- void GetPreReplaceText(CFX_WideString& wsText,
- int32_t nIndex,
- int32_t nOriginLength,
- const FX_WCHAR* lpText,
- int32_t nLength);
+ CFX_WideString GetPreDeleteText(int32_t nIndex, int32_t nLength);
+ CFX_WideString GetPreInsertText(int32_t nIndex,
+ const FX_WCHAR* lpText,
+ int32_t nLength);
+ CFX_WideString GetPreReplaceText(int32_t nIndex,
+ int32_t nOriginLength,
+ const FX_WCHAR* lpText,
+ int32_t nLength);
void Inner_DeleteRange(int32_t nStart, int32_t nCount = -1);
void DeleteRange_DoRecord(int32_t nStart, int32_t nCount, bool bSel = false);
diff --git a/xfa/fwl/core/cfwl_barcode.cpp b/xfa/fwl/core/cfwl_barcode.cpp
index 18cf71ebba..6ddcdf3920 100644
--- a/xfa/fwl/core/cfwl_barcode.cpp
+++ b/xfa/fwl/core/cfwl_barcode.cpp
@@ -165,8 +165,7 @@ void CFWL_Barcode::GenerateBarcodeImageCache() {
if (!m_pBarcodeEngine)
return;
- CFX_WideString wsText;
- GetText(wsText);
+ CFX_WideString wsText = GetText();
CFWL_ThemePart part;
part.m_pWidget = this;
diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp
index b7be67d1bd..5996af9c41 100644
--- a/xfa/fwl/core/cfwl_combobox.cpp
+++ b/xfa/fwl/core/cfwl_combobox.cpp
@@ -211,9 +211,8 @@ void CFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics,
if (!m_pListBox)
return;
- CFX_WideString wsText;
CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
- m_pListBox->GetDataProviderItemText(hItem, wsText);
+ CFX_WideString wsText = m_pListBox->GetDataProviderItemText(hItem);
CFWL_ThemeText theme_text;
theme_text.m_pWidget = this;
@@ -270,9 +269,8 @@ void CFWL_ComboBox::SetCurSel(int32_t iSel) {
if (bClearSel) {
m_pEdit->SetText(CFX_WideString());
} else {
- CFX_WideString wsText;
CFWL_ListItem* hItem = m_pListBox->GetItem(this, iSel);
- m_pListBox->GetDataProviderItemText(hItem, wsText);
+ CFX_WideString wsText = m_pListBox->GetDataProviderItemText(hItem);
m_pEdit->SetText(wsText);
}
m_pEdit->Update();
@@ -296,18 +294,16 @@ void CFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
m_pEdit->Update();
}
-void CFWL_ComboBox::GetEditText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+CFX_WideString CFWL_ComboBox::GetEditText(int32_t nStart,
+ int32_t nCount) const {
if (m_pEdit) {
- m_pEdit->GetText(wsText, nStart, nCount);
- return;
+ return m_pEdit->GetText(nStart, nCount);
}
if (!m_pListBox)
- return;
+ return L"";
CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
- m_pListBox->GetDataProviderItemText(hItem, wsText);
+ return m_pListBox->GetDataProviderItemText(hItem);
}
void CFWL_ComboBox::OpenDropDownList(bool bActivate) {
@@ -414,8 +410,7 @@ void CFWL_ComboBox::ShowDropList(bool bActivate) {
}
void CFWL_ComboBox::MatchEditText() {
- CFX_WideString wsText;
- m_pEdit->GetText(wsText);
+ CFX_WideString wsText = m_pEdit->GetText();
int32_t iMatch = m_pListBox->MatchItem(wsText);
if (iMatch != m_iCurSel) {
m_pListBox->ChangeSelected(iMatch);
@@ -428,9 +423,8 @@ void CFWL_ComboBox::MatchEditText() {
}
void CFWL_ComboBox::SyncEditText(int32_t iListItem) {
- CFX_WideString wsText;
CFWL_ListItem* hItem = m_pListBox->GetItem(this, iListItem);
- m_pListBox->GetDataProviderItemText(hItem, wsText);
+ CFX_WideString wsText = m_pListBox->GetDataProviderItemText(hItem);
m_pEdit->SetText(wsText);
m_pEdit->Update();
m_pEdit->SetSelected();
@@ -458,9 +452,8 @@ void CFWL_ComboBox::Layout() {
m_pEdit->SetWidgetRect(rtEdit);
if (m_iCurSel >= 0) {
- CFX_WideString wsText;
CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
- m_pListBox->GetDataProviderItemText(hItem, wsText);
+ CFX_WideString wsText = m_pListBox->GetDataProviderItemText(hItem);
m_pEdit->LockUpdate();
m_pEdit->SetText(wsText);
m_pEdit->UnlockUpdate();
@@ -553,8 +546,7 @@ void CFWL_ComboBox::ProcessSelChanged(bool bLButtonUp) {
if (!hItem)
return;
- CFX_WideString wsText;
- m_pListBox->GetItemText(this, hItem, wsText);
+ CFX_WideString wsText = m_pListBox->GetItemText(this, hItem);
if (m_pEdit) {
m_pEdit->SetText(wsText);
m_pEdit->Update();
@@ -785,9 +777,8 @@ void CFWL_ComboBox::DisForm_Layout() {
m_pEdit->SetWidgetRect(rtEdit);
if (m_iCurSel >= 0) {
- CFX_WideString wsText;
CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
- m_pListBox->GetDataProviderItemText(hItem, wsText);
+ CFX_WideString wsText = m_pListBox->GetDataProviderItemText(hItem);
m_pEdit->LockUpdate();
m_pEdit->SetText(wsText);
m_pEdit->UnlockUpdate();
@@ -964,13 +955,11 @@ void CFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) {
int32_t iCurSel = m_iCurSel;
bool bDropDown = IsDropDownStyle();
if (bDropDown && m_pEdit) {
- CFX_WideString wsText;
- m_pEdit->GetText(wsText);
+ CFX_WideString wsText = m_pEdit->GetText();
iCurSel = m_pListBox->MatchItem(wsText);
if (iCurSel >= 0) {
- CFX_WideString wsTemp;
CFWL_ListItem* hItem = m_pListBox->GetItem(this, iCurSel);
- m_pListBox->GetDataProviderItemText(hItem, wsTemp);
+ CFX_WideString wsTemp = m_pListBox->GetDataProviderItemText(hItem);
bMatchEqual = wsText == wsTemp;
}
}
@@ -1100,13 +1089,11 @@ void CFWL_ComboBox::DisForm_OnKey(CFWL_MsgKey* pMsg) {
bool bMatchEqual = false;
int32_t iCurSel = m_iCurSel;
if (m_pEdit) {
- CFX_WideString wsText;
- m_pEdit->GetText(wsText);
+ CFX_WideString wsText = m_pEdit->GetText();
iCurSel = pComboList->MatchItem(wsText);
if (iCurSel >= 0) {
- CFX_WideString wsTemp;
CFWL_ListItem* item = m_pListBox->GetSelItem(iCurSel);
- m_pListBox->GetDataProviderItemText(item, wsTemp);
+ CFX_WideString wsTemp = m_pListBox->GetDataProviderItemText(item);
bMatchEqual = wsText == wsTemp;
}
}
diff --git a/xfa/fwl/core/cfwl_combobox.h b/xfa/fwl/core/cfwl_combobox.h
index a4545198b4..b9f4897586 100644
--- a/xfa/fwl/core/cfwl_combobox.h
+++ b/xfa/fwl/core/cfwl_combobox.h
@@ -77,9 +77,7 @@ class CFWL_ComboBox : public CFWL_Widget {
void RemoveAll();
void SetEditText(const CFX_WideString& wsText);
- void GetEditText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
+ CFX_WideString GetEditText(int32_t nStart = 0, int32_t nCount = -1) const;
void OpenDropDownList(bool bActivate);
diff --git a/xfa/fwl/core/cfwl_combolist.cpp b/xfa/fwl/core/cfwl_combolist.cpp
index 0476498388..e333cda18a 100644
--- a/xfa/fwl/core/cfwl_combolist.cpp
+++ b/xfa/fwl/core/cfwl_combolist.cpp
@@ -32,8 +32,7 @@ int32_t CFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) {
int32_t iCount = CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
CFWL_ListItem* hItem = GetItem(this, i);
- CFX_WideString wsText;
- GetItemText(this, hItem, wsText);
+ CFX_WideString wsText = GetItemText(this, hItem);
FX_STRSIZE pos = wsText.Find(wsMatch.c_str());
if (!pos)
return i;
diff --git a/xfa/fwl/core/cfwl_datetimepicker.cpp b/xfa/fwl/core/cfwl_datetimepicker.cpp
index 142daf5fe4..35b038d6ce 100644
--- a/xfa/fwl/core/cfwl_datetimepicker.cpp
+++ b/xfa/fwl/core/cfwl_datetimepicker.cpp
@@ -196,11 +196,9 @@ void CFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) {
DispatchEvent(&ev);
}
-void CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
- if (m_pEdit)
- m_pEdit->GetText(wsText, nStart, nCount);
+CFX_WideString CFWL_DateTimePicker::GetEditText(int32_t nStart,
+ int32_t nCount) const {
+ return m_pEdit ? m_pEdit->GetText(nStart, nCount) : L"";
}
void CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) const {
diff --git a/xfa/fwl/core/cfwl_datetimepicker.h b/xfa/fwl/core/cfwl_datetimepicker.h
index c5dd0ae45c..69e4ef3122 100644
--- a/xfa/fwl/core/cfwl_datetimepicker.h
+++ b/xfa/fwl/core/cfwl_datetimepicker.h
@@ -56,9 +56,7 @@ class CFWL_DateTimePicker : public CFWL_Widget {
void SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
void SetEditText(const CFX_WideString& wsText);
- void GetEditText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
+ CFX_WideString GetEditText(int32_t nStart = 0, int32_t nCount = -1) const;
int32_t CountSelRanges() const { return m_pEdit->CountSelRanges(); }
int32_t GetSelRange(int32_t nIndex, int32_t& nStart) const {
diff --git a/xfa/fwl/core/cfwl_edit.cpp b/xfa/fwl/core/cfwl_edit.cpp
index 99cac68d57..4544ebcb82 100644
--- a/xfa/fwl/core/cfwl_edit.cpp
+++ b/xfa/fwl/core/cfwl_edit.cpp
@@ -113,8 +113,7 @@ void CFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
int32_t iTextLen = m_EdtEngine.GetTextLength();
if (iTextLen > 0) {
- CFX_WideString wsText;
- m_EdtEngine.GetText(wsText, 0);
+ CFX_WideString wsText = m_EdtEngine.GetText(0);
CFX_SizeF sz = CalcTextSize(
wsText, m_pProperties->m_pThemeProvider,
!!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine));
@@ -212,8 +211,7 @@ void CFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics,
FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
- CFX_WideString wsSpell;
- GetText(wsSpell);
+ CFX_WideString wsSpell = GetText();
int32_t nContentLen = wsSpell.GetLength();
for (int i = 0; i < nContentLen; i++) {
if (FX_EDIT_ISLATINWORD(wsSpell[i])) {
@@ -300,10 +298,8 @@ int32_t CFWL_Edit::GetTextLength() const {
return m_EdtEngine.GetTextLength();
}
-void CFWL_Edit::GetText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
- m_EdtEngine.GetText(wsText, nStart, nCount);
+CFX_WideString CFWL_Edit::GetText(int32_t nStart, int32_t nCount) const {
+ return m_EdtEngine.GetText(nStart, nCount);
}
void CFWL_Edit::ClearText() {
@@ -349,7 +345,7 @@ bool CFWL_Edit::Copy(CFX_WideString& wsCopy) {
int32_t nStart, nLength;
for (int32_t i = 0; i < nCount; i++) {
nLength = m_EdtEngine.GetSelRange(i, nStart);
- m_EdtEngine.GetText(wsTemp, nStart, nLength);
+ wsTemp = m_EdtEngine.GetText(nStart, nLength);
wsCopy += wsTemp;
wsTemp.clear();
}
@@ -366,7 +362,7 @@ bool CFWL_Edit::Cut(CFX_WideString& wsCut) {
int32_t nStart, nLength;
for (int32_t i = 0; i < nCount; i++) {
nLength = m_EdtEngine.GetSelRange(i, nStart);
- m_EdtEngine.GetText(wsTemp, nStart, nLength);
+ wsTemp = m_EdtEngine.GetText(nStart, nLength);
wsCut += wsTemp;
wsTemp.clear();
}
@@ -1232,8 +1228,7 @@ bool CFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) {
if (!m_bSetRange)
return true;
- CFX_WideString wsOld, wsText;
- m_EdtEngine.GetText(wsText, 0);
+ CFX_WideString wsText = m_EdtEngine.GetText(0);
if (wsText.IsEmpty()) {
if (cNum == L'0')
return false;
diff --git a/xfa/fwl/core/cfwl_edit.h b/xfa/fwl/core/cfwl_edit.h
index 3c4c80759f..342c6dd4d2 100644
--- a/xfa/fwl/core/cfwl_edit.h
+++ b/xfa/fwl/core/cfwl_edit.h
@@ -80,9 +80,7 @@ class CFWL_Edit : public CFWL_Widget {
virtual void SetText(const CFX_WideString& wsText);
int32_t GetTextLength() const;
- void GetText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
+ CFX_WideString GetText(int32_t nStart = 0, int32_t nCount = -1) const;
void ClearText();
void AddSelRange(int32_t nStart, int32_t nCount = -1);
diff --git a/xfa/fwl/core/cfwl_listbox.cpp b/xfa/fwl/core/cfwl_listbox.cpp
index 1208ab34dc..dff981f283 100644
--- a/xfa/fwl/core/cfwl_listbox.cpp
+++ b/xfa/fwl/core/cfwl_listbox.cpp
@@ -202,11 +202,10 @@ void CFWL_ListBox::SetSelItem(CFWL_ListItem* pItem, bool bSelect) {
SetSelection(pItem, pItem, bSelect);
}
-void CFWL_ListBox::GetDataProviderItemText(CFWL_ListItem* pItem,
- CFX_WideString& wsText) {
+CFX_WideString CFWL_ListBox::GetDataProviderItemText(CFWL_ListItem* pItem) {
if (!pItem)
- return;
- GetItemText(this, pItem, wsText);
+ return L"";
+ return GetItemText(this, pItem);
}
CFWL_ListItem* CFWL_ListBox::GetListItem(CFWL_ListItem* pItem,
@@ -544,8 +543,7 @@ void CFWL_ListBox::DrawItem(CFX_Graphics* pGraphics,
pTheme->DrawBackground(&param);
}
- CFX_WideString wsText;
- GetItemText(this, pItem, wsText);
+ CFX_WideString wsText = GetItemText(this, pItem);
if (wsText.GetLength() <= 0)
return;
@@ -719,8 +717,7 @@ FX_FLOAT CFWL_ListBox::GetMaxTextWidth() {
if (!pItem)
continue;
- CFX_WideString wsText;
- GetItemText(this, pItem, wsText);
+ CFX_WideString wsText = GetItemText(this, pItem);
CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider);
fRet = std::max(fRet, sz.x);
}
@@ -1006,11 +1003,9 @@ bool CFWL_ListBox::OnScroll(CFWL_ScrollBar* pScrollBar,
return true;
}
-void CFWL_ListBox::GetItemText(CFWL_Widget* pWidget,
- CFWL_ListItem* pItem,
- CFX_WideString& wsText) {
- if (pItem)
- wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText;
+CFX_WideString CFWL_ListBox::GetItemText(CFWL_Widget* pWidget,
+ CFWL_ListItem* pItem) {
+ return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_wsText : L"";
}
int32_t CFWL_ListBox::CountItems(const CFWL_Widget* pWidget) const {
diff --git a/xfa/fwl/core/cfwl_listbox.h b/xfa/fwl/core/cfwl_listbox.h
index a2dcdbaf7f..e30068b0b4 100644
--- a/xfa/fwl/core/cfwl_listbox.h
+++ b/xfa/fwl/core/cfwl_listbox.h
@@ -63,9 +63,7 @@ class CFWL_ListBox : public CFWL_Widget {
int32_t GetItemIndex(CFWL_Widget* pWidget, CFWL_ListItem* pItem);
uint32_t GetItemStyles(CFWL_Widget* pWidget, CFWL_ListItem* pItem);
uint32_t GetItemStates(CFWL_ListItem* pItem);
- void GetItemText(CFWL_Widget* pWidget,
- CFWL_ListItem* pItem,
- CFX_WideString& wsText);
+ CFX_WideString GetItemText(CFWL_Widget* pWidget, CFWL_ListItem* pItem);
void GetItemRect(CFWL_Widget* pWidget,
CFWL_ListItem* pItem,
CFX_RectF& rtItem);
@@ -96,7 +94,7 @@ class CFWL_ListBox : public CFWL_Widget {
CFWL_ListItem* GetSelItem(int32_t nIndexSel);
int32_t GetSelIndex(int32_t nIndex);
void SetSelItem(CFWL_ListItem* hItem, bool bSelect = true);
- void GetDataProviderItemText(CFWL_ListItem* hItem, CFX_WideString& wsText);
+ CFX_WideString GetDataProviderItemText(CFWL_ListItem* hItem);
FX_FLOAT GetItemHeight() const { return m_fItemHeight; }
FX_FLOAT CalcItemHeight();
diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp
index b289a39eb3..c9a513607e 100644
--- a/xfa/fxfa/app/xfa_ffchoicelist.cpp
+++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp
@@ -160,8 +160,10 @@ void CXFA_FFListBox::OnSelectChanged(CFWL_Widget* pWidget,
CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget;
int32_t iSels = pListBox->CountSelItems();
if (iSels > 0) {
- pListBox->GetItemText(nullptr, pListBox->GetSelItem(0), eParam.m_wsNewText);
+ eParam.m_wsNewText =
+ pListBox->GetItemText(nullptr, pListBox->GetSelItem(0));
}
+
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam);
}
void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) {
@@ -316,8 +318,7 @@ bool CXFA_FFComboBox::CommitData() {
}
bool CXFA_FFComboBox::IsDataChanged() {
CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget);
- CFX_WideString wsText;
- pFWLcombobox->GetEditText(wsText);
+ CFX_WideString wsText = pFWLcombobox->GetEditText();
int32_t iCursel = pFWLcombobox->GetCurSel();
if (iCursel >= 0) {
CFX_WideString wsSel;
@@ -338,7 +339,7 @@ void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) {
pParam->m_eType = XFA_EVENT_Change;
pParam->m_pTarget = m_pDataAcc;
CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget);
- pFWLcombobox->GetEditText(pParam->m_wsNewText);
+ pParam->m_wsNewText = pFWLcombobox->GetEditText();
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam);
}
uint32_t CXFA_FFComboBox::GetAlignment() {
diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp
index 77ca7a6d91..a070f90b99 100644
--- a/xfa/fxfa/app/xfa_fftextedit.cpp
+++ b/xfa/fxfa/app/xfa_fftextedit.cpp
@@ -187,8 +187,7 @@ bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) {
return true;
}
bool CXFA_FFTextEdit::CommitData() {
- CFX_WideString wsText;
- ((CFWL_Edit*)m_pNormalWidget)->GetText(wsText);
+ CFX_WideString wsText = static_cast<CFWL_Edit*>(m_pNormalWidget)->GetText();
if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) {
m_pDataAcc->UpdateUIDisplay(this);
return true;
@@ -283,8 +282,8 @@ bool CXFA_FFTextEdit::UpdateFWLData() {
}
CFX_WideString wsText;
m_pDataAcc->GetValue(wsText, eType);
- CFX_WideString wsOldText;
- ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText);
+ CFX_WideString wsOldText =
+ static_cast<CFWL_Edit*>(m_pNormalWidget)->GetText();
if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) {
((CFWL_Edit*)m_pNormalWidget)->SetText(wsText);
bUpdate = true;
@@ -306,13 +305,13 @@ void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget,
CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget);
if (m_pDataAcc->GetUIType() == XFA_Element::DateTimeEdit) {
CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit;
- pDateTime->GetEditText(eParam.m_wsNewText);
+ eParam.m_wsNewText = pDateTime->GetEditText();
int32_t iSels = pDateTime->CountSelRanges();
if (iSels) {
eParam.m_iSelEnd = pDateTime->GetSelRange(0, eParam.m_iSelStart);
}
} else {
- pEdit->GetText(eParam.m_wsNewText);
+ eParam.m_wsNewText = pEdit->GetText();
int32_t iSels = pEdit->CountSelRanges();
if (iSels) {
eParam.m_iSelEnd = pEdit->GetSelRange(0, eParam.m_iSelStart);
@@ -616,8 +615,8 @@ uint32_t CXFA_FFDateTimeEdit::GetAlignment() {
return dwExtendedStyle;
}
bool CXFA_FFDateTimeEdit::CommitData() {
- CFX_WideString wsText;
- ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText);
+ CFX_WideString wsText =
+ static_cast<CFWL_DateTimePicker*>(m_pNormalWidget)->GetEditText();
if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) {
m_pDataAcc->UpdateUIDisplay(this);
return true;
@@ -652,8 +651,8 @@ bool CXFA_FFDateTimeEdit::IsDataChanged() {
if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) {
return true;
}
- CFX_WideString wsText;
- ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText);
+ CFX_WideString wsText =
+ static_cast<CFWL_DateTimePicker*>(m_pNormalWidget)->GetEditText();
CFX_WideString wsOldValue;
m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit);
return wsOldValue != wsText;