summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfformfill.cpp8
-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
11 files changed, 36 insertions, 38 deletions
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index d70b678206..3d61336d13 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -500,8 +500,8 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_Widget_Copy(FPDF_DOCUMENT document,
if (!pContext->ContainsXFAForm())
return;
- WideString wsCpText;
- static_cast<CXFA_FFWidget*>(hWidget)->Copy(wsCpText);
+ WideString wsCpText =
+ static_cast<CXFA_FFWidget*>(hWidget)->Copy().value_or(WideString());
ByteString bsCpText = wsCpText.UTF16LE_Encode();
uint32_t len = bsCpText.GetLength() / sizeof(unsigned short);
@@ -531,8 +531,8 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_Widget_Cut(FPDF_DOCUMENT document,
if (!pContext->ContainsXFAForm())
return;
- WideString wsCpText;
- static_cast<CXFA_FFWidget*>(hWidget)->Cut(wsCpText);
+ WideString wsCpText =
+ static_cast<CXFA_FFWidget*>(hWidget)->Cut().value_or(WideString());
ByteString bsCpText = wsCpText.UTF16LE_Encode();
uint32_t len = bsCpText.GetLength() / sizeof(unsigned short);
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,