summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-01-05 15:40:40 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-05 20:55:18 +0000
commit245f80c4ae2bde11de8fdff54e736ec4e4296e0a (patch)
tree4e62bab9aabd17eb1f69e95f9755d5ddb2b144f2 /xfa
parenta172cfb094fe1012d71d556552977c86f2ae639d (diff)
downloadpdfium-245f80c4ae2bde11de8fdff54e736ec4e4296e0a.tar.xz
Convert CFWL_Edit Cut & Copy out param to return
Change-Id: I99776deb809609f69275848ddb81706e2cc82c82 Reviewed-on: https://pdfium-review.googlesource.com/22370 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fwl/cfwl_combobox.h4
-rw-r--r--xfa/fwl/cfwl_edit.cpp14
-rw-r--r--xfa/fwl/cfwl_edit.h4
-rw-r--r--xfa/fxfa/cxfa_ffcombobox.cpp12
-rw-r--r--xfa/fxfa/cxfa_ffcombobox.h4
-rw-r--r--xfa/fxfa/cxfa_fftextedit.cpp8
-rw-r--r--xfa/fxfa/cxfa_fftextedit.h4
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp8
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h4
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp4
10 files changed, 32 insertions, 34 deletions
diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h
index 923e2d8b9a..a9dc635373 100644
--- a/xfa/fwl/cfwl_combobox.h
+++ b/xfa/fwl/cfwl_combobox.h
@@ -83,8 +83,8 @@ class CFWL_ComboBox : public CFWL_Widget {
return EditCanCopy();
}
bool EditCanSelectAll() const { return m_pEdit->GetTextLength() > 0; }
- bool EditCopy(WideString& wsCopy) const { return m_pEdit->Copy(wsCopy); }
- bool EditCut(WideString& wsCut) { return m_pEdit->Cut(wsCut); }
+ Optional<WideString> EditCopy() const { return m_pEdit->Copy(); }
+ Optional<WideString> EditCut() { return m_pEdit->Cut(); }
bool EditPaste(const WideString& wsPaste) { return m_pEdit->Paste(wsPaste); }
void EditSelectAll() { m_pEdit->SelectAll(); }
void EditDelete() { m_pEdit->ClearText(); }
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index cdbca2cf54..960ec9967a 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -322,20 +322,18 @@ void CFWL_Edit::SetAliasChar(wchar_t wAlias) {
m_EdtEngine.SetAliasChar(wAlias);
}
-bool CFWL_Edit::Copy(WideString& wsCopy) {
+Optional<WideString> CFWL_Edit::Copy() {
if (!m_EdtEngine.HasSelection())
- return false;
+ return {};
- wsCopy = m_EdtEngine.GetSelectedText();
- return true;
+ return {m_EdtEngine.GetSelectedText()};
}
-bool CFWL_Edit::Cut(WideString& wsCut) {
+Optional<WideString> CFWL_Edit::Cut() {
if (!m_EdtEngine.HasSelection())
- return false;
+ return {};
- wsCut = m_EdtEngine.DeleteSelectedText();
- return true;
+ return {m_EdtEngine.DeleteSelectedText()};
}
bool CFWL_Edit::Paste(const WideString& wsPaste) {
diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h
index 6aedca8dec..9c667f5e14 100644
--- a/xfa/fwl/cfwl_edit.h
+++ b/xfa/fwl/cfwl_edit.h
@@ -80,8 +80,8 @@ class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate {
int32_t GetLimit() const;
void SetLimit(int32_t nLimit);
void SetAliasChar(wchar_t wAlias);
- bool Copy(WideString& wsCopy);
- bool Cut(WideString& wsCut);
+ Optional<WideString> Copy();
+ Optional<WideString> Cut();
bool Paste(const WideString& wsPaste);
bool Undo();
bool Redo();
diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp
index 58a0f94f9d..13bda7adbb 100644
--- a/xfa/fxfa/cxfa_ffcombobox.cpp
+++ b/xfa/fxfa/cxfa_ffcombobox.cpp
@@ -232,13 +232,15 @@ bool CXFA_FFComboBox::CanSelectAll() {
return ToComboBox(m_pNormalWidget.get())->EditCanSelectAll();
}
-bool CXFA_FFComboBox::Copy(WideString& wsCopy) {
- return ToComboBox(m_pNormalWidget.get())->EditCopy(wsCopy);
+Optional<WideString> CXFA_FFComboBox::Copy() {
+ return ToComboBox(m_pNormalWidget.get())->EditCopy();
}
-bool CXFA_FFComboBox::Cut(WideString& wsCut) {
- return m_pDataAcc->IsChoiceListAllowTextEntry() &&
- ToComboBox(m_pNormalWidget.get())->EditCut(wsCut);
+Optional<WideString> CXFA_FFComboBox::Cut() {
+ if (!m_pDataAcc->IsChoiceListAllowTextEntry())
+ return {};
+
+ return ToComboBox(m_pNormalWidget.get())->EditCut();
}
bool CXFA_FFComboBox::Paste(const WideString& wsPaste) {
diff --git a/xfa/fxfa/cxfa_ffcombobox.h b/xfa/fxfa/cxfa_ffcombobox.h
index 81da2c2125..727e1ba7bf 100644
--- a/xfa/fxfa/cxfa_ffcombobox.h
+++ b/xfa/fxfa/cxfa_ffcombobox.h
@@ -29,8 +29,8 @@ class CXFA_FFComboBox : public CXFA_FFField {
bool CanCut() override;
bool CanPaste() override;
bool CanSelectAll() override;
- bool Copy(WideString& wsCopy) override;
- bool Cut(WideString& wsCut) override;
+ Optional<WideString> Copy() override;
+ Optional<WideString> Cut() override;
bool Paste(const WideString& wsPaste) override;
void SelectAll() override;
void Delete() override;
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index b97b218894..3f4260c748 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -398,12 +398,12 @@ bool CXFA_FFTextEdit::CanSelectAll() {
return ToEdit(m_pNormalWidget.get())->GetTextLength() > 0;
}
-bool CXFA_FFTextEdit::Copy(WideString& wsCopy) {
- return ToEdit(m_pNormalWidget.get())->Copy(wsCopy);
+Optional<WideString> CXFA_FFTextEdit::Copy() {
+ return ToEdit(m_pNormalWidget.get())->Copy();
}
-bool CXFA_FFTextEdit::Cut(WideString& wsCut) {
- return ToEdit(m_pNormalWidget.get())->Copy(wsCut);
+Optional<WideString> CXFA_FFTextEdit::Cut() {
+ return ToEdit(m_pNormalWidget.get())->Cut();
}
bool CXFA_FFTextEdit::Paste(const WideString& wsPaste) {
diff --git a/xfa/fxfa/cxfa_fftextedit.h b/xfa/fxfa/cxfa_fftextedit.h
index dd3801b4df..404d35ec18 100644
--- a/xfa/fxfa/cxfa_fftextedit.h
+++ b/xfa/fxfa/cxfa_fftextedit.h
@@ -51,8 +51,8 @@ class CXFA_FFTextEdit : public CXFA_FFField {
bool CanCut() override;
bool CanPaste() override;
bool CanSelectAll() override;
- bool Copy(WideString& wsCopy) override;
- bool Cut(WideString& wsCut) override;
+ Optional<WideString> Copy() override;
+ Optional<WideString> Cut() override;
bool Paste(const WideString& wsPaste) override;
void SelectAll() override;
void Delete() override;
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 1314b8a3cd..2a844bbb82 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -1166,12 +1166,12 @@ bool CXFA_FFWidget::CanDeSelect() {
return CanCopy();
}
-bool CXFA_FFWidget::Copy(WideString& wsCopy) {
- return false;
+Optional<WideString> CXFA_FFWidget::Copy() {
+ return {};
}
-bool CXFA_FFWidget::Cut(WideString& wsCut) {
- return false;
+Optional<WideString> CXFA_FFWidget::Cut() {
+ return {};
}
bool CXFA_FFWidget::Paste(const WideString& wsPaste) {
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 13372320b8..f52098301f 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -127,8 +127,8 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem {
virtual bool CanSelectAll();
virtual bool CanDelete();
virtual bool CanDeSelect();
- virtual bool Copy(WideString& wsCopy);
- virtual bool Cut(WideString& wsCut);
+ virtual Optional<WideString> Copy();
+ virtual Optional<WideString> Cut();
virtual bool Paste(const WideString& wsPaste);
virtual void SelectAll();
virtual void Delete();
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 8988cf1903..79e48bab9b 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -150,9 +150,7 @@ WideString CXFA_FFWidgetHandler::GetSelectedText(CXFA_FFWidget* widget) {
if (!widget->CanCopy())
return WideString();
- WideString val;
- widget->Copy(val);
- return val;
+ return widget->Copy().value_or(WideString());
}
void CXFA_FFWidgetHandler::PasteText(CXFA_FFWidget* widget,