summaryrefslogtreecommitdiff
path: root/fpdfsdk/formfiller/cffl_textobject.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-08-01 18:34:43 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-08-02 19:15:00 +0000
commitb4fee4d5d471475ada1d0d9110e1a534b49477ba (patch)
tree3f969af1ac350b5c884f44f3f6d755d98d911415 /fpdfsdk/formfiller/cffl_textobject.cpp
parentdb14532fb2637b34f0926b6c3a931132854f53bb (diff)
downloadpdfium-b4fee4d5d471475ada1d0d9110e1a534b49477ba.tar.xz
Add CFFL_TextField class.chromium/3175
This class implements common code used by several CFFL_FormFiller sub-classes. Make those sub-classes inherit from CFFL_TextField, instead of inheriting from CFFL_FormFiller directly and then implementing the same functionality multiple times. Change-Id: Iad8a735b6d6e18e89d617636b753805d3f77a286 Reviewed-on: https://pdfium-review.googlesource.com/9850 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/formfiller/cffl_textobject.cpp')
-rw-r--r--fpdfsdk/formfiller/cffl_textobject.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/fpdfsdk/formfiller/cffl_textobject.cpp b/fpdfsdk/formfiller/cffl_textobject.cpp
new file mode 100644
index 0000000000..d84557eb88
--- /dev/null
+++ b/fpdfsdk/formfiller/cffl_textobject.cpp
@@ -0,0 +1,35 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fpdfsdk/formfiller/cffl_textobject.h"
+
+CPWL_Wnd* CFFL_TextObject::ResetPDFWindow(CPDFSDK_PageView* pPageView,
+ bool bRestoreValue) {
+ if (bRestoreValue)
+ SaveState(pPageView);
+
+ DestroyPDFWindow(pPageView);
+ if (bRestoreValue)
+ RestoreState(pPageView);
+
+ CPWL_Wnd::ObservedPtr pRet(GetPDFWindow(pPageView, !bRestoreValue));
+ m_pWidget->UpdateField(); // May invoke JS, invalidating |pRet|.
+ return pRet.Get();
+}
+
+CFFL_TextObject::CFFL_TextObject(CPDFSDK_FormFillEnvironment* pApp,
+ CPDFSDK_Widget* pWidget)
+ : CFFL_FormFiller(pApp, pWidget) {}
+
+CFFL_TextObject::~CFFL_TextObject() {}
+
+CBA_FontMap* CFFL_TextObject::MaybeCreateFontMap() {
+ if (!m_pFontMap) {
+ m_pFontMap =
+ pdfium::MakeUnique<CBA_FontMap>(m_pWidget.Get(), GetSystemHandler());
+ }
+ return m_pFontMap.get();
+}