summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-09-13 06:46:40 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-13 06:46:40 -0700
commit067990ccf96ae962392a2dbacbfd8348dc4c7676 (patch)
tree5e6a1d32d1b19bc2f7ff4197693d8612737342fc /fpdfsdk
parentbb8935e9def5ad865be613eebea597a77fc7c547 (diff)
downloadpdfium-067990ccf96ae962392a2dbacbfd8348dc4c7676.tar.xz
Stop converting widestring -> c_str -> widestring in several places.
Avoids a needless alloc and copy. Review-Url: https://codereview.chromium.org/2338553002
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp13
-rw-r--r--fpdfsdk/formfiller/cffl_combobox.cpp8
-rw-r--r--fpdfsdk/formfiller/cffl_listbox.cpp2
-rw-r--r--fpdfsdk/formfiller/cffl_textfield.cpp6
-rw-r--r--fpdfsdk/fxedit/fxet_list.cpp6
-rw-r--r--fpdfsdk/fxedit/include/fxet_list.h6
-rw-r--r--fpdfsdk/pdfwindow/PWL_ComboBox.cpp20
-rw-r--r--fpdfsdk/pdfwindow/PWL_ComboBox.h5
-rw-r--r--fpdfsdk/pdfwindow/PWL_Edit.cpp10
-rw-r--r--fpdfsdk/pdfwindow/PWL_Edit.h4
-rw-r--r--fpdfsdk/pdfwindow/PWL_EditCtrl.cpp8
-rw-r--r--fpdfsdk/pdfwindow/PWL_EditCtrl.h4
-rw-r--r--fpdfsdk/pdfwindow/PWL_ListBox.cpp2
-rw-r--r--fpdfsdk/pdfwindow/PWL_ListBox.h2
-rw-r--r--fpdfsdk/pdfwindow/PWL_Utils.cpp4
15 files changed, 43 insertions, 57 deletions
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index a8ebef6e99..016e78a848 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -1391,9 +1391,9 @@ void CPDFSDK_Widget::ResetAppearance_ComboBox(const CFX_WideString* sValue) {
} else {
int32_t nCurSel = pField->GetSelectedIndex(0);
if (nCurSel < 0)
- pEdit->SetText(pField->GetValue().c_str());
+ pEdit->SetText(pField->GetValue());
else
- pEdit->SetText(pField->GetOptionLabel(nCurSel).c_str());
+ pEdit->SetText(pField->GetOptionLabel(nCurSel));
}
CFX_FloatRect rcContent = pEdit->GetContentRect();
@@ -1462,7 +1462,7 @@ void CPDFSDK_Widget::ResetAppearance_ListBox() {
}
}
- pEdit->SetText(pField->GetOptionLabel(i).c_str());
+ pEdit->SetText(pField->GetOptionLabel(i));
CFX_FloatRect rcContent = pEdit->GetContentRect();
FX_FLOAT fItemHeight = rcContent.Height();
@@ -1578,14 +1578,9 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const CFX_WideString* sValue) {
pEdit->SetFontSize(fFontSize);
pEdit->Initialize();
-
- if (sValue)
- pEdit->SetText(*sValue);
- else
- pEdit->SetText(pField->GetValue().c_str());
+ pEdit->SetText(sValue ? *sValue : pField->GetValue());
CFX_FloatRect rcContent = pEdit->GetContentRect();
-
CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(
pEdit.get(), CFX_FloatPoint(0.0f, 0.0f), nullptr, !bCharArray, subWord);
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index f6aef20c02..fc590fd940 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -65,11 +65,11 @@ CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp,
swText = m_pWidget->GetOptionLabel(nCurSel);
for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) {
- pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str());
+ pWnd->AddString(m_pWidget->GetOptionLabel(i));
}
pWnd->SetSelect(nCurSel);
- pWnd->SetText(swText.c_str());
+ pWnd->SetText(swText);
return pWnd;
}
@@ -172,7 +172,7 @@ void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView,
static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
- pEdit->ReplaceSel(fa.sChange.c_str());
+ pEdit->ReplaceSel(fa.sChange);
}
}
break;
@@ -219,7 +219,7 @@ void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) {
pComboBox->SetSelect(m_State.nIndex);
} else {
if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
- pEdit->SetText(m_State.sValue.c_str());
+ pEdit->SetText(m_State.sValue);
pEdit->SetSel(m_State.nStart, m_State.nEnd);
}
}
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index 36950bd2b2..860fd07a75 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -52,7 +52,7 @@ CPWL_Wnd* CFFL_ListBox::NewPDFWindow(const PWL_CREATEPARAM& cp,
pWnd->SetFillerNotify(pIFormFiller);
for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++)
- pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str());
+ pWnd->AddString(m_pWidget->GetOptionLabel(i));
if (pWnd->HasFlag(PLBS_MULTIPLESEL)) {
m_OriginSelections.clear();
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index 1947940094..369bb4d209 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -99,7 +99,7 @@ CPWL_Wnd* CFFL_TextField::NewPDFWindow(const PWL_CREATEPARAM& cp,
}
}
- pWnd->SetText(swValue.c_str());
+ pWnd->SetText(swValue);
return pWnd;
}
@@ -196,7 +196,7 @@ void CFFL_TextField::SetActionData(CPDFSDK_PageView* pPageView,
if (CPWL_Edit* pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) {
pEdit->SetFocus();
pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
- pEdit->ReplaceSel(fa.sChange.c_str());
+ pEdit->ReplaceSel(fa.sChange);
}
break;
default:
@@ -232,7 +232,7 @@ void CFFL_TextField::RestoreState(CPDFSDK_PageView* pPageView) {
ASSERT(pPageView);
if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, TRUE)) {
- pWnd->SetText(m_State.sValue.c_str());
+ pWnd->SetText(m_State.sValue);
pWnd->SetSel(m_State.nStart, m_State.nEnd);
}
}
diff --git a/fpdfsdk/fxedit/fxet_list.cpp b/fpdfsdk/fxedit/fxet_list.cpp
index 96fb60dcaa..7bf1bd8a27 100644
--- a/fpdfsdk/fxedit/fxet_list.cpp
+++ b/fpdfsdk/fxedit/fxet_list.cpp
@@ -49,7 +49,7 @@ void CFX_ListItem::SetSelect(FX_BOOL bSelected) {
m_bSelected = bSelected;
}
-void CFX_ListItem::SetText(const FX_WCHAR* text) {
+void CFX_ListItem::SetText(const CFX_WideString& text) {
m_pEdit->SetText(text);
}
@@ -396,7 +396,7 @@ int32_t CFX_ListCtrl::GetSelect() const {
return m_nSelItem;
}
-void CFX_ListCtrl::AddString(const FX_WCHAR* str) {
+void CFX_ListCtrl::AddString(const CFX_WideString& str) {
AddItem(str);
ReArrange(GetCount() - 1);
}
@@ -677,7 +677,7 @@ void CFX_ListCtrl::SetFontSize(FX_FLOAT fFontSize) {
m_fFontSize = fFontSize;
}
-void CFX_ListCtrl::AddItem(const FX_WCHAR* str) {
+void CFX_ListCtrl::AddItem(const CFX_WideString& str) {
CFX_ListItem* pListItem = new CFX_ListItem();
pListItem->SetFontMap(m_pFontMap);
pListItem->SetFontSize(m_fFontSize);
diff --git a/fpdfsdk/fxedit/include/fxet_list.h b/fpdfsdk/fxedit/include/fxet_list.h
index 2377e1d080..b5cd392eda 100644
--- a/fpdfsdk/fxedit/include/fxet_list.h
+++ b/fpdfsdk/fxedit/include/fxet_list.h
@@ -105,7 +105,7 @@ class CFX_ListItem final {
void SetRect(const CLST_Rect& rect);
void SetSelect(FX_BOOL bSelected);
- void SetText(const FX_WCHAR* text);
+ void SetText(const CFX_WideString& text);
void SetFontSize(FX_FLOAT fFontSize);
CFX_WideString GetText() const;
@@ -243,7 +243,7 @@ class CFX_ListCtrl : protected CFX_ListContainer {
int32_t GetTopItem() const;
CFX_FloatRect GetContentRect() const;
int32_t GetItemIndex(const CFX_FloatPoint& point) const;
- void AddString(const FX_WCHAR* str);
+ void AddString(const CFX_WideString& str);
void SetTopItem(int32_t nIndex);
void Select(int32_t nItemIndex);
void SetCaret(int32_t nItemIndex);
@@ -281,7 +281,7 @@ class CFX_ListCtrl : protected CFX_ListContainer {
FX_BOOL IsItemVisible(int32_t nItemIndex) const;
void SetScrollInfo();
void SetScrollPosY(FX_FLOAT fy);
- void AddItem(const FX_WCHAR* str);
+ void AddItem(const CFX_WideString& str);
CFX_WideString GetItemText(int32_t nIndex) const;
void SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected);
int32_t GetLastSelected() const;
diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp
index ebeb6751a0..c02b268d14 100644
--- a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp
+++ b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp
@@ -221,12 +221,12 @@ CFX_WideString CPWL_ComboBox::GetText() const {
return CFX_WideString();
}
-void CPWL_ComboBox::SetText(const FX_WCHAR* text) {
+void CPWL_ComboBox::SetText(const CFX_WideString& text) {
if (m_pEdit)
m_pEdit->SetText(text);
}
-void CPWL_ComboBox::AddString(const FX_WCHAR* str) {
+void CPWL_ComboBox::AddString(const CFX_WideString& str) {
if (m_pList)
m_pList->AddString(str);
}
@@ -239,30 +239,26 @@ void CPWL_ComboBox::SetSelect(int32_t nItemIndex) {
if (m_pList)
m_pList->Select(nItemIndex);
- m_pEdit->SetText(m_pList->GetText().c_str());
-
+ m_pEdit->SetText(m_pList->GetText());
m_nSelectItem = nItemIndex;
}
void CPWL_ComboBox::SetEditSel(int32_t nStartChar, int32_t nEndChar) {
- if (m_pEdit) {
+ if (m_pEdit)
m_pEdit->SetSel(nStartChar, nEndChar);
- }
}
void CPWL_ComboBox::GetEditSel(int32_t& nStartChar, int32_t& nEndChar) const {
nStartChar = -1;
nEndChar = -1;
- if (m_pEdit) {
+ if (m_pEdit)
m_pEdit->GetSel(nStartChar, nEndChar);
- }
}
void CPWL_ComboBox::Clear() {
- if (m_pEdit) {
+ if (m_pEdit)
m_pEdit->Clear();
- }
}
void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM& cp) {
@@ -619,11 +615,9 @@ FX_BOOL CPWL_ComboBox::IsPopup() const {
}
void CPWL_ComboBox::SetSelectText() {
- CFX_WideString swText = m_pList->GetText();
m_pEdit->SelectAll();
- m_pEdit->ReplaceSel(m_pList->GetText().c_str());
+ m_pEdit->ReplaceSel(m_pList->GetText());
m_pEdit->SelectAll();
-
m_nSelectItem = m_pList->GetCurSel();
}
diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.h b/fpdfsdk/pdfwindow/PWL_ComboBox.h
index 02f9d1380a..df9eb5546e 100644
--- a/fpdfsdk/pdfwindow/PWL_ComboBox.h
+++ b/fpdfsdk/pdfwindow/PWL_ComboBox.h
@@ -69,9 +69,8 @@ class CPWL_ComboBox : public CPWL_Wnd {
void SetFillerNotify(IPWL_Filler_Notify* pNotify);
CFX_WideString GetText() const;
- void SetText(const FX_WCHAR* text);
-
- void AddString(const FX_WCHAR* str);
+ void SetText(const CFX_WideString& text);
+ void AddString(const CFX_WideString& str);
int32_t GetSelect() const;
void SetSelect(int32_t nItemIndex);
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp
index 1aa7b5eb5a..c85993b9cb 100644
--- a/fpdfsdk/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp
@@ -38,12 +38,10 @@ CFX_ByteString CPWL_Edit::GetClassName() const {
void CPWL_Edit::OnDestroy() {}
-void CPWL_Edit::SetText(const FX_WCHAR* csText) {
+void CPWL_Edit::SetText(const CFX_WideString& csText) {
CFX_WideString swText = csText;
-
if (HasFlag(PES_RICH)) {
CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText);
-
if (CXML_Element* pXML =
CXML_Element::Parse(sValue.c_str(), sValue.GetLength())) {
int32_t nCount = pXML->CountChildren();
@@ -74,7 +72,7 @@ void CPWL_Edit::SetText(const FX_WCHAR* csText) {
}
}
- m_pEdit->SetText(swText.c_str());
+ m_pEdit->SetText(swText);
}
void CPWL_Edit::RePosChildWnd() {
@@ -571,9 +569,9 @@ void CPWL_Edit::SetLimitChar(int32_t nLimitChar) {
m_pEdit->SetLimitChar(nLimitChar);
}
-void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText) {
+void CPWL_Edit::ReplaceSel(const CFX_WideString& wsText) {
m_pEdit->Clear();
- m_pEdit->InsertText(csText, DEFAULT_CHARSET);
+ m_pEdit->InsertText(wsText, DEFAULT_CHARSET);
}
CFX_FloatRect CPWL_Edit::GetFocusRect() const {
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.h b/fpdfsdk/pdfwindow/PWL_Edit.h
index df69ebf5d7..568f4805a9 100644
--- a/fpdfsdk/pdfwindow/PWL_Edit.h
+++ b/fpdfsdk/pdfwindow/PWL_Edit.h
@@ -85,8 +85,8 @@ class CPWL_Edit : public CPWL_EditCtrl {
void CutText();
- void SetText(const FX_WCHAR* csText);
- void ReplaceSel(const FX_WCHAR* csText);
+ void SetText(const CFX_WideString& csText);
+ void ReplaceSel(const CFX_WideString& csText);
CFX_ByteString GetTextAppearanceStream(const CFX_FloatPoint& ptOffset) const;
CFX_ByteString GetCaretAppearanceStream(const CFX_FloatPoint& ptOffset) const;
diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
index febf69e7d0..575fd39089 100644
--- a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
+++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
@@ -464,8 +464,8 @@ FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const {
return fFontSize;
}
-void CPWL_EditCtrl::SetText(const FX_WCHAR* csText) {
- m_pEdit->SetText(csText);
+void CPWL_EditCtrl::SetText(const CFX_WideString& wsText) {
+ m_pEdit->SetText(wsText);
}
void CPWL_EditCtrl::CopyText() {}
@@ -476,9 +476,9 @@ void CPWL_EditCtrl::CutText() {}
void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) {}
-void CPWL_EditCtrl::InsertText(const FX_WCHAR* csText) {
+void CPWL_EditCtrl::InsertText(const CFX_WideString& wsText) {
if (!IsReadOnly())
- m_pEdit->InsertText(csText, DEFAULT_CHARSET);
+ m_pEdit->InsertText(wsText, DEFAULT_CHARSET);
}
void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) {
diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.h b/fpdfsdk/pdfwindow/PWL_EditCtrl.h
index f767d1ba72..8be2b00821 100644
--- a/fpdfsdk/pdfwindow/PWL_EditCtrl.h
+++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.h
@@ -105,8 +105,8 @@ class CPWL_EditCtrl : public CPWL_Wnd {
void IOnInvalidateRect(CFX_FloatRect* pRect);
protected:
- void InsertText(const FX_WCHAR* csText);
- void SetText(const FX_WCHAR* csText);
+ void InsertText(const CFX_WideString& wsText);
+ void SetText(const CFX_WideString& wsText);
void CopyText();
void PasteText();
void CutText();
diff --git a/fpdfsdk/pdfwindow/PWL_ListBox.cpp b/fpdfsdk/pdfwindow/PWL_ListBox.cpp
index 1265a8d446..2b44e29319 100644
--- a/fpdfsdk/pdfwindow/PWL_ListBox.cpp
+++ b/fpdfsdk/pdfwindow/PWL_ListBox.cpp
@@ -366,7 +366,7 @@ CFX_FloatRect CPWL_ListBox::GetFocusRect() const {
return CPWL_Wnd::GetFocusRect();
}
-void CPWL_ListBox::AddString(const FX_WCHAR* str) {
+void CPWL_ListBox::AddString(const CFX_WideString& str) {
m_pList->AddString(str);
}
diff --git a/fpdfsdk/pdfwindow/PWL_ListBox.h b/fpdfsdk/pdfwindow/PWL_ListBox.h
index 91ab7f768f..e42ca24ab4 100644
--- a/fpdfsdk/pdfwindow/PWL_ListBox.h
+++ b/fpdfsdk/pdfwindow/PWL_ListBox.h
@@ -75,7 +75,7 @@ class CPWL_ListBox : public CPWL_Wnd {
void OnNotifySelChanged(FX_BOOL bKeyDown, FX_BOOL& bExit, uint32_t nFlag);
- void AddString(const FX_WCHAR* str);
+ void AddString(const CFX_WideString& str);
void SetTopVisibleIndex(int32_t nItemIndex);
void ScrollToListItem(int32_t nItemIndex);
void ResetContent();
diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp
index 0574454c4f..7c7e05af00 100644
--- a/fpdfsdk/pdfwindow/PWL_Utils.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp
@@ -448,7 +448,7 @@ CFX_ByteString CPWL_Utils::GetTextAppStream(const CFX_FloatRect& rcBBox,
pEdit->SetFontSize(fFontSize);
pEdit->Initialize();
- pEdit->SetText(sText.c_str());
+ pEdit->SetText(sText);
CFX_ByteString sEdit =
CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_FloatPoint(0.0f, 0.0f));
@@ -480,7 +480,7 @@ CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
pEdit->SetFontSize(fFontSize);
pEdit->Initialize();
- pEdit->SetText(sLabel.c_str());
+ pEdit->SetText(sLabel);
CFX_FloatRect rcLabelContent = pEdit->GetContentRect();
CPWL_Icon Icon;