summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_fftextedit.cpp67
-rw-r--r--xfa/fxfa/cxfa_fftextedit.h16
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp17
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.h3
4 files changed, 103 insertions, 0 deletions
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index 82b6f63b59..8f68368757 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -20,6 +20,14 @@
#include "xfa/fxfa/cxfa_ffapp.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+namespace {
+
+CFWL_Edit* ToEdit(CFWL_Widget* widget) {
+ return static_cast<CFWL_Edit*>(widget);
+}
+
+} // namespace
+
CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc)
: CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {}
@@ -356,3 +364,62 @@ void CXFA_FFTextEdit::OnDrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix& matrix) {
m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
}
+
+bool CXFA_FFTextEdit::CanUndo() {
+ return ToEdit(m_pNormalWidget.get())->CanUndo();
+}
+
+bool CXFA_FFTextEdit::CanRedo() {
+ return ToEdit(m_pNormalWidget.get())->CanRedo();
+}
+
+bool CXFA_FFTextEdit::Undo() {
+ return ToEdit(m_pNormalWidget.get())->Undo();
+}
+
+bool CXFA_FFTextEdit::Redo() {
+ return ToEdit(m_pNormalWidget.get())->Redo();
+}
+
+bool CXFA_FFTextEdit::CanCopy() {
+ return ToEdit(m_pNormalWidget.get())->HasSelection();
+}
+
+bool CXFA_FFTextEdit::CanCut() {
+ if (ToEdit(m_pNormalWidget.get())->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)
+ return false;
+ return ToEdit(m_pNormalWidget.get())->HasSelection();
+}
+
+bool CXFA_FFTextEdit::CanPaste() {
+ return !(ToEdit(m_pNormalWidget.get())->GetStylesEx() &
+ FWL_STYLEEXT_EDT_ReadOnly);
+}
+
+bool CXFA_FFTextEdit::CanSelectAll() {
+ return ToEdit(m_pNormalWidget.get())->GetTextLength() > 0;
+}
+
+bool CXFA_FFTextEdit::Copy(WideString& wsCopy) {
+ return ToEdit(m_pNormalWidget.get())->Copy(wsCopy);
+}
+
+bool CXFA_FFTextEdit::Cut(WideString& wsCut) {
+ return ToEdit(m_pNormalWidget.get())->Copy(wsCut);
+}
+
+bool CXFA_FFTextEdit::Paste(const WideString& wsPaste) {
+ return ToEdit(m_pNormalWidget.get())->Paste(wsPaste);
+}
+
+void CXFA_FFTextEdit::SelectAll() {
+ ToEdit(m_pNormalWidget.get())->SelectAll();
+}
+
+void CXFA_FFTextEdit::Delete() {
+ ToEdit(m_pNormalWidget.get())->ClearText();
+}
+
+void CXFA_FFTextEdit::DeSelect() {
+ ToEdit(m_pNormalWidget.get())->ClearSelection();
+}
diff --git a/xfa/fxfa/cxfa_fftextedit.h b/xfa/fxfa/cxfa_fftextedit.h
index 9735b9e7d8..dd3801b4df 100644
--- a/xfa/fxfa/cxfa_fftextedit.h
+++ b/xfa/fxfa/cxfa_fftextedit.h
@@ -42,6 +42,22 @@ class CXFA_FFTextEdit : public CXFA_FFField {
void OnTextFull(CFWL_Widget* pWidget);
bool CheckWord(const ByteStringView& sWord);
+ // CXFA_FFWidget
+ bool CanUndo() override;
+ bool CanRedo() override;
+ bool Undo() override;
+ bool Redo() override;
+ bool CanCopy() override;
+ bool CanCut() override;
+ bool CanPaste() override;
+ bool CanSelectAll() override;
+ bool Copy(WideString& wsCopy) override;
+ bool Cut(WideString& wsCut) override;
+ bool Paste(const WideString& wsPaste) override;
+ void SelectAll() override;
+ void Delete() override;
+ void DeSelect() override;
+
protected:
uint32_t GetAlignment();
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 524bbed9e2..8f916d804b 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -142,6 +142,23 @@ bool CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget,
return bRet;
}
+WideString CXFA_FFWidgetHandler::GetSelectedText(CXFA_FFWidget* widget) {
+ if (!widget->CanCopy())
+ return WideString();
+
+ WideString val;
+ widget->Copy(val);
+ return val;
+}
+
+void CXFA_FFWidgetHandler::PasteText(CXFA_FFWidget* widget,
+ const WideString& text) {
+ if (!widget->CanPaste())
+ return;
+
+ widget->Paste(text);
+}
+
FWL_WidgetHit CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget,
const CFX_PointF& point) {
if (!(hWidget->GetStatus() & XFA_WidgetStatus_Visible))
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.h b/xfa/fxfa/cxfa_ffwidgethandler.h
index 474412069e..e2b50dc27c 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.h
+++ b/xfa/fxfa/cxfa_ffwidgethandler.h
@@ -53,6 +53,9 @@ class CXFA_FFWidgetHandler {
uint32_t dwFlags,
const CFX_PointF& point);
+ WideString GetSelectedText(CXFA_FFWidget* widget);
+ void PasteText(CXFA_FFWidget* widget, const WideString& text);
+
bool OnKeyDown(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags);
bool OnKeyUp(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags);
bool OnChar(CXFA_FFWidget* hWidget, uint32_t dwChar, uint32_t dwFlags);