summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_fftextedit.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-20 16:21:31 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-21 13:29:50 +0000
commitb8777a2c5f38ea4d6fc74ea01a114d3e056c0fdb (patch)
tree83acc47e45d932146a70941b7484e78c426b3b27 /xfa/fxfa/cxfa_fftextedit.cpp
parent36eed87d19e741be9909500c45dd12e50ff6a1ab (diff)
downloadpdfium-b8777a2c5f38ea4d6fc74ea01a114d3e056c0fdb.tar.xz
Add embeddertest for CFWL_Edit
This CL adds two mouse selection tests for CFWL_Edit. In order to do so the needed selection code was added to the XFA widget handler and plumbed down to the CFWL_Edit field as needed. Bug: pdfium:840 Change-Id: Ia3b5f5d191494a4579c01524df8fb35b24cc0085 Reviewed-on: https://pdfium-review.googlesource.com/14530 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/cxfa_fftextedit.cpp')
-rw-r--r--xfa/fxfa/cxfa_fftextedit.cpp67
1 files changed, 67 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();
+}