summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/formfiller
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-14 13:51:24 -0400
committerDan Sinclair <dsinclair@chromium.org>2016-03-14 13:51:24 -0400
commitf766ad219f66543654520f6a1955836f519e26d1 (patch)
tree2edf8bc93b89503a3669f7add5b6c2a407b8a78c /fpdfsdk/src/formfiller
parent54b0abed08048008498471e39b7c72b034474090 (diff)
downloadpdfium-f766ad219f66543654520f6a1955836f519e26d1.tar.xz
Move fpdfsdk/src up to fpdfsdk/.
This CL moves the files in fpdfsdk/src/ up one level to fpdfsdk/ and fixes up the include paths, include guards and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1799773002 .
Diffstat (limited to 'fpdfsdk/src/formfiller')
-rw-r--r--fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp259
-rw-r--r--fpdfsdk/src/formfiller/FFL_CheckBox.cpp116
-rw-r--r--fpdfsdk/src/formfiller/FFL_ComboBox.cpp302
-rw-r--r--fpdfsdk/src/formfiller/FFL_FormFiller.cpp727
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp1015
-rw-r--r--fpdfsdk/src/formfiller/FFL_ListBox.cpp223
-rw-r--r--fpdfsdk/src/formfiller/FFL_PushButton.cpp38
-rw-r--r--fpdfsdk/src/formfiller/FFL_RadioButton.cpp121
-rw-r--r--fpdfsdk/src/formfiller/FFL_TextField.cpp292
9 files changed, 0 insertions, 3093 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
deleted file mode 100644
index 35c2be6319..0000000000
--- a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright 2014 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/include/formfiller/FFL_CBA_Fontmap.h"
-
-#include "core/include/fpdfapi/cpdf_document.h"
-#include "core/include/fpdfapi/cpdf_simple_parser.h"
-#include "core/include/fpdfapi/fpdf_page.h"
-#include "fpdfsdk/include/fsdk_baseannot.h"
-
-CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot,
- IFX_SystemHandler* pSystemHandler)
- : CPWL_FontMap(pSystemHandler),
- m_pDocument(NULL),
- m_pAnnotDict(NULL),
- m_pDefaultFont(NULL),
- m_sAPType("N") {
- CPDF_Page* pPage = pAnnot->GetPDFPage();
-
- m_pDocument = pPage->m_pDocument;
- m_pAnnotDict = pAnnot->GetPDFAnnot()->GetAnnotDict();
- Initialize();
-}
-
-CBA_FontMap::~CBA_FontMap() {}
-
-void CBA_FontMap::Reset() {
- Empty();
- m_pDefaultFont = NULL;
- m_sDefaultFontName = "";
-}
-
-void CBA_FontMap::Initialize() {
- int32_t nCharset = DEFAULT_CHARSET;
-
- if (!m_pDefaultFont) {
- m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName);
- if (m_pDefaultFont) {
- if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) {
- nCharset = pSubstFont->m_Charset;
- } else {
- if (m_sDefaultFontName == "Wingdings" ||
- m_sDefaultFontName == "Wingdings2" ||
- m_sDefaultFontName == "Wingdings3" ||
- m_sDefaultFontName == "Webdings")
- nCharset = SYMBOL_CHARSET;
- else
- nCharset = ANSI_CHARSET;
- }
- AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset);
- AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName);
- }
- }
-
- if (nCharset != ANSI_CHARSET)
- CPWL_FontMap::Initialize();
-}
-
-void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont,
- const CFX_ByteString& sFontName) {
- ASSERT(pFont);
-
- if (m_pDefaultFont)
- return;
-
- m_pDefaultFont = pFont;
- m_sDefaultFontName = sFontName;
-
- int32_t nCharset = DEFAULT_CHARSET;
- if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont())
- nCharset = pSubstFont->m_Charset;
- AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset);
-}
-
-CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias,
- int32_t nCharset) {
- if (m_pAnnotDict->GetStringBy("Subtype") == "Widget") {
- CPDF_Document* pDocument = GetDocument();
- CPDF_Dictionary* pRootDict = pDocument->GetRoot();
- if (!pRootDict)
- return NULL;
-
- CPDF_Dictionary* pAcroFormDict = pRootDict->GetDictBy("AcroForm");
- if (!pAcroFormDict)
- return NULL;
-
- CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR");
- if (!pDRDict)
- return NULL;
-
- return FindResFontSameCharset(pDRDict, sFontAlias, nCharset);
- }
-
- return NULL;
-}
-
-CPDF_Document* CBA_FontMap::GetDocument() {
- return m_pDocument;
-}
-
-CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict,
- CFX_ByteString& sFontAlias,
- int32_t nCharset) {
- if (!pResDict)
- return NULL;
-
- CPDF_Dictionary* pFonts = pResDict->GetDictBy("Font");
- if (!pFonts)
- return NULL;
-
- CPDF_Document* pDocument = GetDocument();
- CPDF_Font* pFind = NULL;
- for (const auto& it : *pFonts) {
- const CFX_ByteString& csKey = it.first;
- CPDF_Object* pObj = it.second;
- if (!pObj)
- continue;
-
- CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
- if (!pElement)
- continue;
- if (pElement->GetStringBy("Type") != "Font")
- continue;
-
- CPDF_Font* pFont = pDocument->LoadFont(pElement);
- if (!pFont)
- continue;
- const CFX_SubstFont* pSubst = pFont->GetSubstFont();
- if (!pSubst)
- continue;
- if (pSubst->m_Charset == nCharset) {
- sFontAlias = csKey;
- pFind = pFont;
- }
- }
- return pFind;
-}
-
-void CBA_FontMap::AddedFont(CPDF_Font* pFont,
- const CFX_ByteString& sFontAlias) {
- AddFontToAnnotDict(pFont, sFontAlias);
-}
-
-void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
- const CFX_ByteString& sAlias) {
- if (!pFont)
- return;
-
- CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP");
-
- if (!pAPDict) {
- pAPDict = new CPDF_Dictionary;
- m_pAnnotDict->SetAt("AP", pAPDict);
- }
-
- // to avoid checkbox and radiobutton
- CPDF_Object* pObject = pAPDict->GetElement(m_sAPType);
- if (ToDictionary(pObject))
- return;
-
- CPDF_Stream* pStream = pAPDict->GetStreamBy(m_sAPType);
- if (!pStream) {
- pStream = new CPDF_Stream(NULL, 0, NULL);
- int32_t objnum = m_pDocument->AddIndirectObject(pStream);
- pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum);
- }
-
- CPDF_Dictionary* pStreamDict = pStream->GetDict();
-
- if (!pStreamDict) {
- pStreamDict = new CPDF_Dictionary;
- pStream->InitStream(NULL, 0, pStreamDict);
- }
-
- if (pStreamDict) {
- CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources");
- if (!pStreamResList) {
- pStreamResList = new CPDF_Dictionary();
- pStreamDict->SetAt("Resources", pStreamResList);
- }
-
- if (pStreamResList) {
- CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font");
- if (!pStreamResFontList) {
- pStreamResFontList = new CPDF_Dictionary;
- int32_t objnum = m_pDocument->AddIndirectObject(pStreamResFontList);
- pStreamResList->SetAtReference("Font", m_pDocument, objnum);
- }
- if (!pStreamResFontList->KeyExist(sAlias))
- pStreamResFontList->SetAtReference(sAlias, m_pDocument,
- pFont->GetFontDict());
- }
- }
-}
-
-CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
- CPDF_Dictionary* pAcroFormDict = NULL;
- const bool bWidget = (m_pAnnotDict->GetStringBy("Subtype") == "Widget");
- if (bWidget) {
- if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot())
- pAcroFormDict = pRootDict->GetDictBy("AcroForm");
- }
-
- CFX_ByteString sDA;
- CPDF_Object* pObj;
- if ((pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA")))
- sDA = pObj->GetString();
-
- if (bWidget) {
- if (sDA.IsEmpty()) {
- pObj = FPDF_GetFieldAttr(pAcroFormDict, "DA");
- sDA = pObj ? pObj->GetString() : CFX_ByteString();
- }
- }
-
- CPDF_Dictionary* pFontDict = NULL;
-
- if (!sDA.IsEmpty()) {
- CPDF_SimpleParser syntax(sDA);
- syntax.FindTagParamFromStart("Tf", 2);
- CFX_ByteString sFontName = syntax.GetWord();
- sAlias = PDF_NameDecode(sFontName).Mid(1);
-
- if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDictBy("DR"))
- if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"))
- pFontDict = pDRFontDict->GetDictBy(sAlias);
-
- if (!pFontDict)
- if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP"))
- if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N"))
- if (CPDF_Dictionary* pNormalResDict =
- pNormalDict->GetDictBy("Resources"))
- if (CPDF_Dictionary* pResFontDict =
- pNormalResDict->GetDictBy("Font"))
- pFontDict = pResFontDict->GetDictBy(sAlias);
-
- if (bWidget) {
- if (!pFontDict) {
- if (pAcroFormDict) {
- if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR"))
- if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"))
- pFontDict = pDRFontDict->GetDictBy(sAlias);
- }
- }
- }
- }
-
- return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr;
-}
-
-void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) {
- m_sAPType = sAPType;
-
- Reset();
- Initialize();
-}
diff --git a/fpdfsdk/src/formfiller/FFL_CheckBox.cpp b/fpdfsdk/src/formfiller/FFL_CheckBox.cpp
deleted file mode 100644
index 485f86ba75..0000000000
--- a/fpdfsdk/src/formfiller/FFL_CheckBox.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2014 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/include/formfiller/FFL_CheckBox.h"
-
-#include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
-#include "fpdfsdk/include/fsdk_mgr.h"
-#include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h"
-#include "public/fpdf_fwlevent.h"
-
-CFFL_CheckBox::CFFL_CheckBox(CPDFDoc_Environment* pApp, CPDFSDK_Widget* pWidget)
- : CFFL_Button(pApp, pWidget) {}
-
-CFFL_CheckBox::~CFFL_CheckBox() {}
-
-CPWL_Wnd* CFFL_CheckBox::NewPDFWindow(const PWL_CREATEPARAM& cp,
- CPDFSDK_PageView* pPageView) {
- CPWL_CheckBox* pWnd = new CPWL_CheckBox();
- pWnd->Create(cp);
- pWnd->SetCheck(m_pWidget->IsChecked());
- return pWnd;
-}
-
-FX_BOOL CFFL_CheckBox::OnKeyDown(CPDFSDK_Annot* pAnnot,
- FX_UINT nKeyCode,
- FX_UINT nFlags) {
- switch (nKeyCode) {
- case FWL_VKEY_Return:
- case FWL_VKEY_Space:
- return TRUE;
- default:
- return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags);
- }
-}
-FX_BOOL CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot,
- FX_UINT nChar,
- FX_UINT nFlags) {
- switch (nChar) {
- case FWL_VKEY_Return:
- case FWL_VKEY_Space: {
- CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
- ASSERT(pIFormFiller);
-
- CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
- ASSERT(pPageView);
-
- FX_BOOL bReset = FALSE;
- FX_BOOL bExit = FALSE;
-
- pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, bExit, nFlags);
-
- if (bReset)
- return TRUE;
- if (bExit)
- return TRUE;
-
- CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
-
- if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, TRUE))
- pWnd->SetCheck(!pWnd->IsChecked());
-
- CommitData(pPageView, nFlags);
- return TRUE;
- }
- default:
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
- }
-}
-
-FX_BOOL CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point);
-
- if (IsValid()) {
- if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, TRUE)) {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- pWnd->SetCheck(!pWidget->IsChecked());
- }
-
- if (!CommitData(pPageView, nFlags))
- return FALSE;
- }
-
- return TRUE;
-}
-
-FX_BOOL CFFL_CheckBox::IsDataChanged(CPDFSDK_PageView* pPageView) {
- CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, FALSE);
- return pWnd && pWnd->IsChecked() != m_pWidget->IsChecked();
-}
-
-void CFFL_CheckBox::SaveData(CPDFSDK_PageView* pPageView) {
- if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, FALSE)) {
- bool bNewChecked = pWnd->IsChecked();
-
- if (bNewChecked) {
- CPDF_FormField* pField = m_pWidget->GetFormField();
- for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
- if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
- if (pCtrl->IsChecked()) {
- break;
- }
- }
- }
- }
-
- m_pWidget->SetCheck(bNewChecked, false);
- m_pWidget->UpdateField();
- SetChangeMark();
- }
-}
diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
deleted file mode 100644
index 5e88a5d133..0000000000
--- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-// Copyright 2014 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/include/formfiller/FFL_ComboBox.h"
-
-#include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h"
-#include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
-#include "fpdfsdk/include/formfiller/FFL_IFormFiller.h"
-#include "fpdfsdk/include/fsdk_common.h"
-#include "fpdfsdk/include/fsdk_mgr.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ComboBox.h"
-
-CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot)
- : CFFL_FormFiller(pApp, pAnnot), m_pFontMap(NULL) {
- m_State.nIndex = 0;
- m_State.nStart = 0;
- m_State.nEnd = 0;
-}
-
-CFFL_ComboBox::~CFFL_ComboBox() {
- for (const auto& it : m_Maps)
- it.second->InvalidateFocusHandler(this);
- delete m_pFontMap;
-}
-
-PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() {
- PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
-
- int nFlags = m_pWidget->GetFieldFlags();
- if (nFlags & FIELDFLAG_EDIT) {
- cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
- }
-
- if (!m_pFontMap)
- m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler());
- cp.pFontMap = m_pFontMap;
- cp.pFocusHandler = this;
-
- return cp;
-}
-
-CPWL_Wnd* CFFL_ComboBox::NewPDFWindow(const PWL_CREATEPARAM& cp,
- CPDFSDK_PageView* pPageView) {
- CPWL_ComboBox* pWnd = new CPWL_ComboBox();
- pWnd->AttachFFLData(this);
- pWnd->Create(cp);
-
- CFFL_IFormFiller* pFormFiller = m_pApp->GetIFormFiller();
- pWnd->SetFillerNotify(pFormFiller);
-
- int32_t nCurSel = m_pWidget->GetSelectedIndex(0);
- CFX_WideString swText;
- if (nCurSel < 0)
- swText = m_pWidget->GetValue();
- else
- swText = m_pWidget->GetOptionLabel(nCurSel);
-
- for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) {
- pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str());
- }
-
- pWnd->SetSelect(nCurSel);
- pWnd->SetText(swText.c_str());
- return pWnd;
-}
-
-FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot,
- FX_UINT nChar,
- FX_UINT nFlags) {
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
-}
-
-FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView) {
- CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE);
- if (!pWnd)
- return FALSE;
-
- int32_t nCurSel = pWnd->GetSelect();
- if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT))
- return nCurSel != m_pWidget->GetSelectedIndex(0);
-
- if (nCurSel >= 0)
- return nCurSel != m_pWidget->GetSelectedIndex(0);
-
- return pWnd->GetText() != m_pWidget->GetValue();
-}
-
-void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView) {
- CPWL_ComboBox* pWnd =
- static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE));
- if (!pWnd)
- return;
-
- CFX_WideString swText = pWnd->GetText();
- int32_t nCurSel = pWnd->GetSelect();
-
- bool bSetValue = false;
-
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
- bSetValue = (nCurSel < 0) || (swText != m_pWidget->GetOptionLabel(nCurSel));
-
- if (bSetValue) {
- m_pWidget->SetValue(swText, FALSE);
- } else {
- m_pWidget->GetSelectedIndex(0);
- m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE);
- }
-
- m_pWidget->ResetFieldAppearance(TRUE);
- m_pWidget->UpdateField();
- SetChangeMark();
-
- m_pWidget->GetPDFPage();
-}
-
-void CFFL_ComboBox::GetActionData(CPDFSDK_PageView* pPageView,
- CPDF_AAction::AActionType type,
- PDFSDK_FieldAction& fa) {
- switch (type) {
- case CPDF_AAction::KeyStroke:
- if (CPWL_ComboBox* pComboBox =
- static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
- if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
- fa.bFieldFull = pEdit->IsTextFull();
- int nSelStart = 0;
- int nSelEnd = 0;
- pEdit->GetSel(nSelStart, nSelEnd);
- fa.nSelEnd = nSelEnd;
- fa.nSelStart = nSelStart;
- fa.sValue = pEdit->GetText();
- fa.sChangeEx = GetSelectExportText();
-
- if (fa.bFieldFull) {
- fa.sChange = L"";
- fa.sChangeEx = L"";
- }
- }
- }
- break;
- case CPDF_AAction::Validate:
- if (CPWL_ComboBox* pComboBox =
- static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
- if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
- fa.sValue = pEdit->GetText();
- }
- }
- break;
- case CPDF_AAction::LoseFocus:
- case CPDF_AAction::GetFocus:
- fa.sValue = m_pWidget->GetValue();
- break;
- default:
- break;
- }
-}
-
-void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView,
- CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& fa) {
- switch (type) {
- case CPDF_AAction::KeyStroke:
- if (CPWL_ComboBox* pComboBox =
- static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
- if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
- pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
- pEdit->ReplaceSel(fa.sChange.c_str());
- }
- }
- break;
- default:
- break;
- }
-}
-
-FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& faOld,
- const PDFSDK_FieldAction& faNew) {
- switch (type) {
- case CPDF_AAction::KeyStroke:
- return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) ||
- faOld.nSelStart != faNew.nSelStart ||
- faOld.sChange != faNew.sChange;
- default:
- break;
- }
-
- return FALSE;
-}
-
-void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView) {
- ASSERT(pPageView);
-
- if (CPWL_ComboBox* pComboBox =
- static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
- m_State.nIndex = pComboBox->GetSelect();
-
- if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
- pEdit->GetSel(m_State.nStart, m_State.nEnd);
- m_State.sValue = pEdit->GetText();
- }
- }
-}
-
-void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) {
- ASSERT(pPageView);
-
- if (CPWL_ComboBox* pComboBox =
- static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, TRUE))) {
- if (m_State.nIndex >= 0) {
- pComboBox->SetSelect(m_State.nIndex);
- } else {
- if (CPWL_Edit* pEdit = pComboBox->GetEdit()) {
- pEdit->SetText(m_State.sValue.c_str());
- pEdit->SetSel(m_State.nStart, m_State.nEnd);
- }
- }
- }
-}
-
-CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView,
- FX_BOOL bRestoreValue) {
- if (bRestoreValue)
- SaveState(pPageView);
-
- DestroyPDFWindow(pPageView);
-
- CPWL_Wnd* pRet = NULL;
-
- if (bRestoreValue) {
- RestoreState(pPageView);
- pRet = GetPDFWindow(pPageView, FALSE);
- } else {
- pRet = GetPDFWindow(pPageView, TRUE);
- }
-
- m_pWidget->UpdateField();
-
- return pRet;
-}
-
-#ifdef PDF_ENABLE_XFA
-FX_BOOL CFFL_ComboBox::IsFieldFull(CPDFSDK_PageView* pPageView) {
- if (CPWL_ComboBox* pComboBox =
- static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
- if (CPWL_Edit* pEdit = pComboBox->GetEdit())
- return pEdit->IsTextFull();
- }
- return FALSE;
-}
-#endif // PDF_ENABLE_XFA
-
-void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) {
- ASSERT(m_pApp);
-
- if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) {
- CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
- pEdit->SetCharSet(134);
- pEdit->SetCodePage(936);
-
- pEdit->SetReadyToInput();
- CFX_WideString wsText = pEdit->GetText();
- int nCharacters = wsText.GetLength();
- CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
- unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str();
- m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer,
- nCharacters, TRUE);
-
- pEdit->SetEditNotify(this);
- }
-}
-
-void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd) {
- ASSERT(m_pApp);
-}
-
-void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit) {
- ASSERT(pEdit);
-}
-
-CFX_WideString CFFL_ComboBox::GetSelectExportText() {
- CFX_WideString swRet;
-
- int nExport = -1;
- CPDFSDK_PageView* pPageView = GetCurPageView();
- if (CPWL_ComboBox* pComboBox =
- (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) {
- nExport = pComboBox->GetSelect();
- }
-
- if (nExport >= 0) {
- if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) {
- swRet = pFormField->GetOptionValue(nExport);
- if (swRet.IsEmpty())
- swRet = pFormField->GetOptionLabel(nExport);
- }
- }
-
- return swRet;
-}
diff --git a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
deleted file mode 100644
index e596ba08ba..0000000000
--- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
+++ /dev/null
@@ -1,727 +0,0 @@
-// Copyright 2014 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/include/formfiller/FFL_FormFiller.h"
-
-#include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h"
-#include "fpdfsdk/include/fsdk_common.h"
-#include "fpdfsdk/include/fsdk_mgr.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-
-#define GetRed(rgb) ((uint8_t)(rgb))
-#define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8))
-#define GetBlue(rgb) ((uint8_t)((rgb) >> 16))
-
-#define FFL_HINT_ELAPSE 800
-
-CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp,
- CPDFSDK_Annot* pAnnot)
- : m_pApp(pApp), m_pAnnot(pAnnot), m_bValid(FALSE), m_ptOldPos(0, 0) {
- m_pWidget = (CPDFSDK_Widget*)pAnnot;
-}
-
-CFFL_FormFiller::~CFFL_FormFiller() {
- for (const auto& it : m_Maps) {
- CPWL_Wnd* pWnd = it.second;
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
- pWnd->InvalidateProvider(this);
- pWnd->Destroy();
- delete pWnd;
- delete pData;
- }
- m_Maps.clear();
-}
-
-void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView,
- const CFX_FloatRect& rcWindow) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- pWnd->Move(CFX_FloatRect(rcWindow), TRUE, FALSE);
- }
-}
-
-CFX_FloatRect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- return pWnd->GetWindowRect();
- }
-
- return CFX_FloatRect(0, 0, 0, 0);
-}
-
-FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot) {
- ASSERT(pPageView);
- ASSERT(pAnnot);
-
- CFX_FloatRect rcAnnot = m_pWidget->GetRect();
-
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- CFX_FloatRect rcWindow = pWnd->GetWindowRect();
- rcAnnot = PWLtoFFL(rcWindow);
- }
-
- CFX_FloatRect rcWin = rcAnnot;
-
- CFX_FloatRect rcFocus = GetFocusBox(pPageView);
- if (!rcFocus.IsEmpty())
- rcWin.Union(rcFocus);
-
- CFX_FloatRect rect = CPWL_Utils::InflateRect(rcWin, 1);
-
- return rect.GetOutterRect();
-}
-
-void CFFL_FormFiller::OnDraw(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- FX_DWORD dwFlags) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- CFX_Matrix mt = GetCurMatrix();
- mt.Concat(*pUser2Device);
- pWnd->DrawAppearance(pDevice, &mt);
- } else {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (CFFL_IFormFiller::IsVisible(pWidget))
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- }
-}
-
-void CFFL_FormFiller::OnDrawDeactive(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- FX_DWORD dwFlags) {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
-}
-
-void CFFL_FormFiller::OnCreate(CPDFSDK_Annot* pAnnot) {}
-
-void CFFL_FormFiller::OnLoad(CPDFSDK_Annot* pAnnot) {}
-
-void CFFL_FormFiller::OnDelete(CPDFSDK_Annot* pAnnot) {}
-
-void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot) {}
-
-void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot) {
- EndTimer();
- ASSERT(m_pWidget);
-}
-
-FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) {
- m_bValid = TRUE;
- FX_RECT rect = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
-
- if (!rect.Contains((int)point.x, (int)point.y))
- return FALSE;
-
- return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags);
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom);
- pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y)) {
- m_ptOldPos = point;
- }
-
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- short zDelta,
- const CFX_FloatPoint& point) {
- if (!IsValid())
- return FALSE;
-
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) {
- return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags);
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) {
- pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags);
- return TRUE;
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot,
- FX_UINT nKeyCode,
- FX_UINT nFlags) {
- if (IsValid()) {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView);
-
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- return pWnd->OnKeyDown(nKeyCode, nFlags);
- }
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot,
- FX_UINT nChar,
- FX_UINT nFlags) {
- if (IsValid()) {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView);
-
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- return pWnd->OnChar(nChar, nFlags);
- }
- }
-
- return FALSE;
-}
-
-void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
- CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument();
- CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage);
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE))
- pWnd->SetFocus();
-
- m_bValid = TRUE;
- FX_RECT rcRect = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
-}
-
-void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
- if (!IsValid())
- return;
-
- CPDFSDK_PageView* pPageView = GetCurPageView();
- if (!pPageView)
- return;
-
- CommitData(pPageView, nFlag);
-
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
- pWnd->KillFocus();
-
- FX_BOOL bDestroyPDFWindow;
- switch (m_pWidget->GetFieldType()) {
- case FIELDTYPE_PUSHBUTTON:
- case FIELDTYPE_CHECKBOX:
- case FIELDTYPE_RADIOBUTTON:
- bDestroyPDFWindow = TRUE;
- break;
- default:
- bDestroyPDFWindow = FALSE;
- break;
- }
- EscapeFiller(pPageView, bDestroyPDFWindow);
-}
-
-FX_BOOL CFFL_FormFiller::IsValid() const {
- return m_bValid;
-}
-
-PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() {
- ASSERT(m_pApp);
-
- PWL_CREATEPARAM cp;
- cp.pParentWnd = NULL;
- cp.pProvider = this;
- cp.rcRectWnd = GetPDFWindowRect();
-
- FX_DWORD dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE;
- FX_DWORD dwFieldFlag = m_pWidget->GetFieldFlags();
- if (dwFieldFlag & FIELDFLAG_READONLY) {
- dwCreateFlags |= PWS_READONLY;
- }
-
- FX_COLORREF color;
- if (m_pWidget->GetFillColor(color)) {
- cp.sBackgroundColor =
- CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color));
- }
-
- if (m_pWidget->GetBorderColor(color)) {
- cp.sBorderColor =
- CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color));
- }
-
- cp.sTextColor = CPWL_Color(COLORTYPE_GRAY, 0);
-
- if (m_pWidget->GetTextColor(color)) {
- cp.sTextColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color));
- }
-
- cp.fFontSize = m_pWidget->GetFontSize();
- cp.dwBorderWidth = m_pWidget->GetBorderWidth();
-
- int nBorderStyle = m_pWidget->GetBorderStyle();
-
- switch (nBorderStyle) {
- case BBS_SOLID:
- cp.nBorderStyle = PBS_SOLID;
- break;
- case BBS_DASH:
- cp.nBorderStyle = PBS_DASH;
- cp.sDash = CPWL_Dash(3, 3, 0);
- break;
- case BBS_BEVELED:
- cp.nBorderStyle = PBS_BEVELED;
- cp.dwBorderWidth *= 2;
- break;
- case BBS_INSET:
- cp.nBorderStyle = PBS_INSET;
- cp.dwBorderWidth *= 2;
- break;
- case BBS_UNDERLINE:
- cp.nBorderStyle = PBS_UNDERLINED;
- break;
- }
-
- if (cp.fFontSize <= 0) {
- dwCreateFlags |= PWS_AUTOFONTSIZE;
- }
-
- cp.dwFlags = dwCreateFlags;
- cp.pSystemHandler = m_pApp->GetSysHandler();
- return cp;
-}
-
-CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView,
- FX_BOOL bNew) {
- ASSERT(pPageView);
-
- auto it = m_Maps.find(pPageView);
- const bool found = it != m_Maps.end();
- CPWL_Wnd* pWnd = found ? it->second : nullptr;
- if (!bNew)
- return pWnd;
-
- if (found) {
- CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pWnd->GetAttachedData();
- if (pPrivateData->nWidgetAge != m_pWidget->GetAppearanceAge()) {
- return ResetPDFWindow(
- pPageView, m_pWidget->GetValueAge() == pPrivateData->nValueAge);
- }
- } else {
- PWL_CREATEPARAM cp = GetCreateParam();
- cp.hAttachedWnd = (FX_HWND)m_pWidget;
-
- CFFL_PrivateData* pPrivateData = new CFFL_PrivateData;
- pPrivateData->pWidget = m_pWidget;
- pPrivateData->pPageView = pPageView;
- pPrivateData->nWidgetAge = m_pWidget->GetAppearanceAge();
- pPrivateData->nValueAge = 0;
-
- cp.pAttachedData = pPrivateData;
-
- pWnd = NewPDFWindow(cp, pPageView);
- m_Maps[pPageView] = pWnd;
- }
-
- return pWnd;
-}
-
-void CFFL_FormFiller::DestroyPDFWindow(CPDFSDK_PageView* pPageView) {
- auto it = m_Maps.find(pPageView);
- if (it == m_Maps.end())
- return;
-
- CPWL_Wnd* pWnd = it->second;
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
- pWnd->Destroy();
- delete pWnd;
- delete pData;
-
- m_Maps.erase(it);
-}
-
-CFX_Matrix CFFL_FormFiller::GetWindowMatrix(void* pAttachedData) {
- if (CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pAttachedData) {
- if (pPrivateData->pPageView) {
- CFX_Matrix mtPageView;
- pPrivateData->pPageView->GetCurrentMatrix(mtPageView);
- CFX_Matrix mt = GetCurMatrix();
- mt.Concat(mtPageView);
-
- return mt;
- }
- }
- return CFX_Matrix(1, 0, 0, 1, 0, 0);
-}
-
-CFX_Matrix CFFL_FormFiller::GetCurMatrix() {
- CFX_Matrix mt;
-
- CFX_FloatRect rcDA;
- m_pWidget->GetPDFAnnot()->GetRect(rcDA);
-
- switch (m_pWidget->GetRotate()) {
- default:
- case 0:
- mt = CFX_Matrix(1, 0, 0, 1, 0, 0);
- break;
- case 90:
- mt = CFX_Matrix(0, 1, -1, 0, rcDA.right - rcDA.left, 0);
- break;
- case 180:
- mt = CFX_Matrix(-1, 0, 0, -1, rcDA.right - rcDA.left,
- rcDA.top - rcDA.bottom);
- break;
- case 270:
- mt = CFX_Matrix(0, -1, 1, 0, 0, rcDA.top - rcDA.bottom);
- break;
- }
- mt.e += rcDA.left;
- mt.f += rcDA.bottom;
-
- return mt;
-}
-
-CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) {
- ASSERT(m_pApp);
-
- return L"";
-}
-
-CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const {
- CFX_FloatRect rectAnnot;
- m_pWidget->GetPDFAnnot()->GetRect(rectAnnot);
-
- FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left;
- FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom;
- if ((m_pWidget->GetRotate() / 90) & 0x01)
- return CFX_FloatRect(0, 0, fHeight, fWidth);
-
- return CFX_FloatRect(0, 0, fWidth, fHeight);
-}
-
-CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() {
- UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage();
- CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument();
- return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr;
-}
-
-CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
- CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect()));
- CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox();
- if (rcPage.Contains(rcFocus))
- return rcFocus;
- }
- return CFX_FloatRect(0, 0, 0, 0);
-}
-
-CFX_FloatRect CFFL_FormFiller::FFLtoPWL(const CFX_FloatRect& rect) {
- CFX_Matrix mt;
- mt.SetReverse(GetCurMatrix());
-
- CFX_FloatRect temp = rect;
- mt.TransformRect(temp);
-
- return temp;
-}
-
-CFX_FloatRect CFFL_FormFiller::PWLtoFFL(const CFX_FloatRect& rect) {
- CFX_Matrix mt = GetCurMatrix();
-
- CFX_FloatRect temp = rect;
- mt.TransformRect(temp);
-
- return temp;
-}
-
-CFX_FloatPoint CFFL_FormFiller::FFLtoPWL(const CFX_FloatPoint& point) {
- CFX_Matrix mt;
- mt.SetReverse(GetCurMatrix());
-
- CFX_FloatPoint pt = point;
- mt.Transform(pt.x, pt.y);
-
- return pt;
-}
-
-CFX_FloatPoint CFFL_FormFiller::PWLtoFFL(const CFX_FloatPoint& point) {
- CFX_Matrix mt = GetCurMatrix();
-
- CFX_FloatPoint pt = point;
- mt.Transform(pt.x, pt.y);
-
- return pt;
-}
-
-CFX_FloatPoint CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView,
- const CFX_FloatPoint& pt) {
- return FFLtoPWL(pt);
-}
-
-CFX_FloatRect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView,
- const CFX_FloatRect& rect) {
- return rect;
-}
-
-FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView,
- FX_UINT nFlag) {
- if (IsDataChanged(pPageView)) {
- FX_BOOL bRC = TRUE;
- FX_BOOL bExit = FALSE;
- CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
- pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag);
- if (bExit)
- return TRUE;
- if (!bRC) {
- ResetPDFWindow(pPageView, FALSE);
- return TRUE;
- }
-
- pIFormFiller->OnValidate(m_pWidget, pPageView, bRC, bExit, nFlag);
- if (bExit)
- return TRUE;
- if (!bRC) {
- ResetPDFWindow(pPageView, FALSE);
- return TRUE;
- }
-
- SaveData(pPageView);
- pIFormFiller->OnCalculate(m_pWidget, pPageView, bExit, nFlag);
- if (bExit)
- return TRUE;
-
- pIFormFiller->OnFormat(m_pWidget, pPageView, bExit, nFlag);
- }
- return TRUE;
-}
-
-FX_BOOL CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView) {
- return FALSE;
-}
-
-void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) {}
-
-#ifdef PDF_ENABLE_XFA
-FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) {
- return FALSE;
-}
-#endif // PDF_ENABLE_XFA
-
-void CFFL_FormFiller::SetChangeMark() {
- m_pApp->FFI_OnChange();
-}
-
-void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView,
- CPDF_AAction::AActionType type,
- PDFSDK_FieldAction& fa) {
- fa.sValue = m_pWidget->GetValue();
-}
-
-void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView,
- CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& fa) {}
-
-FX_BOOL CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& faOld,
- const PDFSDK_FieldAction& faNew) {
- return FALSE;
-}
-
-void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView) {}
-
-void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) {}
-
-CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView,
- FX_BOOL bRestoreValue) {
- return GetPDFWindow(pPageView, FALSE);
-}
-
-void CFFL_FormFiller::TimerProc() {}
-
-IFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const {
- return m_pApp->GetSysHandler();
-}
-
-void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView,
- FX_BOOL bDestroyPDFWindow) {
- m_bValid = FALSE;
-
- FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget);
- InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
-
- if (bDestroyPDFWindow)
- DestroyPDFWindow(pPageView);
-}
-
-void CFFL_FormFiller::InvalidateRect(double left,
- double top,
- double right,
- double bottom) {
- UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage();
- m_pApp->FFI_Invalidate(pPage, left, top, right, bottom);
-}
-
-CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget)
- : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {}
-
-CFFL_Button::~CFFL_Button() {}
-
-void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot) {
- m_bMouseIn = TRUE;
- FX_RECT rect = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
-}
-
-void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot) {
- m_bMouseIn = FALSE;
-
- FX_RECT rect = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
- EndTimer();
- ASSERT(m_pWidget);
-}
-
-FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- CFX_FloatRect rcAnnot = pAnnot->GetRect();
- if (!rcAnnot.Contains(point.x, point.y))
- return FALSE;
-
- m_bMouseDown = TRUE;
- m_bValid = TRUE;
- FX_RECT rect = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
- return TRUE;
-}
-
-FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- CFX_FloatRect rcAnnot = pAnnot->GetRect();
- if (!rcAnnot.Contains(point.x, point.y))
- return FALSE;
-
- m_bMouseDown = FALSE;
- m_pWidget->GetPDFPage();
-
- FX_RECT rect = GetViewBBox(pPageView, pAnnot);
- InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
- return TRUE;
-}
-
-FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- ASSERT(m_pApp);
-
- return TRUE;
-}
-
-void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- FX_DWORD dwFlags) {
- ASSERT(pPageView);
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- CPDF_FormControl* pCtrl = pWidget->GetFormControl();
- CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode();
-
- if (eHM != CPDF_FormControl::Push) {
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- return;
- }
-
- if (m_bMouseDown) {
- if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down))
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL);
- else
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- } else if (m_bMouseIn) {
- if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Rollover))
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Rollover,
- NULL);
- else
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- } else {
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
- }
-}
-
-void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- FX_DWORD dwFlags) {
- OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
-}
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
deleted file mode 100644
index 75f18e7c73..0000000000
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ /dev/null
@@ -1,1015 +0,0 @@
-// Copyright 2014 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/include/formfiller/FFL_IFormFiller.h"
-
-#include "core/include/fpdfapi/cpdf_document.h"
-#include "fpdfsdk/include/formfiller/FFL_CheckBox.h"
-#include "fpdfsdk/include/formfiller/FFL_ComboBox.h"
-#include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
-#include "fpdfsdk/include/formfiller/FFL_ListBox.h"
-#include "fpdfsdk/include/formfiller/FFL_PushButton.h"
-#include "fpdfsdk/include/formfiller/FFL_RadioButton.h"
-#include "fpdfsdk/include/formfiller/FFL_TextField.h"
-#include "fpdfsdk/include/fsdk_mgr.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-
-#define FFL_MAXLISTBOXHEIGHT 140.0f
-
-CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp)
- : m_pApp(pApp), m_bNotifying(FALSE) {}
-
-CFFL_IFormFiller::~CFFL_IFormFiller() {
- for (auto& it : m_Maps)
- delete it.second;
- m_Maps.clear();
-}
-
-FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- CFX_FloatPoint point) {
- CFX_FloatRect rc = pAnnot->GetRect();
- if (rc.Contains(point.x, point.y))
- return TRUE;
- return FALSE;
-}
-
-FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- return pFormFiller->GetViewBBox(pPageView, pAnnot);
-
- ASSERT(pPageView);
-
- CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
- CFX_FloatRect rcAnnot;
- pPDFAnnot->GetRect(rcAnnot);
-
- CFX_FloatRect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1);
- return rcWin.GetOutterRect();
-}
-
-void CFFL_IFormFiller::OnDraw(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- FX_DWORD dwFlags) {
- ASSERT(pPageView);
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
-
- if (IsVisible(pWidget)) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- if (pFormFiller->IsValid()) {
- pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
- pAnnot->GetPDFPage();
-
- CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
- if (pDocument->GetFocusAnnot() == pAnnot) {
- CFX_FloatRect rcFocus = pFormFiller->GetFocusBox(pPageView);
- if (!rcFocus.IsEmpty()) {
- CFX_PathData path;
- path.SetPointCount(5);
- path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO);
- path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO);
- path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO);
- path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO);
- path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO);
-
- CFX_GraphStateData gsd;
- gsd.SetDashCount(1);
- gsd.m_DashArray[0] = 1.0f;
- gsd.m_DashPhase = 0;
- gsd.m_LineWidth = 1.0f;
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
- ArgbEncode(255, 0, 0, 0), FXFILL_ALTERNATE);
- }
- }
- return;
- }
- }
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, pUser2Device,
- dwFlags);
- else
- pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
-
- if (!IsReadOnly(pWidget) && IsFillingAllowed(pWidget))
- pWidget->DrawShadow(pDevice, pPageView);
- }
-}
-
-void CFFL_IFormFiller::OnCreate(CPDFSDK_Annot* pAnnot) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- pFormFiller->OnCreate(pAnnot);
- }
-}
-
-void CFFL_IFormFiller::OnLoad(CPDFSDK_Annot* pAnnot) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- pFormFiller->OnLoad(pAnnot);
- }
-}
-
-void CFFL_IFormFiller::OnDelete(CPDFSDK_Annot* pAnnot) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- pFormFiller->OnDelete(pAnnot);
- }
-
- UnRegisterFormFiller(pAnnot);
-}
-
-void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlag) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (!m_bNotifying) {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::CursorEnter).GetDict()) {
- m_bNotifying = TRUE;
-
- int nValueAge = pWidget->GetValueAge();
-
- pWidget->ClearAppModified();
-
- ASSERT(pPageView);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- pWidget->OnAAction(CPDF_AAction::CursorEnter, fa, pPageView);
- m_bNotifying = FALSE;
-
- if (pWidget->IsAppModified()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- pWidget->GetValueAge() == nValueAge);
- }
- }
- }
- }
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) {
- pFormFiller->OnMouseEnter(pPageView, pAnnot);
- }
-}
-
-void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlag) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (!m_bNotifying) {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::CursorExit).GetDict()) {
- m_bNotifying = TRUE;
- pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
-
- ASSERT(pPageView);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
- pWidget->OnAAction(CPDF_AAction::CursorExit, fa, pPageView);
- m_bNotifying = FALSE;
-
- if (pWidget->IsAppModified()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- nValueAge == pWidget->GetValueAge());
- }
- }
- }
- }
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- pFormFiller->OnMouseExit(pPageView, pAnnot);
- }
-}
-
-FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (!m_bNotifying) {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (Annot_HitTest(pPageView, pAnnot, point) &&
- pWidget->GetAAction(CPDF_AAction::ButtonDown).GetDict()) {
- m_bNotifying = TRUE;
- pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
-
- ASSERT(pPageView);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlags);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlags);
- pWidget->OnAAction(CPDF_AAction::ButtonDown, fa, pPageView);
- m_bNotifying = FALSE;
-
- if (!IsValidAnnot(pPageView, pAnnot))
- return TRUE;
-
- if (pWidget->IsAppModified()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- nValueAge == pWidget->GetValueAge());
- }
- }
- }
- }
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- return pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
-
- switch (pWidget->GetFieldType()) {
- case FIELDTYPE_PUSHBUTTON:
- case FIELDTYPE_CHECKBOX:
- case FIELDTYPE_RADIOBUTTON:
- if (GetViewBBox(pPageView, pAnnot).Contains((int)point.x, (int)point.y))
- pDocument->SetFocusAnnot(pAnnot);
- break;
- default:
- pDocument->SetFocusAnnot(pAnnot);
- break;
- }
-
- FX_BOOL bRet = FALSE;
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- bRet = pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
- }
-
- if (pDocument->GetFocusAnnot() == pAnnot) {
- FX_BOOL bExit = FALSE;
- FX_BOOL bReset = FALSE;
- OnButtonUp(pWidget, pPageView, bReset, bExit, nFlags);
- if (bExit)
- return TRUE;
-#ifdef PDF_ENABLE_XFA
- OnClick(pWidget, pPageView, bReset, bExit, nFlags);
- if (bExit)
- return TRUE;
-#endif // PDF_ENABLE_XFA
- }
- return bRet;
-}
-
-void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget,
- CPDFSDK_PageView* pPageView,
- FX_BOOL& bReset,
- FX_BOOL& bExit,
- FX_UINT nFlag) {
- ASSERT(pWidget);
-
- if (!m_bNotifying) {
- if (pWidget->GetAAction(CPDF_AAction::ButtonUp).GetDict()) {
- m_bNotifying = TRUE;
- int nAge = pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
-
- ASSERT(pPageView);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
- pWidget->OnAAction(CPDF_AAction::ButtonUp, fa, pPageView);
- m_bNotifying = FALSE;
-
- if (!IsValidAnnot(pPageView, pWidget)) {
- bExit = TRUE;
- return;
- }
-
- if (nAge != pWidget->GetAppearanceAge()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- nValueAge == pWidget->GetValueAge());
- }
-
- bReset = TRUE;
- }
- }
- }
-}
-
-FX_BOOL CFFL_IFormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_IFormFiller::OnMouseMove(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- // change cursor
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) {
- return pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_IFormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- short zDelta,
- const CFX_FloatPoint& point) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_IFormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_IFormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot,
- FX_UINT nKeyCode,
- FX_UINT nFlags) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags);
- }
-
- return FALSE;
-}
-
-FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot,
- FX_UINT nChar,
- FX_UINT nFlags) {
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
- if (nChar == FWL_VKEY_Tab)
- return TRUE;
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE))
- return pFormFiller->OnChar(pAnnot, nChar, nFlags);
-
- return FALSE;
-}
-
-FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
- if (!pAnnot)
- return FALSE;
-
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (!m_bNotifying) {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::GetFocus).GetDict()) {
- m_bNotifying = TRUE;
- pWidget->GetAppearanceAge();
-
- int nValueAge = pWidget->GetValueAge();
- pWidget->ClearAppModified();
-
- CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
- ASSERT(pPageView);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
- CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, TRUE);
- if (!pFormFiller)
- return FALSE;
- pFormFiller->GetActionData(pPageView, CPDF_AAction::GetFocus, fa);
- pWidget->OnAAction(CPDF_AAction::GetFocus, fa, pPageView);
- m_bNotifying = FALSE;
-
- if (pWidget->IsAppModified()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- nValueAge == pWidget->GetValueAge());
- }
- }
- }
- }
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
- pFormFiller->SetFocusForAnnot(pAnnot, nFlag);
-
- return TRUE;
-}
-
-FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
- if (!pAnnot)
- return FALSE;
- ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- pFormFiller->KillFocusForAnnot(pAnnot, nFlag);
-
- if (!m_bNotifying) {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::LoseFocus).GetDict()) {
- m_bNotifying = TRUE;
- pWidget->ClearAppModified();
-
- CPDFSDK_PageView* pPageView = pWidget->GetPageView();
- ASSERT(pPageView);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
- pFormFiller->GetActionData(pPageView, CPDF_AAction::LoseFocus, fa);
-
- pWidget->OnAAction(CPDF_AAction::LoseFocus, fa, pPageView);
- m_bNotifying = FALSE;
- }
- }
- }
-
- return TRUE;
-}
-
-FX_BOOL CFFL_IFormFiller::IsVisible(CPDFSDK_Widget* pWidget) {
- return pWidget->IsVisible();
-}
-
-FX_BOOL CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) {
- int nFieldFlags = pWidget->GetFieldFlags();
- return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY;
-}
-
-FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) {
- if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
- return TRUE;
-
- CPDF_Page* pPage = pWidget->GetPDFPage();
- CPDF_Document* pDocument = pPage->m_pDocument;
- FX_DWORD dwPermissions = pDocument->GetUserPermissions();
- return (dwPermissions & FPDFPERM_FILL_FORM) ||
- (dwPermissions & FPDFPERM_ANNOT_FORM) ||
- (dwPermissions & FPDFPERM_MODIFY);
-}
-
-CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot,
- FX_BOOL bRegister) {
- auto it = m_Maps.find(pAnnot);
- if (it != m_Maps.end())
- return it->second;
-
- if (!bRegister)
- return nullptr;
-
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- int nFieldType = pWidget->GetFieldType();
- CFFL_FormFiller* pFormFiller;
- switch (nFieldType) {
- case FIELDTYPE_PUSHBUTTON:
- pFormFiller = new CFFL_PushButton(m_pApp, pWidget);
- break;
- case FIELDTYPE_CHECKBOX:
- pFormFiller = new CFFL_CheckBox(m_pApp, pWidget);
- break;
- case FIELDTYPE_RADIOBUTTON:
- pFormFiller = new CFFL_RadioButton(m_pApp, pWidget);
- break;
- case FIELDTYPE_TEXTFIELD:
- pFormFiller = new CFFL_TextField(m_pApp, pWidget);
- break;
- case FIELDTYPE_LISTBOX:
- pFormFiller = new CFFL_ListBox(m_pApp, pWidget);
- break;
- case FIELDTYPE_COMBOBOX:
- pFormFiller = new CFFL_ComboBox(m_pApp, pWidget);
- break;
- case FIELDTYPE_UNKNOWN:
- default:
- pFormFiller = nullptr;
- break;
- }
-
- if (!pFormFiller)
- return nullptr;
-
- m_Maps[pAnnot] = pFormFiller;
- return pFormFiller;
-}
-
-void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot) {
- if (pAnnot) {
- UnRegisterFormFiller(pAnnot);
- }
-}
-
-void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) {
- auto it = m_Maps.find(pAnnot);
- if (it == m_Maps.end())
- return;
-
- delete it->second;
- m_Maps.erase(it);
-}
-
-void CFFL_IFormFiller::QueryWherePopup(void* pPrivateData,
- FX_FLOAT fPopupMin,
- FX_FLOAT fPopupMax,
- int32_t& nRet,
- FX_FLOAT& fPopupRet) {
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
-
- CFX_FloatRect rcPageView(0, 0, 0, 0);
- rcPageView.right = pData->pWidget->GetPDFPage()->GetPageWidth();
- rcPageView.bottom = pData->pWidget->GetPDFPage()->GetPageHeight();
- rcPageView.Normalize();
-
- CFX_FloatRect rcAnnot = pData->pWidget->GetRect();
-
- FX_FLOAT fTop = 0.0f;
- FX_FLOAT fBottom = 0.0f;
-
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pData->pWidget;
- switch (pWidget->GetRotate() / 90) {
- default:
- case 0:
- fTop = rcPageView.top - rcAnnot.top;
- fBottom = rcAnnot.bottom - rcPageView.bottom;
- break;
- case 1:
- fTop = rcAnnot.left - rcPageView.left;
- fBottom = rcPageView.right - rcAnnot.right;
- break;
- case 2:
- fTop = rcAnnot.bottom - rcPageView.bottom;
- fBottom = rcPageView.top - rcAnnot.top;
- break;
- case 3:
- fTop = rcPageView.right - rcAnnot.right;
- fBottom = rcAnnot.left - rcPageView.left;
- break;
- }
-
- FX_FLOAT fFactHeight = 0;
- FX_BOOL bBottom = TRUE;
- FX_FLOAT fMaxListBoxHeight = 0;
- if (fPopupMax > FFL_MAXLISTBOXHEIGHT) {
- if (fPopupMin > FFL_MAXLISTBOXHEIGHT) {
- fMaxListBoxHeight = fPopupMin;
- } else {
- fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT;
- }
- } else {
- fMaxListBoxHeight = fPopupMax;
- }
-
- if (fBottom > fMaxListBoxHeight) {
- fFactHeight = fMaxListBoxHeight;
- bBottom = TRUE;
- } else {
- if (fTop > fMaxListBoxHeight) {
- fFactHeight = fMaxListBoxHeight;
- bBottom = FALSE;
- } else {
- if (fTop > fBottom) {
- fFactHeight = fTop;
- bBottom = FALSE;
- } else {
- fFactHeight = fBottom;
- bBottom = TRUE;
- }
- }
- }
-
- nRet = bBottom ? 0 : 1;
- fPopupRet = fFactHeight;
-}
-
-void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget,
- CPDFSDK_PageView* pPageView,
- FX_BOOL& bRC,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- if (!m_bNotifying) {
- if (pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) {
- m_bNotifying = TRUE;
- pWidget->ClearAppModified();
-
- ASSERT(pPageView);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- fa.bWillCommit = TRUE;
- fa.bKeyDown = TRUE;
- fa.bRC = TRUE;
-
- CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
- pFormFiller->GetActionData(pPageView, CPDF_AAction::KeyStroke, fa);
- pFormFiller->SaveState(pPageView);
-
- PDFSDK_FieldAction faOld = fa;
- pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pPageView);
-
- bRC = fa.bRC;
- m_bNotifying = FALSE;
- }
- }
-}
-
-void CFFL_IFormFiller::OnValidate(CPDFSDK_Widget* pWidget,
- CPDFSDK_PageView* pPageView,
- FX_BOOL& bRC,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- if (!m_bNotifying) {
- if (pWidget->GetAAction(CPDF_AAction::Validate).GetDict()) {
- m_bNotifying = TRUE;
- pWidget->ClearAppModified();
-
- ASSERT(pPageView);
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- fa.bKeyDown = TRUE;
- fa.bRC = TRUE;
-
- CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE);
- pFormFiller->GetActionData(pPageView, CPDF_AAction::Validate, fa);
- pFormFiller->SaveState(pPageView);
-
- PDFSDK_FieldAction faOld = fa;
- pWidget->OnAAction(CPDF_AAction::Validate, fa, pPageView);
-
- bRC = fa.bRC;
- m_bNotifying = FALSE;
- }
- }
-}
-
-void CFFL_IFormFiller::OnCalculate(CPDFSDK_Widget* pWidget,
- CPDFSDK_PageView* pPageView,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- if (!m_bNotifying) {
- ASSERT(pWidget);
- CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
- CPDFSDK_InterForm* pInterForm =
- (CPDFSDK_InterForm*)pDocument->GetInterForm();
- pInterForm->OnCalculate(pWidget->GetFormField());
-
- m_bNotifying = FALSE;
- }
-}
-
-void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget,
- CPDFSDK_PageView* pPageView,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- if (!m_bNotifying) {
- ASSERT(pWidget);
- CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
- CPDFSDK_InterForm* pInterForm =
- (CPDFSDK_InterForm*)pDocument->GetInterForm();
-
- FX_BOOL bFormated = FALSE;
- CFX_WideString sValue =
- pInterForm->OnFormat(pWidget->GetFormField(), bFormated);
-
- if (bExit)
- return;
-
- if (bFormated) {
- pInterForm->ResetFieldAppearance(pWidget->GetFormField(), sValue.c_str(),
- TRUE);
- pInterForm->UpdateField(pWidget->GetFormField());
- }
-
- m_bNotifying = FALSE;
- }
-}
-
-#ifdef PDF_ENABLE_XFA
-void CFFL_IFormFiller::OnClick(CPDFSDK_Widget* pWidget,
- CPDFSDK_PageView* pPageView,
- FX_BOOL& bReset,
- FX_BOOL& bExit,
- FX_UINT nFlag) {
- if (!m_bNotifying) {
- if (pWidget->HasXFAAAction(PDFSDK_XFA_Click)) {
- m_bNotifying = TRUE;
- int nAge = pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
- pWidget->OnXFAAAction(PDFSDK_XFA_Click, fa, pPageView);
- m_bNotifying = FALSE;
-
- if (!IsValidAnnot(pPageView, pWidget)) {
- bExit = TRUE;
- return;
- }
-
- if (nAge != pWidget->GetAppearanceAge()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- nValueAge == pWidget->GetValueAge());
- }
-
- bReset = TRUE;
- }
- }
- }
-}
-
-void CFFL_IFormFiller::OnFull(CPDFSDK_Widget* pWidget,
- CPDFSDK_PageView* pPageView,
- FX_BOOL& bReset,
- FX_BOOL& bExit,
- FX_UINT nFlag) {
- if (!m_bNotifying) {
- if (pWidget->HasXFAAAction(PDFSDK_XFA_Full)) {
- m_bNotifying = TRUE;
- int nAge = pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
- pWidget->OnXFAAAction(PDFSDK_XFA_Full, fa, pPageView);
- m_bNotifying = FALSE;
-
- if (!IsValidAnnot(pPageView, pWidget)) {
- bExit = TRUE;
- return;
- }
-
- if (nAge != pWidget->GetAppearanceAge()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- nValueAge == pWidget->GetValueAge());
- }
-
- bReset = TRUE;
- }
- }
- }
-}
-
-void CFFL_IFormFiller::OnPopupPreOpen(void* pPrivateData,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
- ASSERT(pData);
- ASSERT(pData->pWidget);
-
- FX_BOOL bTempReset = FALSE;
- FX_BOOL bTempExit = FALSE;
- OnPreOpen(pData->pWidget, pData->pPageView, bTempReset, bTempExit, nFlag);
-
- if (bTempReset || bTempExit) {
- bExit = TRUE;
- }
-}
-
-void CFFL_IFormFiller::OnPopupPostOpen(void* pPrivateData,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
- ASSERT(pData);
- ASSERT(pData->pWidget);
-
- FX_BOOL bTempReset = FALSE;
- FX_BOOL bTempExit = FALSE;
- OnPostOpen(pData->pWidget, pData->pPageView, bTempReset, bTempExit, nFlag);
-
- if (bTempReset || bTempExit) {
- bExit = TRUE;
- }
-}
-
-void CFFL_IFormFiller::OnPreOpen(CPDFSDK_Widget* pWidget,
- CPDFSDK_PageView* pPageView,
- FX_BOOL& bReset,
- FX_BOOL& bExit,
- FX_UINT nFlag) {
- if (!m_bNotifying) {
- if (pWidget->HasXFAAAction(PDFSDK_XFA_PreOpen)) {
- m_bNotifying = TRUE;
- int nAge = pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
- pWidget->OnXFAAAction(PDFSDK_XFA_PreOpen, fa, pPageView);
- m_bNotifying = FALSE;
-
- if (!IsValidAnnot(pPageView, pWidget)) {
- bExit = TRUE;
- return;
- }
-
- if (nAge != pWidget->GetAppearanceAge()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- nValueAge == pWidget->GetValueAge());
- }
-
- bReset = TRUE;
- }
- }
- }
-}
-
-void CFFL_IFormFiller::OnPostOpen(CPDFSDK_Widget* pWidget,
- CPDFSDK_PageView* pPageView,
- FX_BOOL& bReset,
- FX_BOOL& bExit,
- FX_UINT nFlag) {
- if (!m_bNotifying) {
- if (pWidget->HasXFAAAction(PDFSDK_XFA_PostOpen)) {
- m_bNotifying = TRUE;
- int nAge = pWidget->GetAppearanceAge();
- int nValueAge = pWidget->GetValueAge();
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
-
- pWidget->OnXFAAAction(PDFSDK_XFA_PostOpen, fa, pPageView);
- m_bNotifying = FALSE;
-
- if (!IsValidAnnot(pPageView, pWidget)) {
- bExit = TRUE;
- return;
- }
-
- if (nAge != pWidget->GetAppearanceAge()) {
- if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE)) {
- pFormFiller->ResetPDFWindow(pPageView,
- nValueAge == pWidget->GetValueAge());
- }
-
- bReset = TRUE;
- }
- }
- }
-}
-#endif // PDF_ENABLE_XFA
-
-FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot) {
- if (pPageView)
- return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
-
- return FALSE;
-}
-
-void CFFL_IFormFiller::OnBeforeKeyStroke(void* pPrivateData,
- CFX_WideString& strChange,
- const CFX_WideString& strChangeEx,
- int nSelStart,
- int nSelEnd,
- FX_BOOL bKeyDown,
- FX_BOOL& bRC,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
- ASSERT(pData->pWidget);
-
- CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
-
-#ifdef PDF_ENABLE_XFA
- if (pFormFiller->IsFieldFull(pData->pPageView)) {
- FX_BOOL bFullExit = FALSE;
- FX_BOOL bFullReset = FALSE;
- OnFull(pData->pWidget, pData->pPageView, bFullReset, bFullExit, nFlag);
-
- if (bFullReset || bFullExit) {
- bExit = TRUE;
- return;
- }
- }
-#endif // PDF_ENABLE_XFA
-
- if (!m_bNotifying) {
- if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) {
- m_bNotifying = TRUE;
- int nAge = pData->pWidget->GetAppearanceAge();
- int nValueAge = pData->pWidget->GetValueAge();
-
- CPDFSDK_Document* pDocument = pData->pPageView->GetSDKDocument();
-
- PDFSDK_FieldAction fa;
- fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
- fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
- fa.sChange = strChange;
- fa.sChangeEx = strChangeEx;
- fa.bKeyDown = bKeyDown;
- fa.bWillCommit = FALSE;
- fa.bRC = TRUE;
- fa.nSelStart = nSelStart;
- fa.nSelEnd = nSelEnd;
-
- pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa);
- pFormFiller->SaveState(pData->pPageView);
-
- if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa,
- pData->pPageView)) {
- if (!IsValidAnnot(pData->pPageView, pData->pWidget)) {
- bExit = TRUE;
- m_bNotifying = FALSE;
- return;
- }
-
- if (nAge != pData->pWidget->GetAppearanceAge()) {
- CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow(
- pData->pPageView, nValueAge == pData->pWidget->GetValueAge());
- pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
- bExit = TRUE;
- }
-
- if (fa.bRC) {
- pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke,
- fa);
- bRC = FALSE;
- } else {
- pFormFiller->RestoreState(pData->pPageView);
- bRC = FALSE;
- }
-
- if (pDocument->GetFocusAnnot() != pData->pWidget) {
- pFormFiller->CommitData(pData->pPageView, nFlag);
- bExit = TRUE;
- }
- } else {
- if (!IsValidAnnot(pData->pPageView, pData->pWidget)) {
- bExit = TRUE;
- m_bNotifying = FALSE;
- return;
- }
- }
-
- m_bNotifying = FALSE;
- }
- }
-}
diff --git a/fpdfsdk/src/formfiller/FFL_ListBox.cpp b/fpdfsdk/src/formfiller/FFL_ListBox.cpp
deleted file mode 100644
index 638618f784..0000000000
--- a/fpdfsdk/src/formfiller/FFL_ListBox.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-// Copyright 2014 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/include/formfiller/FFL_ListBox.h"
-
-#include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h"
-#include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
-#include "fpdfsdk/include/formfiller/FFL_IFormFiller.h"
-#include "fpdfsdk/include/fsdk_common.h"
-#include "fpdfsdk/include/fsdk_mgr.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ListBox.h"
-
-#define FFL_DEFAULTLISTBOXFONTSIZE 12.0f
-
-CFFL_ListBox::CFFL_ListBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget)
- : CFFL_FormFiller(pApp, pWidget), m_pFontMap(NULL) {}
-
-CFFL_ListBox::~CFFL_ListBox() {
- delete m_pFontMap;
-}
-
-PWL_CREATEPARAM CFFL_ListBox::GetCreateParam() {
- PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
-
- FX_DWORD dwFieldFlag = m_pWidget->GetFieldFlags();
-
- if (dwFieldFlag & FIELDFLAG_MULTISELECT) {
- cp.dwFlags |= PLBS_MULTIPLESEL;
- }
-
- cp.dwFlags |= PWS_VSCROLL;
-
- if (cp.dwFlags & PWS_AUTOFONTSIZE)
- cp.fFontSize = FFL_DEFAULTLISTBOXFONTSIZE;
-
- if (!m_pFontMap)
- m_pFontMap = new CBA_FontMap(m_pWidget, m_pApp->GetSysHandler());
- cp.pFontMap = m_pFontMap;
-
- return cp;
-}
-
-CPWL_Wnd* CFFL_ListBox::NewPDFWindow(const PWL_CREATEPARAM& cp,
- CPDFSDK_PageView* pPageView) {
- CPWL_ListBox* pWnd = new CPWL_ListBox();
- pWnd->AttachFFLData(this);
- pWnd->Create(cp);
-
- CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
- pWnd->SetFillerNotify(pIFormFiller);
-
- for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++)
- pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str());
-
- if (pWnd->HasFlag(PLBS_MULTIPLESEL)) {
- m_OriginSelections.clear();
-
- FX_BOOL bSetCaret = FALSE;
- for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) {
- if (m_pWidget->IsOptionSelected(i)) {
- if (!bSetCaret) {
- pWnd->SetCaret(i);
- bSetCaret = TRUE;
- }
- pWnd->Select(i);
- m_OriginSelections.insert(i);
- }
- }
- } else {
- for (int i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) {
- if (m_pWidget->IsOptionSelected(i)) {
- pWnd->Select(i);
- break;
- }
- }
- }
-
- pWnd->SetTopVisibleIndex(m_pWidget->GetTopVisibleIndex());
-
- return pWnd;
-}
-
-FX_BOOL CFFL_ListBox::OnChar(CPDFSDK_Annot* pAnnot,
- FX_UINT nChar,
- FX_UINT nFlags) {
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
-}
-
-FX_BOOL CFFL_ListBox::IsDataChanged(CPDFSDK_PageView* pPageView) {
- CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE);
- if (!pListBox)
- return FALSE;
-
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
- size_t nSelCount = 0;
- for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; ++i) {
- if (pListBox->IsItemSelected(i)) {
- if (m_OriginSelections.count(i) == 0)
- return TRUE;
-
- ++nSelCount;
- }
- }
-
- return nSelCount != m_OriginSelections.size();
- }
- return pListBox->GetCurSel() != m_pWidget->GetSelectedIndex(0);
-}
-
-void CFFL_ListBox::SaveData(CPDFSDK_PageView* pPageView) {
- ASSERT(m_pWidget);
-
- if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE)) {
- CFX_IntArray aOldSelect, aNewSelect;
-
- {
- for (int i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) {
- if (m_pWidget->IsOptionSelected(i)) {
- aOldSelect.Add(i);
- }
- }
- }
-
- int32_t nNewTopIndex = pListBox->GetTopVisibleIndex();
-
- m_pWidget->ClearSelection(FALSE);
-
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
- for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) {
- if (pListBox->IsItemSelected(i)) {
- m_pWidget->SetOptionSelection(i, TRUE, FALSE);
- aNewSelect.Add(i);
- }
- }
- } else {
- m_pWidget->SetOptionSelection(pListBox->GetCurSel(), TRUE, FALSE);
- aNewSelect.Add(pListBox->GetCurSel());
- }
-
- m_pWidget->SetTopVisibleIndex(nNewTopIndex);
- m_pWidget->ResetFieldAppearance(TRUE);
- m_pWidget->UpdateField();
- SetChangeMark();
- }
-}
-
-void CFFL_ListBox::GetActionData(CPDFSDK_PageView* pPageView,
- CPDF_AAction::AActionType type,
- PDFSDK_FieldAction& fa) {
- switch (type) {
- case CPDF_AAction::Validate:
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
- fa.sValue = L"";
- } else {
- if (CPWL_ListBox* pListBox =
- (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE)) {
- int32_t nCurSel = pListBox->GetCurSel();
- if (nCurSel >= 0)
- fa.sValue = m_pWidget->GetOptionLabel(nCurSel);
- }
- }
- break;
- case CPDF_AAction::LoseFocus:
- case CPDF_AAction::GetFocus:
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
- fa.sValue = L"";
- } else {
- int32_t nCurSel = m_pWidget->GetSelectedIndex(0);
- if (nCurSel >= 0)
- fa.sValue = m_pWidget->GetOptionLabel(nCurSel);
- }
- break;
- default:
- break;
- }
-}
-
-void CFFL_ListBox::SetActionData(CPDFSDK_PageView* pPageView,
- CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& fa) {}
-
-void CFFL_ListBox::SaveState(CPDFSDK_PageView* pPageView) {
- ASSERT(pPageView);
-
- if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE)) {
- for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) {
- if (pListBox->IsItemSelected(i)) {
- m_State.Add(i);
- }
- }
- }
-}
-
-void CFFL_ListBox::RestoreState(CPDFSDK_PageView* pPageView) {
- if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE)) {
- for (int i = 0, sz = m_State.GetSize(); i < sz; i++)
- pListBox->Select(m_State[i]);
- }
-}
-
-CPWL_Wnd* CFFL_ListBox::ResetPDFWindow(CPDFSDK_PageView* pPageView,
- FX_BOOL bRestoreValue) {
- if (bRestoreValue)
- SaveState(pPageView);
-
- DestroyPDFWindow(pPageView);
-
- CPWL_Wnd* pRet = NULL;
-
- if (bRestoreValue) {
- RestoreState(pPageView);
- pRet = GetPDFWindow(pPageView, FALSE);
- } else {
- pRet = GetPDFWindow(pPageView, TRUE);
- }
-
- m_pWidget->UpdateField();
-
- return pRet;
-}
diff --git a/fpdfsdk/src/formfiller/FFL_PushButton.cpp b/fpdfsdk/src/formfiller/FFL_PushButton.cpp
deleted file mode 100644
index d5bd509718..0000000000
--- a/fpdfsdk/src/formfiller/FFL_PushButton.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2014 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/include/formfiller/FFL_PushButton.h"
-
-#include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
-#include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h"
-
-CFFL_PushButton::CFFL_PushButton(CPDFDoc_Environment* pApp,
- CPDFSDK_Annot* pAnnot)
- : CFFL_Button(pApp, pAnnot) {}
-
-CFFL_PushButton::~CFFL_PushButton() {}
-
-CPWL_Wnd* CFFL_PushButton::NewPDFWindow(const PWL_CREATEPARAM& cp,
- CPDFSDK_PageView* pPageView) {
- CPWL_PushButton* pWnd = new CPWL_PushButton();
- pWnd->Create(cp);
-
- return pWnd;
-}
-
-FX_BOOL CFFL_PushButton::OnChar(CPDFSDK_Annot* pAnnot,
- FX_UINT nChar,
- FX_UINT nFlags) {
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
-}
-
-void CFFL_PushButton::OnDraw(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- FX_DWORD dwFlags) {
- CFFL_Button::OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
-}
diff --git a/fpdfsdk/src/formfiller/FFL_RadioButton.cpp b/fpdfsdk/src/formfiller/FFL_RadioButton.cpp
deleted file mode 100644
index 029bcf1a17..0000000000
--- a/fpdfsdk/src/formfiller/FFL_RadioButton.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2014 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/include/formfiller/FFL_RadioButton.h"
-
-#include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
-#include "fpdfsdk/include/fsdk_mgr.h"
-#include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h"
-
-CFFL_RadioButton::CFFL_RadioButton(CPDFDoc_Environment* pApp,
- CPDFSDK_Annot* pWidget)
- : CFFL_Button(pApp, pWidget) {}
-
-CFFL_RadioButton::~CFFL_RadioButton() {}
-
-CPWL_Wnd* CFFL_RadioButton::NewPDFWindow(const PWL_CREATEPARAM& cp,
- CPDFSDK_PageView* pPageView) {
- CPWL_RadioButton* pWnd = new CPWL_RadioButton();
- pWnd->Create(cp);
-
- pWnd->SetCheck(m_pWidget->IsChecked());
-
- return pWnd;
-}
-
-FX_BOOL CFFL_RadioButton::OnKeyDown(CPDFSDK_Annot* pAnnot,
- FX_UINT nKeyCode,
- FX_UINT nFlags) {
- switch (nKeyCode) {
- case FWL_VKEY_Return:
- case FWL_VKEY_Space:
- return TRUE;
- default:
- return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags);
- }
-}
-
-FX_BOOL CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot,
- FX_UINT nChar,
- FX_UINT nFlags) {
- switch (nChar) {
- case FWL_VKEY_Return:
- case FWL_VKEY_Space: {
- CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
- CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
- ASSERT(pPageView);
-
- FX_BOOL bReset = FALSE;
- FX_BOOL bExit = FALSE;
-
- pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, bExit, nFlags);
-
- if (bReset)
- return TRUE;
- if (bExit)
- return TRUE;
-
- CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
-
- if (CPWL_RadioButton* pWnd =
- (CPWL_RadioButton*)GetPDFWindow(pPageView, TRUE))
- pWnd->SetCheck(TRUE);
- CommitData(pPageView, nFlags);
- return TRUE;
- }
- default:
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
- }
-}
-
-FX_BOOL CFFL_RadioButton::OnLButtonUp(CPDFSDK_PageView* pPageView,
- CPDFSDK_Annot* pAnnot,
- FX_UINT nFlags,
- const CFX_FloatPoint& point) {
- CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point);
-
- if (IsValid()) {
- if (CPWL_RadioButton* pWnd =
- (CPWL_RadioButton*)GetPDFWindow(pPageView, TRUE))
- pWnd->SetCheck(TRUE);
-
- if (!CommitData(pPageView, nFlags))
- return FALSE;
- }
-
- return TRUE;
-}
-
-FX_BOOL CFFL_RadioButton::IsDataChanged(CPDFSDK_PageView* pPageView) {
- if (CPWL_RadioButton* pWnd =
- (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
- return pWnd->IsChecked() != m_pWidget->IsChecked();
- }
-
- return FALSE;
-}
-
-void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) {
- if (CPWL_RadioButton* pWnd =
- (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
- bool bNewChecked = pWnd->IsChecked();
-
- if (bNewChecked) {
- CPDF_FormField* pField = m_pWidget->GetFormField();
- for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
- if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
- if (pCtrl->IsChecked()) {
- break;
- }
- }
- }
- }
-
- m_pWidget->SetCheck(bNewChecked, false);
- m_pWidget->UpdateField();
- SetChangeMark();
- }
-}
diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp
deleted file mode 100644
index 42f2aad48f..0000000000
--- a/fpdfsdk/src/formfiller/FFL_TextField.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-// Copyright 2014 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/include/formfiller/FFL_TextField.h"
-
-#include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h"
-#include "fpdfsdk/include/fsdk_common.h"
-#include "fpdfsdk/include/fsdk_mgr.h"
-
-CFFL_TextField::CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot)
- : CFFL_FormFiller(pApp, pAnnot), m_pFontMap(NULL) {
- m_State.nStart = m_State.nEnd = 0;
-}
-
-CFFL_TextField::~CFFL_TextField() {
- for (const auto& it : m_Maps)
- it.second->InvalidateFocusHandler(this);
- delete m_pFontMap;
-}
-
-PWL_CREATEPARAM CFFL_TextField::GetCreateParam() {
- PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
-
- int nFlags = m_pWidget->GetFieldFlags();
-
- if (nFlags & FIELDFLAG_PASSWORD) {
- cp.dwFlags |= PES_PASSWORD;
- }
-
- if (!(nFlags & FIELDFLAG_DONOTSPELLCHECK)) {
- }
-
- if (nFlags & FIELDFLAG_MULTILINE) {
- cp.dwFlags |= PES_MULTILINE | PES_AUTORETURN | PES_TOP;
-
- if (!(nFlags & FIELDFLAG_DONOTSCROLL)) {
- cp.dwFlags |= PWS_VSCROLL | PES_AUTOSCROLL;
- }
- } else {
- cp.dwFlags |= PES_CENTER;
-
- if (!(nFlags & FIELDFLAG_DONOTSCROLL)) {
- cp.dwFlags |= PES_AUTOSCROLL;
- }
- }
-
- if (nFlags & FIELDFLAG_COMB) {
- cp.dwFlags |= PES_CHARARRAY;
- }
-
- if (nFlags & FIELDFLAG_RICHTEXT) {
- cp.dwFlags |= PES_RICH;
- }
-
- cp.dwFlags |= PES_UNDO;
-
- switch (m_pWidget->GetAlignment()) {
- default:
- case BF_ALIGN_LEFT:
- cp.dwFlags |= PES_LEFT;
- break;
- case BF_ALIGN_MIDDLE:
- cp.dwFlags |= PES_MIDDLE;
- break;
- case BF_ALIGN_RIGHT:
- cp.dwFlags |= PES_RIGHT;
- break;
- }
-
- if (!m_pFontMap)
- m_pFontMap = new CBA_FontMap(m_pWidget, m_pApp->GetSysHandler());
- cp.pFontMap = m_pFontMap;
- cp.pFocusHandler = this;
-
- return cp;
-}
-
-CPWL_Wnd* CFFL_TextField::NewPDFWindow(const PWL_CREATEPARAM& cp,
- CPDFSDK_PageView* pPageView) {
- CPWL_Edit* pWnd = new CPWL_Edit();
- pWnd->AttachFFLData(this);
- pWnd->Create(cp);
-
- CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
- pWnd->SetFillerNotify(pIFormFiller);
-
- int32_t nMaxLen = m_pWidget->GetMaxLen();
- CFX_WideString swValue = m_pWidget->GetValue();
-
- if (nMaxLen > 0) {
- if (pWnd->HasFlag(PES_CHARARRAY)) {
- pWnd->SetCharArray(nMaxLen);
- pWnd->SetAlignFormatV(PEAV_CENTER);
- } else {
- pWnd->SetLimitChar(nMaxLen);
- }
- }
-
- pWnd->SetText(swValue.c_str());
- return pWnd;
-}
-
-FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot,
- FX_UINT nChar,
- FX_UINT nFlags) {
- switch (nChar) {
- case FWL_VKEY_Return:
- if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE)) {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView);
- m_bValid = !m_bValid;
- CFX_FloatRect rcAnnot = pAnnot->GetRect();
- m_pApp->FFI_Invalidate(pAnnot->GetUnderlyingPage(), rcAnnot.left,
- rcAnnot.top, rcAnnot.right, rcAnnot.bottom);
-
- if (m_bValid) {
- if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE))
- pWnd->SetFocus();
- } else {
- if (CommitData(pPageView, nFlags)) {
- DestroyPDFWindow(pPageView);
- return TRUE;
- }
- return FALSE;
- }
- }
- break;
- case FWL_VKEY_Escape: {
- CPDFSDK_PageView* pPageView = GetCurPageView();
- ASSERT(pPageView);
- EscapeFiller(pPageView, TRUE);
- return TRUE;
- }
- }
-
- return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
-}
-
-FX_BOOL CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView) {
- if (CPWL_Edit* pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
- return pEdit->GetText() != m_pWidget->GetValue();
-
- return FALSE;
-}
-
-void CFFL_TextField::SaveData(CPDFSDK_PageView* pPageView) {
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) {
- CFX_WideString sOldValue = m_pWidget->GetValue();
- CFX_WideString sNewValue = pWnd->GetText();
-
- m_pWidget->SetValue(sNewValue, FALSE);
- m_pWidget->ResetFieldAppearance(TRUE);
- m_pWidget->UpdateField();
- SetChangeMark();
- }
-}
-
-void CFFL_TextField::GetActionData(CPDFSDK_PageView* pPageView,
- CPDF_AAction::AActionType type,
- PDFSDK_FieldAction& fa) {
- switch (type) {
- case CPDF_AAction::KeyStroke:
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) {
- fa.bFieldFull = pWnd->IsTextFull();
-
- fa.sValue = pWnd->GetText();
-
- if (fa.bFieldFull) {
- fa.sChange = L"";
- fa.sChangeEx = L"";
- }
- }
- break;
- case CPDF_AAction::Validate:
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) {
- fa.sValue = pWnd->GetText();
- }
- break;
- case CPDF_AAction::LoseFocus:
- case CPDF_AAction::GetFocus:
- fa.sValue = m_pWidget->GetValue();
- break;
- default:
- break;
- }
-}
-
-void CFFL_TextField::SetActionData(CPDFSDK_PageView* pPageView,
- CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& fa) {
- switch (type) {
- case CPDF_AAction::KeyStroke:
- if (CPWL_Edit* pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) {
- pEdit->SetFocus();
- pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
- pEdit->ReplaceSel(fa.sChange.c_str());
- }
- break;
- default:
- break;
- }
-}
-
-FX_BOOL CFFL_TextField::IsActionDataChanged(CPDF_AAction::AActionType type,
- const PDFSDK_FieldAction& faOld,
- const PDFSDK_FieldAction& faNew) {
- switch (type) {
- case CPDF_AAction::KeyStroke:
- return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) ||
- faOld.nSelStart != faNew.nSelStart ||
- faOld.sChange != faNew.sChange;
- default:
- break;
- }
-
- return FALSE;
-}
-
-void CFFL_TextField::SaveState(CPDFSDK_PageView* pPageView) {
- ASSERT(pPageView);
-
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) {
- pWnd->GetSel(m_State.nStart, m_State.nEnd);
- m_State.sValue = pWnd->GetText();
- }
-}
-
-void CFFL_TextField::RestoreState(CPDFSDK_PageView* pPageView) {
- ASSERT(pPageView);
-
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, TRUE)) {
- pWnd->SetText(m_State.sValue.c_str());
- pWnd->SetSel(m_State.nStart, m_State.nEnd);
- }
-}
-
-CPWL_Wnd* CFFL_TextField::ResetPDFWindow(CPDFSDK_PageView* pPageView,
- FX_BOOL bRestoreValue) {
- if (bRestoreValue)
- SaveState(pPageView);
-
- DestroyPDFWindow(pPageView);
-
- CPWL_Wnd* pRet = NULL;
-
- if (bRestoreValue) {
- RestoreState(pPageView);
- pRet = GetPDFWindow(pPageView, FALSE);
- } else {
- pRet = GetPDFWindow(pPageView, TRUE);
- }
-
- m_pWidget->UpdateField();
-
- return pRet;
-}
-
-#ifdef PDF_ENABLE_XFA
-FX_BOOL CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView) {
- if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) {
- return pWnd->IsTextFull();
- }
-
- return FALSE;
-}
-#endif // PDF_ENABLE_XFA
-
-void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd) {
- ASSERT(m_pApp);
- if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) {
- CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
- pEdit->SetCharSet(134);
- pEdit->SetCodePage(936);
-
- pEdit->SetReadyToInput();
- CFX_WideString wsText = pEdit->GetText();
- int nCharacters = wsText.GetLength();
- CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
- unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str();
- m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer,
- nCharacters, TRUE);
-
- pEdit->SetEditNotify(this);
- }
-}
-
-void CFFL_TextField::OnKillFocus(CPWL_Wnd* pWnd) {}
-
-void CFFL_TextField::OnAddUndo(CPWL_Edit* pEdit) {}