summaryrefslogtreecommitdiff
path: root/fpdfsdk/pwl
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-04-19 20:55:54 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-19 20:55:54 +0000
commitee96772e0878fa385b9a4a736a2fc109e19fd01e (patch)
treedef5fed9024c0aef25d7d1f81729b6f0a6687179 /fpdfsdk/pwl
parentc84ea8eda5a53229cf1faaed7cb54013b9ea18c3 (diff)
downloadpdfium-ee96772e0878fa385b9a4a736a2fc109e19fd01e.tar.xz
Add public APIs for undo / redo in forms.
Add FORM_CanUndo(), FORM_CanRedo(), FORM_Undo(), and FORM_Redo(). BUG=chromium:764260 Change-Id: I1d9ea67152d9b35d9b8e1d7ef7d019706fdfa30a Reviewed-on: https://pdfium-review.googlesource.com/30872 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/pwl')
-rw-r--r--fpdfsdk/pwl/cpwl_combo_box.cpp16
-rw-r--r--fpdfsdk/pwl/cpwl_combo_box.h4
-rw-r--r--fpdfsdk/pwl/cpwl_edit_ctrl.cpp14
-rw-r--r--fpdfsdk/pwl/cpwl_edit_ctrl.h8
-rw-r--r--fpdfsdk/pwl/cpwl_wnd.cpp16
-rw-r--r--fpdfsdk/pwl/cpwl_wnd.h6
6 files changed, 52 insertions, 12 deletions
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index 1576b022fd..2e6e56c52b 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -196,6 +196,22 @@ void CPWL_ComboBox::ReplaceSelection(const WideString& text) {
m_pEdit->ReplaceSelection(text);
}
+bool CPWL_ComboBox::CanUndo() {
+ return m_pEdit && m_pEdit->CanUndo();
+}
+
+bool CPWL_ComboBox::CanRedo() {
+ return m_pEdit && m_pEdit->CanRedo();
+}
+
+bool CPWL_ComboBox::Undo() {
+ return m_pEdit && m_pEdit->Undo();
+}
+
+bool CPWL_ComboBox::Redo() {
+ return m_pEdit && m_pEdit->Redo();
+}
+
WideString CPWL_ComboBox::GetText() {
return m_pEdit ? m_pEdit->GetText() : WideString();
}
diff --git a/fpdfsdk/pwl/cpwl_combo_box.h b/fpdfsdk/pwl/cpwl_combo_box.h
index 28c063d5fd..a4e823c4dc 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.h
+++ b/fpdfsdk/pwl/cpwl_combo_box.h
@@ -63,6 +63,10 @@ class CPWL_ComboBox : public CPWL_Wnd {
WideString GetText() override;
WideString GetSelectedText() override;
void ReplaceSelection(const WideString& text) override;
+ bool CanUndo() override;
+ bool CanRedo() override;
+ bool Undo() override;
+ bool Redo() override;
void SetFillerNotify(IPWL_Filler_Notify* pNotify);
diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
index 5e2f7acda6..579a587175 100644
--- a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
@@ -401,22 +401,20 @@ void CPWL_EditCtrl::Backspace() {
m_pEdit->Backspace();
}
-bool CPWL_EditCtrl::CanUndo() const {
+bool CPWL_EditCtrl::CanUndo() {
return !IsReadOnly() && m_pEdit->CanUndo();
}
-bool CPWL_EditCtrl::CanRedo() const {
+bool CPWL_EditCtrl::CanRedo() {
return !IsReadOnly() && m_pEdit->CanRedo();
}
-void CPWL_EditCtrl::Redo() {
- if (CanRedo())
- m_pEdit->Redo();
+bool CPWL_EditCtrl::Undo() {
+ return CanUndo() && m_pEdit->Undo();
}
-void CPWL_EditCtrl::Undo() {
- if (CanUndo())
- m_pEdit->Undo();
+bool CPWL_EditCtrl::Redo() {
+ return CanRedo() && m_pEdit->Redo();
}
int32_t CPWL_EditCtrl::GetCharSet() const {
diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.h b/fpdfsdk/pwl/cpwl_edit_ctrl.h
index 544464770f..a21c8a2700 100644
--- a/fpdfsdk/pwl/cpwl_edit_ctrl.h
+++ b/fpdfsdk/pwl/cpwl_edit_ctrl.h
@@ -36,10 +36,10 @@ class CPWL_EditCtrl : public CPWL_Wnd {
void SetCharSet(uint8_t nCharSet) { m_nCharSet = nCharSet; }
int32_t GetCharSet() const;
- bool CanUndo() const;
- bool CanRedo() const;
- void Redo();
- void Undo();
+ bool CanUndo() override;
+ bool CanRedo() override;
+ bool Undo() override;
+ bool Redo() override;
void SetReadyToInput();
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index c6d6b79136..8782e85a14 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -365,6 +365,22 @@ WideString CPWL_Wnd::GetSelectedText() {
void CPWL_Wnd::ReplaceSelection(const WideString& text) {}
+bool CPWL_Wnd::CanUndo() {
+ return false;
+}
+
+bool CPWL_Wnd::CanRedo() {
+ return false;
+}
+
+bool CPWL_Wnd::Undo() {
+ return false;
+}
+
+bool CPWL_Wnd::Redo() {
+ return false;
+}
+
bool CPWL_Wnd::OnMouseWheel(short zDelta,
const CFX_PointF& point,
uint32_t nFlag) {
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index 9c790eb5b8..a24635fa1f 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -184,6 +184,12 @@ class CPWL_Wnd : public CPWL_TimerHandler, public Observable<CPWL_Wnd> {
virtual WideString GetText();
virtual WideString GetSelectedText();
virtual void ReplaceSelection(const WideString& text);
+
+ virtual bool CanUndo();
+ virtual bool CanRedo();
+ virtual bool Undo();
+ virtual bool Redo();
+
virtual CFX_FloatRect GetFocusRect() const;
virtual CFX_FloatRect GetClientRect() const;